-
Notifications
You must be signed in to change notification settings - Fork 18
drop when #167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drop when #167
Conversation
WalkthroughThe PR refactors workflow construction to use explicit conditional logic. It removes multiple conditional “add_*_when” helpers from Workflow/Job/Step and Cargo, updates standard.rs to assemble jobs via mutable state, and adds conditional autofix/fmt/clippy steps and release jobs based on flags. Public APIs largely unchanged except removed methods. Changes
Sequence Diagram(s)sequenceDiagram
actor Developer
participant to_ci_workflow
participant Workflow
participant Jobs as build/lint/test
participant Release as release/release-pr
Developer->>to_ci_workflow: call(auto_release, auto_fix, tests, benches)
to_ci_workflow->>Workflow: init base workflow
to_ci_workflow->>Jobs: add build + lint (+autofix steps if auto_fix)
to_ci_workflow->>Jobs: add test (nextest/bench if selected)
alt auto_release == true
to_ci_workflow->>Release: append release + release-pr jobs
else auto_release == false
Note over to_ci_workflow,Release: No release jobs appended
end
to_ci_workflow-->>Developer: GH workflow
sequenceDiagram
participant LintJob
participant CargoFmt
participant CargoClippy
participant Autofix as Autofix Action
alt auto_fix == true
LintJob->>CargoFmt: cargo fmt --all
LintJob->>CargoClippy: cargo clippy --fix --allow-dirty --all-features/--workspace
LintJob->>Autofix: uses: autofix-ci action
else auto_fix == false
LintJob->>CargoFmt: cargo fmt --all -- --check
LintJob->>CargoClippy: cargo clippy --all-features/--workspace
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Assessment against linked issues
Assessment against linked issues: Out-of-scope changes
Possibly related PRs
Poem
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
crates/gh-workflow-tailcall/src/standard.rs (2)
109-114: Restrict autofix workflow to PRs only (avoid pushes to main).Current triggers include push to main via
self.workflow_event(), which risks running autofix onmain. Make autofix run only on pull_request events to meet the objective “never on the main branch.”Apply this diff:
fn to_autofix_workflow(&self) -> GHWorkflow { // NOTE: The workflow name needs to by `autofix.ci` GHWorkflow::new("autofix.ci") .add_env(self.workflow_flags()) - .on(self.workflow_event()) - .add_job("lint", self.lint_job(true)) + .on(Event::default().pull_request( + PullRequest::default() + .add_type(PullRequestType::Opened) + .add_type(PullRequestType::Synchronize) + .add_type(PullRequestType::Reopened) + .add_branch("main"), + )) + .add_job("lint", self.lint_job(true)) }
74-80: Setup steps order is reversed.Iterating with
.rev()will execute the last-added setup step first, which is counterintuitive and contradicts the comment.Apply this diff:
- // Add setup steps in reverse order to maintain the correct sequence - for step in self.setup.iter().rev() { + // Add setup steps in the order they were added + for step in &self.setup { job = job.add_step(step.clone()); }
🧹 Nitpick comments (4)
crates/gh-workflow-tailcall/src/standard.rs (4)
174-190: Fmt steps look good; consider using--workspacefor clarity.
cargo fmt --allworks, but--workspaceis the contemporary flag. Optional.Apply this diff (optional):
- .add_args("--all"), + .add_args("--workspace"),- .add_args("--all") + .add_args("--workspace") .add_args("--check"),
192-209: Add--allow-stagedto clippy --fix to avoid edge-case failures.If files are staged (e.g., by a prior step),
--fixcan balk without--allow-staged.Apply this diff:
.nightly() .add_args("--fix") .add_args("--allow-dirty") + .add_args("--allow-staged") .add_args("--all-features --workspace -- -D warnings"),
228-234: Use a maintained installer for nextest instead of building via cargo install (faster, fewer cache misses).Switch to
taiki-e/install-actionfor reproducible, cached installs.Apply this diff:
- if matches!(self.test_runner, TestRunner::Nextest) { - job = job.add_step( - Cargo::new("install") - .args("cargo-nextest --locked") - .name("Install nextest"), - ); - } + if matches!(self.test_runner, TestRunner::Nextest) { + job = job.add_step( + Step::uses("taiki-e", "install-action", "v2") + .name("Install nextest") + .add_with(("tool", "cargo-nextest")), + ); + }
161-172: Avoid mixed caching strategies across jobs.Lint uses a custom Toolchain cache + directories; tests use
Swatinem/rust-cache. Unify to one approach to reduce overhead and cache fragmentation.Also applies to: 236-241
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
crates/gh-workflow-tailcall/src/standard.rs(4 hunks)crates/gh-workflow/src/cargo.rs(0 hunks)crates/gh-workflow/src/workflow.rs(0 hunks)
💤 Files with no reviewable changes (2)
- crates/gh-workflow/src/cargo.rs
- crates/gh-workflow/src/workflow.rs
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: tusharmath
PR: tailcallhq/gh-workflow#97
File: crates/gh-workflow-tailcall/src/workflow.rs:121-121
Timestamp: 2024-12-10T06:33:21.046Z
Learning: In `crates/gh-workflow-tailcall/src/workflow.rs`, prefer converting standalone functions into methods of the `Workflow` struct when appropriate.
📚 Learning: 2024-12-10T06:33:21.046Z
Learnt from: tusharmath
PR: tailcallhq/gh-workflow#97
File: crates/gh-workflow-tailcall/src/workflow.rs:121-121
Timestamp: 2024-12-10T06:33:21.046Z
Learning: In `crates/gh-workflow-tailcall/src/workflow.rs`, prefer converting standalone functions into methods of the `Workflow` struct when appropriate.
Applied to files:
crates/gh-workflow-tailcall/src/standard.rs
🧬 Code graph analysis (1)
crates/gh-workflow-tailcall/src/standard.rs (2)
crates/gh-workflow/src/cargo.rs (1)
new(28-36)crates/gh-workflow/src/workflow.rs (8)
new(108-110)new(245-251)new(371-373)new(654-664)new(685-688)new(825-827)uses(483-497)uses(523-532)
🔇 Additional comments (2)
crates/gh-workflow-tailcall/src/standard.rs (2)
118-131: Explicit conditional job assembly is clearer than the previous add_*_when chaining.The refactor reads well; jobs are appended only when flags warrant it.
140-141: add_needs accepts Job instances
add_needs is defined aspub fn add_needs<J: Into<Job>>(mut self, needs: J) -> Self, so passingself.test_job()andself.lint_job(false)is valid.Likely an incorrect or invalid review comment.
| let mut job = self.init_job(if auto_fix { "Lint Fix" } else { "Lint" }); | ||
|
|
||
| let job = if auto_fix { | ||
| job.concurrency( | ||
| if auto_fix { | ||
| job = job.concurrency( | ||
| Concurrency::new(Expression::new("autofix-${{github.ref}}")) | ||
| .cancel_in_progress(false), | ||
| ) | ||
| } else { | ||
| job | ||
| }; | ||
| ); | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Grant write permissions for autofix job.
The autofix step may need contents: write to push fixes. Elevate only when auto_fix is true.
Apply this diff:
- if auto_fix {
- job = job.concurrency(
+ if auto_fix {
+ job = job
+ .permissions(Permissions::default().contents(Level::Write))
+ .concurrency(
Concurrency::new(Expression::new("autofix-${{github.ref}}"))
.cancel_in_progress(false),
- );
+ );
}📝 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.
| let mut job = self.init_job(if auto_fix { "Lint Fix" } else { "Lint" }); | |
| let job = if auto_fix { | |
| job.concurrency( | |
| if auto_fix { | |
| job = job.concurrency( | |
| Concurrency::new(Expression::new("autofix-${{github.ref}}")) | |
| .cancel_in_progress(false), | |
| ) | |
| } else { | |
| job | |
| }; | |
| ); | |
| } | |
| let mut job = self.init_job(if auto_fix { "Lint Fix" } else { "Lint" }); | |
| if auto_fix { | |
| job = job | |
| .permissions(Permissions::default().contents(Level::Write)) | |
| .concurrency( | |
| Concurrency::new(Expression::new("autofix-${{github.ref}}")) | |
| .cancel_in_progress(false), | |
| ); | |
| } |
🤖 Prompt for AI Agents
In crates/gh-workflow-tailcall/src/standard.rs around lines 152 to 160, the
autofix job needs elevated write permission so it can push fixes; when auto_fix
is true, after setting concurrency update the job to grant contents: write
(e.g., call the job.permissions(...) API to set contents to write) and ensure
this permission escalation is applied only in the auto_fix branch.
| if auto_fix { | ||
| job = job.add_step(Step::uses( | ||
| "autofix-ci", | ||
| "action", | ||
| "551dded8c6cc8a1054039c8bc0b8b48c51dfc6ef", | ||
| ), | ||
| ) | ||
| )); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Pin looks good; verify the referenced commit is still the recommended digest.
Ensure autofix-ci/action@551dded… is the current recommended pinned ref.
🌐 Web query:
Is 551dded8c6cc8a1054039c8bc0b8b48c51dfc6ef the latest recommended pinned commit for autofix-ci/action? If not, what commit digest should be used as of today?
💡 Result:
No — that's not the current recommended pin. Use commit 635ffb0c9798bd160680f18fd73371e355b85f27 (the v1.3.2 release) as of 2025-09-02. [1][2]
Sources:
- Setup docs showing the pinned commit. [1]
- Release v1.3.2 (635ffb0) on the repo. [2]
Update autofix-ci/action pin to v1.3.2 commit
Change the pinned digest from 551dded8c6cc8a1054039c8bc0b8b48c51dfc6ef to the current recommended 635ffb0c9798bd160680f18fd73371e355b85f27 (v1.3.2) as of 2025-09-02 cite12
if auto_fix {
job = job.add_step(Step::uses(
"autofix-ci",
"action",
- "551dded8c6cc8a1054039c8bc0b8b48c51dfc6ef",
+ "635ffb0c9798bd160680f18fd73371e355b85f27",
));
}📝 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 auto_fix { | |
| job = job.add_step(Step::uses( | |
| "autofix-ci", | |
| "action", | |
| "551dded8c6cc8a1054039c8bc0b8b48c51dfc6ef", | |
| ), | |
| ) | |
| )); | |
| } | |
| if auto_fix { | |
| job = job.add_step(Step::uses( | |
| "autofix-ci", | |
| "action", | |
| "635ffb0c9798bd160680f18fd73371e355b85f27", | |
| )); | |
| } |
🤖 Prompt for AI Agents
In crates/gh-workflow-tailcall/src/standard.rs around lines 211 to 217, the
pinned commit digest for the autofix-ci/action is outdated; replace
"551dded8c6cc8a1054039c8bc0b8b48c51dfc6ef" with the updated digest
"635ffb0c9798bd160680f18fd73371e355b85f27" (v1.3.2) so the Step::uses call
references the current recommended commit SHA.
vprefix fromusesAPIautofix-cistepto_ci_workflowpublic (feat: maketo_ci_workflowpublic #114)Summary by CodeRabbit