From 46939967d42e93aac2659fe8431d7cd219f48ff9 Mon Sep 17 00:00:00 2001 From: Deirdre Connolly Date: Tue, 19 Jan 2021 19:44:40 -0500 Subject: [PATCH] Add source-based coverage workflow --- .github/workflows/coverage.yaml | 58 +++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/coverage.yaml diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml new file mode 100644 index 0000000..892f79d --- /dev/null +++ b/.github/workflows/coverage.yaml @@ -0,0 +1,58 @@ +name: CI + +on: + pull_request: + branches: + - main + push: + branches: + - main + +jobs: + + coverage: + name: Coverage + timeout-minutes: 30 + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + + - 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 + 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