Skip to content

ci: shellcheck + bats on push and PR#25

Merged
justi merged 4 commits into
mainfrom
ci/shellcheck-bats
Apr 26, 2026
Merged

ci: shellcheck + bats on push and PR#25
justi merged 4 commits into
mainfrom
ci/shellcheck-bats

Conversation

@justi
Copy link
Copy Markdown
Owner

@justi justi commented Apr 26, 2026

Summary

  • Adds .github/workflows/ci.yml with two jobs: shellcheck (lints bin/revive + install.sh) and bats (runs the 111-test suite).
  • Fixes one SC2012 warning in purpose_from_gemspec (ls *.gemspec | headfind -maxdepth 1). Behavior unchanged.

Why

Repo is installed via curl | bash, so a regression in install.sh ships directly to users. CI on PRs catches that before merge. Cheapest insurance available — both tools are already part of the documented dev loop in CLAUDE.md.

Test plan

  • shellcheck bin/revive install.sh clean locally
  • bats tests/ — 111/111 pass locally
  • Workflow runs green on this PR

🤖 Generated with Claude Code

Runs shellcheck on bin/revive and install.sh, plus the full bats
suite, on push to main and on every PR. Fixes one SC2012 warning
in purpose_from_gemspec (replace `ls *.gemspec | head` with `find`).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 26, 2026 16:51
apt-installed bats on ubuntu-latest is too old — `run` does not merge
stderr into $output, which broke the suggest stdout-vs-stderr test.
Use the official bats-core GitHub action to pin a current release.
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 GitHub Actions CI to automatically lint and test this bash-based CLI on pushes to main and on pull requests, and adjusts gemspec PURPOSE extraction to satisfy ShellCheck.

Changes:

  • Add .github/workflows/ci.yml with shellcheck and bats jobs for PR/push validation.
  • Replace ls *.gemspec | head with a find-based approach in purpose_from_gemspec to address SC2012.

Reviewed changes

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

File Description
bin/revive Updates gemspec discovery logic used by PURPOSE extraction.
.github/workflows/ci.yml Introduces CI jobs for ShellCheck linting and Bats test execution.

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

Comment thread .github/workflows/ci.yml
push:
branches: [main]
pull_request:

Copy link

Copilot AI Apr 26, 2026

Choose a reason for hiding this comment

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

Consider explicitly setting workflow permissions (e.g., contents: read) at the top-level to follow GitHub Actions least-privilege defaults. This limits the default GITHUB_TOKEN scope for both jobs since they only need to check out code and run local commands.

Suggested change
permissions:
contents: read

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/ci.yml
shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Copy link

Copilot AI Apr 26, 2026

Choose a reason for hiding this comment

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

The shellcheck job assumes shellcheck is already available on ubuntu-latest. To make CI more deterministic (and consistent with the bats job that installs its dependencies), consider installing shellcheck explicitly or using a dedicated ShellCheck action so runner image changes don’t break linting.

Suggested change
- uses: actions/checkout@v4
- uses: actions/checkout@v4
- name: install shellcheck
run: sudo apt-get update && sudo apt-get install -y shellcheck

Copilot uses AI. Check for mistakes.
justi added 2 commits April 27, 2026 01:57
Test 71 asserted that meta-comments (which `cmd_suggest` writes to
stderr) don't leak into stdout. But it checked the merged $output,
which always contains both — so the assertion only "passed" because
bats default errexit behavior ignores all but the last [[ ]] in a
test. Stricter bats environments (CI) caught the bug.

Switch the test to `run --separate-stderr` so $output really is
stdout-only, and add explicit `|| return 1` on each assertion so
intermediate failures aren't silently swallowed regardless of
errexit semantics. Pin bats >= 1.5.0 for the flag.
- Add top-level `permissions: contents: read` for least-privilege
  GITHUB_TOKEN scope (both jobs only read the repo).
- Install shellcheck explicitly via apt instead of relying on the
  ubuntu-latest runner image — keeps CI deterministic if the image
  ever drops the preinstalled binary.
@justi justi merged commit eda81f8 into main Apr 26, 2026
3 checks passed
@justi justi deleted the ci/shellcheck-bats branch April 26, 2026 17:25
@justi justi mentioned this pull request Apr 26, 2026
3 tasks
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