Only run cargo check when rust code is changed#7760
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe CI workflow adds a ChangesConditional Rust Code Detection
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
This should reduce CI time when only updating library files |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/ci.yaml:
- Around line 62-72: The git diff pathspecs in the conditional that checks
"${MERGE_BASE}...HEAD" do not include rust-toolchain.toml or .cargo/config.toml,
so changes to toolchain pinning or cargo config won't set "changed=true"; update
the pathspec list inside that if-block (the block that echoes
"changed=true"/"changed=false") to also include 'rust-toolchain.toml' and
'.cargo/config.toml' so the check in the ci workflow picks up edits to those
files.
- Around line 164-168: The current job if-expression is inadvertently wrapped by
GitHub Actions' default success() which can make cargo_check skip on
refs/heads/main if determine_changes fails; update the condition so it includes
an explicit status-check only on the main-branch arm (e.g., change the main
clause to "github.ref == 'refs/heads/main' && always()") so the presence of a
status function prevents the implicit success() wrapping while leaving the
existing determine_changes-based arm unchanged; target the if in the cargo_check
job and modify the expression that references
needs.determine_changes.outputs.rust_code and github.ref.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 2002e931-2cb2-48cb-88b0-8f7e305ff6b0
📒 Files selected for processing (1)
.github/workflows/ci.yaml
| if: | | ||
| ( | ||
| !contains(github.event.pull_request.labels.*.name, 'skip:ci') && | ||
| needs.determine_changes.outputs.rust_code == 'true' | ||
| ) || github.ref == 'refs/heads/main' |
There was a problem hiding this comment.
cargo_check may be silently skipped on main if determine_changes fails
GitHub Actions implicitly wraps any job if expression with success() when no explicit status-check function is present. "A default status check of success() is applied unless you include one of these functions." This means the effective condition is:
success() && ( (…skip:ci check… && rust_code == 'true') || github.ref == 'refs/heads/main' )
If determine_changes fails (e.g., git merge-base cannot resolve origin/${BASE_REF}), success() evaluates to false and the entire expression short-circuits — so cargo_check is silently skipped even on refs/heads/main, defeating the intent of the unconditional escape hatch. The fix is to guard only the main branch arm with an explicit status-check:
🛠️ Proposed fix
- if: |
- (
- !contains(github.event.pull_request.labels.*.name, 'skip:ci') &&
- needs.determine_changes.outputs.rust_code == 'true'
- ) || github.ref == 'refs/heads/main'
+ if: |
+ (
+ needs.determine_changes.result == 'success' &&
+ !contains(github.event.pull_request.labels.*.name, 'skip:ci') &&
+ needs.determine_changes.outputs.rust_code == 'true'
+ ) || (
+ !failure() && !cancelled() &&
+ github.ref == 'refs/heads/main'
+ )🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.github/workflows/ci.yaml around lines 164 - 168, The current job
if-expression is inadvertently wrapped by GitHub Actions' default success()
which can make cargo_check skip on refs/heads/main if determine_changes fails;
update the condition so it includes an explicit status-check only on the
main-branch arm (e.g., change the main clause to "github.ref ==
'refs/heads/main' && always()") so the presence of a status function prevents
the implicit success() wrapping while leaving the existing
determine_changes-based arm unchanged; target the if in the cargo_check job and
modify the expression that references needs.determine_changes.outputs.rust_code
and github.ref.
Summary by CodeRabbit