chore: fix Makefile — add fmt-check, docker, hooks targets; 30s test timeout (refs #17)
This commit is contained in:
30
Makefile
30
Makefile
@@ -1,4 +1,4 @@
|
|||||||
.PHONY: all build lint fmt test check clean run debug
|
.PHONY: all build lint fmt fmt-check test check clean run debug docker hooks
|
||||||
|
|
||||||
BINARY := chatd
|
BINARY := chatd
|
||||||
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
|
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
|
||||||
@@ -17,18 +17,15 @@ fmt:
|
|||||||
gofmt -s -w .
|
gofmt -s -w .
|
||||||
goimports -w .
|
goimports -w .
|
||||||
|
|
||||||
test:
|
fmt-check:
|
||||||
go test -v -race -cover ./...
|
|
||||||
|
|
||||||
# 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)
|
@test -z "$$(gofmt -l .)" || (echo "Files not formatted:" && gofmt -l . && exit 1)
|
||||||
@echo "==> Running linter..."
|
|
||||||
golangci-lint run --config .golangci.yml ./...
|
test:
|
||||||
@echo "==> Running tests..."
|
go test -timeout 30s -v -race -cover ./...
|
||||||
go test -v -race ./...
|
|
||||||
|
# check runs all validation without making changes
|
||||||
|
# Used by CI and Docker build — fails if anything is wrong
|
||||||
|
check: test lint fmt-check
|
||||||
@echo "==> Building..."
|
@echo "==> Building..."
|
||||||
go build -ldflags "$(LDFLAGS)" -o /dev/null ./cmd/chatd
|
go build -ldflags "$(LDFLAGS)" -o /dev/null ./cmd/chatd
|
||||||
@echo "==> All checks passed!"
|
@echo "==> All checks passed!"
|
||||||
@@ -41,3 +38,12 @@ debug: build
|
|||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf bin/ chatd data.db
|
rm -rf bin/ chatd data.db
|
||||||
|
|
||||||
|
docker:
|
||||||
|
docker build -t chat .
|
||||||
|
|
||||||
|
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