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
This commit is contained in:
2026-01-08 01:51:46 -08:00
parent 12f6f6fe75
commit 4ef9141960
2 changed files with 39 additions and 1 deletions

38
Makefile Normal file
View File

@@ -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

View File

@@ -3,7 +3,7 @@
A single linear checklist of tasks to implement the complete pixa caching image reverse proxy server. A single linear checklist of tasks to implement the complete pixa caching image reverse proxy server.
## Project Setup ## 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/*) - [ ] Create project structure (cmd/pixad, internal/*)
- [ ] Implement globals package - [ ] Implement globals package
- [ ] Implement logger package - [ ] Implement logger package