Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Then you can start creating GitHub Actions in your [tests/ci.rs](https://github.
- Add the following code to generate the GitHub Actions workflow:

```rust
use gh_workflows::*;
use gh_workflow::*;

#[test]
fn main() {
Expand Down
1 change: 1 addition & 0 deletions crates/gh-workflow-tailcall/src/standard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
}

#[derive(Debug, Clone, Setters)]
#[setters(borrow_self)]
pub struct StandardWorkflow {
/// When enabled, a release job is added to the workflow.
/// *IMPORTANT:* Ensure `secrets.CARGO_REGISTRY_TOKEN` is set for your
Expand Down Expand Up @@ -69,11 +70,11 @@
///
/// This reduces duplication across different job types.
fn init_job(&self, name: impl ToString) -> Job {
let mut job = Job::new(name).permissions(Permissions::default().contents(Level::Read));

Check failure on line 73 in crates/gh-workflow-tailcall/src/standard.rs

View workflow job for this annotation

GitHub Actions / Build and Test

the trait bound `&mut gh_workflow::Permissions: Into<gh_workflow::Permissions>` is not satisfied

Check failure on line 73 in crates/gh-workflow-tailcall/src/standard.rs

View workflow job for this annotation

GitHub Actions / Lint Fix

the trait bound `&mut gh_workflow::Permissions: std::convert::Into<gh_workflow::Permissions>` is not satisfied

Check failure on line 73 in crates/gh-workflow-tailcall/src/standard.rs

View workflow job for this annotation

GitHub Actions / Lint

the trait bound `&mut gh_workflow::Permissions: std::convert::Into<gh_workflow::Permissions>` is not satisfied

// Add setup steps in reverse order to maintain the correct sequence
for step in self.setup.iter().rev() {
job = job.add_step(step.clone());

Check failure on line 77 in crates/gh-workflow-tailcall/src/standard.rs

View workflow job for this annotation

GitHub Actions / Build and Test

mismatched types

Check failure on line 77 in crates/gh-workflow-tailcall/src/standard.rs

View workflow job for this annotation

GitHub Actions / Lint Fix

mismatched types

Check failure on line 77 in crates/gh-workflow-tailcall/src/standard.rs

View workflow job for this annotation

GitHub Actions / Lint

mismatched types
}

job.add_step(Step::checkout())
Expand Down Expand Up @@ -135,7 +136,7 @@
fn release_job(&self, cmd: Command) -> Job {
self.init_job(cmd.to_string().to_title_case())
.concurrency(
Concurrency::new(Expression::new("release-${{github.ref}}"))

Check failure on line 139 in crates/gh-workflow-tailcall/src/standard.rs

View workflow job for this annotation

GitHub Actions / Build and Test

the trait bound `&mut gh_workflow::Concurrency: Into<gh_workflow::Concurrency>` is not satisfied

Check failure on line 139 in crates/gh-workflow-tailcall/src/standard.rs

View workflow job for this annotation

GitHub Actions / Lint Fix

the trait bound `&mut gh_workflow::Concurrency: std::convert::Into<gh_workflow::Concurrency>` is not satisfied

Check failure on line 139 in crates/gh-workflow-tailcall/src/standard.rs

View workflow job for this annotation

GitHub Actions / Lint

the trait bound `&mut gh_workflow::Concurrency: std::convert::Into<gh_workflow::Concurrency>` is not satisfied
.cancel_in_progress(false),
)
.cond(self.workflow_cond())
Expand All @@ -147,7 +148,7 @@
"${{ secrets.CARGO_REGISTRY_TOKEN }}",
))
.permissions(self.write_permissions())
.add_step(Release::default().command(cmd))

Check failure on line 151 in crates/gh-workflow-tailcall/src/standard.rs

View workflow job for this annotation

GitHub Actions / Build and Test

the trait bound `gh_workflow::Step<_>: From<&mut gh_workflow::release_plz::Release>` is not satisfied

Check failure on line 151 in crates/gh-workflow-tailcall/src/standard.rs

View workflow job for this annotation

GitHub Actions / Lint Fix

the trait bound `gh_workflow::Step<_>: std::convert::From<&mut gh_workflow::release_plz::Release>` is not satisfied

Check failure on line 151 in crates/gh-workflow-tailcall/src/standard.rs

View workflow job for this annotation

GitHub Actions / Lint

the trait bound `gh_workflow::Step<_>: std::convert::From<&mut gh_workflow::release_plz::Release>` is not satisfied
}

fn lint_job(&self, auto_fix: bool) -> Job {
Expand All @@ -155,11 +156,11 @@

let job = if auto_fix {
job.concurrency(
Concurrency::new(Expression::new("autofix-${{github.ref}}"))

Check failure on line 159 in crates/gh-workflow-tailcall/src/standard.rs

View workflow job for this annotation

GitHub Actions / Build and Test

the trait bound `&mut gh_workflow::Concurrency: Into<gh_workflow::Concurrency>` is not satisfied

Check failure on line 159 in crates/gh-workflow-tailcall/src/standard.rs

View workflow job for this annotation

GitHub Actions / Lint Fix

the trait bound `&mut gh_workflow::Concurrency: std::convert::Into<gh_workflow::Concurrency>` is not satisfied

Check failure on line 159 in crates/gh-workflow-tailcall/src/standard.rs

View workflow job for this annotation

GitHub Actions / Lint

the trait bound `&mut gh_workflow::Concurrency: std::convert::Into<gh_workflow::Concurrency>` is not satisfied
.cancel_in_progress(false),
)
} else {
job

Check failure on line 163 in crates/gh-workflow-tailcall/src/standard.rs

View workflow job for this annotation

GitHub Actions / Build and Test

`if` and `else` have incompatible types

Check failure on line 163 in crates/gh-workflow-tailcall/src/standard.rs

View workflow job for this annotation

GitHub Actions / Lint Fix

`if` and `else` have incompatible types

Check failure on line 163 in crates/gh-workflow-tailcall/src/standard.rs

View workflow job for this annotation

GitHub Actions / Lint

`if` and `else` have incompatible types
};

job.add_step(
Expand Down Expand Up @@ -205,7 +206,7 @@
.add_step(Toolchain::default().add_stable())
.add_step_when(
matches!(self.test_runner, TestRunner::Nextest),
Cargo::new("install")

Check failure on line 209 in crates/gh-workflow-tailcall/src/standard.rs

View workflow job for this annotation

GitHub Actions / Build and Test

the trait bound `gh_workflow::Step<_>: From<&mut gh_workflow::Cargo>` is not satisfied

Check failure on line 209 in crates/gh-workflow-tailcall/src/standard.rs

View workflow job for this annotation

GitHub Actions / Lint Fix

the trait bound `gh_workflow::Step<_>: std::convert::From<&mut gh_workflow::Cargo>` is not satisfied

Check failure on line 209 in crates/gh-workflow-tailcall/src/standard.rs

View workflow job for this annotation

GitHub Actions / Lint

the trait bound `gh_workflow::Step<_>: std::convert::From<&mut gh_workflow::Cargo>` is not satisfied
.args("cargo-nextest --locked")
.name("Install nextest"),
)
Expand All @@ -214,7 +215,7 @@
.name("Cache Rust dependencies")
.add_with(("cache-all-crates", "true")),
)
.add_step(match self.test_runner {

Check failure on line 218 in crates/gh-workflow-tailcall/src/standard.rs

View workflow job for this annotation

GitHub Actions / Build and Test

the trait bound `gh_workflow::Step<_>: From<&mut gh_workflow::Cargo>` is not satisfied

Check failure on line 218 in crates/gh-workflow-tailcall/src/standard.rs

View workflow job for this annotation

GitHub Actions / Lint Fix

the trait bound `gh_workflow::Step<_>: std::convert::From<&mut gh_workflow::Cargo>` is not satisfied

Check failure on line 218 in crates/gh-workflow-tailcall/src/standard.rs

View workflow job for this annotation

GitHub Actions / Lint

the trait bound `gh_workflow::Step<_>: std::convert::From<&mut gh_workflow::Cargo>` is not satisfied
TestRunner::Cargo => Cargo::new("test")
.args("--all-features --workspace")
.name("Cargo Test"),
Expand All @@ -224,12 +225,12 @@
})
.add_step_when(
self.benchmarks,
Cargo::new("bench").args("--workspace").name("Cargo Bench"),

Check failure on line 228 in crates/gh-workflow-tailcall/src/standard.rs

View workflow job for this annotation

GitHub Actions / Build and Test

the trait bound `gh_workflow::Step<_>: From<&mut gh_workflow::Cargo>` is not satisfied

Check failure on line 228 in crates/gh-workflow-tailcall/src/standard.rs

View workflow job for this annotation

GitHub Actions / Lint Fix

the trait bound `gh_workflow::Step<_>: std::convert::From<&mut gh_workflow::Cargo>` is not satisfied

Check failure on line 228 in crates/gh-workflow-tailcall/src/standard.rs

View workflow job for this annotation

GitHub Actions / Lint

the trait bound `gh_workflow::Step<_>: std::convert::From<&mut gh_workflow::Cargo>` is not satisfied
)
}

fn write_permissions(&self) -> Permissions {
Permissions::default()

Check failure on line 233 in crates/gh-workflow-tailcall/src/standard.rs

View workflow job for this annotation

GitHub Actions / Build and Test

mismatched types

Check failure on line 233 in crates/gh-workflow-tailcall/src/standard.rs

View workflow job for this annotation

GitHub Actions / Lint Fix

mismatched types

Check failure on line 233 in crates/gh-workflow-tailcall/src/standard.rs

View workflow job for this annotation

GitHub Actions / Lint

mismatched types
.pull_requests(Level::Write)
.packages(Level::Write)
.contents(Level::Write)
Expand Down
2 changes: 1 addition & 1 deletion crates/gh-workflow/src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::toolchain::Version;
use crate::{Run, Step};

#[derive(Clone, Setters)]
#[setters(strip_option, into)]
#[setters(strip_option, into, borrow_self)]
pub struct Cargo {
Comment on lines +7 to 8
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.

/// The command to be executed for eg: fmt, clippy, build, test, etc.
pub command: String,
Expand Down
58 changes: 29 additions & 29 deletions crates/gh-workflow/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::is_default;
/// Represents all possible webhook events that can trigger a workflow
/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows
#[derive(Default, Debug, Clone, Deserialize, Serialize, Merge, Setters, PartialEq, Eq)]
#[setters(strip_option, into)]
#[setters(strip_option, into, borrow_self)]
pub struct Event {
#[serde(skip_serializing_if = "Option::is_none")]
pub branch_protection_rule: Option<BranchProtectionRule>,
Expand Down Expand Up @@ -94,7 +94,7 @@ pub enum BranchProtectionRuleType {

/// Configuration for branch protection rule events
#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
#[setters(strip_option, into)]
#[setters(strip_option, into, borrow_self)]
pub struct BranchProtectionRule {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub types: Vec<BranchProtectionRuleType>,
Expand Down Expand Up @@ -124,7 +124,7 @@ pub enum CheckRunType {
}

#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
#[setters(strip_option, into)]
#[setters(strip_option, into, borrow_self)]
pub struct CheckRun {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub types: Vec<CheckRunType>,
Expand All @@ -150,7 +150,7 @@ pub enum CheckSuiteType {
/// Configuration for check suite events

#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
#[setters(strip_option, into)]
#[setters(strip_option, into, borrow_self)]
pub struct CheckSuite {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub types: Vec<CheckSuiteType>,
Expand All @@ -167,7 +167,7 @@ impl CheckSuite {
/// Configuration for create events (branch or tag creation)
/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#create
#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
#[setters(strip_option, into)]
#[setters(strip_option, into, borrow_self)]
pub struct Create {
/// Filter on specific branch names
#[serde(default, skip_serializing_if = "Vec::is_empty")]
Expand All @@ -194,7 +194,7 @@ impl Create {
/// Configuration for delete events (branch or tag deletion)
/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#delete
#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
#[setters(strip_option, into)]
#[setters(strip_option, into, borrow_self)]
pub struct Delete {
/// Filter on specific branch names
#[serde(default, skip_serializing_if = "Vec::is_empty")]
Expand Down Expand Up @@ -222,7 +222,7 @@ impl Delete {
/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#deployment

#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
#[setters(strip_option, into)]
#[setters(strip_option, into, borrow_self)]
pub struct Deployment {
/// Filter on specific branch names
#[serde(default, skip_serializing_if = "Vec::is_empty")]
Expand All @@ -241,7 +241,7 @@ impl Deployment {
/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#deployment_status

#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
#[setters(strip_option, into)]
#[setters(strip_option, into, borrow_self)]
pub struct DeploymentStatus {
/// Filter on specific deployment states
#[serde(default, skip_serializing_if = "Vec::is_empty")]
Expand Down Expand Up @@ -407,7 +407,7 @@ pub enum IssuesType {
/// Configuration for issue events

#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
#[setters(strip_option, into)]
#[setters(strip_option, into, borrow_self)]
pub struct Issues {
/// Filter on specific issue event types
#[serde(default, skip_serializing_if = "Vec::is_empty")]
Expand Down Expand Up @@ -438,7 +438,7 @@ pub enum LabelType {
/// Configuration for label events

#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
#[setters(strip_option, into)]
#[setters(strip_option, into, borrow_self)]
pub struct Label {
/// Filter on specific label event types
#[serde(default, skip_serializing_if = "Vec::is_empty")]
Expand All @@ -460,7 +460,7 @@ pub enum MergeGroupType {
}

#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
#[setters(strip_option, into)]
#[setters(strip_option, into, borrow_self)]
pub struct MergeGroup {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub types: Vec<MergeGroupType>,
Expand All @@ -484,7 +484,7 @@ pub enum MilestoneType {
}

#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
#[setters(strip_option, into)]
#[setters(strip_option, into, borrow_self)]
pub struct Milestone {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub types: Vec<MilestoneType>,
Expand Down Expand Up @@ -517,7 +517,7 @@ pub enum PullRequestType {
}

#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
#[setters(strip_option, into)]
#[setters(strip_option, into, borrow_self)]
pub struct PullRequest {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub types: Vec<PullRequestType>,
Expand Down Expand Up @@ -560,7 +560,7 @@ pub enum PullRequestReviewType {
/// Configuration for pull request review events

#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
#[setters(strip_option, into)]
#[setters(strip_option, into, borrow_self)]
pub struct PullRequestReview {
/// Filter on specific pull request review event types
#[serde(default, skip_serializing_if = "Vec::is_empty")]
Expand Down Expand Up @@ -590,7 +590,7 @@ pub enum PullRequestReviewCommentType {

/// Configuration for pull request review comment events
#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
#[setters(strip_option, into)]
#[setters(strip_option, into, borrow_self)]
pub struct PullRequestReviewComment {
/// Filter on specific pull request review comment event types
#[serde(default, skip_serializing_if = "Vec::is_empty")]
Expand All @@ -608,7 +608,7 @@ impl PullRequestReviewComment {
/// Configuration for pull request target events
/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target
#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
#[setters(strip_option, into)]
#[setters(strip_option, into, borrow_self)]
pub struct PullRequestTarget {
/// Filter on specific pull request event types
#[serde(default, skip_serializing_if = "Vec::is_empty")]
Expand All @@ -635,7 +635,7 @@ impl PullRequestTarget {
/// Configuration for push events
/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push
#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
#[setters(strip_option, into)]
#[setters(strip_option, into, borrow_self)]
pub struct Push {
/// Filter on specific branch names
#[serde(default, skip_serializing_if = "Vec::is_empty")]
Expand Down Expand Up @@ -682,7 +682,7 @@ pub enum RegistryPackageType {
/// Configuration for registry package events

#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
#[setters(strip_option, into)]
#[setters(strip_option, into, borrow_self)]
pub struct RegistryPackage {
/// Filter on specific registry package event types
#[serde(default, skip_serializing_if = "Vec::is_empty")]
Expand Down Expand Up @@ -721,7 +721,7 @@ pub enum ReleaseType {
/// Configuration for release events

#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
#[setters(strip_option, into)]
#[setters(strip_option, into, borrow_self)]
pub struct Release {
/// Filter on specific release event types
#[serde(default, skip_serializing_if = "Vec::is_empty")]
Expand All @@ -737,7 +737,7 @@ impl Release {
}

#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
#[setters(strip_option, into)]
#[setters(strip_option, into, borrow_self)]
pub struct RepositoryDispatch {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub types: Vec<String>,
Expand All @@ -751,7 +751,7 @@ impl RepositoryDispatch {
}

#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
#[setters(strip_option, into)]
#[setters(strip_option, into, borrow_self)]
pub struct Schedule {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub cron: Vec<String>,
Expand All @@ -765,7 +765,7 @@ impl Schedule {
}

#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
#[setters(strip_option, into)]
#[setters(strip_option, into, borrow_self)]
pub struct Watch {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub types: Vec<String>,
Expand All @@ -781,7 +781,7 @@ impl Watch {
/// Configuration for workflow call events
/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_call
#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
#[setters(strip_option, into)]
#[setters(strip_option, into, borrow_self)]
pub struct WorkflowCall {
/// Inputs for the workflow call
#[serde(skip_serializing_if = "HashMap::is_empty")]
Expand All @@ -796,7 +796,7 @@ pub struct WorkflowCall {

/// Configuration for workflow call input
#[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq, Setters, Eq)]
#[setters(strip_option, into)]
#[setters(strip_option, into, borrow_self)]
pub struct WorkflowCallInput {
/// Description of the input
#[serde(skip_serializing_if = "String::is_empty")]
Expand All @@ -814,7 +814,7 @@ pub struct WorkflowCallInput {

/// Configuration for workflow call output
#[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq, Setters, Eq)]
#[setters(strip_option, into)]
#[setters(strip_option, into, borrow_self)]
pub struct WorkflowCallOutput {
/// Description of the output
#[serde(skip_serializing_if = "String::is_empty")]
Expand All @@ -826,7 +826,7 @@ pub struct WorkflowCallOutput {

/// Configuration for workflow call secret
#[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq, Setters, Eq)]
#[setters(strip_option, into)]
#[setters(strip_option, into, borrow_self)]
pub struct WorkflowCallSecret {
/// Description of the secret
#[serde(skip_serializing_if = "String::is_empty")]
Expand All @@ -840,7 +840,7 @@ pub struct WorkflowCallSecret {
/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch

#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
#[setters(strip_option, into)]
#[setters(strip_option, into, borrow_self)]
pub struct WorkflowDispatch {
/// Inputs for the workflow dispatch
#[serde(skip_serializing_if = "HashMap::is_empty")]
Expand All @@ -849,7 +849,7 @@ pub struct WorkflowDispatch {

/// Configuration for workflow dispatch input
#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
#[setters(strip_option, into)]
#[setters(strip_option, into, borrow_self)]
pub struct WorkflowDispatchInput {
/// Description of the input
#[serde(skip_serializing_if = "String::is_empty")]
Expand Down Expand Up @@ -880,7 +880,7 @@ pub enum WorkflowRunType {

/// Configuration for workflow run events
#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
#[setters(strip_option, into)]
#[setters(strip_option, into, borrow_self)]
pub struct WorkflowRun {
/// Filter on specific workflow run event types
#[serde(default, skip_serializing_if = "Vec::is_empty")]
Expand Down
2 changes: 1 addition & 1 deletion crates/gh-workflow/src/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::error::{Error, Result};
use crate::{Job, Jobs, Workflow};

#[derive(Setters, Clone)]
#[setters(into)]
#[setters(into, borrow_self)]
pub struct Generate {
workflow: Workflow,
name: String,
Expand Down
2 changes: 1 addition & 1 deletion crates/gh-workflow/src/release_plz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use derive_setters::Setters;
use crate::{Step, Use};

#[derive(Clone, Default, Setters)]
#[setters(strip_option, into)]
#[setters(strip_option, into, borrow_self)]
pub struct Release {
/// The release-plz command to run. Accepted values: release-pr, release.
/// (By default it runs both commands).
Expand Down
2 changes: 1 addition & 1 deletion crates/gh-workflow/src/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ pub struct Target {
/// NOTE: The public API should be close to the original action as much as
/// possible.
#[derive(Default, Clone, Setters)]
#[setters(strip_option, into)]
#[setters(strip_option, into, borrow_self)]
pub struct Toolchain {
Comment on lines +143 to 144
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.

pub toolchain: Vec<Version>,
#[setters(skip)]
Expand Down
Loading
Loading