Skip to content

Add actionlint to catch errors in GitHub Actions workflows - #997

Open
chernojagne wants to merge 4 commits into
fsspec:mainfrom
autar-pr:setup-actionlint-838a4952
Open

Add actionlint to catch errors in GitHub Actions workflows#997
chernojagne wants to merge 4 commits into
fsspec:mainfrom
autar-pr:setup-actionlint-838a4952

Conversation

@chernojagne

Copy link
Copy Markdown

Add actionlint to 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.yml references ${{ matrix.PY }} on line 40, but the matrix key is python-versionPY is undefined and resolves to an empty string, so setup-miniconda silently 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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread .github/actionlint.yaml
Comment on lines +11 to +14
- '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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

security-medium medium

Suppressing SC2086 and SC2155 globally across all workflows is discouraged due to security and correctness risks:

  1. 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.
  2. SC2155 (Declare and assign separately to avoid masking return values): Combining declaration and assignment (e.g., export FOO=$(cmd)) masks the exit code of cmd, 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; } >> file

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for flagging this. A few notes on why these are suppressed:

  • SC2086 (unquoted $GITHUB_OUTPUT): the existing release-on-merge.yml uses >> $GITHUB_OUTPUT without 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.

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.

1 participant