Skip to content

Commit fec1d55

Browse files
committed
Compute coverage in CI
fixes #5
1 parent 022ab6b commit fec1d55

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

.github/workflows/ci.yml

+47
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,53 @@ jobs:
9090

9191
- run: cargo check ${{ matrix.RUST.FLAGS }}
9292

93+
coverage:
94+
runs-on: ubuntu-latest
95+
steps:
96+
- uses: actions/checkout@v3
97+
with:
98+
persist-credentials: false
99+
100+
- uses: dtolnay/rust-toolchain@1ce4a7352a1efe5dede2e52c75512b34256e4f44
101+
with:
102+
toolchain: nightly
103+
components: llvm-tools-preview
104+
105+
- uses: actions/cache@v3
106+
id: cargo-cache
107+
with:
108+
path: |
109+
~/.cargo/bin/
110+
~/.cargo/registry/index/
111+
~/.cargo/registry/cache/
112+
~/.cargo/git/db/
113+
target/
114+
key: ${{ runner.os }}-cargo-4-${{ hashFiles('**/Cargo.toml') }}
115+
116+
- run: cargo install cargo-binutils
117+
if: steps.cargo-cache.outputs.cache-hit != 'true'
118+
119+
- run: cargo test
120+
env:
121+
RUSTFLAGS: "-Cinstrument-coverage"
122+
LLVM_PROFILE_FILE: "rust-cov/cov-%m-%p.profraw"
123+
124+
- run: |
125+
set -xe
126+
cargo profdata -- merge -sparse rust-cov/*.profraw -o cargo-test-rust-cov.profdata
127+
cargo cov -- export \
128+
$(env RUSTFLAGS="-Cinstrument-coverage" cargo test --tests --no-run --message-format=json | jq -r "select(.profile.test == true) | .filenames[]") \
129+
-instr-profile=cargo-test-rust-cov.profdata \
130+
--ignore-filename-regex='/.cargo/registry' \
131+
--ignore-filename-regex='/rustc/' \
132+
--ignore-filename-regex='/.rustup/toolchains/' --format=lcov > cargo-test.lcov
133+
134+
genhtml cargo-test.lcov -o coverage-html
135+
- uses: actions/[email protected]
136+
with:
137+
name: coverage-html
138+
path: coverage-html
139+
93140
fuzz:
94141
runs-on: ubuntu-latest
95142
strategy:

0 commit comments

Comments
 (0)