From 0f0e2cff33114bd029f60b20c361b479a889fd6d Mon Sep 17 00:00:00 2001 From: Deirdre Connolly Date: Thu, 10 Jun 2021 23:12:13 -0400 Subject: [PATCH] Switch to unstable source-based code coverage --- .github/workflows/main.yml | 65 +++++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 19 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 14ec37d..4aa024a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -54,25 +54,6 @@ jobs: command: test args: --all-features --all-targets - coverage: - name: Code Coverage (+nightly) - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2.3.4 - - uses: actions-rs/toolchain@v1.0.7 - with: - toolchain: nightly - override: true - - name: Run cargo-tarpaulin - uses: actions-rs/tarpaulin@v0.1 - with: - version: '0.12.3' - timeout: 300 - - name: Upload coverage report to Codecov - uses: codecov/codecov-action@v1.5.0 - with: - token: ${{ secrets.CODECOV_TOKEN }} - clippy: name: Clippy (+nightly) runs-on: ubuntu-latest @@ -88,3 +69,49 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} args: --all-features --all-targets -- -D warnings + + coverage: + name: Coverage (+nightly) + # The large timeout is to accommodate nightly builds + timeout-minutes: 45 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2.3.4 + with: + persist-credentials: false + + - uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + override: true + profile: minimal + components: llvm-tools-preview + + - name: Install rustfilt symbol demangler + run: | + cargo install rustfilt + - name: Rerun tests for 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 + + - 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