From 6d8170d219b349363d0e8c063da4092a425279ab Mon Sep 17 00:00:00 2001 From: Tyler Koenig Date: Sun, 17 May 2026 14:08:22 -0400 Subject: [PATCH] build: add Makefile for dev, test, and build orchestration --- Makefile | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..84f7b6c --- /dev/null +++ b/Makefile @@ -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