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:
2026-02-25 18:18:00 +07:00
parent f702e64139
commit 0000188265

View File

@@ -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") VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
LDFLAGS := -X main.Version=$(VERSION) LDFLAGS := -X main.Version=$(VERSION)
@@ -21,10 +21,10 @@ lint:
@echo "Running linter..." @echo "Running linter..."
golangci-lint run golangci-lint run
# Run tests # Run tests (30-second timeout)
test: test:
@echo "Running tests..." @echo "Running tests..."
go test -v ./... go test -timeout 30s -v ./...
# Build the binary # Build the binary
build: ./bin/pixad build: ./bin/pixad
@@ -58,3 +58,10 @@ devserver: docker devserver-stop
devserver-stop: devserver-stop:
-docker stop pixad-dev 2>/dev/null -docker stop pixad-dev 2>/dev/null
-docker rm 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