Skip to content

Commit 363dbda

Browse files
committed
Switch to llvm-cov for CI coverage
1 parent e4ec77e commit 363dbda

File tree

2 files changed

+45
-53
lines changed

2 files changed

+45
-53
lines changed

.github/workflows/coverage.yml

+12-18
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,25 @@ jobs:
1818
with:
1919
toolchain: stable
2020
override: true
21+
- name: Install cargo-llvm-cov
22+
uses: taiki-e/install-action@cargo-llvm-cov
2123
- name: Run no-default-features tests with code coverage
2224
uses: actions-rs/cargo@v1
2325
with:
24-
command: test
25-
args: --no-default-features --no-fail-fast
26-
env:
27-
RUSTC_BOOTSTRAP: '1'
28-
CARGO_INCREMENTAL: '0'
29-
RUSTFLAGS: '-Zprofile -Cinstrument-coverage -Ccodegen-units=1 -Cllvm-args=--inline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'
30-
RUSTDOCFLAGS: '-Zprofile -Cinstrument-coverage -Ccodegen-units=1 -Cllvm-args=--inline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'
26+
command: llvm-cov
27+
args: --no-report --no-default-features --no-fail-fast
3128
- name: Run default tests with code coverage
3229
uses: actions-rs/cargo@v1
3330
with:
34-
command: test
35-
args: --all-features --no-fail-fast
36-
env:
37-
RUSTC_BOOTSTRAP: '1'
38-
CARGO_INCREMENTAL: '0'
39-
RUSTFLAGS: '-Zprofile -Cinstrument-coverage -Ccodegen-units=1 -Cllvm-args=--inline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'
40-
RUSTDOCFLAGS: '-Zprofile -Cinstrument-coverage -Ccodegen-units=1 -Cllvm-args=--inline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'
41-
- name: Run grcov
42-
id: coverage
43-
uses: rraval/grcov@master
31+
command: llvm-cov
32+
args: --no-report --all-features --no-fail-fast
33+
- name: Generate Report
34+
uses: actions-rs/cargo@v1
35+
with:
36+
command: llvm-cov
37+
args: report --lcov --output-path lcov.info
4438
- name: Coveralls upload
4539
uses: coverallsapp/github-action@master
4640
with:
4741
github-token: ${{ secrets.GITHUB_TOKEN }}
48-
path-to-lcov: ${{ steps.coverage.outputs.report }}
42+
path-to-lcov: lcov.info

bb.edn

+33-35
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,34 @@
11
{:tasks
2-
{:init (do (def code-cov-env
3-
{"CARGO_INCREMENTAL" "0"
4-
"RUSTFLAGS" "-Cinstrument-coverage -Copt-level=0 -Ccodegen-units=1 -Cllvm-args=--inline-threshold=0 -Clink-dead-code -Coverflow-checks=off"
5-
"LLVM_PROFILE_FILE" "target/coverage/cargo-test-%p-%m.profraw"}))
6-
:requires ([babashka.fs :as fs])
7-
clean {:doc "Removes target folder"
8-
:task (fs/delete-tree "target")}
9-
test_lib_features (shell "cargo test --all-features --no-fail-fast")
10-
test_lib_no_default_features (shell "cargo test --no-default-features --no-fail-fast")
11-
cargo-test {:doc "Runs all cargo tests"
12-
:depends [test_lib_features test_lib_no_default_features]}
13-
cargo-fmt {:doc "Checks cargo fmt"
14-
:task (shell "cargo fmt --check")}
15-
cargo-clippy-all-features {:doc "Cargo clippy with all features"
16-
:task (shell "cargo clippy --all-features -- --deny warnings")}
17-
cargo-clippy-no-defaults {:doc "Cargo clippy with no default features"
18-
:task (shell "cargo clippy --no-default-features -- --deny warnings")}
19-
cargo-clippy-examples {:doc "Cargo clippy on examples"
20-
:task (shell "cargo clippy --examples -- --deny warnings -A clippy::unwrap-used")}
21-
clippy {:doc "Runs all variations of cargo clippy"
22-
:depends [cargo-clippy-all-features cargo-clippy-no-defaults cargo-clippy-examples]}
23-
cov-all-features {:doc "Coverage, all features"
24-
:task (shell {:extra-env code-cov-env} "cargo test --all-features")}
25-
cov-std-only {:doc "Coverage, std only"
26-
:task (shell {:extra-env code-cov-env} "cargo test --no-default-features")}
27-
cov-examples {:doc "Coverage, examples"
28-
:task (shell {:extra-env code-cov-env} "cargo test --examples")}
29-
clean-cov {:doc "Cleans all .profraw files and generated html"
30-
:task (fs/delete-tree "target/coverage")}
31-
grcov {:doc "Runs grcov to generate human readable html"
32-
:task (shell "grcov target/coverage --binary-path ./target/debug/deps/ -s . -t html --branch --ignore-not-existing -o target/coverage/html")}
33-
coverage {:doc "Generates coverage in human friendly html in target/coverage/"
34-
:depends [clean-cov cov-all-features cov-std-only cov-examples grcov]}
35-
test {:doc "Runs all tests and checks"
36-
:depends [cargo-test cargo-fmt clippy]}}}
2+
{:requires ([babashka.fs :as fs])
3+
clean {:doc "Removes target folder"
4+
:task (fs/delete-tree "target")}
5+
test_all_features (shell "cargo test --all-features --no-fail-fast")
6+
test_no_default_features (shell "cargo test --no-default-features --no-fail-fast")
7+
cargo-test {:doc "Runs all cargo tests"
8+
:depends [test_all_features test_no_default_features]}
9+
cargo-fmt {:doc "Checks cargo fmt"
10+
:task (shell "cargo fmt --check")}
11+
cargo-clippy-all-features {:doc "Cargo clippy with all features"
12+
:task (shell "cargo clippy --all-features -- --deny warnings")}
13+
cargo-clippy-no-defaults {:doc "Cargo clippy with no default features"
14+
:task (shell "cargo clippy --no-default-features -- --deny warnings")}
15+
cargo-clippy-examples {:doc "Cargo clippy on examples"
16+
:task (shell "cargo clippy --examples -- --deny warnings -A clippy::unwrap-used")}
17+
clippy {:doc "Runs all variations of cargo clippy"
18+
:depends [cargo-clippy-all-features cargo-clippy-no-defaults cargo-clippy-examples]}
19+
cov-all-features {:doc "Coverage, all features"
20+
:task (shell "cargo llvm-cov --no-report --all-features")}
21+
cov-std-only {:doc "Coverage, std only"
22+
:task (shell "cargo llvm-cov --no-report --no-default-features")}
23+
cov-examples {:doc "Coverage, examples"
24+
:task (shell "cargo llvm-cov --no-report --examples")}
25+
cov-clean {:doc "Cleans all .profraw files and generated html"
26+
:task (shell "cargo llvm-cov clean --workspace")}
27+
cov-html {:doc "Runs llvm-cov to generate human readable html"
28+
:depends [cov-clean cov-all-features cov-std-only]
29+
:task (shell "cargo llvm-cov report --html")}
30+
cov {:doc "Generates coverage and reports to the terminal"
31+
:depends [cov-clean cov-all-features cov-std-only cov-examples]
32+
:task (shell "cargo llvm-cov report")}
33+
test {:doc "Runs all tests and checks"
34+
:depends [cargo-test cargo-fmt clippy]}}}

0 commit comments

Comments
 (0)