Skip to content

ci: add shellcheck to CI and lefthook#22

Merged
ojongerius merged 2 commits into
mainfrom
ci/add-shellcheck
Apr 5, 2026
Merged

ci: add shellcheck to CI and lefthook#22
ojongerius merged 2 commits into
mainfrom
ci/add-shellcheck

Conversation

@ojongerius
Copy link
Copy Markdown
Contributor

@ojongerius ojongerius commented Apr 5, 2026

Summary

  • Add shellcheck.yml workflow triggered on .sh file changes
  • Add shellcheck pre-commit hook to lefthook (gracefully skips if not installed)
  • Matches the pattern used in the ar monorepo

Test plan

  • Push a .sh file change and verify shellcheck workflow runs
  • Verify lefthook runs shellcheck on staged .sh files

Add shellcheck.yml workflow triggered on .sh file changes, and
a shellcheck pre-commit hook via lefthook. Matches the pattern
used in the ar monorepo.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds ShellCheck linting to the repo via both GitHub Actions CI and a local lefthook pre-commit hook, aligning shell script linting with existing Go CI checks.

Changes:

  • Add a new GitHub Actions workflow to run ShellCheck on .sh changes.
  • Add a lefthook pre-commit job to run ShellCheck on staged .sh files (with a skip message if not installed).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
lefthook.yml Adds a shellcheck pre-commit job for staged .sh files.
.github/workflows/shellcheck.yml Introduces a CI workflow to run ShellCheck when .sh files change.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lefthook.yml Outdated

- name: shellcheck
glob: "**/*.sh"
run: command -v shellcheck >/dev/null 2>&1 && shellcheck {staged_files} || echo "shellcheck not installed — skipping"
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

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

The A && shellcheck ... || echo "shellcheck not installed" construct will also hit the || echo ... branch when shellcheck is installed but returns a non-zero exit code (i.e., lint failures), causing the hook to pass and hiding real issues. Restructure this so the "skip" path only happens when shellcheck is missing, and otherwise propagate shellcheck's exit status.

Suggested change
run: command -v shellcheck >/dev/null 2>&1 && shellcheck {staged_files} || echo "shellcheck not installed — skipping"
run: if command -v shellcheck >/dev/null 2>&1; then shellcheck {staged_files}; else echo "shellcheck not installed — skipping"; fi

Copilot uses AI. Check for mistakes.
Comment thread lefthook.yml Outdated
Comment on lines +23 to +25
- name: shellcheck
glob: "**/*.sh"
run: command -v shellcheck >/dev/null 2>&1 && shellcheck {staged_files} || echo "shellcheck not installed — skipping"
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

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

The header comment says the run commands "check the entire module — not just staged files", but this new job runs shellcheck only on {staged_files}. Either update the comment to reflect this exception or adjust the command to lint all tracked .sh files for consistency.

Copilot uses AI. Check for mistakes.
Comment on lines +7 to +11
- "**/*.sh"
pull_request:
branches: [main]
paths:
- "**/*.sh"
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

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

With paths: ["**/*.sh"] only, this workflow will not run when the workflow file itself is modified (or when adding/configuring ShellCheck via config files). Consider including .github/workflows/shellcheck.yml (and any ShellCheck config files you expect) in the paths list so changes to the workflow are validated in PRs.

Suggested change
- "**/*.sh"
pull_request:
branches: [main]
paths:
- "**/*.sh"
- "**/*.sh"
- ".github/workflows/shellcheck.yml"
pull_request:
branches: [main]
paths:
- "**/*.sh"
- ".github/workflows/shellcheck.yml"

Copilot uses AI. Check for mistakes.
- Fix lefthook command to not swallow shellcheck failures
- Add workflow file itself to path triggers
- Update header comment to clarify staged-only for shellcheck
@ojongerius ojongerius merged commit 7ee52cd into main Apr 5, 2026
5 checks passed
@ojongerius ojongerius deleted the ci/add-shellcheck branch April 5, 2026 09:08
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.

2 participants