Files
go-cuckoo/Makefile
M.V. Hutz ece10585a5
All checks were successful
CI / Unit Tests (push) Successful in 13s
CI / Go Lint (push) Successful in 17s
CI / Mutation Tests (push) Successful in 33s
CI / Fuzz Tests (push) Successful in 58s
style: restructure makefile (#4)
Currently, the `Makefile` is not well structured, and does not follow best practices. With the help of [`checkmake`](https://github.com/checkmake/checkmake), the Makefile can be forced to follow them.

### Decisions

- Added CI job `lint-makefile`, which forces the Makefile to conform to standards.
- The `make help` was set as the default target. This is common practice in the industry.
- The `make help` uses `grep` | `awk` to create a command table from `##` comments after each target. It seems a bit icky, but it is something that Docker, Kubernetes, and Helm all do.

Reviewed-on: #4
Co-authored-by: M.V. Hutz <git@maximhutz.me>
Co-committed-by: M.V. Hutz <git@maximhutz.me>
2026-03-19 00:14:54 +00:00

42 lines
1.3 KiB
Makefile

.PHONY: all help install clean test-unit test-mutation test-fuzz test docs lint-go lint-makefile lint
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
test-mutation: ## Run mutation tests with gremlins
gremlins unleash
test-fuzz: ## Run all fuzz tests for 30s each
@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
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
lint: lint-go lint-makefile ## Lint all code
docs: ## Serve godoc locally
@echo ">>> Visit: http://localhost:6060/pkg/$$(go list -m)"
godoc -http=:6060
clean: ## Clean build and test caches
go clean -cache -testcache
all: lint test ## Run all checks and tests