-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
48 lines (38 loc) · 1.21 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
COVERAGE_OUT := .coverage.out
COVERAGE_HTML := coverage.html
GO_EXEC := $(shell which go)
GO_TEST_COVER := $(GO_EXEC) test -shuffle=on -cover -covermode=atomic
default: test
.PHONY: help
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}'
.PHONY: dep
dep: ## Download dependencies
$(GO_EXEC) mod tidy
$(GO_EXEC) mod download
.PHONY: dep-update
dep-update: ## Update dependencies
$(GO_EXEC) get -t -u ./...
$(GO_EXEC) mod tidy
$(GO_EXEC) mod download
.PHONY: bench
bench: ## Run benchmarks
$(GO_EXEC) test -bench=. -benchmem -benchtime=10s ./...
.PHONY: format
format: dep ## Format source code
gofmt -l -s -w $(shell pwd)
goimports -w $(shell pwd)
.PHONY: lint
lint: dep ## Run linters
golangci-lint run --timeout 5m
.PHONY: test
test: ## Run unit tests
@rm -f $(COVERAGE_OUT)
$(GO_TEST_COVER) -race -coverprofile=$(COVERAGE_OUT) ./...
.PHONY: coverage.html
coverage.html: ## Generate html coverage report from previous test run
$(GO_EXEC) tool cover -html "$(COVERAGE_OUT)" -o "$(COVERAGE_HTML)"
.PHONY: changelog
changelog: ## Generate changelog
git cliff > CHANGELOG.md