-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (110 loc) · 4.38 KB
/
Copy pathcodecov.yml
File metadata and controls
128 lines (110 loc) · 4.38 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
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@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
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: Read just version
id: just_version
run: |
version="$(grep '^just_version :=' justfile | cut -d '"' -f 2)"
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Install just
uses: taiki-e/cache-cargo-install-action@417450f3c33ee20393705369577571770643d4c7 # v3.0.7
with:
tool: just@${{ steps.just_version.outputs.version }}
- name: Export coverage tool versions
id: tool_versions
run: |
{
echo "CARGO_LLVM_COV_VERSION=$(just --evaluate cargo_llvm_cov_version)"
echo "CARGO_NEXTEST_VERSION=$(just --evaluate 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@417450f3c33ee20393705369577571770643d4c7 # v3.0.7
with:
tool: cargo-llvm-cov@${{ steps.tool_versions.outputs.CARGO_LLVM_COV_VERSION }}
- name: Install cargo-nextest
uses: taiki-e/cache-cargo-install-action@417450f3c33ee20393705369577571770643d4c7 # v3.0.7
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/