-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
71 lines (58 loc) · 2.27 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
LINTER_VERSION=v1.58.1
LINTER=./bin/golangci-lint
ifeq ($(OS),Windows_NT)
LINTER=./bin/golangci-lint.exe
endif
.PHONY: all
all: clean setup lint test ## Run sequentially clean, setup, lint and test.
.PHONY: lint
lint: ## Run linter and detect go mod tidy changes.
$(LINTER) run -c ./.golangci-lint.yml --fix
@make tidy
@if ! git diff --quiet; then \
echo "'go mod tidy' resulted in changes or working tree is dirty:"; \
git --no-pager diff; \
fi
.PHONY: setup
setup: ## Download dependencies.
go mod download
@if [ ! -f "$(LINTER)" ]; then \
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s $(LINTER_VERSION); \
fi
.PHONY: test
test: ## Run tests (with race condition detection).
go test -race -timeout=30s ./...
.PHONY: test-integration
test-integration: ## Run integration tests (with race condition detection).
go test -race -timeout=5m -tags=integration ./...
.PHONY: bench
bench: ## Run benchmarks.
go test -race -benchmem -benchtime=5s -bench=.
.PHONY: bench-integration
bench-integration: ## Run integration benchmarks.
go test -race -tags=integration -benchmem -benchtime=5s -bench=.
.PHONY: cover
cover: ## Run tests with coverage. Generates "cover.out" profile and its html representation.
go test -race -timeout=30s -coverprofile=cover.out -coverpkg=./... ./...
go tool cover -html=cover.out -o cover.html
.PHONY: cover-integration
cover-integration: ## Run integration tests with coverage. Generates "cover-integration.out" profile and its html representation.
go test -race -timeout=5m -tags=integration -coverprofile=cover-integration.out -coverpkg=./... ./...
go tool cover -html=cover-integration.out -o cover-integration.html
.PHONY: tidy
tidy: ## Simply runs 'go mod tidy'.
go mod tidy
.PHONY: clean
clean: ## Clean up go tests cache and coverage generated files.
go clean -testcache
@for file in cover.html cover.out cover-integration.html cover-integration.out; do \
if [ -f $$file ]; then \
echo "rm -f $$file"; \
rm -f $$file; \
fi \
done
.PHONY: help
# Absolutely awesome: https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.DEFAULT_GOAL := help