build: add Makefile for dev, test, and build orchestration

This commit is contained in:
2026-05-17 14:08:22 -04:00
parent 73c6a315c1
commit 6d8170d219
+57
View File
@@ -0,0 +1,57 @@
BINARY := nib
MODULE := github.com/lerko/nib
GOFLAGS := -trimpath
.PHONY: build dev test lint fmt vet clean run help
## —— Build ——————————————————————————————————
build: ## Build production binary
go build $(GOFLAGS) -o $(BINARY) .
dev: ## Build and run with default serve
go run . serve
## —— Quality ————————————————————————————————
test: ## Run all tests
go test ./...
test-v: ## Run all tests (verbose)
go test -v ./...
test-cover: ## Run tests with coverage report
go test -coverprofile=coverage.out ./...
go tool cover -func=coverage.out
@rm -f coverage.out
lint: vet fmt-check ## Run all linters
vet: ## Run go vet
go vet ./...
fmt: ## Format all Go files
gofmt -w .
fmt-check: ## Check formatting (fails if unformatted)
@test -z "$$(gofmt -l .)" || (echo "unformatted files:" && gofmt -l . && exit 1)
## —— Utility ————————————————————————————————
clean: ## Remove build artifacts
rm -f $(BINARY) coverage.out
run: build ## Build then run with args (usage: make run ARGS="serve")
./$(BINARY) $(ARGS)
tidy: ## Tidy and verify module dependencies
go mod tidy
go mod verify
## —— Help ———————————————————————————————————
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-14s\033[0m %s\n", $$1, $$2}'
.DEFAULT_GOAL := help