Conversation
Reviewer's GuideImplements a new composite GitHub Action “ratchet coverage” that uses cargo tarpaulin with caching to enforce non-decreasing coverage baselines, alongside documentation updates and CODEOWNERS assignment. Sequence diagram for ratchet coverage action executionsequenceDiagram
participant Workflow
participant Cache as actions/cache
participant Cargo as cargo-tarpaulin
participant SaveCache as actions/cache/save
Workflow->>Cache: Restore baseline file
Workflow->>Cache: Cache cargo artifacts
Workflow->>Cargo: Install cargo-tarpaulin
Workflow->>Cargo: Run coverage
Cargo-->>Workflow: Output coverage percent
Workflow->>Workflow: Compare with baseline
alt Coverage decreased
Workflow->>Workflow: Fail job
else Coverage not decreased
Workflow->>SaveCache: Save updated baseline
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughA new GitHub Action, "Ratchet coverage", has been introduced to enforce and maintain Rust code coverage baselines using Changes
Sequence Diagram(s)sequenceDiagram
participant Workflow
participant Cache
participant Cargo
participant Tarpaulin
participant BaselineFile
Workflow->>Cache: Restore baseline coverage file
Workflow->>Cache: Restore cargo/tarpaulin cache
Workflow->>Cargo: Install cargo-tarpaulin
Workflow->>Tarpaulin: Run cargo tarpaulin for coverage
Tarpaulin-->>Workflow: Return coverage percentage
Workflow->>BaselineFile: Read stored baseline coverage
Workflow->>Workflow: Compare current vs baseline coverage
alt Coverage dropped
Workflow-->>Workflow: Fail action with error
else Coverage maintained/increased
Workflow->>BaselineFile: Update baseline file
Workflow->>Cache: Save updated baseline file
end
Workflow-->>Workflow: Output coverage percentage
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 (
|
There was a problem hiding this comment.
Hey @leynos - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `.github/actions/ratchet-coverage/action.yml:54` </location>
<code_context>
+ fi
+ echo "Current coverage: $current%"
+ echo "Baseline coverage: $baseline%"
+ if [ "$(echo "$current < $baseline" | bc -l)" = "1" ]; then
+ echo "Coverage decreased" >&2
+ exit 1
</code_context>
<issue_to_address>
Comparison using bc assumes both values are valid numbers.
Validate that both $current and $baseline are non-empty and numeric before using them in the bc comparison to prevent errors.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Actionable comments posted: 4
🔭 Outside diff range comments (1)
.github/actions/ratchet-coverage/action.yml (1)
60-66: Critical: Invalid cache action referenceYou’re using
actions/cache/save@v4to save the baseline, but the official action isactions/cache@v4for both restore and save steps. The current reference will fail.Change to:
- uses: actions/cache@v4 if: success() with: path: ${{ inputs.baseline-file }} key: ratchet-baseline-${{ runner.os }}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (5)
.github/actions/ratchet-coverage/CHANGELOG.md(1 hunks).github/actions/ratchet-coverage/README.md(1 hunks).github/actions/ratchet-coverage/action.yml(1 hunks)CODEOWNERS(1 hunks)README.md(1 hunks)
🔇 Additional comments (2)
CODEOWNERS (1)
1-5: Approve CODEOWNERS additionsDesignating
@leynosas the owner for the newratchet-coverageaction directory aligns with the other actions and ensures proper ownership assignment.README.md (1)
12-12: Approve new action listingListing
Ratchet coverageunder available actions correctly reflects the newly added action and its version.
| ```yaml | ||
| - uses: ./.github/actions/setup-rust@v1 | ||
| - uses: ./.github/actions/ratchet-coverage@v1 | ||
| with: | ||
| baseline-file: .cache/coverage-baseline | ||
| args: --workspace | ||
| ``` |
There was a problem hiding this comment.
Critical: Example uses unsupported args input
The usage example passes args: --workspace, but since args isn’t defined in action.yml, this will error.
Update either the example or the action’s inputs section.
🤖 Prompt for AI Agents
In .github/actions/ratchet-coverage/README.md around lines 21 to 27, the example
usage includes an unsupported input `args` which is not defined in the
action.yml inputs, causing errors. To fix this, either remove the `args:
--workspace` line from the example or add `args` as a valid input parameter in
the action.yml file under the inputs section with appropriate description and
default value if needed.
| | Name | Description | Required | Default | | ||
| | --- | --- | --- | --- | | ||
| | baseline-file | File used to persist the baseline coverage percentage between runs | no | `.coverage-baseline` | | ||
| | args | Additional arguments passed to `cargo tarpaulin` | no | *(none)* | | ||
|
|
There was a problem hiding this comment.
Critical: Documentation out of sync with action.yml inputs
The inputs table includes args, but the action manifest doesn’t declare this input. Workflows using args will fail.
Ensure action.yml and README inputs are aligned.
🤖 Prompt for AI Agents
In .github/actions/ratchet-coverage/README.md lines 8 to 12, the README lists an
input named 'args' that is not declared in the action.yml file, causing workflow
failures. To fix this, update the action.yml file to include the 'args' input
with the appropriate description, required flag, and default value matching the
README, or remove 'args' from the README if it is not supported. Ensure both
files have consistent input declarations.
|
@sourcery-ai review |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Hey @leynos - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `.github/actions/ratchet-coverage/action.yml:44` </location>
<code_context>
+ set -euo pipefail
+ output=$(cargo tarpaulin ${{ inputs.args }} --out lcov)
+ echo "$output"
+ percent=$(echo "$output" | grep -oE '[0-9]+\.[0-9]+(?=%)' | head -n1)
+ echo "percent=$percent" >> "$GITHUB_OUTPUT"
+ shell: bash
</code_context>
<issue_to_address>
Coverage percentage extraction may fail for integer-only outputs.
Update the regex to '[0-9]+(\.[0-9]+)?(?=%)' to match both integer and floating-point percentages.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| set -euo pipefail | ||
| output=$(cargo tarpaulin ${{ inputs.args }} --out lcov) | ||
| echo "$output" | ||
| percent=$(echo "$output" | grep -oE '[0-9]+\.[0-9]+(?=%)' | head -n1) |
There was a problem hiding this comment.
issue (bug_risk): Coverage percentage extraction may fail for integer-only outputs.
Update the regex to '[0-9]+(.[0-9]+)?(?=%)' to match both integer and floating-point percentages.
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
.github/actions/ratchet-coverage/action.yml (1)
58-62: Numeric validation before BC comparison
You’ve implemented the suggested pre-check to ensure both$currentand$baselineare valid numbers before invokingbc. This addresses the earlier warning aboutbcassumptions.
📜 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 comments (3)
.github/actions/ratchet-coverage/action.yml (3)
3-11: Inputs section now matches documentation
Theargsinput is correctly declared, aligningaction.ymlwith the README and preventing workflow breakage.
47-68: Verify availability ofbcon all runner OSes
This step relies onbcfor float comparison. While Ubuntu hasbcpreinstalled, macOS and Windows runners may not. Please confirm or installbcexplicitly to avoid cross-OS failures.
69-75: Confirm correct cache action version
The save step usesactions/cache/save@v4while restore usesactions/cache@v4. Please verify thatactions/cache/save@v4is a valid alias and aligns with the intended major version in the Marketplace.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@sourcery-ai review |
There was a problem hiding this comment.
Hey @leynos - I've reviewed your changes - here's some feedback:
- The
Save baselinestep is usingactions/cache/save@v4, which isn’t a valid action—useactions/cache@v4(with apoststep) to persist the baseline file instead. - Consider including branch name or other identifiers in the cache key for
ratchet-baselineso each branch/matrix line tracks its own coverage baseline rather than clobbering a shared one. - Run and fix the reported ShellCheck warnings in your bash steps to catch quoting issues and ensure robust error handling in the composite action.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `Save baseline` step is using `actions/cache/save@v4`, which isn’t a valid action—use `actions/cache@v4` (with a `post` step) to persist the baseline file instead.
- Consider including branch name or other identifiers in the cache key for `ratchet-baseline` so each branch/matrix line tracks its own coverage baseline rather than clobbering a shared one.
- Run and fix the reported ShellCheck warnings in your bash steps to catch quoting issues and ensure robust error handling in the composite action.
## Individual Comments
### Comment 1
<location> `.github/actions/ratchet-coverage/action.yml:71` </location>
<code_context>
+ echo "Coverage decreased" >&2
+ exit 1
+ fi
+ printf '%.2f' "$current" > "$file"
+ shell: bash
+ - name: Save baseline
</code_context>
<issue_to_address>
Overwriting the baseline file may cause issues in concurrent runs.
Parallel workflow runs could overwrite the same baseline file, causing race conditions. Use a branch- or run-specific cache key to avoid conflicts.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| echo "Coverage decreased" >&2 | ||
| exit 1 | ||
| fi | ||
| printf '%.2f' "$current" > "$file" |
There was a problem hiding this comment.
issue (bug_risk): Overwriting the baseline file may cause issues in concurrent runs.
Parallel workflow runs could overwrite the same baseline file, causing race conditions. Use a branch- or run-specific cache key to avoid conflicts.
There was a problem hiding this comment.
Actionable comments posted: 3
♻️ Duplicate comments (3)
.github/actions/ratchet-coverage/action.yml (3)
8-11: Duplicate resolved:argsinput declared
The missingargsinput noted in previous reviews has been added correctly and aligns with the README.
44-48: Duplicate resolved: regex and guard for coverage extraction
The regex now matches both integer and decimal percentages and the guard handles extraction failures. This addresses the prior feedback.
62-66: Duplicate resolved: numeric validation before comparison
Both$currentand$baselineare validated against a proper numeric pattern before usingbc. This implements the suggested guard.
| uses: actions/cache/save@v4 | ||
| with: | ||
| path: ${{ inputs.baseline-file }} | ||
| key: ratchet-baseline-${{ runner.os }} |
There was a problem hiding this comment.
Critical: incorrect cache action reference
The uses: actions/cache/save@v4 target does not exist. The save operation should reuse actions/cache@v4.
Apply this diff:
- uses: actions/cache/save@v4
+ uses: actions/cache@v4📝 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.
| uses: actions/cache/save@v4 | |
| with: | |
| path: ${{ inputs.baseline-file }} | |
| key: ratchet-baseline-${{ runner.os }} | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ inputs.baseline-file }} | |
| key: ratchet-baseline-${{ runner.os }} |
🤖 Prompt for AI Agents
In .github/actions/ratchet-coverage/action.yml at lines 75 to 78, the cache
action is incorrectly referenced as actions/cache/save@v4, which does not exist.
Replace this with the correct action reference actions/cache@v4 to properly use
the cache save functionality.
| set -euo pipefail | ||
| output=$(cargo tarpaulin ${{ inputs.args }} --out lcov) | ||
| echo "$output" | ||
| percent=$(echo "$output" | grep -oP '[0-9]+(?:\.[0-9]+)?(?=%)' | head -n1) |
There was a problem hiding this comment.
🧹 Nitpick (assertive)
Capture tarpaulin stderr for accurate parsing
Currently only stdout is captured; any errors on stderr could be missed and break the regex match.
Apply this diff to include stderr in the output:
- output=$(cargo tarpaulin ${{ inputs.args }} --out lcov)
+ output=$(cargo tarpaulin ${{ inputs.args }} --out lcov 2>&1)📝 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.
| set -euo pipefail | |
| output=$(cargo tarpaulin ${{ inputs.args }} --out lcov) | |
| echo "$output" | |
| percent=$(echo "$output" | grep -oP '[0-9]+(?:\.[0-9]+)?(?=%)' | head -n1) | |
| set -euo pipefail | |
| - output=$(cargo tarpaulin ${{ inputs.args }} --out lcov) | |
| + output=$(cargo tarpaulin ${{ inputs.args }} --out lcov 2>&1) | |
| echo "$output" | |
| percent=$(echo "$output" | grep -oP '[0-9]+(?:\.[0-9]+)?(?=%)' | head -n1) |
🤖 Prompt for AI Agents
In .github/actions/ratchet-coverage/action.yml around lines 41 to 44, the script
captures only stdout from the cargo tarpaulin command, missing any stderr output
which may contain important error messages and affect regex parsing. Modify the
command to capture both stdout and stderr by redirecting stderr to stdout,
ensuring the output variable contains all output for accurate parsing and error
detection.
| if [ "$(echo "$current < $baseline" | bc -l)" = "1" ]; then | ||
| echo "Coverage decreased" >&2 | ||
| exit 1 | ||
| fi |
There was a problem hiding this comment.
🧹 Nitpick (assertive)
Ensure bc availability or restrict to Linux runners
bc may not be installed on Windows or macOS runners, causing failures. Consider either installing bc or adding an OS check.
For example, prepend in the Ratchet coverage step:
+ if [[ "$RUNNER_OS" != "Linux" ]]; then
+ echo "This action only supports Linux runners for float comparisons." >&2
+ exit 1
+ fi📝 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.
| if [ "$(echo "$current < $baseline" | bc -l)" = "1" ]; then | |
| echo "Coverage decreased" >&2 | |
| exit 1 | |
| fi | |
| # Ensure we're on Linux where `bc` is guaranteed to be installed | |
| if [[ "$RUNNER_OS" != "Linux" ]]; then | |
| echo "This action only supports Linux runners for float comparisons." >&2 | |
| exit 1 | |
| fi | |
| if [ "$(echo "$current < $baseline" | bc -l)" = "1" ]; then | |
| echo "Coverage decreased" >&2 | |
| exit 1 | |
| fi |
🤖 Prompt for AI Agents
In .github/actions/ratchet-coverage/action.yml around lines 67 to 70, the script
uses `bc` for floating-point comparison, but `bc` may not be installed on
Windows or macOS runners, causing failures. Fix this by adding a check for the
operating system before running the comparison or ensure `bc` is installed on
the runner. Alternatively, restrict the action to run only on Linux runners
where `bc` is available.
Summary
Testing
shellcheck.github/actions/ratchet-coverage/action.yml(fails: SC2296, SC2215, etc)https://chatgpt.com/codex/tasks/task_e_685833bc868c8322bc657544a8d76023
Summary by Sourcery
Introduce a new 'ratchet coverage' GitHub Action for automated coverage tracking, enhance documentation and caching, and establish ownership via CODEOWNERS
New Features:
Enhancements:
Documentation:
Chores:
Summary by CodeRabbit