Skip to content

Run each linter as its own CI check, add actionlint and zizmor - #371

Merged
seberm merged 2 commits into
bitcoinix:masterfrom
sebsgent:lint-checks
Dec 1, 2026
Merged

seberm merged 2 commits into
bitcoinix:masterfrom
sebsgent:lint-checks

Conversation

@sebsgent

@sebsgent sebsgent commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #370, as announced there.

Changes

  • test/lint.nix defines the linters once: actionlint, deadnix, shellcheck, statix and zizmor (offline audits only). Each is a flake check and a job of a new lint CI matrix, reported as lint (<linter>). The matrix replaces the shellcheck job, and test/shellcheck.sh moves into lint.nix.
  • The ci-workflows check requires the matrix to list exactly the linters of lint.nix, and lint is in ci_gate's needs.
  • Locally: ./test/run-tests.sh lint (replaces the shellcheck target), and all linters are in nix develop.
  • Optional pre-commit hook .#pre-commit-hook: it runs the same linters on the whole staged tree, so a finding in any file blocks the commit, and prints only the output of failing linters. It keeps running the linters of the checkout it was installed from, so checking out untrusted code doesn't change what it runs, and it warns when test/lint.nix has changed since. Installing and removing it is described in dev/README.md.
  • Workflow hardening for zizmor's findings, in a separate commit:
    • persist-credentials: false on every checkout. The only git operations after checkout fetch from the public repository.
    • The labeler's pull-requests: write permission is granted per job instead of for the whole workflow.
    • The docs site path is passed to upload-pages-artifact directly instead of through GITHUB_ENV.
    • The pull_request_target (labeler, pr-size) and workflow_run (docs) triggers are kept, with a comment explaining why each is safe and # zizmor: ignore[dangerous-triggers].

nixfmt still comes later, in its own formatting-only PR.

Testing

  • All five lint checks, ci-workflows and the pre-commit hook build and pass locally, and the hook passes on the staged tree.
  • Negative control: removing persist-credentials: false from a checkout makes the zizmor check and the hook fail (artipacked). A passing hook prints nothing.
  • The lint matrix, nix flake check and VM scenarios are left to CI.

Assisted-by: Claude Code (claude-opus-5-5)

@github-actions github-actions Bot added area: ci .github/, test/, dev/ area: docs docs/, README, examples/, SECURITY.md, book.toml, assets area: packages pkgs/ and flake pins area: release helper/ release tooling, signing, release keys size: L 100–499 changed lines (additions + deletions) labels Dec 1, 2026
@seberm seberm added this to the v0.2.2 milestone Dec 1, 2026

@sebsgent sebsgent left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No must-fix or should-fix items. The change is correct and complete.

Before release:

  • After merging, run "bitcoinix docs" once via workflow_dispatch on master. The upload-pages-artifact path (${{ runner.temp }}/site) and the master fetch without credentials only run outside PRs. Scheduled tag checks don't trigger a docs build, so otherwise the next release would be their first run. A manual run redeploys the latest release (v0.2.1).

Optional:

  • On every commit, even when nothing fails, the hook prints zizmor's progress log: 7 INFO lines, a WARN about the python shell in pr-size.yml, and a "No findings" line.
  • dev/README.md says the hook lints "the staged files". It lints the whole staged tree, so a finding in a file the commit doesn't touch also blocks the commit.

Tested:

  • Each linter fails on an injected violation: actionlint (undefined context), deadnix (unused let), shellcheck (SC2154 in an extensionless shebang file), statix (manual_inherit), zizmor (artipacked).
  • The shellcheck file selection matches the old test/shellcheck.sh exactly (43 files).
  • The pre-commit hook checks the index, not the working tree. It fails with git commit -a and with git commit -- <path>, warns when test/lint.nix has changed, and works in a linked worktree.
  • The install command refuses to overwrite an existing hook file, replaces its own symlink, and follows core.hooksPath.
  • ./test/run-tests.sh lint passes.
  • All 12 checkouts set persist-credentials: false. Anonymous access to the public repo works for the remaining git fetch calls.

Assisted-by: Claude Code (Claude Opus 5.5)

@sebsgent
sebsgent marked this pull request as ready for review December 1, 2026 16:34
@viberaven

Copy link
Copy Markdown
Contributor

Reviewed head db7dbda672eba1f1fd841dbd8a855705c3411fcd.

No actionable findings. The linter matrix, flake checks, and required CI gate are consistent. The earlier optional comments about noisy successful hooks and the staged-tree wording are addressed in this head.

Validation on x86_64-linux:

  • Built #lint (all five linters), #checks.x86_64-linux.ci-workflows, and #pre-commit-hook; ./test/run-tests.sh lint also passed.
  • In a disposable repository, injected violations were rejected by actionlint, deadnix, shellcheck (including an extensionless script), statix, and zizmor.
  • Verified that an unstaged violation does not fail the hook, while a staged violation fails even with a clean working copy. Also checked git commit -a, path-specific commits, and an alternate GIT_INDEX_FILE.
  • A clean hook produced no output. Changing test/lint.nix produced the reinstall warning while the hook continued using its installed linter definitions.
  • git diff --check passed.

GitHub CI is green for this head. The live Pages deployment path was inspected but not executed locally.

Check out without persisting the GitHub token in .git/config
(`persist-credentials: false`). No job needs it: the only git
operations after checkout fetch from the public repository.

Grant the labeler's pull-requests write permission per job instead of
for the whole workflow.

Pass the docs site directory to upload-pages-artifact directly instead
of through GITHUB_ENV.

Document why the pull_request_target and workflow_run triggers are
safe, and mark them as accepted zizmor findings: the labeler only calls
the GitHub API, pr-size only diffs the PR head in a bare repository,
and the docs release build runs only after "Verify release tags", with
the workflow and tooling of the default branch.

Assisted-by: Claude Code (claude-opus-5-5)
Define the linters once in test/lint.nix: actionlint, deadnix,
shellcheck, statix and zizmor (offline audits only). Each linter is a
flake check and a job of the `lint` CI matrix, reported as
`lint (<linter>)`, so a failing linter shows up without opening the
logs. The matrix replaces the shellcheck job, and test/shellcheck.sh
moves into lint.nix. The ci-workflows check requires the matrix to
list exactly the linters of lint.nix.

`./test/run-tests.sh lint` (replacing the `shellcheck` target) runs all
linters locally, and `nix develop` provides them.

Add an optional pre-commit hook, `.#pre-commit-hook`, that runs the
same linters on the staged tree. It runs the linters of the checkout
it was installed from, so checking out untrusted code doesn't change
what it runs, and warns when test/lint.nix has changed since.

Assisted-by: Claude Code (claude-opus-5-5)
@seberm
seberm enabled auto-merge December 1, 2026 19:52
@seberm
seberm merged commit a0b61f9 into bitcoinix:master Dec 1, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ci .github/, test/, dev/ area: docs docs/, README, examples/, SECURITY.md, book.toml, assets area: packages pkgs/ and flake pins area: release helper/ release tooling, signing, release keys size: L 100–499 changed lines (additions + deletions)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants