Repository navigation
163 lines (146 loc) · 5.61 KB
/
Copy pathcoverage.yml
File metadata and controls
163 lines (146 loc) · 5.61 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
name: Coverage
# Report-only code coverage measurement using cargo-llvm-cov + nextest.
# This job mirrors the CI test runner but instruments the build with
# source-based coverage, then publishes an LCOV artifact and a summary
# in the GitHub Actions job summary. It does NOT gate merges — once a
# baseline is established, a follow-up PR can add a regression threshold.
#
# See issue #3819 for context.
# Runs on push to main only. Coverage is a report-only trend metric: the
# full instrumented `cargo llvm-cov nextest --workspace` (~20-30 min) used
# to run on every PR, where it duplicated the per-PR test lane to produce
# a number that gates no merge. The main-branch series is all the trend
# needs; per-PR runs were pure waste. Use `workflow_dispatch` for an
# ad-hoc run (e.g. to refresh the LCOV artifact).
on:
push:
branches: [main]
# Skip coverage when a main push's entire diff is non-runtime files —
# it cannot shift the number, so the ~20-30 min run is pure waste.
# `paths-ignore` skips only when *every* changed path matches.
paths-ignore:
- 'docs/**'
- '**.md'
- 'xtask/**' # build tooling, not runtime
- '.github/workflows/**' # pipeline YAML, not runtime
- 'sdk/**' # generated SDKs (not rust-measured)
- 'web/**' # web frontend (not rust)
- 'crates/librefang-api/dashboard/**' # react dashboard (not rust)
- '**/*.svg'
- '**/*.png'
- '**/*.jpg'
- '**/*.jpeg'
- '**/*.gif'
- '**/*.ico'
- 'CODEOWNERS'
- '.gitignore'
- '.editorconfig'
- '.secrets.baseline'
workflow_dispatch:
permissions:
contents: read
concurrency:
# Each main commit's coverage is its own data point — never cancel an
# in-progress run when a newer commit lands.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
env:
CARGO_TERM_COLOR: always
# Coverage instrumentation generates many warnings inside generated
# code; don't promote them to errors here (CI's main lane already
# enforces -D warnings on the non-instrumented build).
RUSTFLAGS: ""
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
coverage:
name: Workspace coverage (llvm-cov)
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
with:
components: llvm-tools-preview
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
with:
shared-key: coverage
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@4616abf838e456930a67014fba647f87c185cc6c # cargo-llvm-cov
with:
tool: cargo-llvm-cov
- name: Install nextest
uses: taiki-e/install-action@4616abf838e456930a67014fba647f87c185cc6c # nextest
- name: Install Tauri system deps
run: |
sudo apt-get update
sudo apt-get install -y \
libwebkit2gtk-4.1-dev \
libgtk-3-dev \
libayatana-appindicator3-dev \
librsvg2-dev \
libdbus-1-dev \
libsecret-1-dev \
pkg-config \
patchelf
- name: Ensure dashboard build dir exists
run: mkdir -p crates/librefang-api/static/react
- name: Generate coverage (LCOV)
env:
RUST_TEST_THREADS: "1"
run: |
# pipefail: tee always exits 0, so without this the cargo failure
# would be masked and the job would falsely succeed.
set -o pipefail
# Tee combined stdout+stderr to a log so a follow-up step can
# surface failing test names even when the run-log download API
# is admin-only (HTTP 403 for non-admin readers).
cargo llvm-cov nextest \
--workspace \
--no-fail-fast \
--lcov \
--output-path lcov.info 2>&1 | tee nextest-output.log
- name: Surface failing tests
if: failure()
run: |
{
echo "## Failing tests (nextest)"
echo ""
echo '```'
# nextest prints lines like " FAIL [ 0.123s] crate test::name"
# in the run summary; TIMEOUT and LEAK are the other terminal states.
grep -E '^\s+(FAIL|TIMEOUT|LEAK)\b' nextest-output.log \
|| echo "(no FAIL/TIMEOUT/LEAK lines found — inspect the nextest-output artifact)"
echo '```'
echo ""
echo "### Last 200 lines of nextest output"
echo '```'
tail -n 200 nextest-output.log
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
- name: Generate coverage summary
if: success()
run: |
cargo llvm-cov report --summary-only | tee coverage-summary.txt
{
echo "## Code coverage"
echo ""
echo '```'
cat coverage-summary.txt
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
- name: Upload nextest output
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: nextest-output
path: nextest-output.log
if-no-files-found: warn
retention-days: 14
- name: Upload LCOV artifact
if: success()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: coverage-lcov
path: lcov.info
if-no-files-found: error
retention-days: 14