chore: add hooks target and 30s test timeout to Makefile
Add missing fmt-check to .PHONY, add hooks target for pre-commit hook installation, and add 30-second timeout to test target per repo policy.
This commit is contained in:
13
Makefile
13
Makefile
@@ -1,4 +1,4 @@
|
||||
.PHONY: check lint test fmt build clean docker docker-test devserver devserver-stop
|
||||
.PHONY: check lint test fmt fmt-check build clean docker docker-test devserver devserver-stop hooks
|
||||
|
||||
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
|
||||
LDFLAGS := -X main.Version=$(VERSION)
|
||||
@@ -21,10 +21,10 @@ lint:
|
||||
@echo "Running linter..."
|
||||
golangci-lint run
|
||||
|
||||
# Run tests
|
||||
# Run tests (30-second timeout)
|
||||
test:
|
||||
@echo "Running tests..."
|
||||
go test -v ./...
|
||||
go test -timeout 30s -v ./...
|
||||
|
||||
# Build the binary
|
||||
build: ./bin/pixad
|
||||
@@ -58,3 +58,10 @@ devserver: docker devserver-stop
|
||||
devserver-stop:
|
||||
-docker stop pixad-dev 2>/dev/null
|
||||
-docker rm pixad-dev 2>/dev/null
|
||||
|
||||
# Install pre-commit hook
|
||||
hooks:
|
||||
@printf '#!/bin/sh\nset -e\n' > .git/hooks/pre-commit
|
||||
@printf 'go mod tidy\ngo fmt ./...\ngit diff --exit-code -- go.mod go.sum || { echo "go mod tidy changed files; please stage and retry"; exit 1; }\n' >> .git/hooks/pre-commit
|
||||
@printf 'make check\n' >> .git/hooks/pre-commit
|
||||
@chmod +x .git/hooks/pre-commit
|
||||
|
||||
Reference in New Issue
Block a user