Skip to content

Add ratchet coverage action#11

Open
leynos wants to merge 4 commits intomainfrom
codex/create-ratcheting-coverage-action-with-caching
Open

Add ratchet coverage action#11
leynos wants to merge 4 commits intomainfrom
codex/create-ratcheting-coverage-action-with-caching

Conversation

@leynos
Copy link
Copy Markdown
Owner

@leynos leynos commented Jun 22, 2025

Summary

  • add ratchet coverage action using cargo tarpaulin and cache
  • list new action in README
  • document in README and CHANGELOG
  • define CODEOWNERS for actions
  • enhance ratchet coverage docs with details on usage and caching

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:

  • Add a composite GitHub Action 'ratchet coverage' that runs cargo tarpaulin, caches results, and fails the workflow if coverage decreases

Enhancements:

  • Implement caching for coverage baselines and tarpaulin artifacts across runs

Documentation:

  • List the new ratchet coverage action in the main README
  • Add detailed usage documentation and release history for the new action
  • Update CHANGELOG with initial v1.0.0 entry

Chores:

  • Define CODEOWNERS for GitHub actions

Summary by CodeRabbit

  • New Features
    • Introduced a new GitHub Action, "Ratchet coverage", for enforcing Rust code coverage baselines using cargo tarpaulin.
  • Documentation
    • Added detailed README and changelog for the new action, including usage instructions and workflow examples.
    • Updated the main README to list the new action.
  • Chores
    • Added a CODEOWNERS file assigning responsibility for GitHub Actions directories.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Jun 22, 2025

Reviewer's Guide

Implements 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 execution

sequenceDiagram
  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
Loading

File-Level Changes

Change Details Files
Introduce ratchet coverage composite action with caching and baseline enforcement
  • Define action inputs/outputs and composite steps in action.yml
  • Restore and save coverage baseline via actions/cache
  • Cache cargo artifacts and install cargo-tarpaulin
  • Run tarpaulin, parse coverage percent, compare against baseline, and fail on decrease
.github/actions/ratchet-coverage/action.yml
Add and update documentation for the new action
  • List ratchet coverage in the main README
  • Add detailed action-specific README with usage, inputs/outputs, and implementation notes
  • Create CHANGELOG entry for initial v1.0.0 release
README.md
.github/actions/ratchet-coverage/README.md
.github/actions/ratchet-coverage/CHANGELOG.md
Assign ownership for GitHub Actions workflows
  • Create CODEOWNERS file specifying responsibility for the actions directory
CODEOWNERS

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 22, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

A new GitHub Action, "Ratchet coverage", has been introduced to enforce and maintain Rust code coverage baselines using cargo tarpaulin. Documentation, changelog, and ownership files have been added, and the main project README now lists this action among available options.

Changes

File(s) Change Summary
.github/actions/ratchet-coverage/README.md,
.github/actions/ratchet-coverage/CHANGELOG.md
Added documentation and changelog for the new "Ratchet coverage" GitHub Action.
.github/actions/ratchet-coverage/action.yml Introduced the composite GitHub Action to run, compare, and ratchet Rust code coverage using cargo tarpaulin.
CODEOWNERS Designated @leynos as code owner for all GitHub Actions under .github/actions/.
README.md Added "Ratchet coverage" to the list of available GitHub Actions in the main project README.

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
Loading

Poem

A ratchet for coverage, so clever and neat,
Ensures our Rust code will never retreat.
With baselines and caching, the numbers don’t lie,
If coverage should drop, the build says goodbye!
Now bunnies can code with a hop and a cheer,
For coverage regressions, we no longer fear!
🐇✨

✨ Finishing Touches
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in Comment
  • Commit Unit Tests in branch codex/create-ratcheting-coverage-action-with-caching

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread .github/actions/ratchet-coverage/action.yml
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🔭 Outside diff range comments (1)
.github/actions/ratchet-coverage/action.yml (1)

60-66: Critical: Invalid cache action reference

You’re using actions/cache/save@v4 to save the baseline, but the official action is actions/cache@v4 for 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

📥 Commits

Reviewing files that changed from the base of the PR and between c384881 and d37868f.

📒 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 additions

Designating @leynos as the owner for the new ratchet-coverage action directory aligns with the other actions and ensures proper ownership assignment.

README.md (1)

12-12: Approve new action listing

Listing Ratchet coverage under available actions correctly reflects the newly added action and its version.

Comment thread .github/actions/ratchet-coverage/action.yml
Comment thread .github/actions/ratchet-coverage/CHANGELOG.md
Comment on lines +21 to +27
```yaml
- uses: ./.github/actions/setup-rust@v1
- uses: ./.github/actions/ratchet-coverage@v1
with:
baseline-file: .cache/coverage-baseline
args: --workspace
```
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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.

Comment on lines +8 to +12
| 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)* |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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.

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Jun 22, 2025

@sourcery-ai review

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Jun 22, 2025

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 22, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 $current and $baseline are valid numbers before invoking bc. This addresses the earlier warning about bc assumptions.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d37868f and 3863ee9.

📒 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
The args input is correctly declared, aligning action.yml with the README and preventing workflow breakage.


47-68: Verify availability of bc on all runner OSes
This step relies on bc for float comparison. While Ubuntu has bc preinstalled, macOS and Windows runners may not. Please confirm or install bc explicitly to avoid cross-OS failures.


69-75: Confirm correct cache action version
The save step uses actions/cache/save@v4 while restore uses actions/cache@v4. Please verify that actions/cache/save@v4 is a valid alias and aligns with the intended major version in the Marketplace.

Comment thread .github/actions/ratchet-coverage/action.yml
@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Jun 22, 2025

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 22, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Jun 22, 2025

@sourcery-ai review

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @leynos - I've reviewed your changes - here's some feedback:

  • 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.
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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
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"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

♻️ Duplicate comments (3)
.github/actions/ratchet-coverage/action.yml (3)

8-11: Duplicate resolved: args input declared
The missing args input 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 $current and $baseline are validated against a proper numeric pattern before using bc. This implements the suggested guard.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3863ee9 and cfef83b.

📒 Files selected for processing (1)
  • .github/actions/ratchet-coverage/action.yml (1 hunks)

Comment on lines +75 to +78
uses: actions/cache/save@v4
with:
path: ${{ inputs.baseline-file }}
key: ratchet-baseline-${{ runner.os }}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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.

Suggested change
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.

Comment on lines +41 to +44
set -euo pipefail
output=$(cargo tarpaulin ${{ inputs.args }} --out lcov)
echo "$output"
percent=$(echo "$output" | grep -oP '[0-9]+(?:\.[0-9]+)?(?=%)' | head -n1)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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.

Suggested change
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.

Comment on lines +67 to +70
if [ "$(echo "$current < $baseline" | bc -l)" = "1" ]; then
echo "Coverage decreased" >&2
exit 1
fi
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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.

Suggested change
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant