-
-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (81 loc) · 3.1 KB
/
Copy pathcoverage.yml
File metadata and controls
93 lines (81 loc) · 3.1 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
# SPDX-License-Identifier: MPL-2.0
# Line/region coverage for the Rust workspace via cargo-llvm-cov.
#
# Why: the workspace had fuzzing and a stack-depth guard but no coverage
# measurement, so coverage regressions went unnoticed (see TESTING.md). This
# workflow measures coverage on every change, publishes an LCOV report + an
# HTML report as artifacts, writes a summary to the job page, and enforces a
# conservative line-coverage FLOOR so coverage can only ratchet upward.
#
# Raising the floor: bump COVERAGE_FLOOR (and the matching --fail-under-lines
# value below) as coverage improves. It is intentionally a floor, not a target.
name: Coverage
on:
push:
paths:
- 'crates/**'
- 'Cargo.toml'
- 'Cargo.lock'
- '.github/workflows/coverage.yml'
pull_request:
paths:
- 'crates/**'
- 'Cargo.toml'
- 'Cargo.lock'
- '.github/workflows/coverage.yml'
permissions: read-all
env:
# Minimum acceptable line coverage (percent). Ratchet upward over time.
# Baseline at introduction was ~46.7% line coverage (workspace, excl. my-llvm);
# the floor sits just below that so it gates regressions without being flaky.
COVERAGE_FLOOR: "40"
jobs:
coverage:
name: llvm-cov
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Rust
uses: dtolnay/rust-toolchain@2c7215f132e9ebf062739d9130488b56d53c060c # stable
with:
toolchain: stable
components: llvm-tools-preview
- name: Install cargo-llvm-cov
run: cargo install cargo-llvm-cov --locked
# Collect coverage once, then render multiple reports from the same data.
# The LLVM back end (my-llvm) needs a system LLVM toolchain, so it is
# excluded here to keep the job hermetic; everything else is measured.
# NOTE: --workspace/--exclude are only valid on the test-running form, not
# on the `report` subcommand, which renders the already-collected data.
- name: Collect coverage
run: cargo llvm-cov --no-report --workspace --exclude my-llvm
# Coverage gate. --fail-under-lines must mirror COVERAGE_FLOOR.
- name: Enforce coverage floor
run: cargo llvm-cov report --fail-under-lines "${COVERAGE_FLOOR}"
- name: Coverage summary
if: always()
run: |
{
echo '## Coverage summary'
echo '```'
cargo llvm-cov report --summary-only
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
- name: Generate LCOV report
if: always()
run: cargo llvm-cov report --lcov --output-path lcov.info
- name: Generate HTML report
if: always()
run: cargo llvm-cov report --html --output-dir coverage-html
- name: Upload coverage reports
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: coverage-report
path: |
lcov.info
coverage-html
if-no-files-found: warn