Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 58 additions & 2 deletions .github/workflows/coverage-gate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ on:
- 'web/src/**'
- 'web/vite.config.ts'
- 'web/package.json'
push:
branches: [main]
paths:
- 'web/src/**'
- 'web/vite.config.ts'
- 'web/package.json'

permissions:
contents: read
pull-requests: write

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.
cancel-in-progress: true

env:
Expand Down Expand Up @@ -152,7 +158,7 @@ jobs:
retention-days: 14

- name: Comment on PR
if: steps.gate.outputs.status != 'skip'
if: github.event_name == 'pull_request' && steps.gate.outputs.status != 'skip'
uses: actions/github-script@v7
with:
script: |
Expand Down Expand Up @@ -192,3 +198,53 @@ jobs:
body: fullBody,
});
}

# Update coverage badge gist on push to main
- name: Update coverage badge
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/github-script@v7
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.
script: |
const fs = require('fs');
const summaryPath = 'web/coverage/coverage-summary.json';

if (!fs.existsSync(summaryPath)) {
console.log('No coverage summary — skipping badge update');
return;
}

const summary = JSON.parse(fs.readFileSync(summaryPath, 'utf8'));
const pct = Math.round(summary.total?.lines?.pct ?? 0);

// Color based on coverage percentage
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';
Comment on lines +223 to +228
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.

const badge = {
schemaVersion: 1,
label: 'coverage',
message: `${pct}%`,
color,
};

try {
await github.rest.gists.update({
gist_id: process.env.GIST_ID,
files: {
'coverage-badge.json': {
content: JSON.stringify(badge),
},
},
});
console.log(`Badge updated: ${pct}% (${color})`);
} catch (err) {
console.log(`Failed to update gist: ${err.message}`);
// Non-fatal — don't fail the build for a badge
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# KubeStellar Console

![Coverage](https://img.shields.io/badge/coverage-25%25-yellow)
![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/clubanderson/b9a9ae8469f1897a22d5a40629bc1e82/raw/coverage-badge.json)

AI-powered multi-cluster Kubernetes dashboard with guided install missions for 250+ CNCF projects.

Expand Down
Loading