From a65a14b8ecc3b4cb5ed4397108facebfcd1828ba Mon Sep 17 00:00:00 2001 From: clawbot Date: Sun, 1 Mar 2026 07:56:01 -0800 Subject: [PATCH] add fmt-check, hooks, docker targets; add 30s test timeout --- Makefile | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 1da1f2d..1775f2a 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all build lint fmt test check clean +.PHONY: all build lint fmt fmt-check test check clean docker hooks BINARY := dnswatcher VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev") @@ -17,21 +17,26 @@ fmt: gofmt -s -w . goimports -w . +fmt-check: + @test -z "$$(gofmt -l .)" || (echo "Files not formatted:" && gofmt -l . && exit 1) + test: - go test -v -race -cover ./... + go test -v -race -cover -timeout 30s ./... # Check runs all validation without making changes # Used by CI and Docker build - fails if anything is wrong -check: - @echo "==> Checking formatting..." - @test -z "$$(gofmt -l .)" || (echo "Files not formatted:" && gofmt -l . && exit 1) - @echo "==> Running linter..." - golangci-lint run --config .golangci.yml ./... - @echo "==> Running tests..." - go test -v -race ./... +check: fmt-check lint test @echo "==> Building..." go build -ldflags "$(LDFLAGS)" -o /dev/null ./cmd/dnswatcher @echo "==> All checks passed!" +docker: + docker build . + +hooks: + @printf '#!/bin/sh\nset -e\nmake check\n' > .git/hooks/pre-commit + @chmod +x .git/hooks/pre-commit + @echo "Pre-commit hook installed." + clean: rm -rf bin/