Skip to content

Commit

Permalink
ci: store HTML coverage report
Browse files Browse the repository at this point in the history
- use grcov over llvmcov for simplicity and ability to reuse results (?)
- upload as artifact and not to codecov.io
- split test and build into separate jobs, so failed tests do not appear
  as failing the build, and allowing to use a nightly toolchain for
  tests while still building with stable toolchain
  • Loading branch information
ydirson committed Aug 22, 2023
1 parent 62f0fd2 commit 58b013f
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
#container:
# image: centos8

steps:
- uses: dtolnay/rust-toolchain@1.69.0
- uses: actions/checkout@v3
Expand All @@ -22,18 +22,29 @@ jobs:
- name: Build
run: cargo build --verbose

- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov

- name: Generate code coverage
run: cargo llvm-cov --all-features --workspace --codecov --output-path cov.json

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
files: cov.json
fail_ci_if_error: true

toolchain: nightly
override: true
- name: Run tests
run: cargo test --verbose
run: |
cargo clean
cargo test --verbose
env:
CARGO_INCREMENTAL: '0'
RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'
RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'

- name: Test coverage report
run: grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing -o ./target/debug/coverage/

- name: Upload test coverage report
uses: actions/upload-artifact@v3
with:
name: coverage-html
path: ./target/debug/coverage/

0 comments on commit 58b013f

Please sign in to comment.