This is a set of pre-commit
hooks for (primarily Go) development.
Hooks:
go-test
: runsgo test ./...
at the repo rootgoimports
: ensure all the imports are includeddep-check
: ensure all your 3rd party packages are vendored (see dep)todo-jira-check
: ensure all TODO comments reference a JIRA ticket
repos:
- repo: https://github.com/domodwyer/pre-commit
rev: v1.0.0
hooks:
- id: go-test
stages: [commit, push]
types: [go]
exclude: \.pb.go$ # Ignore generated protobuf files
args: ["-timeout=30s"] # Set a deadline (fast tests == happy developers)
- id: goimports
stages: [commit, push, manual]
types: [go]
exclude: \.pb.go$ # Ignore generated protobuf files
args: ["-local=itsallbroken.com"] # Separate local imports
- id: dep-check
stages: [push, manual]
types: [go]
- id: todo-jira-check # Requires python
stages: [commit, push, manual]
args: ["--tag=DEV"] # JIRA ticket tag (defaults to DEV)
New TODOs introduced into the codebase should be tracked in JIRA so they're eventually done!
The todo-jira-check
hook searches changed files for TODO
comments (lines
prefixed by #
or //
) that do not reference a JIRA ticket. A valid TODO is in
the form: TODO(DEV-4242)
, where the DEV
tag is configurable, and 4242
is
the ticket number.