style: restructure makefile #4

Merged
mvhutz merged 6 commits from style/makefile-check into main 2026-03-19 00:14:55 +00:00
Showing only changes of commit a367c10957 - Show all commits

View File

@@ -1,12 +1,40 @@
unit: .PHONY: all help install clean test-unit test-mutation test-fuzz test docs lint-go lint-makefile
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*##' $(MAKEFILE_LIST) | awk -F ':.*## ' '{printf " %-15s %s\n", $$1, $$2}'
install: ## Install dev tools
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
go install github.com/checkmake/checkmake/cmd/checkmake@latest
go install github.com/go-gremlins/gremlins/cmd/gremlins@latest
go install golang.org/x/tools/cmd/godoc@latest
go install golang.org/x/vuln/cmd/govulncheck@latest
test-unit: ## Run unit tests with coverage
go test ./... -cover -v go test ./... -cover -v
mutation: test-mutation: ## Run mutation tests with gremlins
gremlins unleash gremlins unleash
fuzz: test-fuzz: ## Run all fuzz tests for 30s each
go test ./... -fuzz=$(FN) @for func in $$(grep -r --include='*_test.go' -oh 'func Fuzz\w*' . | sed 's/func //'); do \
echo "Fuzzing $$func..."; \
go test ./... -fuzz="^$$func$$" -fuzztime=30s; \
done
docs: test: test-unit test-mutation test-fuzz ## Run all tests
lint-go: ## Lint Go code
golangci-lint run ./...
lint-makefile: ## Lint the Makefile
checkmake Makefile
docs: ## Serve godoc locally
@echo ">>> Visit: http://localhost:6060/pkg/git.maximhutz.com/tools/dsa/" @echo ">>> Visit: http://localhost:6060/pkg/git.maximhutz.com/tools/dsa/"
godoc -http=:6060 godoc -http=:6060
clean: ## Clean build and test caches
go clean -cache -testcache
all: lint-go lint-makefile test ## Run all checks and tests