Skip to content

✨ Enable coverage reporting in CI, add badge, gate new code at 80%#4064

Merged
clubanderson merged 1 commit intomainfrom
feat/coverage-ci-gate
Apr 1, 2026
Merged

✨ Enable coverage reporting in CI, add badge, gate new code at 80%#4064
clubanderson merged 1 commit intomainfrom
feat/coverage-ci-gate

Conversation

@clubanderson
Copy link
Copy Markdown
Collaborator

Summary

  • Coverage CI workflow: New .github/workflows/coverage-gate.yml runs on PRs that touch web/src/**. It runs vitest --coverage, then parses the JSON summary to check line coverage of only the files modified in the PR against an 80% threshold.
  • Warning, not blocking: Files below 80% are flagged in a PR comment but do not fail the build. This lets us ramp up coverage gradually without blocking existing work.
  • Coverage badge: Added a static coverage badge to README.md (currently shows 25% — will be updated as coverage improves).
  • Vitest config: Added json-summary reporter so the gate script can parse per-file coverage. Installed @vitest/coverage-v8 as a devDependency.

How it works

  1. Workflow triggers on PRs to main that modify web/src/**, web/vite.config.ts, or web/package.json
  2. Runs npx vitest run --coverage in the web/ directory
  3. Gets the list of modified .ts/.tsx files (excluding tests) via git diff
  4. For each modified file, looks up line coverage in coverage/coverage-summary.json
  5. Posts a markdown table as a PR comment showing each file's coverage vs the 80% threshold
  6. Updates the same comment on subsequent pushes (no comment spam)

Test plan

  • Verify YAML is valid (done locally with python3 -c "import yaml; yaml.safe_load(...)")
  • Verify npm run build passes
  • Verify workflow triggers on this PR and posts a coverage comment
  • Verify modified files are correctly identified and coverage is reported

- Add coverage-gate.yml workflow that runs on PRs touching web/src
- Checks line coverage of modified files against 80% threshold
- Posts coverage report as a PR comment (warning only, not blocking)
- Add json-summary reporter to vitest coverage config
- Install @vitest/coverage-v8 for CI coverage collection
- Add coverage badge to README

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
Copilot AI review requested due to automatic review settings April 1, 2026 02:22
@kubestellar-prow kubestellar-prow bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Apr 1, 2026
@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

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 1, 2026

Deploy Preview for kubestellarconsole ready!

Name Link
🔨 Latest commit 937db83
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/69cc8161887eb40008a65584
😎 Deploy Preview https://deploy-preview-4064.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/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 1, 2026
@clubanderson clubanderson merged commit 71a7c5c into main Apr 1, 2026
19 of 21 checks passed
@kubestellar-prow kubestellar-prow bot deleted the feat/coverage-ci-gate branch April 1, 2026 02:24
@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

Adds a CI workflow that runs Vitest coverage on PRs touching web/src/** and posts a per-modified-file coverage report to the PR, along with wiring up Vitest to emit a JSON summary and adding a README coverage badge.

Changes:

  • Add .github/workflows/coverage-gate.yml to run vitest --coverage, compute coverage for modified files, and comment a markdown report on the PR.
  • Update web/vite.config.ts to enable the json-summary coverage reporter and add @vitest/coverage-v8 to dev dependencies.
  • Add a static coverage badge to README.md.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
web/vite.config.ts Adds json-summary to coverage reporters so CI can parse per-file coverage.
web/package.json Adds @vitest/coverage-v8 needed for V8-based coverage in Vitest.
web/package-lock.json Locks the new coverage dependency and transitive packages.
README.md Displays a coverage badge on the project README.
.github/workflows/coverage-gate.yml New workflow to run coverage on PRs and post/update a coverage report comment.
Files not reviewed (1)
  • web/package-lock.json: Language not supported

paths:
- 'web/src/**'
- 'web/vite.config.ts'
- 'web/package.json'
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 workflow triggers on changes to web/package.json but not web/package-lock.json. Lockfile-only dependency updates can change coverage behavior and should also trigger this workflow; consider adding web/package-lock.json to the on.pull_request.paths list.

Suggested change
- 'web/package.json'
- 'web/package.json'
- 'web/package-lock.json'

Copilot uses AI. Check for mistakes.
' "$SUMMARY_FILE")

if [ "$LINE_PCT" = "null" ] || [ -z "$LINE_PCT" ]; then
REPORT_LINES="${REPORT_LINES}| \`${file}\` | — | No coverage data | :grey_question: |\n"
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.

When a modified file has no entry in coverage-summary.json, the script adds a “No coverage data” row but does not flip ALL_PASS to false. That can incorrectly report “All modified files meet the threshold” even though coverage for some modified files is unknown/missing. Treat missing coverage data as below-threshold (or as 0%) so the overall status becomes warn/fail accordingly.

Suggested change
REPORT_LINES="${REPORT_LINES}| \`${file}\` | | No coverage data | :grey_question: |\n"
REPORT_LINES="${REPORT_LINES}| \`${file}\` | 0% | ${THRESHOLD}% | :warning: No coverage data |\n"
BELOW_THRESHOLD="${BELOW_THRESHOLD}${file} (no coverage data)\n"
ALL_PASS=false

Copilot uses AI. Check for mistakes.
Comment on lines +11 to +17
permissions:
contents: read
pull-requests: write

concurrency:
group: coverage-gate-${{ github.event.pull_request.number }}
cancel-in-progress: true
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.

This job requests pull-requests: write and runs on pull_request, which includes fork PRs. On fork PRs, GITHUB_TOKEN is read-only, so the “Comment on PR” step will 403 and fail the job. Consider gating write/commenting behavior behind a same-repo check (e.g., github.event.pull_request.head.repo.id == github.repository_id as used in .github/workflows/handle-complications.lock.yml:53) or making the comment step non-fatal for forks.

Copilot uses AI. Check for mistakes.
Comment on lines +172 to +178
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});

const existing = comments.find(c => c.body.includes(marker));
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.

github.rest.issues.listComments is not paginated here (defaults to 30). If a PR has many comments, the existing marker comment may not be returned and the workflow can create duplicate coverage comments. Use github.paginate(...) (or request a higher per_page and paginate) when searching for the marker.

Suggested change
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const existing = comments.find(c => c.body.includes(marker));
const comments = await github.paginate(
github.rest.issues.listComments,
{
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
per_page: 100,
},
);
const existing = comments.find(c => c.body && c.body.includes(marker));

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

🔄 Auto-Applying Copilot Code Review

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

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

  • .github/workflows/coverage-gate.yml (line 9): - 'web/package.json' - 'web/package-lock.json'
  • .github/workflows/coverage-gate.yml (line 99): REPORT_LINES="${REPORT_LINES}| \${file}` | 0% | ${THRESHOLD}% | ⚠️ No c...`
  • .github/workflows/coverage-gate.yml (line 178): const comments = await github.paginate( github.rest.issues.listCom...

Also address these general comments:

  • .github/workflows/coverage-gate.yml (line 17): This job requests pull-requests: write and runs on pull_request, which includes fork PRs. On fork PRs, `GITHUB_TOKEN

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/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants