Skip to content

[plan] Update workflow compiler to generate grouped shell redirects (SC2129) #15059

@github-actions

Description

@github-actions

Objective

Modify the gh-aw workflow compiler to generate grouped shell redirects instead of individual redirects, eliminating 164 shellcheck SC2129 style warnings across all compiled workflows.

Context

From discussion #15009 - Actionlint/shellcheck reports 164 occurrences of SC2129 across all 149 workflows (49% of all findings). This is a style issue in compiler-generated code.

Current Pattern (Generated):

echo "line 1" >> "$GH_AW_PROMPT"
echo "line 2" >> "$GH_AW_PROMPT"
echo "line 3" >> "$GH_AW_PROMPT"

Desired Pattern:

{
  echo "line 1"
  echo "line 2"
  echo "line 3"
} >> "$GH_AW_PROMPT"

Approach

  1. Locate the compiler code that generates shell scripts with redirects (likely in prompt construction or YAML generation phase)

    • Check pkg/workflow/compiler.go or pkg/workflow/compiler_yaml.go
    • Look for code generating multiple consecutive redirects to the same file/variable
  2. Implement grouping logic:

    • Detect sequences of commands redirecting to the same file
    • Group them using brace syntax { ... }
    • Apply single redirect at the end
  3. Handle edge cases:

    • Single redirects (don't group)
    • Mixed redirect types (> vs >>)
    • Redirects to different files
    • Preserve error handling behavior
  4. Test the changes:

    • Recompile several workflows with make recompile
    • Verify generated .lock.yml files use grouped redirects
    • Run gh aw compile --actionlint to confirm SC2129 warnings eliminated
    • Run make test-unit to ensure tests pass
    • Test workflow execution to ensure behavior unchanged

Files to Modify

  • pkg/workflow/compiler.go or pkg/workflow/compiler_yaml.go (compiler logic)
  • Potentially add helper functions for grouping redirects
  • Update tests if needed

Acceptance Criteria

  • Compiler generates grouped redirects for consecutive commands targeting same file
  • All 164 SC2129 warnings eliminated (verify with actionlint)
  • Edge cases handled correctly (single redirects, mixed types)
  • Unit tests pass (make test-unit)
  • Sample workflows recompile and execute correctly
  • Generated code is cleaner and more performant

AI generated by Plan Command for discussion #15009

  • expires on Feb 14, 2026, 1:28 AM UTC

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions