Conversation
Reviewer's GuideReplaced the unsupported lookahead-based regex in the coverage parser with a simpler pattern that captures the percent sign and then strips it via File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary by CodeRabbit
Summary by CodeRabbit
WalkthroughThe script for extracting the coverage percentage in the ratchet-coverage GitHub Action was updated. The regex now captures the percentage value along with the percent sign, which is then removed using Changes
Possibly related PRs
Poem
✨ Finishing Touches🧪 Generate Unit Tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
.github/actions/ratchet-coverage/action.yml(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`.github/actions/*/{action.yml,README.md,CHANGELOG.md,src/,tests/}`: Each action...
.github/actions/*/{action.yml,README.md,CHANGELOG.md,src/,tests/}: Each action must have its own directory under .github/actions/, containing action.yml, README.md, src/, tests/, and CHANGELOG.md
📄 Source: CodeRabbit Inference Engine (AGENTS.md)
List of files the instruction was applied to:
.github/actions/ratchet-coverage/action.yml
`.github/actions/*/action.yml`: Fill in action.yml with every input and output; ...
.github/actions/*/action.yml: Fill in action.yml with every input and output; mark required ones clearly
For composite actions and path context, use "${{ github.action_path }}" when referencing sibling scripts for portability
📄 Source: CodeRabbit Inference Engine (AGENTS.md)
List of files the instruction was applied to:
.github/actions/ratchet-coverage/action.yml
| percent=$(echo "$output" | grep -oEm1 '[0-9]+(\.[0-9]+)?%' | tr -d '%') | ||
| echo "percent=$percent" >> "$GITHUB_OUTPUT" |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Good optimisation, but first-match may grab the wrong percentage
Dropping the head hop with -m1 is neat; however, -m1 still returns the very first percentage in the output, which for multi-crate workspaces is usually a crate-level figure, not the overall “Summary” line. This can silently mis-report coverage.
Consider anchoring to the Summary: line (or taking the last match) instead:
-percent=$(echo "$output" | grep -oEm1 '[0-9]+(\.[0-9]+)?%' | tr -d '%')
+percent=$(echo "$output" \
+ | awk '/^Summary:/ { for (i=1;i<=NF;i++) if ($i ~ /%$/) { gsub("%","",$i); print $i; exit } }')(or keep grep but pipe through tail -n1).
Worth a quick check if the action will run on projects with multiple crates.
🏁 Script executed:
#!/bin/bash
set -e
echo "Displaying lines 1-200 of action.yml for context:"
sed -n '1,200p' .github/actions/ratchet-coverage/action.yml || echo "File not found."Length of output: 2718
🌐 Web query:
What does cargo llvm-cov --summary-only output look like for a multi-crate workspace?
💡 Result:
When you run cargo llvm-cov --summary-only in a multi-crate workspace, it generates a summary of code coverage for each crate in the workspace. The output typically includes the following information for each crate:
- Crate Name: The name of the crate.
- Total Lines: The total number of lines in the crate's source code.
- Covered Lines: The number of lines that have been executed during testing.
- Uncovered Lines: The number of lines that have not been executed during testing.
- Coverage Percentage: The percentage of lines that have been covered by tests.
This summary helps you quickly assess the test coverage across all crates in your workspace.
For more detailed information on using cargo llvm-cov and its options, you can refer to the official documentation. (docs.rs)
Citations:
Anchor coverage extraction to the overall “Summary:” line
The current grep with -m1 will grab the first percentage in multi-crate output (a crate-level figure), not the final workspace summary. To ensure you report the true overall coverage, filter on the “Summary:” line or take the last match. For example, in .github/actions/ratchet-coverage/action.yml step Run coverage (around lines 50–51):
- percent=$(echo "$output" | grep -oEm1 '[0-9]+(\.[0-9]+)?%' | tr -d '%')
+ # Option 1: anchor to the "Summary:" line
+ percent=$(echo "$output" \
+ | grep '^Summary:' \
+ | grep -oE '[0-9]+(\.[0-9]+)?%' \
+ | tr -d '%')
# Or Option 2: take the last match
# percent=$(echo "$output" \
# | grep -oE '[0-9]+(\.[0-9]+)?%' \
# | tail -n1 \
# | tr -d '%')Please update the extraction logic to avoid mis-reporting coverage in multi-crate workspaces.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| percent=$(echo "$output" | grep -oEm1 '[0-9]+(\.[0-9]+)?%' | tr -d '%') | |
| echo "percent=$percent" >> "$GITHUB_OUTPUT" | |
| # Option 1: anchor to the "Summary:" line | |
| percent=$(echo "$output" \ | |
| | grep '^Summary:' \ | |
| | grep -oE '[0-9]+(\.[0-9]+)?%' \ | |
| | tr -d '%') | |
| # Or Option 2: take the last match | |
| # percent=$(echo "$output" \ | |
| # | grep -oE '[0-9]+(\.[0-9]+)?%' \ | |
| # | tail -n1 \ | |
| # | tr -d '%') | |
| echo "percent=$percent" >> "$GITHUB_OUTPUT" |
🤖 Prompt for AI Agents
In .github/actions/ratchet-coverage/action.yml around lines 50 to 51, the
coverage extraction uses grep with -m1 which captures the first percentage
found, often a crate-level coverage, not the overall summary. Modify the
extraction logic to first filter the output lines containing "Summary:" and then
extract the percentage from that line, or alternatively, capture the last
percentage match in the entire output. This ensures the reported coverage
reflects the true overall workspace summary.
Summary
Testing
git status --shorthttps://chatgpt.com/codex/tasks/task_e_68692df5ac248322ad1afce17110257b
Summary by Sourcery
CI: