Skip to content

feat(step.foreach): add item_var, single-step, and foreach.index support#181

Merged
intel352 merged 4 commits intomainfrom
copilot/add-step-foreach-functionality
Feb 27, 2026
Merged

feat(step.foreach): add item_var, single-step, and foreach.index support#181
intel352 merged 4 commits intomainfrom
copilot/add-step-foreach-functionality

Conversation

Copy link
Contributor

Copilot AI commented Feb 27, 2026

  • Explore codebase to understand existing step.foreach implementation
  • Add item_var config key support (item_var is now canonical; item_key retained for backward compat)
  • Add step (singular) config key support as alternative to steps
  • Add {{.foreach.index}} access via a foreach map injected into child context
  • Update cmd/wfctl/type_registry.go ConfigKeys for step.foreach
  • Fix: thread app parameter from StepFactory to sub-step factories (was using captured outer app=nil)
  • Fix: remove outer app param from NewForEachStepFactory (matches NewRetryWithBackoffStepFactory signature)
  • Fix: validate step/steps types explicitly; error when both are provided
  • Fix: replace duplicate foreachBuildSubStep with shared buildSubStep helper
  • Fix: guard foreach map injection to avoid overwriting conflicting user keys
  • Add tests: mutual exclusivity of step/steps, wrong types, app threading, conflict guard
  • All 18 foreach tests pass, full build clean

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

… support

Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
Copilot AI changed the title [WIP] Add step.foreach pipeline step for list iteration feat(step.foreach): add item_var, single-step, and foreach.index support Feb 27, 2026
@intel352 intel352 marked this pull request as ready for review February 27, 2026 02:41
Copilot AI review requested due to automatic review settings February 27, 2026 02:41
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds missing spec features to the step.foreach pipeline step so foreach iterations can bind a custom item variable name, define a single sub-step via shorthand, and reference an iteration-scoped foreach map in templates.

Changes:

  • Add item_var as the canonical per-item binding key (keeping item_key for backward compatibility).
  • Support step (singular) as an alternative to steps for single sub-step configurations.
  • Inject foreach context (including foreach.index) into each iteration; update wfctl type registry and add tests.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
module/pipeline_step_foreach.go Adds item_var, step shorthand parsing, and injects foreach map into child context.
module/pipeline_step_foreach_test.go Adds tests for item_var, step shorthand, foreach.index, and error cases.
cmd/wfctl/type_registry.go Updates step.foreach ConfigKeys to include new supported options.

@intel352
Copy link
Contributor

@copilot apply changes based on the comments in this thread

…dation, reuse buildSubStep

Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
@intel352 intel352 merged commit a4d5ca8 into main Feb 27, 2026
14 checks passed
@intel352 intel352 deleted the copilot/add-step-foreach-functionality branch February 27, 2026 03:17
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.

3 participants