Add README coverage badge and PR coverage checks#932
Conversation
📝 WalkthroughWalkthroughUpdates CI to collect and publish test coverage: replaces test step with Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the project's testing and quality assurance by implementing comprehensive code coverage reporting. It integrates the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Ignored Files
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||
There was a problem hiding this comment.
Code Review
This pull request introduces code coverage reporting using c8. It adds a test:coverage script to package.json, updates the .gitignore to exclude coverage artifacts, and adds a coverage badge to the README.md. The changes are well-implemented. I've suggested a small improvement in package.json to enhance maintainability by avoiding command duplication in the npm scripts.
There was a problem hiding this comment.
Pull request overview
This PR adds a coverage-running test script and wires it into the PR test workflow, while also surfacing PR test/coverage status via a new README badge and preventing local coverage artifacts from being committed.
Changes:
- Add
test:coveragenpm script (viac8) and addc8as a dev dependency. - Update PR CI workflow to run
npm run test:coverageinstead ofnpm test. - Add a README badge for coverage/status and ignore generated
coverageartifacts in.gitignore.
Reviewed changes
Copilot reviewed 3 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Adds test:coverage script and c8 devDependency. |
| package-lock.json | Locks c8 and its transitive dependencies. |
| .github/workflows/pr-tests.yml | Switches PR test job to run coverage-enabled test script. |
| README.md | Adds a new badge and link definitions for “coverage”. |
| .gitignore | Ignores coverage/ and .coverage/ output directories. |
Comments suppressed due to low confidence (2)
package.json:13
- The
test:coveragescript invokesc8vianpx. Sincec8is a devDependency, running it directly (via the localnode_modules/.binthat npm adds to PATH) avoids any chance ofnpxfetching/executing a different version when dependencies aren’t installed, and is more deterministic for CI/local runs.
"test:coverage": "npx c8 --all --include=\"src/**/*.{mjs,jsx,js}\" node --import ./tests/setup/browser-shim.mjs --test",
README.md:46
[coverage-image]points to a GitHub Actions workflow status badge (.../workflows/pr-tests/badge.svg), which indicates whether the workflow is passing rather than reporting a coverage percentage/threshold. If the goal is an actual coverage badge/check, you’ll need to publish coverage results somewhere (e.g., upload an lcov report to a coverage service or generate a badge from artifacts) or rename the badge/label to reflect that it’s a CI status badge.
[coverage-image]: https://github.com/ChatGPTBox-dev/chatGPTBox/workflows/pr-tests/badge.svg
[coverage-url]: https://github.com/ChatGPTBox-dev/chatGPTBox/actions/workflows/pr-tests.yml
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@package.json`:
- Line 13: The test:coverage script ("test:coverage") collects coverage but
doesn't enforce thresholds; update the project to fail CI when coverage is below
required levels by adding explicit coverage thresholds—either add a "c8" (or
"nyc") config section in package.json with minimum percentages for
statements/branches/functions/lines, or modify the "test:coverage" script to
pass c8/nyc CLI flags that enable check-coverage and set those minimums; target
the "test:coverage" script and the package.json config so CI will error out when
coverage falls below the specified thresholds.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (4)
.github/workflows/pr-tests.yml.gitignoreREADME.mdpackage.json
Run the PR test workflow through npm run test:coverage and generate a repo-hosted coverage badge payload from coverage summary output. Use c8 directly from npm scripts and emit text, lcov, and json-summary reports so CI can update badge data without external coverage services. Replace the README coverage badge source with a shields endpoint that reads badges/coverage.json, auto-commit badge updates on master pushes, handle non-fast-forward push races with fetch/rebase retries, and scope write token permission to a push-only badge update job. Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
36d9b77 to
468228a
Compare
|
@codex review |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.github/workflows/pr-tests.yml (1)
59-60: Consider using artifacts to avoid running tests twice.The
update_coverage_badgejob runsnpm run test:coverageagain even though thetestsjob already ran it. This doubles CI time on pushes to master.You could upload the coverage output as an artifact in the
testsjob and download it here instead of re-running tests.♻️ Example artifact-based approach
In
testsjob, after running coverage:- run: npm run test:coverage - uses: actions/upload-artifact@v4 if: github.event_name == 'push' && github.ref == 'refs/heads/master' with: name: coverage-report path: coverage/ retention-days: 1In
update_coverage_badgejob, replace test:coverage with download:- uses: actions/download-artifact@v4 with: name: coverage-report path: coverage/🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/pr-tests.yml around lines 59 - 60, The CI duplicates running `npm run test:coverage` in the `update_coverage_badge` job; instead, modify the `tests` job to upload the generated coverage directory as an artifact (use actions/upload-artifact after `npm run test:coverage`, conditional for push to master if desired) and change the `update_coverage_badge` job to download that artifact (use actions/download-artifact) and use the downloaded coverage files rather than re-running `npm run test:coverage`; update job names `tests` and `update_coverage_badge` and the steps referencing `npm run test:coverage`, `actions/upload-artifact@v4`, and `actions/download-artifact@v4` accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.github/workflows/pr-tests.yml:
- Around line 59-60: The CI duplicates running `npm run test:coverage` in the
`update_coverage_badge` job; instead, modify the `tests` job to upload the
generated coverage directory as an artifact (use actions/upload-artifact after
`npm run test:coverage`, conditional for push to master if desired) and change
the `update_coverage_badge` job to download that artifact (use
actions/download-artifact) and use the downloaded coverage files rather than
re-running `npm run test:coverage`; update job names `tests` and
`update_coverage_badge` and the steps referencing `npm run test:coverage`,
`actions/upload-artifact@v4`, and `actions/download-artifact@v4` accordingly.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (6)
.github/workflows/pr-tests.yml.github/workflows/scripts/update-coverage-badge.mjs.gitignoreREADME.mdbadges/coverage.jsonpackage.json
✅ Files skipped from review due to trivial changes (1)
- badges/coverage.json
🚧 Files skipped from review as they are similar to previous changes (2)
- package.json
- README.md
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 7 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
.github/workflows/scripts/update-coverage-badge.mjs:34
roundedPercentageis computed withtoFixed(2)but then converted back to a Number, which drops trailing zeros (e.g.,10.10becomes10.1). If the intention is a consistently 2-decimal badge like the committedbadges/coverage.json, keep the formatted percentage as a string formessageand only coerce to a number for color selection (if needed).
const roundedPercentage = Number(linesPercentage.toFixed(2))
const badge = {
schemaVersion: 1,
label: 'coverage',
message: `${roundedPercentage}%`,
color: getBadgeColor(roundedPercentage),
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Codex Review: Didn't find any major issues. Breezy! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
User description
Run the PR test workflow through npm run test:coverage and add a coverage badge in README so coverage status is visible from the repository page.
Add c8 as a dev dependency and ignore generated .coverage/ and coverage/ artifacts to keep local coverage output out of commits.
Normalize the c8 --include glob quoting in package.json so the pattern is parsed as intended during script execution.
PR Type
Enhancement, Tests
Description
Add coverage badge to README for visibility
Integrate c8 code coverage tool as dev dependency
Update PR workflow to run test:coverage command
Add coverage glob pattern with proper quoting
Diagram Walkthrough
File Walkthrough
pr-tests.yml
Update workflow to run coverage tests.github/workflows/pr-tests.yml
npm testtonpm run test:coverageREADME.md
Add coverage badge and referencesREADME.md
package.json
Add c8 coverage tool and test scriptpackage.json
test:coveragescript with c8 coverage tool--allflag andsrc/**/*.{mjs,jsx,js}includepattern
Summary by CodeRabbit
Tests
Documentation
Chores