# Pangolin server Makefile
# Run `make help` to list all targets.

MODULE := pangolin/server
GO     := go
GOTEST := $(GO) test

.PHONY: help deps build build-codegen test test-unit test-integration lint clean

help: ## Show this help
	@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
		awk 'BEGIN{FS=":.*?## "} {printf "  %-20s %s\n", $$1, $$2}'

deps: ## Fetch all module dependencies and generate go.sum
	$(GO) mod tidy
	$(GO) mod download

build: ## Build the main API server binary (placeholder until cmd/server exists)
	$(GO) build ./...

build-codegen: ## Build the codegen CLI tool
	$(GO) build -o bin/codegen ./cmd/codegen

test-unit: ## Run unit tests (no external services required)
	$(GOTEST) -v -count=1 -race ./internal/codes/... -run 'Test[^I][^n][^t]'

test: ## Run all unit tests (no -tags integration)
	$(GOTEST) -v -count=1 -race ./...

test-integration: ## Run integration tests (requires Docker; uses testcontainers)
	$(GOTEST) -v -count=1 -race -tags integration -timeout 5m ./internal/codes/...

lint: ## Run staticcheck (install: go install honnef.co/go/tools/cmd/staticcheck@latest)
	staticcheck ./...

clean: ## Remove build artifacts
	rm -rf bin/
