chore: multi-metric coverage badges & extraction script#67
Conversation
Reviewer's GuideIntroduces multi-metric coverage tracking by updating the README badges to show line, branch, and function coverage, and automates extraction, validation, and updating of these metrics via a new GitHub Actions workflow and support script. Flow diagram for coverage metrics extraction scriptflowchart TD
Start([Start]) --> CheckFile{Does coverage-final.json exist?}
CheckFile -- No --> Error1[Exit: Coverage file missing]
CheckFile -- Yes --> ParseFile[Parse coverage-final.json]
ParseFile -- Error --> Error2[Exit: Failed to parse]
ParseFile -- Success --> Aggregate[Aggregate line, branch, function totals]
Aggregate --> Calc[Calculate percentages]
Calc --> OutputType{JSON_OUTPUT=true?}
OutputType -- Yes --> JsonOut[Print JSON]
OutputType -- No --> ShellOut[Print shell exports]
JsonOut --> End([End])
ShellOut --> End
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Claude finished @docdyhr's task —— View job Code Review for Multi-Metric Coverage BadgesI've thoroughly analyzed this PR that adds comprehensive test and coverage badge functionality. Here's my detailed review: Review Progress
🔍 Overall Assessment: Well-Implemented with Some IssuesThis PR adds valuable multi-metric coverage badges with automated workflows. The implementation is solid but has several issues that need addressing.
|
There was a problem hiding this comment.
Pull Request Overview
This PR implements a comprehensive test coverage badge system with automated metrics extraction and updating. The changes introduce a Node.js script to extract coverage metrics from Jest output and a GitHub Actions workflow to automatically update README badges with current test and coverage statistics.
- Adds coverage metrics extraction script that parses Jest coverage data and outputs shell variables or JSON
- Implements automated GitHub Actions workflow for running tests, extracting metrics, and updating badges
- Updates README badges to show detailed coverage metrics (lines, branches, functions) instead of generic coverage
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| scripts/extract-coverage-metrics.js | New script to parse Jest coverage JSON and extract line/branch/function coverage percentages |
| .github/workflows/test-coverage-badges.yml | Complete CI workflow for running tests, extracting metrics, and automatically updating README badges |
| README.md | Updates badges from generic coverage to specific metrics and adjusts test count references |
Comments suppressed due to low confidence (1)
There was a problem hiding this comment.
Hey @docdyhr - I've reviewed your changes - here's some feedback:
- Remove the
|| truefrom the "Tests with coverage" step so that test failures fail the workflow immediately instead of being silently ignored. - Consider using Jest’s built-in JSON output (
--json --outputFile) instead of grepping console summaries, to make your metrics extraction more reliable. - The sed-based badge updates in README.md are brittle—think about centralizing badge definitions or using a templating approach to reduce regex maintenance overhead.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Remove the `|| true` from the "Tests with coverage" step so that test failures fail the workflow immediately instead of being silently ignored.
- Consider using Jest’s built-in JSON output (`--json --outputFile`) instead of grepping console summaries, to make your metrics extraction more reliable.
- The sed-based badge updates in README.md are brittle—think about centralizing badge definitions or using a templating approach to reduce regex maintenance overhead.
## Individual Comments
### Comment 1
<location> `scripts/extract-coverage-metrics.js:22` </location>
<code_context>
+try {
+ data = JSON.parse(fs.readFileSync(reportPath, "utf-8"));
+} catch (e) {
+ console.error("# failed to parse coverage-final.json", e.message);
+ process.exit(1);
+}
</code_context>
<issue_to_address>
Consider printing the full error object for debugging.
Printing e.stack instead of just e.message will provide more context for debugging parsing errors.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
console.error("# failed to parse coverage-final.json", e.message);
=======
console.error("# failed to parse coverage-final.json", e.stack);
>>>>>>> REPLACE
</suggested_fix>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Claude finished @docdyhr's task —— View job Code Review for Multi-Metric Coverage BadgesI've thoroughly analyzed this PR that adds comprehensive test and coverage badge functionality. Here's my detailed review: Review Progress
🔍 Overall Assessment: Well-Implemented with Some IssuesThis PR adds valuable multi-metric coverage badges with automated workflows. The implementation is solid but has several issues that need addressing.
|
Summary
Introduce multi-metric (lines / branches / functions) coverage visibility and automated badge updates. Expands test suite from 207 to 404 tests (all passing) and adds a guardrail script enforcing minimal thresholds (lines>=30, branches>=5, functions>=5) as a foundation for future ratcheting.
Key Changes
Rationale
Granular coverage metrics improve signal and help focus future improvements (e.g., branch coverage often lags lines). Guardrail starts permissive to avoid blocking while establishing baseline after large test suite expansion. History file will enable trend visualization in a later PR.
Follow-Up Ideas (Not in this PR)
Testing
Security & Quality
|| truemasking in test step).Checklist