-
Notifications
You must be signed in to change notification settings - Fork 4
66 lines (63 loc) · 2.06 KB
/
coverage.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
---
name: Coverage
# yamllint disable-line rule:truthy
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-C instrument-coverage"
# yamllint disable-line rule:line-length
RUSTDOCFLAGS: "-C instrument-coverage -Z unstable-options --persist-doctests target/debug/doctestbins"
LLVM_PROFILE_FILE: "profile-%m.profraw"
jobs:
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@nightly
with:
components: llvm-tools-preview
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/install-linuxbrew
- uses: ./.github/actions/install-sdl2
- name: Install Coverage Tools
run: |
cargo install rustfilt cargo-binutils
brew install jq
- name: Run Tests
run: cargo test --features "serde"
# source: https://doc.rust-lang.org/rustc/instrument-coverage.html
- name: Merge Coverage
run: rust-profdata merge -sparse profile-*.profraw -o coverage.profdata
- name: Collect Coverage
run: |
rust-cov export \
$( \
for file in \
$( \
cargo test --features "serde" --no-run --message-format=json \
| jq -r "select(.profile.test == true) | .filenames[]" \
| grep -v dsym - \
) \
target/debug/doctestbins/*/rust_out; \
do \
[[ -x $file ]] && printf "%s %s " -object "$file"; \
done \
) \
--format lcov \
--Xdemangler=rustfilt \
--ignore-filename-regex=/.cargo/registry \
--ignore-filename-regex=/target/debug \
--ignore-filename-regex=/tests \
--instr-profile=coverage.profdata > coverage.txt
- name: Upload Coverage
uses: codecov/codecov-action@v3
with:
files: ./coverage.txt
verbose: true
fail_ci_if_error: true