-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
57 lines (42 loc) · 1.84 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
.PHONY: help prerequisites deps format lint test bench coverage-report build release changelog docs clean
.DEFAULT_GOAL := build
BIN_NAME := minutes
# NOTE: Set in CI/CD as well
COVERAGE_OUT := .coverage.out
COVERAGE_HTML := coverage.html
help: ## Show available targets
@echo "Available targets:"
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
prerequisites: ## Download and install prerequisites
go install github.com/goreleaser/goreleaser@latest
go install github.com/sqs/goreturns@latest
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
go install github.com/securego/gosec/v2/cmd/gosec@latest
go install golang.org/x/vuln/cmd/govulncheck@latest
deps: ## Download dependencies
go mod download
go mod tidy
format: ## Run formatter on the project
goreturns -b -local -p -w -e -l .
lint: format ## Run linters on the project
govulncheck ./...
golangci-lint run --timeout 5m -E revive -e '(struct field|type|method|func) [a-zA-Z`]+ should be [a-zA-Z`]+'
gosec -quiet ./...
test: deps ## Run tests
go test -cover -covermode=atomic -coverprofile .coverage.out ./...
bench: deps ## Run benchmarks
# ^$ filters out every unit test, so only benchmarks will run
go test -run '^$$' -benchmem -bench . ./...
coverage-report: ## Generate coverage report from previous test run
go tool cover -html "$(COVERAGE_OUT)" -o "$(COVERAGE_HTML)"
build: deps ## Build binary
goreleaser build --clean --snapshot --single-target
@find bin -name "$(BIN_NAME)" -exec cp "{}" bin/ \;
release: ## Release a new version on GitHub
goreleaser release --clean
changelog: ## Generate changelog
git-cliff > CHANGELOG.md
docs: ## Serve the documentation site locally
@cd www && mkdocs serve
clean: ## Clean up project root
rm -rf bin/ "$(COVERAGE_OUT)" "$(COVERAGE_HTML)"