forked from Dicklesworthstone/coding_agent_session_search
-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (90 loc) · 3.24 KB
/
Copy pathcoverage.yml
File metadata and controls
108 lines (90 loc) · 3.24 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
name: Coverage
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-D warnings"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
coverage:
name: Test Coverage
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Install Rust nightly
uses: dtolnay/rust-toolchain@881ba7bf39a41cda34ac9e123fb41b44ed08232f # nightly
with:
components: llvm-tools-preview
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@8db66d64862314dae6eb34821203eb85fcbc5055 # cargo-llvm-cov
- name: Cache cargo registry
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-coverage-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-coverage-
${{ runner.os }}-cargo-
- name: Generate coverage report
run: |
cargo llvm-cov --workspace --lib -j 1 \
--ignore-filename-regex "(tests/|benches/)" \
--codecov \
--output-path codecov.json
- name: Upload to Codecov
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4
with:
files: codecov.json
fail_ci_if_error: false
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Generate coverage summary
run: |
cargo llvm-cov --workspace --lib -j 1 \
--ignore-filename-regex "(tests/|benches/)" \
--json \
--output-path coverage.json
# Extract coverage percentage
COVERAGE=$(jq -r '.data[0].totals.lines.percent // 0' coverage.json)
echo "## Test Coverage: ${COVERAGE}%" >> $GITHUB_STEP_SUMMARY
# Add badge-style indicator
if (( $(echo "$COVERAGE >= 80" | bc -l) )); then
echo "Status: :white_check_mark: Meets 80% threshold" >> $GITHUB_STEP_SUMMARY
elif (( $(echo "$COVERAGE >= 60" | bc -l) )); then
echo "Status: :warning: Below 80% threshold" >> $GITHUB_STEP_SUMMARY
else
echo "Status: :x: Needs improvement" >> $GITHUB_STEP_SUMMARY
fi
- name: Check coverage threshold
if: github.event_name == 'pull_request'
run: |
COVERAGE=$(jq -r '.data[0].totals.lines.percent // 0' coverage.json)
THRESHOLD=60
echo "Coverage: ${COVERAGE}%"
echo "Threshold: ${THRESHOLD}%"
if (( $(echo "$COVERAGE < $THRESHOLD" | bc -l) )); then
echo "::error::Coverage ${COVERAGE}% is below ${THRESHOLD}% threshold"
exit 1
fi
- name: Upload coverage artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: coverage-report
path: |
codecov.json
coverage.json
retention-days: 14