Add actionlint to catch errors in GitHub Actions workflows - #997
Add actionlint to catch errors in GitHub Actions workflows#997chernojagne wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request integrates actionlint into the pre-commit hooks and adds a configuration file for it. The review feedback recommends against globally ignoring ShellCheck rules SC2086 and SC2155, as doing so introduces risks of command injection and masked command failures in CI/CD workflows.
| - 'shellcheck reported issue in this script: SC1091:.+' # Can't follow non-constant source | ||
| - 'shellcheck reported issue in this script: SC2086:.+' # Double-quote to prevent globbing/word splitting | ||
| - 'shellcheck reported issue in this script: SC2129:.+' # Consider using { cmd1; cmd2; } >> file | ||
| - 'shellcheck reported issue in this script: SC2155:.+' # Declare and assign separately to avoid masking return values |
There was a problem hiding this comment.
Suppressing SC2086 and SC2155 globally across all workflows is discouraged due to security and correctness risks:
- SC2086 (Double quote to prevent globbing and word splitting): Unquoted variables in GitHub Actions are a common source of command injection vulnerabilities (especially when using github context expressions or environment variables containing user-controlled input) and unexpected failures when paths contain spaces.
- SC2155 (Declare and assign separately to avoid masking return values): Combining declaration and assignment (e.g.,
export FOO=$(cmd)) masks the exit code ofcmd, causing the step to succeed even if the command fails. In CI/CD pipelines, we want commands to fail fast and loudly.
It is safer to keep these checks enabled globally and use inline shellcheck disable comments (e.g., # shellcheck disable=SC2086) only where strictly necessary.
- 'shellcheck reported issue in this script: SC1091:.+' # Can't follow non-constant source
- 'shellcheck reported issue in this script: SC2129:.+' # Consider using { cmd1; cmd2; } >> fileThere was a problem hiding this comment.
Thanks for flagging this. A few notes on why these are suppressed:
- SC2086 (unquoted
$GITHUB_OUTPUT): the existingrelease-on-merge.ymluses>> $GITHUB_OUTPUTwithout quotes, which would trip this check. Rather than fixing every pre-existing occurrence in the same PR, the suppression lets actionlint land cleanly and leaves those fixes for a separate pass. - SC2155: same rationale — pre-existing patterns elsewhere would otherwise block adoption.
Happy to remove both suppressions and fix each occurrence inline if that is preferred — just say the word.
Add
actionlintto lint GitHub Actions workflow files.What
Three files:
.github/actionlint.yaml— actionlint config with ShellCheck integration. Common false-positive rules for GitHub Actions expressions are suppressed (SC2086,SC2129,SC2155,SC1091)..github/workflows/actionlint.yml— dedicated CI job triggered on changes to.github/workflows/**. Runs on push and pull_request..pre-commit-config.yaml— actionlint pre-commit hook for local checks before committing workflow changes.Why
The existing
ci.ymlreferences${{ matrix.PY }}on line 40, but the matrix key ispython-version—PYis undefined and resolves to an empty string, sosetup-minicondasilently ignores the version pin for that step. Actionlint catches exactly this class of typo.With this change in place, undefined matrix keys, incorrect action input names, and shell-level bugs in
run:blocks will be flagged automatically — both in CI and locally via pre-commit.This change was generated by Autar and reviewed by a human before submission.