-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (120 loc) · 4.66 KB
/
Copy pathcodecov.yml
File metadata and controls
142 lines (120 loc) · 4.66 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
name: Codecov
concurrency:
# Ensure only one Codecov analysis runs per branch/ref
group: codecov-${{ github.ref_name }}
cancel-in-progress: true
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
# Least-privilege permissions
permissions:
contents: read
jobs:
coverage:
name: Code Coverage
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0 # Needed for Codecov diff analysis
persist-credentials: false
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0
with:
cache: true # toolchain/components are specified in rust-toolchain.toml
cache-bin: false
- name: Set up just
uses: ./.github/actions/setup-just
- name: Export coverage tool versions
id: tool_versions
shell: bash
run: |
set -euo pipefail
resolve_version() {
local name="$1"
local value
if ! value="$(just --evaluate "$name")"; then
echo "::error::Failed to resolve $name from justfile" >&2
return 1
fi
if [[ -z "$value" ]]; then
echo "::error::Resolved empty $name from justfile" >&2
return 1
fi
printf '%s\n' "$value"
}
cargo_llvm_cov_version="$(resolve_version cargo_llvm_cov_version)"
cargo_nextest_version="$(resolve_version cargo_nextest_version)"
{
echo "CARGO_LLVM_COV_VERSION=$cargo_llvm_cov_version"
echo "CARGO_NEXTEST_VERSION=$cargo_nextest_version"
} >> "$GITHUB_OUTPUT"
- name: Install LLVM coverage tools
run: rustup component add llvm-tools-preview
- name: Install cargo-llvm-cov
uses: taiki-e/cache-cargo-install-action@9ee83daaa7b96a6fab930949ecf1122bba04a389 # v3.0.8
with:
tool: cargo-llvm-cov@${{ steps.tool_versions.outputs.CARGO_LLVM_COV_VERSION }}
- name: Install cargo-nextest
uses: taiki-e/cache-cargo-install-action@9ee83daaa7b96a6fab930949ecf1122bba04a389 # v3.0.8
with:
tool: cargo-nextest@${{ steps.tool_versions.outputs.CARGO_NEXTEST_VERSION }}
- name: Run coverage
run: |
mkdir -p coverage
chmod 755 coverage
echo "::group::Running coverage"
# Single source of truth: coverage configuration lives in justfile
just coverage-ci
echo "::endgroup::"
echo "::group::Coverage verification"
ls -la coverage/ || true
if [ ! -f coverage/cobertura.xml ]; then
echo "::error::coverage/cobertura.xml not found. cargo-llvm-cov failed to generate XML output."
exit 2
fi
echo "::notice::Coverage report generated successfully: $(wc -l < coverage/cobertura.xml) lines"
if [ ! -f target/nextest/coverage/test-results/junit.xml ]; then
echo "::error::nextest JUnit report was not generated."
exit 2
fi
echo "::notice::Test results generated successfully."
echo "::endgroup::"
env:
RUST_BACKTRACE: 1
- name: Upload coverage to Codecov
if: ${{ success() && hashFiles('coverage/cobertura.xml') != '' }}
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
with:
files: coverage/cobertura.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Upload test results to Codecov
if: ${{ success() && hashFiles('target/nextest/coverage/test-results/junit.xml') != '' }}
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
with:
files: target/nextest/coverage/test-results/junit.xml
flags: unittests
name: nextest-results
report_type: test_results
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Archive coverage results
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: always()
with:
name: coverage-report
path: coverage/
- name: Archive test results
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: always()
with:
name: test-results
path: target/nextest/coverage/test-results/