Skip to content

✨ Auto-update coverage badge via gist on merge to main#4066

Merged
clubanderson merged 1 commit intomainfrom
feat/dynamic-coverage-badge
Apr 1, 2026
Merged

✨ Auto-update coverage badge via gist on merge to main#4066
clubanderson merged 1 commit intomainfrom
feat/dynamic-coverage-badge

Conversation

@clubanderson
Copy link
Copy Markdown
Collaborator

Summary

  • Coverage badge in README now reads from a dynamic gist endpoint instead of a hardcoded static value
  • coverage-gate.yml now also triggers on push to main (not just PRs)
  • On merge to main: computes total line coverage, updates gist with percentage and color
  • Badge auto-updates: red (<40%), orange (40-59%), green (60%+)

How it works

  1. PR merges to main → coverage-gate workflow runs
  2. Vitest runs with --coverage, produces coverage-summary.json
  3. Workflow reads total line %, updates gist b9a9ae8469f1897a22d5a40629bc1e82
  4. README badge (shields.io/endpoint) reads from gist → displays current %

Test plan

  • Merge this PR → verify coverage-gate workflow runs on push
  • Check gist updates with actual coverage number
  • Verify README badge reflects new value

- 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>
Copilot AI review requested due to automatic review settings April 1, 2026 02:27
@kubestellar-prow
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign clubanderson for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Apr 1, 2026
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 1, 2026

Deploy Preview for kubestellarconsole ready!

Name Link
🔨 Latest commit 1b78339
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/69cc827eaa7da400080c4ef2
😎 Deploy Preview https://deploy-preview-4066.console-deploy-preview.kubestellar.io
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

👋 Hey @clubanderson — thanks for opening this PR!

🤖 This project is developed exclusively using AI coding assistants.

Please do not attempt to code anything for this project manually.
All contributions should be authored using an AI coding tool such as:

This ensures consistency in code style, architecture patterns, test coverage,
and commit quality across the entire codebase.


This is an automated message.

@kubestellar-prow kubestellar-prow bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Apr 1, 2026
@clubanderson clubanderson merged commit ec43b8d into main Apr 1, 2026
15 of 17 checks passed
@kubestellar-prow kubestellar-prow bot deleted the feat/dynamic-coverage-badge branch April 1, 2026 02:28
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

Thank you for your contribution! Your PR has been merged.

Check out what's new:

Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.md to use a shields.io/endpoint badge that reads coverage JSON from a gist.
  • Extend coverage-gate.yml to also trigger on push to main.
  • Add a workflow step that reads web/coverage/coverage-summary.json and 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 }}
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
github-token: ${{ secrets.GITHUB_TOKEN }}
github-token: ${{ secrets.COVERAGE_GIST_TOKEN }}

Copilot uses AI. Check for mistakes.

concurrency:
group: coverage-gate-${{ github.event.pull_request.number }}
group: coverage-gate-${{ github.event.pull_request.number || github.sha }}
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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) }}

Copilot uses AI. Check for mistakes.
Comment on lines +223 to +228
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';
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@clubanderson
Copy link
Copy Markdown
Collaborator Author

🔄 Auto-Applying Copilot Code Review

Copilot code review found 2 code suggestion(s) and 1 general comment(s).

@copilot Please apply all of the following code review suggestions:

  • .github/workflows/coverage-gate.yml (line 209): github-token: ${{ secrets.COVERAGE_GIST_TOKEN }}
  • .github/workflows/coverage-gate.yml (line 22): group: ${{ github.event_name == 'pull_request' && format('coverage-gate-pr-{0}',...

Also address these general comments:

  • .github/workflows/coverage-gate.yml (line 228): The badge color logic doesn’t match the PR description: this code produces brightgreen (>=60), yellow (40–59), and `

Push all fixes in a single commit. Run cd web && npm run build && npm run lint before committing.


Auto-generated by copilot-review-apply workflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the DCO. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants