Skip to content

Commit 4390f96

Browse files
authored
Merge pull request #5954 from sysown/fix/codecov-unit-coverage-merge
fix(ci): merge unit-test Codecov coverage
2 parents c66549e + 555ff35 commit 4390f96

2 files changed

Lines changed: 64 additions & 0 deletions

File tree

.github/workflows/CI-unit-tests-asan-coverage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ jobs:
182182
if: always()
183183
uses: codecov/codecov-action@v4
184184
with:
185+
codecov_yml_path: codecov.yml
185186
files: coverage/lcov.info
186187
flags: unit-tests
187188
name: unit-tests-asan-coverage
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
WORKFLOW_ROOT="${1:-.github/workflows}"
5+
EXPECTED_CONFIG="${2:-codecov.yml}"
6+
7+
mapfile -t WORKFLOWS < <(
8+
rg -l --glob '*.yml' --glob '*.yaml' \
9+
'^[[:space:]]*uses:[[:space:]]*codecov/codecov-action@v4' \
10+
"${WORKFLOW_ROOT}" | sort
11+
)
12+
13+
if [ "${#WORKFLOWS[@]}" -eq 0 ]; then
14+
echo "ERROR: no Codecov workflows found under ${WORKFLOW_ROOT}" >&2
15+
exit 1
16+
fi
17+
18+
for workflow in "${WORKFLOWS[@]}"; do
19+
awk -v file="${workflow}" -v expected="${EXPECTED_CONFIG}" '
20+
function finish_step() {
21+
if (!has_codecov) {
22+
return
23+
}
24+
if (!has_config) {
25+
printf "%s: missing codecov_yml_path: %s\n", file, expected > "/dev/stderr"
26+
bad = 1
27+
}
28+
if (!has_nonblocking) {
29+
printf "%s: Codecov upload must keep fail_ci_if_error: false\n", file > "/dev/stderr"
30+
bad = 1
31+
}
32+
}
33+
34+
/^[[:space:]]*-[[:space:]]/ {
35+
if (in_step) {
36+
finish_step()
37+
}
38+
in_step = 1
39+
has_codecov = 0
40+
has_config = 0
41+
has_nonblocking = 0
42+
}
43+
44+
/uses:[[:space:]]*codecov\/codecov-action@v4/ {
45+
has_codecov = 1
46+
}
47+
/codecov_yml_path:/ && index($0, expected) {
48+
has_config = 1
49+
}
50+
/fail_ci_if_error:[[:space:]]*false/ {
51+
has_nonblocking = 1
52+
}
53+
54+
END {
55+
if (in_step) {
56+
finish_step()
57+
}
58+
exit bad
59+
}
60+
' "${workflow}"
61+
done
62+
63+
echo "Codecov workflow contract OK: ${#WORKFLOWS[@]} workflow(s), config=${EXPECTED_CONFIG}"

0 commit comments

Comments
 (0)