Skip to content

chore(tooling): add prek pre-commit + pre-push hooks - #76

Merged
chagui merged 2 commits into
mainfrom
chagui/tooling/precommit-prek
Apr 30, 2026
Merged

chagui merged 2 commits into
mainfrom
chagui/tooling/precommit-prek

Conversation

@chagui

@chagui chagui commented Apr 30, 2026

Copy link
Copy Markdown
Owner

Summary

Two-stage prek hook setup (drop-in for pre-commit):

  • pre-commit (fast): file hygiene + golangci-lint on packages of staged .go files
  • pre-push (slow): file hygiene + golangci-lint run ./... (mirrors CI)

examples/bazel-project/ is excluded from the lint hook because it's a separate Go module.

Usage

make pre-commit-install   # cargo binstall prek + install both git hooks
make pre-commit           # run pre-commit-stage hooks on all files
make pre-push             # run pre-push-stage hooks on all files

CI remains the source of truth.

Test plan

  • make pre-commit — pass
  • make pre-push — pass
  • git commit triggers the installed hook end-to-end

🤖 Generated with Claude Code

chagui and others added 2 commits April 30, 2026 09:44
Wires up `prek` (Rust drop-in for pre-commit) so staged Go files get
linted before commit without duplicating CI's full-module pass.

- `.pre-commit-config.yaml`: file-hygiene hooks + local golangci-lint hook
- `scripts/precommit-golangci-lint.sh`: reduces staged files to unique
  package dirs, lints only those (fast feedback; CI is the source of truth)
- `Makefile`: `precommit-install` (cargo binstall + `prek install`) and
  `precommit` (run all hooks against every file)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two-stage setup so commits stay fast and pushes still mirror CI:

- pre-commit: lint only packages of staged Go files (existing fast path)
- pre-push: lint the whole root module via `golangci-lint run ./...`

`make pre-commit-install` now wires up both hooks. `make pre-push`
exercises the slow stage on demand.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@chagui
chagui merged commit b4fae69 into main Apr 30, 2026
5 checks passed
@chagui
chagui deleted the chagui/tooling/precommit-prek branch April 30, 2026 08:55
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