Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR testing: add a coverage report for Rust tests #24

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04

steps:
- name: Install nightly rust
Expand All @@ -22,7 +22,7 @@ jobs:
toolchain: nightly
override: true
profile: minimal
components: rustfmt, clippy
components: rustfmt, clippy, llvm-tools-preview
- uses: actions/checkout@v2
- name: Rustfmt check
run: cargo fmt -- --check
Expand All @@ -32,3 +32,25 @@ jobs:
run: cargo test --verbose
- name: Clippy
run: cargo clippy

- name: Install LLVM tools (for llvm-cov)
run: sudo apt-get install llvm

- name: Rerun tests for coverage
run: cargo test
env:
RUSTFLAGS: -Zinstrument-coverage
CARGO_TARGET_DIR: target-cov
LLVM_PROFILE_FILE: "${{ github.workspace }}/test.%p.profraw"

- name: Merge coverage data
run: $(rustc --print target-libdir)/../bin/llvm-profdata merge --sparse test.*.profraw -o test.profdata

- name: Generate coverage report
run: find target-cov/debug/deps -type f -perm -u+x ! -name '*.so' | sed '2,$ s/^/--object /' | xargs llvm-cov show --format=html --instr-profile test.profdata --output-dir coverage-report

- name: Upload coverage report
uses: actions/upload-artifact@v2
with:
name: Rust Coverage
path: coverage-report