Conversation
Reviewer's GuideThis PR enhances the Ratchet coverage GitHub Action by adding a flexible Sequence diagram for the ratchet coverage action execution flowsequenceDiagram
actor User
participant Workflow
participant Cache
participant Cargo
participant MSYS2 as "MSYS2 (Windows only)"
participant BC as "bc"
User->>Workflow: Trigger workflow with Ratchet coverage action
Workflow->>Cache: Restore baseline file
Workflow->>Cache: Restore cargo artifacts
Workflow->>Cargo: Install cargo-llvm-cov
alt On Windows
Workflow->>MSYS2: Install bc
end
Workflow->>Cargo: Run cargo llvm-cov with args
Cargo-->>Workflow: Output coverage percent
Workflow->>BC: Compare current and baseline coverage
alt Coverage decreased
Workflow-->>User: Fail workflow
else Coverage maintained/increased
Workflow->>Cache: Save updated baseline
Workflow-->>User: Pass workflow
end
Entity relationship diagram for baseline and coverage artifacts cachingerDiagram
WORKFLOW ||--o{ BASELINE_CACHE : uses
WORKFLOW ||--o{ CARGO_CACHE : uses
WORKFLOW {
string baseline_file
string args
float percent
}
BASELINE_CACHE {
string file_path
float baseline_percent
}
CARGO_CACHE {
string cargo_bin
string cargo_registry
string cargo_git
string target_dir
}
Class diagram for the Ratchet coverage action inputs and outputsclassDiagram
class RatchetCoverageAction {
+String baseline-file = ".coverage-baseline"
+String args = ""
+String percent
}
RatchetCoverageAction : +run()
RatchetCoverageAction : +validateCoverage()
RatchetCoverageAction : +compareWithBaseline()
RatchetCoverageAction : +updateBaseline()
RatchetCoverageAction : +cacheArtifacts()
RatchetCoverageAction : +installDependencies()
RatchetCoverageAction : +outputPercent()
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 called "Ratchet coverage" has been introduced, including its implementation, documentation, changelog, and ownership assignment. The action enforces a code coverage baseline for Rust projects using Changes
Sequence Diagram(s)sequenceDiagram
participant Workflow
participant RatchetCoverageAction
participant Cache
participant CargoLlvmCov
Workflow->>RatchetCoverageAction: Start Action
RatchetCoverageAction->>Cache: Restore baseline file
RatchetCoverageAction->>Cache: Restore cargo cache
RatchetCoverageAction->>CargoLlvmCov: Install if needed
RatchetCoverageAction->>CargoLlvmCov: Run coverage with args
CargoLlvmCov-->>RatchetCoverageAction: Return coverage percent
RatchetCoverageAction->>RatchetCoverageAction: Validate coverage values
RatchetCoverageAction->>RatchetCoverageAction: Compare with baseline
alt Coverage < Baseline
RatchetCoverageAction->>Workflow: Fail action (coverage decreased)
else Coverage >= Baseline
RatchetCoverageAction->>Cache: Update baseline file in cache
RatchetCoverageAction->>Workflow: Output new coverage percent
end
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:50` </location>
<code_context>
+ set -euo pipefail
+ output=$(cargo tarpaulin --out lcov ${{ inputs.args }})
+ 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 decimal coverage values.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
percent=$(echo "$output" | grep -oE '[0-9]+\.[0-9]+(?=%)' | head -n1)
=======
percent=$(echo "$output" | grep -oE '[0-9]+(\.[0-9]+)?(?=%)' | head -n1)
>>>>>>> REPLACE
</suggested_fix>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
📜 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 (3)
CODEOWNERS (1)
1-5: Ownership assignments look good
Ownership of the newratchet-coveragedirectory (and existing actions) is clearly defined and points to the correct user.README.md (1)
12-12: New action documented correctly
The "Ratchet coverage" entry matches the existing table format, with the correct path and version..github/actions/ratchet-coverage/CHANGELOG.md (1)
3-7: Changelog entries are consistent
The v1.0.1 and v1.0.0 entries accurately describe the addition of theargsinput and the numeric validation enhancement.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@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:
- Pin a specific cargo-tarpaulin version in the install step (e.g.
cargo install cargo-tarpaulin --version x.y.z) to avoid unexpected updates breaking the action. - The PR summary mentions installing
bcon Windows, but the action actually fails early on non-Linux runners—either implement the Windows install or update the docs to remove that bullet. - Clarify in the README that this composite action expects a Rust toolchain (e.g. via your setup-rust action) to already be installed before running tarpaulin.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Pin a specific cargo-tarpaulin version in the install step (e.g. `cargo install cargo-tarpaulin --version x.y.z`) to avoid unexpected updates breaking the action.
- The PR summary mentions installing `bc` on Windows, but the action actually fails early on non-Linux runners—either implement the Windows install or update the docs to remove that bullet.
- Clarify in the README that this composite action expects a Rust toolchain (e.g. via your setup-rust action) to already be installed before running tarpaulin.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: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (3)
.github/actions/ratchet-coverage/CHANGELOG.md(1 hunks).github/actions/ratchet-coverage/README.md(1 hunks).github/actions/ratchet-coverage/action.yml(1 hunks)
🧰 Additional context used
🪛 LanguageTool
.github/actions/ratchet-coverage/CHANGELOG.md
[uncategorized] ~7-~7: Possible missing comma found.
Context: ...e values before comparison - Fail early on non-Linux runners - Handle integer cove...
(AI_HYDRA_LEO_MISSING_COMMA)
🔇 Additional comments (6)
.github/actions/ratchet-coverage/README.md (1)
1-46: Documentation is clear and accurate.
The README correctly details inputs, outputs, usage examples and platform requirements for the Ratchet coverage action..github/actions/ratchet-coverage/action.yml (5)
1-18: Inputs and outputs are clearly defined.
Thebaseline-fileandargsinputs, along with thepercentoutput, are well documented and have sensible defaults.
19-27: Platform check and baseline restore steps are correctly implemented.
Failing early on non-Linux runners and restoring the baseline cache with a consistent key are both handled properly.
28-43: Caching and installation steps look good.
The cache for cargo artifacts and the installation ofcargo-tarpaulinare correctly set up to speed up repeated runs.
44-51: Coverage extraction and percentage parsing are implemented robustly.
The regex handles both integer and decimal percentages and writes the result toGITHUB_OUTPUTas expected.
79-85: Saving the updated baseline cache uses consistent keys.
The final cache step correctly reuses the same key and path, ensuring that the new baseline is stored for subsequent runs.
| - Add `args` input and include it in tarpaulin command | ||
| - Validate numeric coverage values before comparison | ||
| - Fail early on non-Linux runners | ||
| - Handle integer coverage values in output parsing |
There was a problem hiding this comment.
🧹 Nitpick (assertive)
Ensure consistent punctuation in v1.0.1 bullets.
The bullet items under v1.0.1 lack trailing periods, whereas the v1.0.0 entry ends with one. Add a period to each list item for consistency:
- Add `args` input and include it in tarpaulin command
- Validate numeric coverage values before comparison
- Fail early on non-Linux runners
- Handle integer coverage values in output parsing
+ Add `args` input and include it in tarpaulin command.
+ Validate numeric coverage values before comparison.
+ Fail early on non-Linux runners.
+ Handle integer coverage values in output parsing.📝 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.
| - Add `args` input and include it in tarpaulin command | |
| - Validate numeric coverage values before comparison | |
| - Fail early on non-Linux runners | |
| - Handle integer coverage values in output parsing | |
| - Add `args` input and include it in tarpaulin command. | |
| - Validate numeric coverage values before comparison. | |
| - Fail early on non-Linux runners. | |
| - Handle integer coverage values in output parsing. |
🧰 Tools
🪛 LanguageTool
[uncategorized] ~7-~7: Possible missing comma found.
Context: ...e values before comparison - Fail early on non-Linux runners - Handle integer cove...
(AI_HYDRA_LEO_MISSING_COMMA)
🤖 Prompt for AI Agents
In .github/actions/ratchet-coverage/CHANGELOG.md around lines 5 to 8, the bullet
points under v1.0.1 are missing trailing periods, unlike the v1.0.0 entry which
ends with periods. Add a period at the end of each bullet item in the v1.0.1
list to ensure consistent punctuation formatting.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 6
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (3)
.github/actions/ratchet-coverage/CHANGELOG.md(1 hunks).github/actions/ratchet-coverage/README.md(1 hunks).github/actions/ratchet-coverage/action.yml(1 hunks)
🧰 Additional context used
🪛 LanguageTool
.github/actions/ratchet-coverage/CHANGELOG.md
[uncategorized] ~9-~9: You might be missing the article “the” here.
Context: ...1 - Add args input and include it in tarpaulin command. - Validate numeric coverage va...
(AI_EN_LECTOR_MISSING_DETERMINER_THE)
.github/actions/ratchet-coverage/README.md
[uncategorized] ~31-~31: Use a comma before ‘so’ if it connects two independent clauses (unless they are closely connected and short).
Context: ... on Windows, bc is installed via MSYS2 so the float comparison works the same eve...
(COMMA_COMPOUND_SENTENCE_2)
[uncategorized] ~45-~45: A comma might be missing here.
Context: ...arpaulin` only supports Linux. On other platforms the step is skipped. Release history i...
(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
🪛 YAMLlint (1.37.1)
.github/actions/ratchet-coverage/action.yml
[error] 20-20: syntax error: mapping values are not allowed here
(syntax)
|
@sourcery-ai review |
|
@sourcery-ai review |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
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 (3)
.github/actions/ratchet-coverage/CHANGELOG.md(1 hunks).github/actions/ratchet-coverage/README.md(1 hunks).github/actions/ratchet-coverage/action.yml(1 hunks)
🧰 Additional context used
🪛 LanguageTool
.github/actions/ratchet-coverage/CHANGELOG.md
[uncategorized] ~9-~9: Use a comma before ‘so’ if it connects two independent clauses (unless they are closely connected and short).
Context: .... ## v1.0.3 - Remove Linux-only gating so the action runs on all runners. ## v1....
(COMMA_COMPOUND_SENTENCE_2)
.github/actions/ratchet-coverage/README.md
[uncategorized] ~29-~29: Possible missing comma found.
Context: ...e args: --workspace ``` On Windows runners bc is installed via MSYS2, so the flo...
(AI_HYDRA_LEO_MISSING_COMMA)
🔇 Additional comments (2)
.github/actions/ratchet-coverage/README.md (1)
1-55: Skip README review: no issues found..github/actions/ratchet-coverage/action.yml (1)
1-88: No changes needed.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Summary
argsinput to ratchet coverage actionbccomparisonargsinput with default valuebcinstalled on Windows runnersTesting
shellcheck .github/actions/ratchet-coverage/action.yml(fails: SC2296, SC1130, etc.)https://chatgpt.com/codex/tasks/task_e_685833bc868c8322bc657544a8d76023
Summary by Sourcery
Add a new GitHub composite action for ratcheting Rust coverage baselines with configurable arguments, cross-platform float comparisons, and caching support.
New Features:
ratchet-coverageaction to runcargo llvm-cov, compare against a stored baseline, and fail on coverage regressionsargsinput for passing custom arguments tocargo llvm-covbcon Windows runners to support float comparisonsEnhancements:
Documentation:
ratchet-coverageaction and update the main README with usage, caching, and requirements detailsSummary by CodeRabbit