-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
99 lines (64 loc) · 2.18 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
BUILD = `date +%FT%T%z`
# APP_VERSION := `git describe --tags --abbrev=4`
_CURDIR := `git rev-parse --show-toplevel 2>/dev/null | sed -e 's/(//'`
PKG_LIST := $(shell go list ${_CURDIR}/... 2>/dev/null | grep -v mock)
linter := golangci-lint
test_cmd := go test -short -run=.
.PHONY: all
all: lint test
.PHONY: build_all
build_all: lint
.PHONY: full_tests
full_tests: go_lint_max go_performance unit_tests race msan ## Full tests
.PHONY: go_security
go_security: ## Check bugs
@${linter} run --disable-all -E gosec -E govet \
-E scopelint -E staticcheck -E typecheck
.PHONY: lint
lint: go_lint go_performance go_security ## Full liner checks
.PHONY: go_lint
go_lint: ## Lint the files
@${linter} run
.PHONY: go_performance
go_performance: ## Check performance
@${linter} run --disable-all -p performance
.PHONY: go_lint_max
go_lint_max: ## Max lint checks the files
@${linter} run -p bugs -p complexity -p unused -p performance -p format \
-E interfacer -E gocritic
.PHONY: go_style
go_style: ## check style of code
@${linter} run -p style
.PHONY: tests
tests: unit_test race msan ## Run all tests
.PHONY: test
test: unit_test ## Run short test
.PHONY: unit_test
unit_test: ## Run unittests
@${test_cmd} ${PKG_LIST}
.PHONY: race
race: ## Run data race detector
@${test_cmd} -race ${PKG_LIST}
.PHONY: msan
msan: ## Run memory sanitizer
@CXX=clang++ CC=clang \
${test_cmd} -msan -short ${PKG_LIST}
.PHONY: bench
bench: ## Run benchmark tests
@go test -benchmem -bench=. -run=^$ ${PKG_LIST}
.PHONY: go_mod
go_mod: ## mod with proxy
@GOPROXY="https://proxy.golang.org" \
go mod download ${PKG_LIST}
.PHONY: coverage
coverage: ## Generate global code coverage report
[ -x /opt/tools/bin/coverage.sh ] && /opt/tools/bin/coverage.sh || ${_CURDIR}/scripts/coverage.sh;
.PHONY: coverhtml
coverhtml: ## Generate global code coverage report in HTML
[ -x /opt/tools/bin/coverage.sh ] && /opt/tools/bin/coverage.sh html || ${_CURDIR}/scripts/coverage.sh html;
.PHONY: dep
dep: ## Get the dependencies
@go mod vendor
.PHONY: help
help: ## Display this help screen
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'