Skip to content

feat(test): add coverage badge#2

Merged
rkovalov merged 4 commits into
mainfrom
feat/coverage
Mar 1, 2026
Merged

feat(test): add coverage badge#2
rkovalov merged 4 commits into
mainfrom
feat/coverage

Conversation

@rkovalov

@rkovalov rkovalov commented Mar 1, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Documentation

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

    • Enhanced CI to run coverage-aware tests, compute overall coverage percentage, and automatically update the coverage badge.
    • Added a publish environment to the CI workflow to support publishing steps.

@coderabbitai

coderabbitai Bot commented Mar 1, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 38c75f3 and 0b192e5.

📒 Files selected for processing (1)
  • .github/workflows/publish.yml
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/publish.yml

Walkthrough

The CI publish workflow now runs tests with coverage, parses coverage/coverage-summary.json to compute total lines percent and color, and updates a coverage badge in a GitHub Gist; README.md was updated to include the new coverage badge.

Changes

Cohort / File(s) Summary
Coverage Badge Documentation
README.md
Added coverage badge line after existing CI badge (documentation-only).
Workflow Configuration
.github/workflows/publish.yml
Added environment: Publish to publish job; replaced pnpm test with pnpm test:coverage; added "Parse coverage" step to read coverage/coverage-summary.json and emit pct and color; added "Update coverage badge" step using schneegans/dynamic-badges-action with secrets; inserted steps between test and build.

Sequence Diagram(s)

sequenceDiagram
  participant GH as GitHub Actions
  participant Runner as CI Runner
  participant Test as Test (pnpm)
  participant Parser as Parse Coverage Step
  participant Badge as dynamic-badges-action
  participant Gist as GitHub Gist

  GH->>Runner: trigger publish workflow
  Runner->>Test: run `pnpm test:coverage`
  Test-->>Runner: write `coverage/coverage-summary.json`
  Runner->>Parser: read coverage JSON, compute pct & color
  Parser-->>Badge: provide `pct` and `color` outputs
  Badge->>Gist: update badge using Gist ID & auth
  Gist-->>GH: badge updated
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(test): add coverage badge' accurately summarizes the main changes: adding a coverage badge to the project via workflow modifications and README documentation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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
  • Commit unit tests in branch feat/coverage

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
.github/workflows/ci.yml (1)

32-32: Keep the CI test gate on pnpm run test.

Line 32 switches the primary test step to pnpm test:coverage; prefer keeping pnpm run test as the canonical gate and running coverage as an additional step.

Based on learnings: Run tests using pnpm run test.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/ci.yml at line 32, Replace the CI step that runs "pnpm
test:coverage" with the canonical test gate "pnpm run test" (i.e., use "pnpm run
test" as the primary test command) and move or add the coverage invocation
("pnpm test:coverage") into a separate subsequent job/step so coverage runs
after tests; update the workflow step that currently contains "run: pnpm
test:coverage" to run "pnpm run test" and create an additional step that
executes "pnpm test:coverage" only after the test step succeeds.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/ci.yml:
- Around line 41-49: Add a push trigger for main and guard the badge publication
so it only runs on pushes to main: update the workflow triggers to include push:
branches: [main], and add an if condition on the "Update coverage badge" step
(or its job) to only execute when github.event_name == 'push' && github.ref ==
'refs/heads/main' (alternatively check that the required secrets exist) so the
schneegans/dynamic-badges-action step using GIST_SECRET and
TEST_COVERAGE_GIST_ID runs only for real main branch pushes and not for
pull_request or forked PRs.

---

Nitpick comments:
In @.github/workflows/ci.yml:
- Line 32: Replace the CI step that runs "pnpm test:coverage" with the canonical
test gate "pnpm run test" (i.e., use "pnpm run test" as the primary test
command) and move or add the coverage invocation ("pnpm test:coverage") into a
separate subsequent job/step so coverage runs after tests; update the workflow
step that currently contains "run: pnpm test:coverage" to run "pnpm run test"
and create an additional step that executes "pnpm test:coverage" only after the
test step succeeds.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2d0f291 and 0d81265.

📒 Files selected for processing (2)
  • .github/workflows/ci.yml
  • README.md

Comment thread .github/workflows/ci.yml Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/publish.yml:
- Around line 42-44: The workflow currently uses Math.round when computing PCT
which can bump 79.5 to 80 and incorrectly set the badge; change the computation
that sets PCT (the node -e snippet that reads coverage/coverage-summary.json and
assigns PCT) to avoid rounding up—for example use Math.floor or Math.trunc (or
emit the raw percentage as a float) instead of Math.round so thresholding for
the color logic uses a non-upward-rounded value.
- Around line 46-54: The "Update coverage badge" step uses the mutable tag
schneegans/dynamic-badges-action@v1.7.0 and can fail the whole publish job; pin
the uses line to the action's full commit SHA (replace `@v1.7.0` with the
repo@<full-commit-sha>), add continue-on-error: true to the step to make badge
failures non-blocking, and add a conditional like if: ${{ secrets.GIST_SECRET &&
secrets.TEST_COVERAGE_GIST_ID }} so the step is skipped when required secrets
are missing; update the step that currently declares uses:
schneegans/dynamic-badges-action to these changes.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0d81265 and 757a7c8.

📒 Files selected for processing (1)
  • .github/workflows/publish.yml

Comment thread .github/workflows/publish.yml
Comment thread .github/workflows/publish.yml Outdated
@rkovalov rkovalov merged commit c9a5efb into main Mar 1, 2026
2 checks passed
@rkovalov rkovalov deleted the feat/coverage branch March 1, 2026 01:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant