@@ -46,41 +46,41 @@ GOLANGCI_VERSION := v1.38.0
46
46
.PHONY : all
47
47
all : clean verify checkfmt lint test build
48
48
49
- # ########################
50
- # # Development targets ##
51
- # ########################
49
+ # ##############
50
+ # #@ Development
51
+
52
52
.PHONY : checkfmt
53
- checkfmt : # # Check formatting of all go files
53
+ checkfmt : # # Check formatting of all go files
54
54
@ $(MAKE ) --no-print-directory log-$@
55
55
@ goimports -l $(GOIMPORTS_LOCAL_ARG ) main.go cmd/ internal/ scripts/docs/ && echo " OK"
56
56
57
57
.PHONY : clean
58
- clean : # # Clean workspace
58
+ clean : # # Clean workspace
59
59
@ $(MAKE ) --no-print-directory log-$@
60
60
rm -rf ./$(BUILD_DIR ) ./$(COVERAGE_OUT )
61
61
62
62
.PHONY : fmt
63
- fmt : # # Format all go files
63
+ fmt : # # Format all go files
64
64
@ $(MAKE ) --no-print-directory log-$@
65
65
goimports -w $(GOIMPORTS_LOCAL_ARG ) main.go cmd/ internal/ scripts/docs/
66
66
67
67
.PHONY : lint
68
- lint : # # Run linter
68
+ lint : # # Run linter
69
69
@ $(MAKE ) --no-print-directory log-$@
70
70
golangci-lint run ./...
71
71
72
72
.PHONY : staticcheck
73
- staticcheck : # # Run staticcheck
73
+ staticcheck : # # Run staticcheck
74
74
@ $(MAKE ) --no-print-directory log-$@
75
75
$(GO ) run honnef.co/go/tools/cmd/staticcheck -- ./...
76
76
77
77
.PHONY : test
78
- test : # # Run tests
78
+ test : # # Run tests
79
79
@ $(MAKE ) --no-print-directory log-$@
80
80
$(GO ) test -coverprofile=$(COVERAGE_OUT ) -covermode=atomic -v ./...
81
81
82
82
.PHONY : verify
83
- verify : # # Verify 'vendor' dependencies
83
+ verify : # # Verify 'vendor' dependencies
84
84
@ $(MAKE ) --no-print-directory log-$@
85
85
$(GO ) mod verify
86
86
@@ -89,82 +89,106 @@ verify: ## Verify 'vendor' dependencies
89
89
vendor :
90
90
deps :
91
91
92
- # ##################
93
- # # Build targets ##
94
- # ##################
92
+ # ########
93
+ # #@ Build
94
+
95
95
.PHONY : build
96
96
build : clean # # Build binary for current OS/ARCH
97
97
@ $(MAKE ) --no-print-directory log-$@
98
98
$(GOBUILD ) -o ./$(BUILD_DIR ) /$(GOOS ) -$(GOARCH ) /$(PROJECT_NAME )
99
99
100
100
.PHONY : docker
101
- docker : # # Build Docker image
101
+ docker : # # Build Docker image
102
102
@ $(MAKE ) --no-print-directory log-$@
103
103
docker build --pull --tag $(DOCKER_IMAGE ) :$(DOCKER_TAG ) --file Dockerfile .
104
104
105
105
.PHONY : push
106
- push : # # Push Docker image
106
+ push : # # Push Docker image
107
107
@ $(MAKE ) --no-print-directory log-$@
108
108
docker push $(DOCKER_IMAGE ) :$(DOCKER_TAG )
109
109
110
110
.PHONY : docs
111
- docs : # # Generate document of formatter commands
111
+ docs : # # Generate document of formatter commands
112
112
@ $(MAKE ) --no-print-directory log-$@
113
113
$(GORUN ) ./scripts/docs/generate.go
114
114
115
- # ####################
116
- # # Release targets ##
117
- # ####################
115
+ # ##########
116
+ # #@ Release
117
+
118
118
PATTERN =
119
119
120
120
# if the last relase was alpha, beta or rc, 'release' target has to used with current
121
121
# cycle release. For example if latest tag is v0.8.0-rc.2 and v0.8.0 GA needs to get
122
122
# released the following should be executed: "make release version=0.8.0"
123
123
.PHONY : release
124
124
release : VERSION ?= $(shell echo $(CUR_VERSION ) | sed 's/^v//' | awk -F'[ .]' '{print $(PATTERN ) }')
125
- release : # # Prepare release
125
+ release : # # Prepare release
126
126
@ $(MAKE ) --no-print-directory log-$@
127
127
@ ./scripts/release/release.sh " $( VERSION) " " $( CUR_VERSION) " " 1"
128
128
129
129
.PHONY : patch
130
130
patch : PATTERN = '\$$1\".\"\$$2\".\"\$$3+1'
131
- patch : release # # Prepare Patch release
131
+ patch : release # # Prepare Patch release
132
132
133
133
.PHONY : minor
134
134
minor : PATTERN = '\$$1\".\"\$$2+1\".0\"'
135
- minor : release # # Prepare Minor release
135
+ minor : release # # Prepare Minor release
136
136
137
137
.PHONY : major
138
138
major : PATTERN = '\$$1+1\".0.0\"'
139
- major : release # # Prepare Major release
139
+ major : release # # Prepare Major release
140
+
141
+ # ##########
142
+ # #@ Helpers
140
143
141
- # ###################
142
- # # Helper targets ##
143
- # ###################
144
144
.PHONY : goimports
145
- goimports :
145
+ goimports : # # Install goimports
146
146
ifeq (, $(shell which goimports) )
147
147
GO111MODULE=off $(GO) get -u golang.org/x/tools/cmd/goimports
148
148
endif
149
149
150
150
.PHONY : golangci
151
- golangci :
151
+ golangci : # # Install golangci
152
152
ifeq (, $(shell which golangci-lint) )
153
153
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(shell $(GO) env GOPATH)/bin $(GOLANGCI_VERSION)
154
154
endif
155
155
156
156
.PHONY : tools
157
- tools : # # Install required tools
157
+ tools : # # Install required tools
158
158
@ $(MAKE ) --no-print-directory log-$@
159
159
@ $(MAKE ) --no-print-directory goimports golangci
160
160
161
161
# #######################################################################
162
162
# # Self-Documenting Makefile Help ##
163
163
# # https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html ##
164
164
# #######################################################################
165
+
166
+ # #######
167
+ # #@ Help
168
+
165
169
.PHONY : help
166
- help :
167
- @ grep -h -E ' ^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | awk ' BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
170
+ help : # # Display this help
171
+ @awk \
172
+ -v " col=\033[36m" -v " nocol=\033[0m" \
173
+ ' \
174
+ BEGIN { \
175
+ FS = " :.*##" ; \
176
+ printf " Usage:\n make %s<target>%s\n" , col, nocol \
177
+ } \
178
+ /^[a-zA-Z_-]+:.*? # #/ { \
179
+ printf " %s%-12s%s %s\n" , col, $$ 1, nocol, $$ 2 \
180
+ } \
181
+ /^# #@/ { \
182
+ printf " \n%s%s%s\n" , nocol, substr($$ 0, 5), nocol \
183
+ } \
184
+ ' $(MAKEFILE_LIST)
168
185
169
186
log-% :
170
- @ grep -h -E ' ^$*:.*?## .*$$' $(MAKEFILE_LIST ) | awk ' BEGIN {FS = ":.*?## "}; {printf "\033[36m==> %s\033[0m\n", $$2}'
187
+ @grep -h -E ' ^$*:.*?## .*$$' $(MAKEFILE_LIST ) | \
188
+ awk \
189
+ ' BEGIN { \
190
+ FS = " :.*?## " \
191
+ }; \
192
+ { \
193
+ printf " \033[36m==> %s\033[0m\n" , $$ 2 \
194
+ }'
0 commit comments