Replace bespoke source-based coverage config with cargo-llvm-cov (#2286)

* Replace bespoke source-based coverage config with cargo-llvm-cov

* Keep incremental builds disabled

* Use cargo-llvm-cov ^0.1.0-alpha.4

Co-authored-by: teor <teor@riseup.net>
This commit is contained in:
Deirdre Connolly 2021-06-14 21:35:26 -04:00 committed by GitHub
parent 0b4f32a324
commit 28c3a23f14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 20 deletions

View File

@ -20,7 +20,7 @@ jobs:
with:
persist-credentials: false
- uses: actions-rs/toolchain@v1
- uses: actions-rs/toolchain@v1.0.7
with:
toolchain: nightly
override: true
@ -30,28 +30,16 @@ jobs:
- name: Install rustfilt symbol demangler
run: |
cargo install rustfilt
- name: Rerun tests for coverage
- name: Install cargo-llvm-cov cargo command
run: |
cargo install cargo-llvm-cov --version ^0.1.0-alpha.4
- name: Generate code coverage
env:
RUSTFLAGS: -Zinstrument-coverage -C link-dead-code -C debuginfo=2
LLVM_PROFILE_FILE: "${{ github.workspace }}/test.%p.profraw"
ZEBRA_SKIP_NETWORK_TESTS: 1
CARGO_INCREMENTAL: 0
run: |
cargo test
cargo test --no-run --message-format=json | jq -r "select(.profile.test == true) | .filenames[]" | grep -v dSYM - > filenames.txt
- name: Merge coverage data
run: |
$(rustc --print target-libdir)/../bin/llvm-profdata merge test.*.profraw -o test.profdata
- name: Generate detailed html coverage report for github artifact
run: |
$(rustc --print target-libdir)/../bin/llvm-cov show -format=html -ignore-filename-regex=".*/.cargo/registry/.*" -ignore-filename-regex=".*/.cargo/git/.*" -ignore-filename-regex=".*/.rustup/.*" -Xdemangler=rustfilt -show-instantiations -output-dir=./coverage -instr-profile=./test.profdata $(printf -- "-object %s " $(cat filenames.txt))
- uses: actions/upload-artifact@v2
with:
name: coverage
path: ./coverage
run: cargo llvm-cov --lcov > lcov.info
- name: Generate lcov coverage report for codecov
run: |
$(rustc --print target-libdir)/../bin/llvm-cov export -format=lcov -instr-profile=test.profdata $(printf -- "-object %s " $(cat filenames.txt)) > "lcov.info"
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v1.5.2