Skip to content

Add README coverage badge and PR coverage checks#932

Merged
PeterDaveHello merged 1 commit intoChatGPTBox-dev:masterfrom
PeterDaveHello:add-README-test-coverage-badge
Feb 28, 2026
Merged

Add README coverage badge and PR coverage checks#932
PeterDaveHello merged 1 commit intoChatGPTBox-dev:masterfrom
PeterDaveHello:add-README-test-coverage-badge

Conversation

@PeterDaveHello
Copy link
Copy Markdown
Member

@PeterDaveHello PeterDaveHello commented Feb 28, 2026

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

flowchart LR
  A["PR Workflow"] -->|"Run test:coverage"| B["c8 Coverage Tool"]
  B -->|"Generate coverage"| C["Coverage Badge"]
  C -->|"Display in"| D["README.md"]
Loading

File Walkthrough

Relevant files
Configuration changes
pr-tests.yml
Update workflow to run coverage tests                                       

.github/workflows/pr-tests.yml

  • Changed PR test step from npm test to npm run test:coverage
  • Enables coverage reporting in CI/CD pipeline
+1/-1     
Documentation
README.md
Add coverage badge and references                                               

README.md

  • Added coverage badge to badges section
  • Added coverage-image reference link
  • Added coverage-url reference link pointing to pr-tests workflow
+5/-0     
Dependencies
package.json
Add c8 coverage tool and test script                                         

package.json

  • Added test:coverage script with c8 coverage tool
  • Configured c8 with --all flag and src/**/*.{mjs,jsx,js} include
    pattern
  • Added c8 as dev dependency version ^11.0.0
  • Properly quoted glob pattern for correct shell parsing
+2/-0     

Summary by CodeRabbit

  • Tests

    • CI updated to run coverage-aware tests, keep build step, and auto-update coverage status on main.
  • Documentation

    • Added a coverage status badge to the README for visibility into project test coverage.
  • Chores

    • Added coverage directories to ignore list and added tooling to produce coverage reports.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 28, 2026

📝 Walkthrough

Walkthrough

Updates CI to collect and publish test coverage: replaces test step with npm run test:coverage, adds a coverage-update job and script that writes badges/coverage.json, adds c8 devDependency, ignores coverage dirs, and adds README badge references.

Changes

Cohort / File(s) Summary
CI workflow
.github/workflows/pr-tests.yml
Replaces npm test with npm run test:coverage; preserves build step; adds update_coverage_badge job (checkout with fetch-depth:0, Node 22, npm ci, runs test:coverage, runs badge update script, commits badges/coverage.json with retry/fetch/rebase logic); adds repository permissions blocks.
Coverage script
.github/workflows/scripts/update-coverage-badge.mjs
New Node script reads coverage/coverage-summary.json, extracts total lines %, rounds value, maps to badge color, ensures badges/ exists, writes badges/coverage.json.
Package & tooling
package.json
Adds test:coverage npm script and c8 as a devDependency.
Repository ignores
.gitignore
Adds .coverage/ and coverage/ to ignored paths.
Badges & docs
badges/coverage.json, README.md
Adds initial badges/coverage.json and README entries (coverage-image, coverage-url) for displaying coverage badge.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Push as GitHub Push (master)
participant Actions as GitHub Actions Runner
participant Checkout as checkout@v4
participant Node as Node 22
participant Script as update-coverage-badge.mjs
participant Repo as Remote GitHub Repo

Push->>Actions: trigger update_coverage_badge job
Actions->>Checkout: checkout (fetch-depth: 0)
Actions->>Node: setup-node (22) & run `npm ci`
Node->>Node: run `npm run test:coverage` (c8 produces coverage-summary.json)
Node->>Script: run `update-coverage-badge.mjs`
Script->>Node: read `coverage/coverage-summary.json` -> generate `badges/coverage.json`
Node->>Repo: git add/commit badges/coverage.json
Node->>Repo: push (with retry: fetch, rebase, handle conflicts)
Repo-->>Actions: push success/failure (failures handled gracefully)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • hariatisalikon283-star

Poem

"I hop through tests and badges bright,
I count the lines in morning light,
I color green when numbers cheer,
I write a file for all to hear,
A rabbit's badge — coverage in sight! 🐇"

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add README coverage badge and PR coverage checks' directly and accurately describes the main changes: adding a coverage badge to README and implementing coverage checks in PR tests.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, 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 c8 coverage tool, adds a dedicated npm script for running coverage checks, and prominently displays the coverage status via a new badge in the README.md. These changes streamline the process of monitoring code health and ensure that coverage metrics are a standard part of the development and review cycle.

Highlights

  • Code Coverage Integration: Integrated code coverage checks into the pull request test workflow to ensure code quality standards are met.
  • README Update: Added a dynamic code coverage badge to the README.md file, making the coverage status visible directly from the repository page.
  • New Development Dependency: Introduced c8 as a development dependency, a code coverage tool leveraging Node.js's V8 engine.
  • Git Ignore Configuration: Updated the .gitignore file to exclude generated coverage artifacts, preventing them from being committed to the repository.
  • Script Configuration Correction: Normalized the c8 --include glob quoting in package.json to ensure the pattern is correctly parsed during script execution.

🧠 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
  • .gitignore
    • Added entries for .coverage/ and coverage/ directories to prevent them from being tracked by Git.
  • README.md
    • Included a new coverage badge linking to the PR tests workflow.
    • Defined coverage-image and coverage-url references for the new badge.
  • package-lock.json
    • Updated the dependency lock file to include c8 and its associated transitive dependencies.
    • Adjusted dependency resolutions, potentially hoisting some nested packages like ansi-styles, color-convert, and color-name to top-level entries.
  • package.json
    • Added c8 as a new development dependency.
    • Introduced a new test:coverage npm script that utilizes c8 with a corrected glob pattern for source file inclusion.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/pr-tests.yml
Activity
  • No specific human activity (comments, reviews) was provided in the context for this pull request.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@qodo-code-review
Copy link
Copy Markdown
Contributor

qodo-code-review Bot commented Feb 28, 2026

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-code-review
Copy link
Copy Markdown
Contributor

qodo-code-review Bot commented Feb 28, 2026

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Enforce coverage thresholds

Add coverage thresholds to the test:coverage script using --check-coverage and
flags like --lines and --branches to make the CI fail if coverage drops.

package.json [13]

-"test:coverage": "npx c8 --all --include=\"src/**/*.{mjs,jsx,js}\" node --import ./tests/setup/browser-shim.mjs --test",
+"test:coverage": "npx c8 --all --include src/**/*.{mjs,jsx,js} --check-coverage --branches 80 --functions 80 --lines 80 --statements 80 node --import ./tests/setup/browser-shim.mjs --test",
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly proposes adding coverage thresholds to the test:coverage script, which is a valuable improvement for maintaining code quality by ensuring CI fails if coverage drops.

Medium
  • Update

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

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.

Comment thread package.json Outdated
Copy link
Copy Markdown

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 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:coverage npm script (via c8) and add c8 as a dev dependency.
  • Update PR CI workflow to run npm run test:coverage instead of npm test.
  • Add a README badge for coverage/status and ignore generated coverage artifacts 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:coverage script invokes c8 via npx. Since c8 is a devDependency, running it directly (via the local node_modules/.bin that npm adds to PATH) avoids any chance of npx fetching/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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between edebfa2 and 36d9b77.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (4)
  • .github/workflows/pr-tests.yml
  • .gitignore
  • README.md
  • package.json

Comment thread package.json Outdated
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>
@PeterDaveHello PeterDaveHello force-pushed the add-README-test-coverage-badge branch from 36d9b77 to 468228a Compare February 28, 2026 13:36
@PeterDaveHello
Copy link
Copy Markdown
Member Author

@codex review

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
.github/workflows/pr-tests.yml (1)

59-60: Consider using artifacts to avoid running tests twice.

The update_coverage_badge job runs npm run test:coverage again even though the tests job already ran it. This doubles CI time on pushes to master.

You could upload the coverage output as an artifact in the tests job and download it here instead of re-running tests.

♻️ Example artifact-based approach

In tests job, 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: 1

In update_coverage_badge job, 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

📥 Commits

Reviewing files that changed from the base of the PR and between 36d9b77 and 468228a.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (6)
  • .github/workflows/pr-tests.yml
  • .github/workflows/scripts/update-coverage-badge.mjs
  • .gitignore
  • README.md
  • badges/coverage.json
  • package.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

Copy link
Copy Markdown

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

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

  • roundedPercentage is computed with toFixed(2) but then converted back to a Number, which drops trailing zeros (e.g., 10.10 becomes 10.1). If the intention is a consistently 2-decimal badge like the committed badges/coverage.json, keep the formatted percentage as a string for message and 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.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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

@PeterDaveHello PeterDaveHello merged commit 31331b7 into ChatGPTBox-dev:master Feb 28, 2026
7 checks passed
@PeterDaveHello PeterDaveHello deleted the add-README-test-coverage-badge branch February 28, 2026 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants