-
Notifications
You must be signed in to change notification settings - Fork 0
118 lines (101 loc) · 3.45 KB
/
coverage.yml
File metadata and controls
118 lines (101 loc) · 3.45 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
name: Coverage
on:
# Coverage gates PRs pre-merge; release tags publish the canonical
# post-merge coverage number. push-to-main removed because the
# merge commit already matches a validated PR head. ~10 min run, so
# not running it on every merge saves significant runner time.
pull_request:
branches: [ "main" ]
# Positive filter: coverage signal only matters when source / tests /
# dep manifests change. Doc-only / config-only / examples-only PRs
# don't shift the coverage number, and the workflow takes ~10 min
# of Linux quota per run. Keeps the PR-time coverage gate but skips
# the runs that would have produced an identical number.
paths:
- 'src/**'
- 'crates/**'
- 'tests/**'
- 'benches/**'
- 'build.rs'
- 'Cargo.toml'
- '.github/workflows/coverage.yml'
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-*'
workflow_dispatch:
permissions:
contents: read
# Cancel previous runs on the same ref (force-push during PR iteration).
concurrency:
group: coverage-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
coverage:
name: Code Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Rust cache
uses: swatinem/rust-cache@v2
- name: Generate code coverage
run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
env:
JARVY_TEST_MODE: 1
JARVY_FAST_TEST: 1
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: lcov.info
fail_ci_if_error: false
verbose: true
- name: Generate HTML report
run: cargo llvm-cov --all-features --workspace --html
env:
JARVY_TEST_MODE: 1
JARVY_FAST_TEST: 1
- name: Upload HTML coverage report
uses: actions/upload-artifact@v7
with:
name: coverage-report
path: target/llvm-cov/html/
retention-days: 7
coverage-check:
name: Coverage Threshold Check
runs-on: ubuntu-latest
needs: coverage
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Rust cache
uses: swatinem/rust-cache@v2
- name: Check coverage threshold (80%)
run: |
COVERAGE=$(cargo llvm-cov --all-features --workspace --json 2>/dev/null | jq -r '.data[0].totals.lines.percent // 0')
echo "Current coverage: ${COVERAGE}%"
if (( $(echo "$COVERAGE < 50" | bc -l) )); then
echo "::warning::Coverage is below 50% (${COVERAGE}%). Target is 80%."
fi
# Note: Threshold enforcement will be enabled once coverage improves
# if (( $(echo "$COVERAGE < 80" | bc -l) )); then
# echo "::error::Coverage ${COVERAGE}% is below required 80% threshold"
# exit 1
# fi
env:
JARVY_TEST_MODE: 1
JARVY_FAST_TEST: 1