library tests with coverage #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: library tests with coverage | |
on: | |
pull_request: | |
branches: [ "main" ] | |
workflow_dispatch: | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
test: | |
name: tests with coverage | |
runs-on: ubuntu-latest | |
env: | |
CARGO_INCREMENTAL: 0 | |
RUSTFLAGS: -Cinstrument-coverage -Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort | |
RUSTDOCFLAGS: -Cinstrument-coverage -Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions-rs/toolchain@v1.0.6 | |
with: | |
toolchain: nightly | |
override: true | |
- name: Generate test results and coverage report | |
run: | | |
cargo install cargo2junit grcov; | |
rustup component add llvm-tools-preview; | |
cargo test --manifest-path ./parsimony/Cargo.toml -- -Z unstable-options --format json | cargo2junit > results.xml; | |
grcov . -s . --binary-path ./parsimony/target/debug/deps -t lcov --branch --ignore "**/lib.rs" --ignore "**/*tests.rs" -o lcov.info; | |
- name: publish test results to github | |
uses: EnricoMi/publish-unit-test-result-action@v2 | |
if: always() | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
files: results.xml | |
- name: upload coverage report to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
files: lcov.info |