forked from w1ne/labwired-core
-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (78 loc) · 2.89 KB
/
Copy pathcore-coverage-weekly.yml
File metadata and controls
90 lines (78 loc) · 2.89 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
name: Core Coverage Gate
on:
schedule:
- cron: "20 2 * * 0"
workflow_dispatch:
concurrency:
group: core-coverage-weekly
cancel-in-progress: true
jobs:
coverage:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@1.95.0
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: core-coverage
workspaces: |
. -> target
- name: Cache cargo-llvm-cov
id: cache-llvm-cov
uses: actions/cache@v4
with:
path: ~/.cargo/bin/cargo-llvm-cov
key: ${{ runner.os }}-cargo-llvm-cov-v0.6.21
- name: Install coverage tooling
run: |
rustup component add llvm-tools-preview
rustup target add thumbv6m-none-eabi
rustup target add thumbv7m-none-eabi
rustup target add thumbv7em-none-eabi
if ! command -v cargo-llvm-cov >/dev/null 2>&1; then
cargo install cargo-llvm-cov --locked --version 0.6.21
fi
- name: Build firmware fixture for coverage tests
run: |
cargo build -p demo-blinky --release --target thumbv7m-none-eabi
cargo build -p firmware-h563-io-demo --release --target thumbv7m-none-eabi
cargo build -p firmware-f401-demo --release --target thumbv7em-none-eabi
RUSTFLAGS="-C link-arg=-Tlink.x" cargo build -p firmware-rp2040-pio-onboarding --release --target thumbv6m-none-eabi
- name: Run coverage
run: |
mkdir -p out/coverage
cargo llvm-cov -p labwired-core -p labwired-cli --summary-only --json > out/coverage/llvm-cov.json
- name: Enforce minimum line coverage
run: |
python3 - <<'PY'
import json
import pathlib
import sys
# Weekly floor only (not a PR gate). Keep conservative until main baseline
# is measured; PR signal is integrity + onboarding + coverage-matrix + arduino.
threshold = 55.0
p = pathlib.Path("out/coverage/llvm-cov.json")
data = json.loads(p.read_text())
nodes = data.get("data", [])
if not nodes:
print("No coverage data found", file=sys.stderr)
sys.exit(1)
totals = nodes[0].get("totals", {})
lines = totals.get("lines", {})
pct = float(lines.get("percent", 0.0))
print(f"Line coverage: {pct:.2f}% (threshold: {threshold:.2f}%)")
if pct < threshold:
sys.exit(1)
pathlib.Path("out/coverage/summary.txt").write_text(
f"line_coverage_percent={pct:.2f}\nthreshold={threshold:.2f}\n"
)
PY
- name: Upload coverage artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: core-coverage
path: out/coverage/