-
-
Notifications
You must be signed in to change notification settings - Fork 3
79 lines (79 loc) · 2.78 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
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Code Coverage
on:
pull_request:
types: [opened, edited, synchronize]
push:
branches: main
jobs:
coverage:
name: Code Coverage
runs-on: ${{matrix.os}}-latest
strategy:
matrix:
os: [ubuntu, windows, macos]
permissions:
id-token: write
checks: read
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Authenticate GitHub CLI
run: echo ${{github.token}} | gh auth login --with-token
- name: Setup Rust Toolchain and Tools
uses: moonrepo/setup-rust@e013866c4215f77c925f42f60257dec7dd18836e # v1
with:
bins: sccache, grcov, cargo-hack
channel: nightly
components: llvm-tools-preview
cache-target: coverage
- name: Setup Shared Cache Directory
shell: bash
run: |
declare path="${HOME}/.cache/sccache"
if test "${RUNNER_OS}" = "Windows"; then
path=$(cygpath --windows "${path}")
fi
echo "SCCACHE_DIR=${path}" >> "${GITHUB_ENV}"
- name: Restore sccache build artifacts
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
with:
restore-keys: ${{runner.os}}-nightly-coverage-
key: ${{runner.os}}-nightly-coverage-${{hashFiles('**/Cargo.lock')}}
path: ${{env.SCCACHE_DIR}}
- name: Run Tests (coverage)
run: cargo hack test --profile=coverage --feature-powerset
env:
LLVM_PROFILE_FILE: target/coverage/outcome-%p-%m.profraw
RUSTC_WRAPPER: sccache
RUSTDOCFLAGS: >-
-C instrument-coverage
-Zunstable-options
--persist-doctests ${{github.workspace}}/target/coverage
RUSTFLAGS: -C instrument-coverage
- name: Collect Coverage
run: >-
grcov ${{github.workspace}}
--binary-path ${{github.workspace}}/target/coverage
--output-path ${{github.workspace}}/coverage.info
--output-type lcov
--source-dir ${{github.workspace}}
--ignore "/*"
--ignore "C:/*"
--ignore "../*"
--ignore-not-existing
--branch
- name: Check coverage.info exists
run: test -f ${{github.workspace}}/coverage.info
- name: Upload Code Coverage
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4
with:
fail_ci_if_error: true
use_oidc: true
directory: ${{github.workspace}}
files: coverage.info
- name: Upload Code Coverage Artifact
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4
with:
name: ${{matrix.os}}-coverage.info
path: coverage.info
if-no-files-found: error