Add coverage percent badge to README, auto-updated by CI#357
Merged
Conversation
Wires up a shields.io endpoint badge sourced from coverage.json in the repo so the README always shows the latest tested main-source coverage. - tools/coverage_check.py gains a --badge-json PATH flag that writes the shields.io endpoint schema (color-banded against the 90% gate). Writing is decoupled from the threshold gate so a regression still surfaces in the badge instead of silently freezing on the last-good value. - CI's existing coverage step is split into a Generate step (--threshold 0, never gates) and the original strict Enforce step. A new Publish step commits coverage.json back to master on pushes and to the PR head branch on internal pull requests, so reviewers see the coverage delta directly in the PR diff. Skipped on fork PRs (GITHUB_TOKEN is read-only against forks) and on non-canonical matrix entries to avoid races on the same file. - coverage.json is seeded with a "pending" placeholder so the badge renders correctly before the first master-merge CI run replaces it with the real value. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Reverts the PR auto-update path: PRs no longer get a github-actions[bot] commit updating coverage.json on each push. The badge now reflects master's tested state, full stop. The two-step Generate/Enforce split is collapsed back into the single Enforce step (which still writes the badge as a side effect via --badge-json, since the script writes before gating). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
coverage.jsonfile in the repo root.tools/coverage_check.pywith a--badge-json PATHflag that writes the shields.io schema (color-banded against the project's 90% gate). The script writes the JSON before the threshold check, so a regression below 90% still produces an honest value rather than freezing on the last-good one.Publish coverage badge to masterCI step that auto-commitscoverage.jsonback tomasterafter every push so the README badge tracks the latest tested state. Skipped on pull requests; the badge always reflects master.coverage.jsonwith apendingplaceholder so the badge renders correctly until the first master push replaces it. (The auto-commit599395aon this branch demonstrates the publish path working end-to-end — coverage measured at 91.0%.)Why only master
PRs run CI and the threshold gate as usual, but they don't get a
github-actions[bot]commit updatingcoverage.json. The badge is a master-state signal, not a per-PR signal.Test plan
python3 tools/coverage_check_test.py— all 30 tests pass (6 new tests coveringbadge_colorbands, JSON shape, parent-dir creation, threshold decoupling, and main() integration on pass + fail).599395a, confirming the publish step works.Generated with Claude Code