-
Notifications
You must be signed in to change notification settings - Fork 182
/
Makefile
66 lines (55 loc) · 1.47 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
.DEFAULT_GOAL := test
.PHONY: test_gotest
test_gotest:
go clean -testcache
go test -timeout=0 ./...
.PHONY: static_check
static_check: check_tools
@echo Checking correct formatting of files
@FMTOUT=$$(go fmt ./...); \
if [ -z $$FMTOUT ]; then\
echo "go fmt: OK";\
else \
echo "go fmt: problems in files:";\
echo $$FMTOUT;\
false;\
fi
@if GOVETOUT=$$(go vet ./... 2>&1); then\
echo "go vet: OK";\
else \
echo "go vet: problems in files:";\
echo "$$GOVETOUT";\
false;\
fi
@GOIMPORTSOUT=$$(goimports -l .); \
if [ -z "$$GOIMPORTSOUT" ]; then\
echo "goimports: OK";\
else \
echo "goimports: problems in files:";\
echo "$$GOIMPORTSOUT";\
false;\
fi
@STATICCHECKOUT=$$(staticcheck -go 1.22 -checks all ./...); \
if [ -z "$$STATICCHECKOUT" ]; then\
echo "staticcheck: OK";\
else \
echo "staticcheck: problems in files:";\
echo "$$STATICCHECKOUT";\
false;\
fi
@echo Checking all local changes are committed
go mod tidy
out=`git status --porcelain`; echo "$$out"; [ -z "$$out" ]
.PHONY: test
test: test_gotest
.PHONY: ci_test
ci_test: static_check test_gotest
EXECUTABLES = goimports staticcheck
.PHONY: get_tools
get_tools:
go install golang.org/x/tools/cmd/goimports@latest
go install honnef.co/go/tools/cmd/[email protected]
.PHONY: check_tools
check_tools:
@$(foreach exec,$(EXECUTABLES),\
$(if $(shell which $(exec)),true,$(error "$(exec) not found in PATH, consider running `make get_tools`.")))