Skip to content

Add ShellCheck linting workflow#31975

Open
AdeshDeshmukh wants to merge 1 commit intohelm:mainfrom
AdeshDeshmukh:add-shellcheck-workflow
Open

Add ShellCheck linting workflow#31975
AdeshDeshmukh wants to merge 1 commit intohelm:mainfrom
AdeshDeshmukh:add-shellcheck-workflow

Conversation

@AdeshDeshmukh
Copy link
Copy Markdown

This PR adds GitHub Actions workflow to lint bash scripts with ShellCheck.

Changes Made

1. Added ShellCheck Workflow

  • Created .github/workflows/shellcheck.yml
  • Runs on all PRs and pushes to main
  • Uses ubuntu-latest (ShellCheck pre-installed)
  • Lints all *.sh files except vendor and .git directories

2. Fixed ShellCheck Issues

All bash scripts now pass ShellCheck validation:

scripts/release-notes.sh

  • Added quotes around variables to prevent word splitting (SC2086)
  • Replaced deprecated expr with arithmetic expansion $((...))(SC2003)

scripts/util.sh

  • Replaced backticks with $(...) notation (SC2006)
  • Fixed trap command quoting to use single quotes (SC2064)

scripts/validate-license.sh

  • Used mapfile for array assignment (SC2207)

Testing

All scripts pass shellcheck validation
No functional changes to script behavior
Ready for CI integration

Why This Is Needed

  • Enforces bash best practices
  • Catches common mistakes early
  • Improves code quality and maintainability
  • Complements existing Go linting (golangci-lint, govulncheck)

Fixes #31689

This commit adds GitHub Actions workflow for ShellCheck to lint bash scripts:

- Created .github/workflows/shellcheck.yml
- Runs on all pull requests and pushes
- Uses ubuntu-latest where ShellCheck is pre-installed
- Finds and lints all *.sh files in the repository

Additionally, this commit fixes ShellCheck warnings in existing scripts:

- scripts/release-notes.sh: Fixed unquoted variables, replaced expr with 0
- scripts/util.sh: Replaced backticks with $(...), fixed trap command quoting
- scripts/validate-license.sh: Used mapfile for array assignment instead of command substitution

All bash scripts now pass ShellCheck validation.

Fixes: helm#31689
@pull-request-size pull-request-size Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 27, 2026
@gjenkins8
Copy link
Copy Markdown
Member

If you could sign the DCO please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lint Bash scripts with shellcheck

2 participants