✨ Auto-update coverage badge via gist on merge to main#4066
✨ Auto-update coverage badge via gist on merge to main#4066clubanderson merged 1 commit intomainfrom
Conversation
- Add push trigger to coverage-gate workflow for main branch - Update gist with coverage percentage and color after each merge - README badge now reads from dynamic gist endpoint - Gist ID: b9a9ae8469f1897a22d5a40629bc1e82 Signed-off-by: Andrew Anderson <andy@clubanderson.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
✅ Deploy Preview for kubestellarconsole ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
👋 Hey @clubanderson — thanks for opening this PR!
This is an automated message. |
|
Thank you for your contribution! Your PR has been merged. Check out what's new:
Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey |
There was a problem hiding this comment.
Pull request overview
This PR switches the repository’s coverage badge to a dynamic Shields endpoint backed by a GitHub gist, and extends the existing coverage workflow to run on merges to main so it can compute and publish the updated total line coverage.
Changes:
- Update
README.mdto use ashields.io/endpointbadge that reads coverage JSON from a gist. - Extend
coverage-gate.ymlto also trigger onpushtomain. - Add a workflow step that reads
web/coverage/coverage-summary.jsonand attempts to update the gist badge payload after merges.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| README.md | Switch coverage badge from a static value to a Shields endpoint backed by a gist JSON payload. |
| .github/workflows/coverage-gate.yml | Trigger on push-to-main and add a gist update step to publish total coverage for the README badge. |
| env: | ||
| GIST_ID: 'b9a9ae8469f1897a22d5a40629bc1e82' | ||
| with: | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} |
There was a problem hiding this comment.
actions/github-script is using secrets.GITHUB_TOKEN to call github.rest.gists.update, but GITHUB_TOKEN (GitHub App installation token) typically cannot write to a user gist, so the badge update will silently never happen (you catch and ignore the error). Use a dedicated secret (PAT/fine-grained token) with gist write access (e.g., secrets.COVERAGE_GIST_TOKEN) and pass that as github-token for this step (keeping the step restricted to push on main).
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| github-token: ${{ secrets.COVERAGE_GIST_TOKEN }} |
|
|
||
| concurrency: | ||
| group: coverage-gate-${{ github.event.pull_request.number }} | ||
| group: coverage-gate-${{ github.event.pull_request.number || github.sha }} |
There was a problem hiding this comment.
The concurrency group uses github.sha for push runs, which makes every run a unique group and effectively disables cancel-in-progress on repeated pushes to main (older runs won't be cancelled). Consider grouping push runs by branch/ref (e.g., github.ref) so only the latest main run proceeds and you avoid overlapping Vitest runs / gist updates.
| group: coverage-gate-${{ github.event.pull_request.number || github.sha }} | |
| group: ${{ github.event_name == 'pull_request' && format('coverage-gate-pr-{0}', github.event.pull_request.number) || format('coverage-gate-ref-{0}', github.ref) }} |
| const GOOD_THRESHOLD = 60; | ||
| const OK_THRESHOLD = 40; | ||
| let color = 'red'; | ||
| if (pct >= GOOD_THRESHOLD) color = 'brightgreen'; | ||
| else if (pct >= OK_THRESHOLD) color = 'yellow'; | ||
| else color = 'orange'; |
There was a problem hiding this comment.
The badge color logic doesn’t match the PR description: this code produces brightgreen (>=60), yellow (40–59), and orange (<40), and the initial red value is never used. Either align the thresholds/colors with the documented scheme (red <40, orange 40–59, green 60+), or update the PR description to reflect the actual colors.
🔄 Auto-Applying Copilot Code ReviewCopilot code review found 2 code suggestion(s) and 1 general comment(s). @copilot Please apply all of the following code review suggestions:
Also address these general comments:
Push all fixes in a single commit. Run Auto-generated by copilot-review-apply workflow. |
Summary
coverage-gate.ymlnow also triggers on push to main (not just PRs)How it works
--coverage, producescoverage-summary.jsonb9a9ae8469f1897a22d5a40629bc1e82shields.io/endpoint) reads from gist → displays current %Test plan