From 4ef91419608d104c06039c3bb91f530c00d3c865 Mon Sep 17 00:00:00 2001 From: sneak Date: Thu, 8 Jan 2026 01:51:46 -0800 Subject: [PATCH] Add Makefile with check, lint, test, fmt targets - check: default target, runs fmt-check, lint, and test - fmt-check: verifies code is properly formatted - fmt: formats code with gofmt - lint: runs golangci-lint - test: runs go test - build: builds pixad binary with version info - clean: removes build artifacts --- Makefile | 38 ++++++++++++++++++++++++++++++++++++++ TODO.md | 2 +- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..61852d4 --- /dev/null +++ b/Makefile @@ -0,0 +1,38 @@ +.PHONY: check lint test fmt build clean + +VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev") +BUILDARCH := $(shell go env GOARCH) +LDFLAGS := -X main.Version=$(VERSION) -X main.Buildarch=$(BUILDARCH) + +# Default target: run all checks +check: fmt-check lint test + +# Check formatting without modifying files +fmt-check: + @echo "Checking formatting..." + @test -z "$$(gofmt -l .)" || (echo "Files need formatting:"; gofmt -l .; exit 1) + +# Format code +fmt: + @echo "Formatting code..." + gofmt -w . + +# Run linter +lint: + @echo "Running linter..." + golangci-lint run + +# Run tests +test: + @echo "Running tests..." + go test -v ./... + +# Build the binary +build: + @echo "Building pixad..." + go build -ldflags "$(LDFLAGS)" -o bin/pixad ./cmd/pixad + +# Clean build artifacts +clean: + rm -rf bin/ + rm -f data.db diff --git a/TODO.md b/TODO.md index 9b6f080..4e3fd8b 100644 --- a/TODO.md +++ b/TODO.md @@ -3,7 +3,7 @@ A single linear checklist of tasks to implement the complete pixa caching image reverse proxy server. ## Project Setup -- [ ] Create Makefile with check, lint, test, fmt targets +- [x] Create Makefile with check, lint, test, fmt targets - [ ] Create project structure (cmd/pixad, internal/*) - [ ] Implement globals package - [ ] Implement logger package