Skip to content

Conversation

tusharmath
Copy link
Contributor

@tusharmath tusharmath commented Sep 2, 2025

📝 Description

Fix incorrect import statement in the README usage example. The example was showing use gh_workflows::*; when it should be use gh_workflow::*; to match the actual crate name.

🔧 Changes

  • README.md:35: Updated import statement from gh_workflows::* to gh_workflow::*

🎯 Type of Change

  • Bug fix (documentation error)
  • Documentation update
  • New feature
  • Breaking change
  • Performance improvement

✅ Impact

  • Ensures users can successfully follow the usage instructions
  • Aligns documentation with actual crate naming
  • Prevents confusion for new users trying the library

🧪 Testing

  • Verified import statement matches the actual crate name
  • Checked consistency with other references in the documentation

Summary by CodeRabbit

  • Refactor
    • Setter methods across workflow configuration types now borrow mutably, enabling fluent chaining without consuming instances. This improves ergonomics when building workflows and related configurations.
  • Documentation
    • Corrected a usage example import in the README to match the published crate name.

Copy link

coderabbitai bot commented Sep 2, 2025

Walkthrough

Project-wide update to derive_setters usage: multiple public structs now include the borrow_self option in their #[setters(...)] attributes, altering generated setter receivers to borrow self. Additionally, a README import path was corrected from gh_workflows to gh_workflow. No runtime logic or control-flow changes.

Changes

Cohort / File(s) Summary
Docs
README.md
Fix import in Rust example: use gh_workflows::*;use gh_workflow::*;.
Tailcall standard workflow setters
crates/gh-workflow-tailcall/src/standard.rs
Add #[setters(borrow_self)] to StandardWorkflow.
Event setters borrow_self
crates/gh-workflow/src/event.rs
Update all Setters derives to include borrow_self across event-related structs (e.g., Event, Push, PullRequest, WorkflowDispatch, ...).
Workflow core structs setters
crates/gh-workflow/src/workflow.rs
Add borrow_self to Setters derives for Workflow, Job, Container, Credentials, Volume, Concurrency, Permissions, Strategy, Environment, Defaults, RunDefaults, Secret, Artifacts, Artifact.
Cargo command setters
crates/gh-workflow/src/cargo.rs
Change #[setters(strip_option, into)]#[setters(strip_option, into, borrow_self)] for Cargo.
Generate setters
crates/gh-workflow/src/generate.rs
Change #[setters(into)]#[setters(into, borrow_self)] for Generate.
Release setters
crates/gh-workflow/src/release_plz.rs
Change #[setters(strip_option, into)]#[setters(strip_option, into, borrow_self)] for Release.
Toolchain setters
crates/gh-workflow/src/toolchain.rs
Change #[setters(strip_option, into)]#[setters(strip_option, into, borrow_self)] for Toolchain.

Sequence Diagram(s)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

A nibble of docs, a twitch of an ear,
Setters now borrow—chaining is clear.
Hop-hop through structs, I flip each switch,
No flows were changed, just method stitch.
In README fields I plant the seed—
One import fixed; that’s all I need. 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch docs/fix-import-statement-readme

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.

❤️ Share
🪧 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit 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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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

@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

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)

73-73: Fix E0277 by converting chained builder calls to mutable locals

  • init_job (crates/gh-workflow-tailcall/src/standard.rs:73)

    - let mut job = Job::new(name).permissions(Permissions::default().contents(Level::Read));
    + let mut perms = Permissions::default();
    + perms.contents(Level::Read);
    + let mut job = Job::new(name).permissions(perms);
  • release_job (crates/gh-workflow-tailcall/src/standard.rs:138–141)

    - .concurrency(
    -     Concurrency::new(Expression::new("release-${{github.ref}}"))
    -         .cancel_in_progress(false),
    - )
    + .concurrency({
    +     let mut conc = Concurrency::new(Expression::new("release-${{github.ref}}"));
    +     conc.cancel_in_progress(false);
    +     conc
    + })
  • autofix branch (crates/gh-workflow-tailcall/src/standard.rs:158–161)

    - job.concurrency(
    -     Concurrency::new(Expression::new("autofix-${{github.ref}}"))
    -         .cancel_in_progress(false),
    - )
    + job.concurrency({
    +     let mut conc = Concurrency::new(Expression::new("autofix-${{github.ref}}"));
    +     conc.cancel_in_progress(false);
    +     conc
    + })

166-177: Restructure Toolchain/Cargo builder chains to move owned values into add_step/add_step_when.
borrow_self makes setters return &mut; chained temporaries can no longer be moved. Use local mut vars, then pass owned values.

Apply these diffs:

@@
-        job.add_step(
-            Toolchain::default()
-                .add_nightly()
-                .add_clippy()
-                .add_fmt()
-                .cache(true)
-                .cache_directories(vec![
-                    "~/.cargo/registry".into(),
-                    "~/.cargo/git".into(),
-                    "target".into(),
-                ]),
-        )
+        let mut tc = Toolchain::default().add_nightly().add_clippy().add_fmt();
+        tc.cache(true);
+        tc.cache_directories(vec![
+            "~/.cargo/registry".into(),
+            "~/.cargo/git".into(),
+            "target".into(),
+        ]);
+        job.add_step(tc)
@@
-        .add_step(
-            Cargo::new("fmt")
-                .name("Cargo Fmt")
-                .nightly()
-                .add_args("--all")
-                .add_args_when(!auto_fix, "--check"),
-        )
+        .add_step({
+            let mut fmt = Cargo::new("fmt");
+            fmt.name("Cargo Fmt");
+            fmt.nightly();
+            fmt.add_args("--all");
+            fmt.add_args_when(!auto_fix, "--check");
+            fmt
+        })
@@
-        .add_step(
-            Cargo::new("clippy")
-                .name("Cargo Clippy")
-                .nightly()
-                .add_args_when(auto_fix, "--fix")
-                .add_args_when(auto_fix, "--allow-dirty")
-                .add_args("--all-features --workspace -- -D warnings"),
-        )
+        .add_step({
+            let mut clippy = Cargo::new("clippy");
+            clippy.name("Cargo Clippy");
+            clippy.nightly();
+            clippy.add_args_when(auto_fix, "--fix");
+            clippy.add_args_when(auto_fix, "--allow-dirty");
+            clippy.add_args("--all-features --workspace -- -D warnings");
+            clippy
+        })
@@
-            .add_step_when(
-                matches!(self.test_runner, TestRunner::Nextest),
-                Cargo::new("install")
-                    .args("cargo-nextest --locked")
-                    .name("Install nextest"),
-            )
+            .add_step_when(matches!(self.test_runner, TestRunner::Nextest), {
+                let mut install = Cargo::new("install");
+                install.args("cargo-nextest --locked");
+                install.name("Install nextest");
+                install
+            })
@@
-            .add_step(match self.test_runner {
-                TestRunner::Cargo => Cargo::new("test")
-                    .args("--all-features --workspace")
-                    .name("Cargo Test"),
-                TestRunner::Nextest => Cargo::new("nextest")
-                    .args("run --all-features --workspace")
-                    .name("Cargo Nextest"),
-            })
+            .add_step(match self.test_runner {
+                TestRunner::Cargo => {
+                    let mut t = Cargo::new("test");
+                    t.args("--all-features --workspace");
+                    t.name("Cargo Test");
+                    t
+                }
+                TestRunner::Nextest => {
+                    let mut n = Cargo::new("nextest");
+                    n.args("run --all-features --workspace");
+                    n.name("Cargo Nextest");
+                    n
+                }
+            })
@@
-            .add_step_when(
-                self.benchmarks,
-                Cargo::new("bench").args("--workspace").name("Cargo Bench"),
-            )
+            .add_step_when(self.benchmarks, {
+                let mut b = Cargo::new("bench");
+                b.args("--workspace");
+                b.name("Cargo Bench");
+                b
+            })

Also applies to: 179–185, 186–193, 204–212, 219–225, 226–229

🧹 Nitpick comments (1)
crates/gh-workflow-tailcall/src/standard.rs (1)

8-15: Minor docs nits: GitHub casing and a typo.

  • Line 11: “Github” → “GitHub”.
  • Line 33: “github action.” → “GitHub Action.”
  • Line 110: “needs to by” → “needs to be”.

Apply this diff:

@@
-//! workflows you still need to constantly keep referring to the Github
+//! workflows you still need to constantly keep referring to the GitHub
@@
-    /// *IMPORTANT:* Ensure `secrets.CARGO_REGISTRY_TOKEN` is set for your
-    /// github action.
+    /// *IMPORTANT:* Ensure `secrets.CARGO_REGISTRY_TOKEN` is set for your
+    /// GitHub Action.
@@
-        // NOTE: The workflow name needs to by `autofix.ci`
+        // NOTE: The workflow name needs to be `autofix.ci`

Also applies to: 32-35, 110-111

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

📥 Commits

Reviewing files that changed from the base of the PR and between f1fc651 and bb37249.

📒 Files selected for processing (8)
  • README.md (1 hunks)
  • crates/gh-workflow-tailcall/src/standard.rs (1 hunks)
  • crates/gh-workflow/src/cargo.rs (1 hunks)
  • crates/gh-workflow/src/event.rs (29 hunks)
  • crates/gh-workflow/src/generate.rs (1 hunks)
  • crates/gh-workflow/src/release_plz.rs (1 hunks)
  • crates/gh-workflow/src/toolchain.rs (1 hunks)
  • crates/gh-workflow/src/workflow.rs (14 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 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
  • crates/gh-workflow/src/workflow.rs
🪛 GitHub Actions: autofix.ci
crates/gh-workflow-tailcall/src/standard.rs

[error] 73-73: E0277: the trait bound &mut gh_workflow::Permissions: std::convert::Into<gh_workflow::Permissions> is not satisfied. Step: cargo +nightly clippy --fix --allow-dirty --all-features --workspace -- -D warnings.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build and Test
🔇 Additional comments (6)
crates/gh-workflow/src/release_plz.rs (1)

8-8: Consistent setter pattern update

The addition of borrow_self to the Release struct's setters aligns with the project-wide standardization of setter behavior. This ensures generated setters take &mut self instead of consuming self, enabling better method chaining patterns.

crates/gh-workflow/src/generate.rs (1)

14-14: Consistent setter pattern update

The addition of borrow_self to the Generate struct maintains consistency with the project-wide setter standardization. This change allows for more flexible method chaining by using mutable references instead of consuming the struct.

crates/gh-workflow/src/event.rs (1)

14-14: Comprehensive setter pattern standardization

All event-related structs now consistently use borrow_self in their setter derivation. This systematic change ensures uniform behavior across the entire event system, where all generated setters will take &mut self instead of consuming self. The change affects all major event configuration types including Event, BranchProtectionRule, CheckRun, CheckSuite, Create, Delete, Deployment, DeploymentStatus, Issues, Label, MergeGroup, Milestone, PullRequest, PullRequestReview, PullRequestReviewComment, PullRequestTarget, Push, RegistryPackage, Release, RepositoryDispatch, Schedule, Watch, WorkflowCall, WorkflowCallInput, WorkflowCallOutput, WorkflowCallSecret, WorkflowDispatch, WorkflowDispatchInput, and WorkflowRun.

Also applies to: 97-97, 127-127, 153-153, 170-170, 197-197, 225-225, 244-244, 410-410, 441-441, 463-463, 487-487, 520-520, 563-563, 593-593, 611-611, 638-638, 685-685, 724-724, 740-740, 754-754, 768-768, 784-784, 799-799, 817-817, 829-829, 843-843, 852-852, 883-883

README.md (2)

38-38: Correct import path — LGTM.

Good fix aligning the example with the published crate name.


37-49: All gh_workflows references removed
No remaining occurrences found in the repository.

crates/gh-workflow-tailcall/src/standard.rs (1)

29-30: Setter receivers updated to borrow self — OK.

Aligns with workspace-wide borrow_self migration for builder ergonomics.

Comment on lines +7 to 8
#[setters(strip_option, into, borrow_self)]
pub struct Cargo {
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Switch to borrow_self alters setter receivers; ensure consistency with manual by-value builders.

With #[setters(..., borrow_self)], derived setters likely take a borrowed receiver (e.g., &mut self) for chaining, while methods like nightly, args, and add_args* still consume self. Mixed receiver styles can make chained usage awkward and may introduce breaking changes for prior one-liners that ended with a by-value method.

Recommendation:

  • Decide on a consistent style. Either:
    • Keep borrowed setters and add borrowed variants for manual methods, or
    • Revert to by-value setters if preserving old chaining semantics is important.
  • Document the new pattern in README (mutable binding + semicolon between chains, then call a by-value method).

Example aligning a couple of methods (illustrative):

-    pub fn nightly(mut self) -> Self {
-        self.toolchain = Some(Version::Nightly);
-        self
-    }
+    pub fn nightly(&mut self) -> &mut Self {
+        self.toolchain = Some(Version::Nightly);
+        self
+    }

-    pub fn args<T: ToString>(mut self, args: T) -> Self {
-        self.args = vec![args.to_string()];
-        self
-    }
+    pub fn args<T: ToString>(&mut self, args: T) -> &mut Self {
+        self.args = vec![args.to_string()];
+        self
+    }

Run this quick check to spot potentially affected chaining patterns within the repo:

Also applies to: 38-49, 51-70


🏁 Script executed:

#!/usr/bin/env bash
rg -nP 'Cargo::new\([^)]*\)\.[[:alnum:]_]+\([^)]*\)\.([[:alnum:]_]+\()' -S -g '!**/target/**'

Length of output: 220


Make manual builder methods borrow &mut self to match borrow_self setters
Manual methods (nightly, args, add_arg*) still consume and return self, breaking chained calls (e.g. line 228 in crates/gh-workflow-tailcall/src/standard.rs). Convert them to fn nightly(&mut self) -> &mut Self (and similarly for args, add_arg, add_args) to align with the borrow_self style, or revert the borrow_self option if you need to preserve the by-value chaining semantics.

🤖 Prompt for AI Agents
In crates/gh-workflow/src/cargo.rs around lines 7-8, the struct uses
#[setters(..., borrow_self)] but the manual builder methods (nightly, args,
add_arg, add_args) are defined to take and return self by value, breaking
chained calls; change their signatures to take &mut self and return &mut Self
and update their bodies so they mutate &mut self (not consume and re-create) and
end with &mut *self (or simply return self reference), ensuring they push/extend
fields directly on the mutable receiver; alternatively, if you prefer by-value
chaining semantics, remove the borrow_self option from the setters macro so
generated setters match the manual methods—make sure to update any call
sites/tests that assume the previous chaining style.

Comment on lines +143 to 144
#[setters(strip_option, into, borrow_self)]
pub struct Toolchain {
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

borrow_self on Toolchain setters — OK, but update call sites.

This breaks expression-chaining into add_step/add_step_when where a Toolchain temporary is moved. Use local mut vars (see standard.rs suggestions) or add a finishing method if you prefer.


🏁 Script executed:

#!/bin/bash
# Find Toolchain builder chains likely to pass &mut into add_step(_when)
rg -n -C2 -P '\.add_step(?:_when)?\(\s*Toolchain::default\(\)[\s\S]*?\)'

Length of output: 536


Update call sites broken by borrow_self setters
Changing to #[setters(..., borrow_self)] makes methods like add_stable take &mut self and return &mut Self, so chained calls such as

.add_step(Toolchain::default().add_stable())

(e.g. crates/gh-workflow-tailcall/src/standard.rs:206) no longer compile. Refactor these to use a local mutable Toolchain (e.g.

let mut tc = Toolchain::default();
tc.add_stable();
job.add_step(tc);

) or add a finalizer method that consumes the builder.

🤖 Prompt for AI Agents
In crates/gh-workflow/src/toolchain.rs around lines 143-144, changing the setter
attribute to include borrow_self makes builder methods take &mut self and return
&mut Self, which breaks call sites that expect an owned Toolchain from chained
expressions; update every call site (for example
crates/gh-workflow-tailcall/src/standard.rs:206) to instead create a local
mutable Toolchain, call the mutating setters on that local, then pass the final
Toolchain to the caller (i.e., let mut tc = Toolchain::default();
tc.add_stable(); job.add_step(tc);), or alternatively add a finalizer method on
Toolchain that consumes self and returns an owned Toolchain so chained
expression callers can use that consuming method to obtain an owned value.

Comment on lines +46 to 47
#[setters(strip_option, into, borrow_self)]
pub struct Workflow {
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Broad adoption of borrow_self across public types — verify API break and update usage docs.

Applying borrow_self to setters for Workflow, Job, Container, Credentials, Volume, Concurrency, Permissions, Strategy, Environment, Defaults, RunDefaults, Secret, Artifacts, and Artifact shifts the chaining model. Prior chains like Workflow::default().name("X").generate() may no longer compile if setters return a borrowed receiver while generate(self) consumes by value.

Action items:

  • Confirm this is an intentional semver-impacting change and call it out in CHANGELOG.
  • Add a README snippet showing the new pattern:
    • Use a mutable binding, chain borrowed setters, then call by-value methods in a separate statement.
    • Example:
      let mut wf = Workflow::new("CI");
      wf.permissions(Permissions::default()).timeout_minutes(30);
      wf.generate()?;
      
  • Consider parity: many manual builder methods still consume self (e.g., add_job, add_env, etc.). Decide whether to migrate them to borrowed receivers for a uniform API, or explicitly document the mix.

Quick repo scan to find potentially affected one-liners:

I can draft a short MIGRATION.md with before/after examples if helpful.

Also applies to: 223-224, 650-651, 684-685, 706-707, 733-734, 757-758, 813-814, 831-833, 844-846, 862-864, 896-898, 918-920, 932-934


🏁 Script executed:

#!/usr/bin/env bash
# Likely-breakers: one-line chains ending in a by-value method after a setter.
rg -nP '::(new|default)\([^)]*\)\.[[:alpha:]_]+\([^)]*\)\.generate\(' -S -g '!**/target/**'
rg -nP '\.name\([^)]*\)\.(to_string|parse|generate)\(' -S -g '!**/target/**'

Length of output: 172


🏁 Script executed:

#!/usr/bin/env bash
# Search for generate usage chained after setters in the codebase
rg -nP '\.\w+\([^)]*\)\.generate\(' -S -g '!**/target/**'
# Look for any references to generate in documentation or examples
grep -R -n 'generate' README.md || true
grep -R -n 'generate' examples || true
grep -R -n 'generate' tests || true

Length of output: 507


Document semver-breaking setter change and update usage docs

  • Add a breaking-change entry in CHANGELOG: setters annotated with borrow_self now return &mut Self, so chains like
    Workflow::default().name("X").generate() no longer compile.
  • Update README.md (around lines 35–52) to show the new pattern:
    let mut wf = Workflow::new("CI");
    wf.name("X").permissions(Permissions::default());
    wf.generate().unwrap();
  • Align or document the mixed builder API (e.g. add_job, add_env still consuming self) for consistency.
🤖 Prompt for AI Agents
In crates/gh-workflow/src/workflow.rs around lines 46-47, the addition of
#[setters(..., borrow_self)] made setters return &mut Self which is
semver-breaking; add a breaking-change entry to CHANGELOG.md describing that
setters now return &mut Self and that chained temporary-ownership usage (e.g.
Workflow::default().name("X").generate()) no longer compiles, update README.md
(around lines 35–52) to show the new usage pattern using a mutable binding (e.g.
let mut wf = Workflow::new("CI"); wf.name("X").permissions(...);
wf.generate().unwrap();), and either align the API so all builder methods
consistently borrow self or clearly document which methods consume self (e.g.
add_job/add_env) so callers know when to use mutable bindings versus
ownership-moving chains.

@tusharmath tusharmath closed this Sep 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant