Repository navigation
ci: add staged coverage gates, baseline comparison, and PR coverage template - #6
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d0c88232ed
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| run: scripts/coverage_gate.sh coverage.out | ||
| env: | ||
| COVERAGE_STAGE: final | ||
| BASELINE_COVERAGE: ${{ env.BASELINE_COVERAGE }} |
There was a problem hiding this comment.
Propagate baseline coverage from runtime env
The baseline regression check is effectively disabled on pull requests because this step sets BASELINE_COVERAGE from ${{ env.BASELINE_COVERAGE }}, but that context only includes workflow/job/step env keys, not values written at runtime via $GITHUB_ENV in the previous step. As a result, BASELINE_COVERAGE is passed as empty and scripts/coverage_gate.sh skips the head < baseline guard (if [[ -n "$BASELINE_COVERAGE" ]]), so coverage regressions can merge unnoticed.
Useful? React with 👍 / 👎.
| - name: Coverage gate | ||
| run: scripts/coverage_gate.sh coverage.out | ||
| env: | ||
| COVERAGE_STAGE: final |
There was a problem hiding this comment.
Start CI coverage gate at a staged threshold
This hard-codes COVERAGE_STAGE to final, which makes the staged rollout logic in scripts/coverage_gate.sh (stage1|stage2|final) unreachable and immediately enforces the strictest threshold on every run. That defeats the intended staged adoption and will cause CI to fail continuously on branches that have not yet reached final targets, blocking normal PR flow instead of gradually tightening coverage gates.
Useful? React with 👍 / 👎.
Motivation
Description
.github/workflows/ci.ymlto generate coverage withgo test ./... -coverprofile=coverage.outandgo tool cover -func=coverage.out, fetch the base branch and compute a base coverage using a temporary worktree, and invoke the coverage gate script withCOVERAGE_STAGEandBASELINE_COVERAGEenvironment variables.scripts/coverage_gate.shwhich implements staged thresholds (stage1=60,stage2=70,final=80), parses total coverage from the coverage profile, enforces per-package stricter thresholds forinternal/configandinternal/install(>=85%), and fails if current coverage is below the providedBASELINE_COVERAGE..github/pull_request_template.mdwith coverage fields (before/after, affected packages) and a checklist that requires runninggo test ./... -coverprofile=coverage.out,go tool cover -func=coverage.out, no regression versus base, and critical package thresholds.Testing
go test ./... -coverprofile=coverage.outandgo tool cover -func=coverage.outto produce coverage artifacts, which completed and printed per-package results.COVERAGE_STAGE=final scripts/coverage_gate.sh coverage.out, which correctly parsed total coverage (38.4%) and failed because it is below the final threshold (80%).internal/config(71.3%) andinternal/install(21.6%) and failed those per-package checks as expected, validating the stricter-package logic.Codex Task