-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
83 lines (64 loc) · 2.02 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
# Copyright (C) 2020 Yunify, Inc.
VERBOSE = no
.PHONY: help
help:
@echo "Please use \`make <target>\` where <target> is one of"
@echo " format to format the code"
@echo " vet to run golang vet"
@echo " lint to run the staticcheck"
@echo " check to format, vet, lint"
@echo " test to run test case"
@echo " compile compile binary program with debug mode"
@echo " release compile binary program with release mode"
@echo " run run server for test"
@exit 0
COMPILE = _compile() { \
args="$(filter-out $@,$(MAKECMDGOALS))"; \
if [ ${VERBOSE} == "yes" ]; then \
bash -x ./scripts/compile_in_local.sh $$args; \
else \
bash ./scripts/compile_in_local.sh $$args; \
fi \
}
.PHONY: format
format:
@[ ${VERBOSE} == "yes" ] && set -x; go fmt ./...;
.PHONY: vet
vet:
@[ ${VERBOSE} == "yes" ] && set -x; go vet ./...;
.PHONY: lint
lint:
@[ ${VERBOSE} == "yes" ] && set -x; staticcheck ./...;
.PHONY: tidy
tidy:
@[ ${VERBOSE} == "yes" ] && set -x; go mod tidy;
.PHONY: check
check: tidy format vet lint
.PHONY: test
test:
@[ ${VERBOSE} == "yes" ] && set -x; go test -race -v ./... -test.count=1 -failfast
.PHONY: compile
compile:
@$(COMPILE); _compile
.PHONY: release
release:
@$(COMPILE); export COMPILE_MODE="release"; _compile
.PHONY: run
run:
@[ ${VERBOSE} == "yes" ] && sh -x ./scripts/run.sh || sh ./scripts/run.sh
.PHONY: build
build: compile-image build-image push-image
.PHONY: compile-image
compile-image:
@[ ${VERBOSE} == "yes" ] && sh -x ./scripts/compile_in_docker.sh || sh ./scripts/compile_in_docker.sh
.PHONY: build-image
build-image:
@[ ${VERBOSE} == "yes" ] && sh -x ./scripts/build_image.sh || sh ./scripts/build_image.sh
.PHONY: push-image
push-image:
@[ ${VERBOSE} == "yes" ] && sh -x ./scripts/push_image.sh || sh ./scripts/push_image.sh
.DEFAULT_GOAL = help
# Target name % means that it is a rule that matches anything, @: is a recipe;
# the : means do nothing
%:
@: