Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(general): Add coverage upload #57

Merged
merged 16 commits into from
Oct 11, 2024
Merged
2 changes: 2 additions & 0 deletions .config/dictionaries/project.dic
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ bootstrapper
BROTLI
cantopen
cardano
carryforward
CBOR
cbork
cdylib
Expand All @@ -39,6 +40,7 @@ ciphertexts
codegen
codepoints
coti
coverallsapp
cpus
crontabs
crontagged
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/generate-allure-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ jobs:
if-no-files-found: error
retention-days: 1

- name: Collect and upload test coverage
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-reports
path: "**/*${{ env.COVERAGE_EXT }}"
if-no-files-found: error
retention-days: 1

generate-allure-report:
name: Generate allure report
runs-on: ubuntu-latest
Expand Down Expand Up @@ -106,3 +115,49 @@ jobs:
${{ steps.allure.outputs.test_result_icon }} [Test Report](${{ steps.allure.outputs.report_url }}) | ${\color{lightgreen}Pass: ${{ steps.allure.outputs.test_result_passed }}/${{ steps.allure.outputs.test_result_total }}}$ | ${\color{red}Fail: ${{ steps.allure.outputs.test_result_failed }}/${{ steps.allure.outputs.test_result_total }}}$ |
comment_tag: allure_report
mode: upsert

generate-coverage-report:
name: Generate coverage report
runs-on: ubuntu-latest
needs: [generate-test-reports]
steps:
- uses: actions/checkout@v4

- uses: actions/download-artifact@v4
with:
name: coverage-reports

- name: Collect coverage report
run: |
mkdir -p ${{ env.COVERAGE_REPORT_PATH }}
shopt -s globstar
cp **/*${{ env.COVERAGE_EXT }} ${{ env.COVERAGE_REPORT_PATH }}
ls ${{ env.COVERAGE_REPORT_PATH }}

- name: Normalize coverage report paths
run: |
sed -i -e 's/SF:\/root\/build/SF:rust/g' ${{ env.COVERAGE_REPORT_PATH }}/cat-libs.coverage.info

- name: Coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: coverallsapp/github-action@v2
with:
path-to-lcov: "${{ env.COVERAGE_REPORT_PATH }}/cat-libs.coverage.info"
allow-empty: true
debug: true
flag-name: rust-unit-test
base-path: "/home/runner/work/catalyst-libs/catalyst-libs/"
parallel: true

upload-coverage-report:
name: Upload coverage report
needs: [generate-coverage-report]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
parallel-finished: true
carryforward: "rust-unit-test"
2 changes: 2 additions & 0 deletions rust/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ build:
--args2="--libs=cbork-cddl-parser --libs=cbork-abnf-parser" \
--args3="--libs=catalyst-voting" \
--args4="--bins=cbork/cbork" \
--args5="--cov_report=$HOME/build/coverage-report.info" \
--output="release/[^\./]+" \
--junit="cat-libs.junit-report.xml" \
--coverage="cat-libs.coverage.info" \
--docs="true"

SAVE ARTIFACT target/$TARGETARCH/doc doc
Expand Down