style: restructure makefile #4
@@ -6,8 +6,8 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint:
|
lint-go:
|
||||||
name: Golang Lint
|
name: Go Lint
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@@ -23,7 +23,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
version: latest
|
version: latest
|
||||||
|
|
||||||
unit-test:
|
test-unit:
|
||||||
name: Unit Tests
|
name: Unit Tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
@@ -34,9 +34,9 @@ jobs:
|
|||||||
go-version-file: go.mod
|
go-version-file: go.mod
|
||||||
|
|
||||||
- name: Run unit tests
|
- name: Run unit tests
|
||||||
run: go test ./... -cover -v
|
run: make test-unit
|
||||||
|
|
||||||
fuzz-test:
|
test-fuzz:
|
||||||
name: Fuzz Tests
|
name: Fuzz Tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
@@ -47,12 +47,9 @@ jobs:
|
|||||||
go-version-file: go.mod
|
go-version-file: go.mod
|
||||||
|
|
||||||
- name: Run fuzz tests
|
- name: Run fuzz tests
|
||||||
run: |
|
run: make test-fuzz
|
||||||
for func in $(grep -r --include='*_test.go' -oh 'func Fuzz\w*' . | sed 's/func //'); do
|
|
||||||
go test ./... -fuzz="^${func}$" -fuzztime=30s
|
|
||||||
done
|
|
||||||
|
|
||||||
mutation-test:
|
test-mutation:
|
||||||
name: Mutation Tests
|
name: Mutation Tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
@@ -66,4 +63,4 @@ jobs:
|
|||||||
run: go install github.com/go-gremlins/gremlins/cmd/gremlins@latest
|
run: go install github.com/go-gremlins/gremlins/cmd/gremlins@latest
|
||||||
|
|
||||||
- name: Run mutation tests
|
- name: Run mutation tests
|
||||||
run: gremlins unleash
|
run: make test-mutation
|
||||||
|
|||||||
42
Makefile
42
Makefile
@@ -1,12 +1,42 @@
|
|||||||
unit:
|
.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
|
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
|
||||||
@echo ">>> Visit: http://localhost:6060/pkg/git.maximhutz.com/tools/dsa/"
|
|
||||||
|
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
|
godoc -http=:6060
|
||||||
|
|
||||||
|
clean: ## Clean build and test caches
|
||||||
|
go clean -cache -testcache
|
||||||
|
|
||||||
|
all: lint test ## Run all checks and tests
|
||||||
Reference in New Issue
Block a user