From a367c10957315f91a2cdd25920c3f0b124757c43 Mon Sep 17 00:00:00 2001 From: "M.V. Hutz" Date: Tue, 17 Mar 2026 21:25:26 -0400 Subject: [PATCH 1/6] feat: modernize Makefile - Added `checkmake` to enforce good `Makefile` format. - Added `help`, `test`, `lint-markdown`, `lint`, `clean`, and `all` targets. - Added `install` target. - Added target comments to streamline `help` command. --- Makefile | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index d6095e6..f40f508 100644 --- a/Makefile +++ b/Makefile @@ -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 -mutation: +test-mutation: ## Run mutation tests with gremlins gremlins unleash -fuzz: - go test ./... -fuzz=$(FN) +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 -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/" - godoc -http=:6060 \ No newline at end of file + godoc -http=:6060 + +clean: ## Clean build and test caches + go clean -cache -testcache + +all: lint-go lint-makefile test ## Run all checks and tests \ No newline at end of file -- 2.49.1 From f4b12598f160b216bc86351df6595050279e7f17 Mon Sep 17 00:00:00 2001 From: "M.V. Hutz" Date: Tue, 17 Mar 2026 21:36:28 -0400 Subject: [PATCH 2/6] fix: add `lint` job Runs all `lint-*` jobs. --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index f40f508..fba4498 100644 --- a/Makefile +++ b/Makefile @@ -30,6 +30,8 @@ lint-go: ## Lint Go code 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/git.maximhutz.com/tools/dsa/" godoc -http=:6060 -- 2.49.1 From e53ff4f50b2a9e355aac13a40e83e1918284b95c Mon Sep 17 00:00:00 2001 From: "M.V. Hutz" Date: Tue, 17 Mar 2026 21:37:27 -0400 Subject: [PATCH 3/6] fix: add `lint` to `.PHONY` --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index fba4498..dd5baea 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all help install clean test-unit test-mutation test-fuzz test docs lint-go lint-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}' @@ -39,4 +39,4 @@ docs: ## Serve godoc locally clean: ## Clean build and test caches go clean -cache -testcache -all: lint-go lint-makefile test ## Run all checks and tests \ No newline at end of file +all: lint test ## Run all checks and tests \ No newline at end of file -- 2.49.1 From 5c019baa780793698842a07ba451d1fdf561c94f Mon Sep 17 00:00:00 2001 From: "M.V. Hutz" Date: Wed, 18 Mar 2026 19:29:01 -0400 Subject: [PATCH 4/6] refactor: use make in CI, pull module in make docs Instead of duplicating test logic in both the CI and the Makefile, I made the CI call the Makefile. Also, updated `make docs` so it dynamically pulls the module name from `go list -m`. --- .gitea/workflows/ci.yml | 9 +++------ Makefile | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index d5d0a9d..04d2d5b 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -34,7 +34,7 @@ jobs: go-version-file: go.mod - name: Run unit tests - run: go test ./... -cover -v + run: name test-unit fuzz-test: name: Fuzz Tests @@ -47,10 +47,7 @@ jobs: go-version-file: go.mod - name: Run fuzz tests - run: | - for func in $(grep -r --include='*_test.go' -oh 'func Fuzz\w*' . | sed 's/func //'); do - go test ./... -fuzz="^${func}$" -fuzztime=30s - done + run: make test-fuzz mutation-test: name: Mutation Tests @@ -66,4 +63,4 @@ jobs: run: go install github.com/go-gremlins/gremlins/cmd/gremlins@latest - name: Run mutation tests - run: gremlins unleash + run: make test-mutation diff --git a/Makefile b/Makefile index dd5baea..57a7650 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ lint-makefile: ## Lint the Makefile lint: lint-go lint-makefile ## Lint all code docs: ## Serve godoc locally - @echo ">>> Visit: http://localhost:6060/pkg/git.maximhutz.com/tools/dsa/" + @echo ">>> Visit: http://localhost:6060/pkg/$$(go list -m)" godoc -http=:6060 clean: ## Clean build and test caches -- 2.49.1 From 72a8a9c4f7cc7072f2d134613394209d0307e81e Mon Sep 17 00:00:00 2001 From: "M.V. Hutz" Date: Wed, 18 Mar 2026 19:34:09 -0400 Subject: [PATCH 5/6] fix: unit-test CI job calls 'name' instead of make I made a typo. --- .gitea/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 04d2d5b..5ea315d 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -34,7 +34,7 @@ jobs: go-version-file: go.mod - name: Run unit tests - run: name test-unit + run: make test-unit fuzz-test: name: Fuzz Tests -- 2.49.1 From 51930a7cbb97e4d426e1bf31117178cf960a5db3 Mon Sep 17 00:00:00 2001 From: "M.V. Hutz" Date: Wed, 18 Mar 2026 20:01:16 -0400 Subject: [PATCH 6/6] style: rename CI jobs to match Makefile targets --- .gitea/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 5ea315d..8bcb7c2 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -6,8 +6,8 @@ on: pull_request: jobs: - lint: - name: Golang Lint + lint-go: + name: Go Lint runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -23,7 +23,7 @@ jobs: with: version: latest - unit-test: + test-unit: name: Unit Tests runs-on: ubuntu-latest steps: @@ -36,7 +36,7 @@ jobs: - name: Run unit tests run: make test-unit - fuzz-test: + test-fuzz: name: Fuzz Tests runs-on: ubuntu-latest steps: @@ -49,7 +49,7 @@ jobs: - name: Run fuzz tests run: make test-fuzz - mutation-test: + test-mutation: name: Mutation Tests runs-on: ubuntu-latest steps: -- 2.49.1