feat(test): add coverage badge#2
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe 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
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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
.github/workflows/ci.yml (1)
32-32: Keep the CI test gate onpnpm run test.Line 32 switches the primary test step to
pnpm test:coverage; prefer keepingpnpm run testas 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.
There was a problem hiding this comment.
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.
Summary by CodeRabbit
Documentation
Chores