From 00001882652a52c5ef2d4dab76817b41766a1ede Mon Sep 17 00:00:00 2001 From: sneak Date: Wed, 25 Feb 2026 18:18:00 +0700 Subject: [PATCH] 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. --- Makefile | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index b7e0b05..e09733d 100644 --- a/Makefile +++ b/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