2020-06-04 17:41:04 +00:00
|
|
|
# use with https://github.com/casey/just
|
|
|
|
|
2020-06-11 06:05:52 +00:00
|
|
|
# use pre-commit manual stage
|
|
|
|
pre-commit-manual := "pre-commit run --hook-stage manual"
|
|
|
|
|
2020-06-11 02:52:11 +00:00
|
|
|
# fix auto-fixable lint issues in staged files
|
2020-06-04 17:41:04 +00:00
|
|
|
fix:
|
2020-06-11 06:05:52 +00:00
|
|
|
{{ pre-commit-manual }} go-returns-write # fixes all Go lint issues
|
|
|
|
{{ pre-commit-manual }} prettier # fixes all Markdown (& other) lint issues
|
2020-06-04 17:41:04 +00:00
|
|
|
|
2020-06-11 06:05:52 +00:00
|
|
|
# lint issues in - or due - to staged files
|
2020-06-04 17:41:04 +00:00
|
|
|
lint:
|
2020-06-11 06:05:52 +00:00
|
|
|
{{ pre-commit-manual }} go-vet-mod-changed # first run go vet
|
|
|
|
{{ pre-commit-manual }} go-lint-changed # then run golint
|
|
|
|
{{ pre-commit-manual }} golangci-lint-mod-changed # last run golangci-lint
|
2020-06-04 17:41:04 +00:00
|
|
|
|
2020-06-11 06:05:52 +00:00
|
|
|
# lint all issues
|
2020-06-04 17:41:04 +00:00
|
|
|
lint-all:
|
2020-06-11 06:05:52 +00:00
|
|
|
{{ pre-commit-manual }} golangci-lint-repo-mod-all || true # runs golangci-lint
|
2020-06-04 19:30:56 +00:00
|
|
|
|
|
|
|
# run tests in - or due - to staged files
|
|
|
|
test:
|
2020-06-11 06:05:52 +00:00
|
|
|
{{ pre-commit-manual }} go-test-repo-mod-all || true # runs go test
|
2020-06-04 17:41:04 +00:00
|
|
|
|
2020-06-11 06:05:52 +00:00
|
|
|
# push skipping pre-push hooks
|
|
|
|
push:
|
|
|
|
git push --no-verify
|
2020-06-04 17:41:04 +00:00
|
|
|
|
2020-06-11 06:05:52 +00:00
|
|
|
# install/update code automation
|
2020-06-04 19:30:56 +00:00
|
|
|
install:
|
2020-06-04 17:41:04 +00:00
|
|
|
curl https://pre-commit.com/install-local.py | python3 -
|
2020-06-11 06:05:52 +00:00
|
|
|
pre-commit install-hooks
|
|
|
|
# are NOT (yet) automatically installed
|
|
|
|
# through https://github.com/tekwizely/pre-commit-golang
|
2020-06-04 17:41:04 +00:00
|
|
|
go get github.com/sqs/goreturns
|
2020-06-04 19:30:56 +00:00
|
|
|
go get github.com/go-lintpack/lintpack/...
|
|
|
|
go get github.com/go-critic/go-critic/...
|
2020-06-04 19:47:11 +00:00
|
|
|
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin v1.27.0
|
2020-06-04 19:30:56 +00:00
|
|
|
|
2020-06-11 06:05:52 +00:00
|
|
|
# setup hooks for stage (optional)
|
|
|
|
setup stage="pre-push":
|
|
|
|
pre-commit install --hook-type {{ stage }} # uninstall: `pre-commit uninstall`
|