Skip to content

[plan] Fix critical shellcheck issues across high-priority workflows #9995

@github-actions

Description

@github-actions

Objective

Address critical shellcheck errors (SC2155 and other high-impact issues) in the highest-traffic workflows to improve shell script reliability and prevent bugs.

Context

Tool: actionlint + shellcheck
Count: 197 errors across 118 workflows (95.2%)
Most Common: SC2155 - Declare and assign separately to avoid masking return values
Reference: https://www.shellcheck.net/wiki/SC2155

Shellcheck findings indicate shell scripting patterns that can lead to subtle bugs, masked errors, and unexpected behavior. SC2155 is particularly problematic because it can hide command failures.

Problem Example

Bad (SC2155):

local result=$(some_command)  # If some_command fails, $? is 0 (success)

Good:

local result
result=$(some_command)  # If some_command fails, $? reflects the failure

Approach

  1. Identify the top 15-20 highest-traffic workflows with SC2155 errors
  2. For each workflow, review shell script blocks in the compiled .lock.yml files
  3. Separate variable declaration from assignment for local variables
  4. Add proper error checking after command execution
  5. Test that the fix doesn't break workflow functionality
  6. Run make recompile after modifying the source .md files

Priority workflows (likely high-traffic based on naming):

  • CI/CD workflows (ci-doctor, ci-coach)
  • Security workflows (security-compliance, security-fix-pr)
  • Core automation (audit-workflows, compiler-checker)

Files to Modify

Target 15-20 workflows with the highest impact:

  • .github/workflows/ci-doctor.md
  • .github/workflows/ci-coach.md
  • .github/workflows/security-compliance.md
  • .github/workflows/audit-workflows.md
  • Plus 10-15 more from the affected list

Example Fix

Before (in workflow .md file):

- name: Process result
  run: |
    local output=$(git status)
    echo "$output"

After:

- name: Process result
  run: |
    local output
    output=$(git status) || { echo "git status failed"; exit 1; }
    echo "$output"

Acceptance Criteria

  • Top 15-20 workflows have SC2155 fixed
  • Proper error handling added for command execution
  • All modified workflows compile successfully
  • Shellcheck error count reduced by at least 50 issues
  • No functionality broken by the changes
  • make test passes

Testing

# After each fix, compile and check
make build
./gh-aw compile .github/workflows/<workflow-name>.md

# Run actionlint to verify shellcheck issues reduced
make recompile
actionlint .github/workflows/*.lock.yml 2>&1 | grep "SC2155" | wc -l

# Run full test suite
make test

Notes

AI generated by Plan Command for discussion #9966

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions