Handle cargo errors and normalize coverage comparison#22
Conversation
Reviewer's GuideThis PR enhances robustness by wrapping cargo invocations in both the install and coverage scripts with ProcessExecutionError handling (capturing return codes and outputs for clear error reporting and safe exits), normalizes floating-point coverage comparisons by rounding baseline and current values to two decimals, and updates the README and CHANGELOG to document these behaviors. Sequence diagram for improved cargo error handling in install scriptsequenceDiagram
participant User as actor User
participant Script as install_cargo_llvm_cov.py
participant Cargo as cargo
User->>Script: Run install_cargo_llvm_cov.py
Script->>Cargo: cargo install cargo-llvm-cov
alt Success
Cargo-->>Script: Success
Script->>User: Print success message
else ProcessExecutionError
Cargo-->>Script: Error (retcode, stderr)
Script->>User: Print error message with retcode and stderr
Script->>User: Exit with error code
end
Sequence diagram for improved cargo error handling in coverage scriptsequenceDiagram
participant User as actor User
participant Script as run_coverage.py
participant Cargo as cargo
User->>Script: Run run_coverage.py
Script->>Cargo: cargo llvm-cov --summary-only
alt Success
Cargo-->>Script: (retcode=0, output, err)
Script->>User: Print output
Script->>Script: Extract percent and write to file
else ProcessExecutionError
Cargo-->>Script: (retcode!=0, output, err)
Script->>User: Print error message with retcode and err
Script->>User: Exit with error code
end
Class diagram for coverage comparison normalizationclassDiagram
class ratchet_coverage {
+main(baseline_file: Path, current: float)
- read_baseline(baseline_file)
}
ratchet_coverage : float baseline
ratchet_coverage : float current
%% Both baseline and current are now rounded to 2 decimals before comparison
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Warning Rate limit exceeded@leynos has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 31 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
Summary by CodeRabbit
WalkthroughThis update introduces rounding of code coverage values to two decimal places before comparison in both documentation and scripts, aiming to prevent minor floating-point discrepancies. It also enhances error handling and messaging for failed Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ratchet_coverage.py
participant BaselineFile
participant CoverageTool
User->>ratchet_coverage.py: Run script
ratchet_coverage.py->>BaselineFile: Read baseline coverage
BaselineFile-->>ratchet_coverage.py: Return value
ratchet_coverage.py->>CoverageTool: Get current coverage
CoverageTool-->>ratchet_coverage.py: Return value
ratchet_coverage.py->>ratchet_coverage.py: Round both values to 2 decimals
ratchet_coverage.py->>ratchet_coverage.py: Compare values
ratchet_coverage.py-->>User: Report result (pass/fail)
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 (
|
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 (5)
.github/actions/ratchet-coverage/CHANGELOG.md(1 hunks).github/actions/ratchet-coverage/README.md(1 hunks)scripts/ratchet_coverage/install_cargo_llvm_cov.py(1 hunks)scripts/ratchet_coverage/ratchet_coverage.py(1 hunks)scripts/ratchet_coverage/run_coverage.py(2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
`.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/CHANGELOG.md.github/actions/ratchet-coverage/README.md
`.github/actions/*/CHANGELOG.md`: Each action must have a CHANGELOG.md that follows SemVer-based changelog for this action only
.github/actions/*/CHANGELOG.md: Each action must have a CHANGELOG.md that follows SemVer-based changelog for this action only
📄 Source: CodeRabbit Inference Engine (AGENTS.md)
List of files the instruction was applied to:
.github/actions/ratchet-coverage/CHANGELOG.md
`.github/actions/*/README.md`: Each action's README.md must contain a one-liner ...
.github/actions/*/README.md: Each action's README.md must contain a one-liner summary, table of inputs, table of outputs, usage example, and release history link to CHANGELOG
Add a DEPRECATED: banner to README and repository description when deprecating an action
📄 Source: CodeRabbit Inference Engine (AGENTS.md)
List of files the instruction was applied to:
.github/actions/ratchet-coverage/README.md
🪛 Ruff (0.11.9)
scripts/ratchet_coverage/install_cargo_llvm_cov.py
17-17: Trailing comma missing
Add trailing comma
(COM812)
19-19: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling
(B904)
🪛 Pylint (3.3.7)
scripts/ratchet_coverage/install_cargo_llvm_cov.py
[error] 7-7: Unable to import 'plumbum.commands.processes'
(E0401)
[error] 8-8: Unable to import 'typer'
(E0401)
[convention] 11-11: Missing function or method docstring
(C0116)
scripts/ratchet_coverage/run_coverage.py
[error] 11-11: Unable to import 'plumbum.commands.processes'
(E0401)
🔇 Additional comments (6)
.github/actions/ratchet-coverage/CHANGELOG.md (1)
3-8: LGTM! Well-documented changelog entry.The changelog entry clearly documents both the rounding behaviour and improved error handling, aligning with the code changes in the PR.
.github/actions/ratchet-coverage/README.md (1)
37-40: LGTM! Clear documentation of rounding behaviour.The documentation accurately explains the rounding logic and provides good context about why it's necessary to avoid floating-point precision issues.
scripts/ratchet_coverage/ratchet_coverage.py (1)
26-27: LGTM! Consistent rounding implementation.The rounding logic correctly normalises both baseline and current coverage values to 2 decimal places, preventing floating-point precision issues during comparison.
scripts/ratchet_coverage/install_cargo_llvm_cov.py (1)
7-7: LGTM! Specific exception import improves error handling.The specific import of
ProcessExecutionErrorallows for more precise exception handling compared to catching generic exceptions.scripts/ratchet_coverage/run_coverage.py (2)
11-11: LGTM! Specific exception import enables precise error handling.The specific import allows for targeted exception handling of process execution failures.
29-35: Excellent error handling implementation.The enhanced error handling provides robust execution with detailed error reporting:
- Using
retcode=Nonecaptures all return codes properly- Defensive exception handling covers edge cases
- Detailed error messages include return code and stderr for debugging
- Exit code propagation maintains process semantics
This significantly improves the reliability and debuggability of the coverage script.
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Summary
ProcessExecutionErrorin install scriptTesting
python -m py_compile scripts/ratchet_coverage/*.pypytest -qhttps://chatgpt.com/codex/tasks/task_e_6869831eab9883228b88af72b1f10b38
Summary by Sourcery
Handle errors from cargo commands gracefully and normalize coverage comparisons by rounding values to two decimals, with corresponding documentation and changelog updates.
Bug Fixes:
Enhancements:
Documentation: