ci: add ConfigMap-based coverage tracking#8084
ci: add ConfigMap-based coverage tracking#8084bryan-cox wants to merge 2 commits intoopenshift:mainfrom
Conversation
Upload coverage data to Codecov after each unit test run and add codecov.yml to set the default branch to main. - Uses codecov/codecov-action@v5 to upload cover.out - Token passed via env so fork PRs fall back to tokenless upload - codecov.yml sets default branch to main (Codecov defaults to master) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add coverage comparison using a ConfigMap on the arc-runner-set cluster to track baseline coverage and report diffs on PRs. - Extract total and per-directory coverage from cover.out - On push to main: update coverage-baseline ConfigMap with current data - On PRs: compare against baseline, fail if coverage drops >1% - Job summary shows trend indicators and per-directory breakdown Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Pipeline controller notification For optional jobs, comment This repository is configured in: LGTM mode |
|
Important Review skippedAuto reviews are limited based on label configuration. 🚫 Review skipped — only excluded labels are configured. (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Skipping CI for Draft Pull Request. |
|
Please specify an area label DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bryan-cox The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/close |
|
@bryan-cox: Closed this PR. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Summary
Add coverage comparison using a ConfigMap on the arc-runner-set cluster
to track baseline coverage and report diffs on PRs.
cover.outusinggo tool covercoverage-baselineConfigMap inarc-runnersnamespaceDepends on: #8060 (Codecov integration)
Setup on runner cluster
The following was applied to the arc-runner-set cluster:
```bash
export KUBECONFIG=/path/to/github-actions-kubeconfig
Create the ConfigMap
kubectl create configmap coverage-baseline -n arc-runners --from-literal=total=0
Grant the runner ServiceAccount access to the ConfigMap
kubectl create role coverage-baseline-access -n arc-runners
--verb=get,patch
--resource=configmaps
--resource-name=coverage-baseline
kubectl create rolebinding coverage-baseline-access -n arc-runners
--role=coverage-baseline-access
--serviceaccount=arc-runners:arc-runner-set-gha-rs-no-permission
Seed with actual baseline (run tests locally and extract coverage):
go test -race -count=1 -timeout=30m ./... -coverprofile cover.out
Build patch with total and per-directory coverage
TOTAL=$(go tool cover -func=cover.out | grep '^total:' | awk '{print $NF}' | tr -d '%')
PATCH="{"data":{"total":"${TOTAL}""
while IFS='=' read -r dir cov; do
PATCH="${PATCH},"dir.${dir}":"${cov}""
done < <(awk '
NR > 1 {
split($1, a, ":"); file = a[1]
sub("github.com/openshift/hypershift/", "", file)
split(file, parts, "/"); dir = parts[1]
stmts = $2; count = $3
total_stmt[dir] += stmts
if (count > 0) covered_stmt[dir] += stmts
}
END {
for (dir in total_stmt)
printf "%s=%.1f\n", dir, (total_stmt[dir] > 0 ? (covered_stmt[dir]/total_stmt[dir])*100 : 0)
}
' cover.out | sort)
PATCH="${PATCH}}}"
kubectl patch configmap coverage-baseline -n arc-runners -p "$PATCH"
```
The workflow updates this ConfigMap automatically on each push to main.
Test plan
🤖 Generated with Claude Code