-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (51 loc) · 1.85 KB
/
ci_baseline_rust_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
name: "Code coverage"
on:
workflow_call:
inputs:
manifest_dir:
description: "Directory containing the Cargo.toml of the codebase under test"
type: string
default: "."
cargo_test_args:
description: "Commandline passed to `cargo test`"
type: string
secrets:
CODECOV_TOKEN:
description: "Identification token for the upload to codecov.io"
env:
CARGO_MANIFEST_DIR: ${{inputs.manifest_dir}}
jobs:
code_coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
components: llvm-tools-preview
- uses: taiki-e/install-action@v2
with:
tool: grcov
- name: Run tests
run: cargo test ${{inputs.cargo_test_args}}
env:
CARGO_INCREMENTAL: "0"
RUSTFLAGS: "-C instrument-coverage"
RUSTDOCFLAGS: "-Cpanic=abort -Cinstrument-coverage -Zunstable-options --persist-doctests ${{github.workspace}}/target/debug/doctestbins"
LLVM_PROFILE_FILE: "profile-%p-%m.profraw"
- name: Run grcov to merge coverage data
run: |
mkdir coverage
grcov . --binary-path target/debug/deps/ -s . -t lcov --excl-line '!no_rcov!' --branch --ignore-not-existing --ignore '../**' --ignore '/*' -o coverage/tests.lcov
grcov . --binary-path target/debug/doctestbins/ -s . -t lcov --branch --ignore-not-existing --ignore '../**' --ignore '/*' -o coverage/doctests.lcov
- name: Upload to codecov.io
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage/*.lcov
- name: Archive code coverage results
uses: actions/upload-artifact@v3
with:
name: coverage
path: |
coverage/*.lcov