@@ -46,7 +46,7 @@ ifdef IMAGE_NAMESPACE
4646IMAGE_PREFIX =${IMAGE_NAMESPACE}/
4747endif
4848
49- # protoc,my.proto
49+ # # protoc,my.proto
5050define protoc
5151 # protoc $(1)
5252 PATH=${DIST_DIR}:$$PATH protoc \
@@ -66,22 +66,26 @@ endef
6666.PHONY : all
6767all : controller image
6868
69- # downloads vendor files needed by tools.go (i.e. go_install)
69+ # #@ Development
7070.PHONY : go-mod-vendor
71- go-mod-vendor :
71+ go-mod-vendor : # # downloads vendor files needed by tools.go (i.e. go_install)
7272 go mod tidy
7373 go mod vendor
7474
75+ .PHONY : lint
76+ lint : go-mod-vendor # # run all linters
77+ golangci-lint run --fix
78+
7579.PHONY : install-go-tools-local
76- install-go-tools-local : go-mod-vendor
80+ install-go-tools-local : go-mod-vendor # # install all go tools
7781 ./hack/installers/install-codegen-go-tools.sh
7882
7983.PHONY : install-protoc-local
80- install-protoc-local :
84+ install-protoc-local : # # install protoc tool
8185 ./hack/installers/install-protoc.sh
8286
8387.PHONY : install-devtools-local
84- install-devtools-local :
88+ install-devtools-local : # # install dev tools
8589 ./hack/installers/install-dev-tools.sh
8690
8791# Installs all tools required to build and test locally
@@ -94,6 +98,8 @@ APIMACHINERY_PKGS=k8s.io/apimachinery/pkg/util/intstr,+k8s.io/apimachinery/pkg/a
9498.PHONY : install-toolchain
9599install-toolchain : install-go-tools-local install-protoc-local
96100
101+ # #@ Code Generation
102+
97103# generates all auto-generated code
98104.PHONY : codegen
99105codegen : go-mod-vendor gen-proto gen-k8scodegen gen-openapi gen-mocks gen-crd manifests docs
@@ -104,7 +110,7 @@ gen-proto: k8s-proto api-proto ui-proto
104110
105111# generates the .proto files affected by changes to types.go
106112.PHONY : k8s-proto
107- k8s-proto : go-mod-vendor $(TYPES )
113+ k8s-proto : go-mod-vendor $(TYPES ) # # generate kubernetes protobuf files
108114 PATH=${DIST_DIR} :$$ PATH go-to-protobuf \
109115 --go-header-file=./hack/custom-boilerplate.go.txt \
110116 --packages=github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1 \
@@ -117,44 +123,42 @@ k8s-proto: go-mod-vendor $(TYPES)
117123
118124# generates *.pb.go, *.pb.gw.go, swagger from .proto files
119125.PHONY : api-proto
120- api-proto : go-mod-vendor k8s-proto
126+ api-proto : go-mod-vendor k8s-proto # # generate api protobuf files
121127 $(call protoc,pkg/apiclient/rollout/rollout.proto)
122128
123129# generates ui related proto files
124130.PHONY : ui-proto
125- ui-proto :
131+ ui-proto : # # generate ui protobuf files
126132 yarn --cwd ui run protogen
127133
128134# generates k8s client, informer, lister, deepcopy from types.go
129135.PHONY : gen-k8scodegen
130- gen-k8scodegen : go-mod-vendor
136+ gen-k8scodegen : go-mod-vendor # # generate kubernetes codegen files
131137 ./hack/update-codegen.sh
132138
133139# generates ./manifests/crds/
134140.PHONY : gen-crd
135- gen-crd : install-go-tools-local
141+ gen-crd : install-go-tools-local # # generate crd manifests
136142 go run ./hack/gen-crd-spec/main.go
137143
138144# generates mock files from interfaces
139145.PHONY : gen-mocks
140- gen-mocks : install-go-tools-local
146+ gen-mocks : install-go-tools-local # # generate mock files
141147 ./hack/update-mocks.sh
142148
143149# generates openapi_generated.go
144150.PHONY : gen-openapi
145- gen-openapi : $(DIST_DIR ) /openapi-gen
151+ gen-openapi : $(DIST_DIR ) /openapi-gen # # generate openapi files
146152 PATH=${DIST_DIR} :$$ PATH openapi-gen \
147153 --go-header-file ${CURRENT_DIR} /hack/custom-boilerplate.go.txt \
148154 --input-dirs github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1 \
149155 --output-package github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1 \
150156 --report-filename pkg/apis/api-rules/violation_exceptions.list
151157
152- .PHONY : controller
153- controller :
154- CGO_ENABLED=0 go build -v -ldflags ' ${LDFLAGS}' -o ${DIST_DIR} /rollouts-controller ./cmd/rollouts-controller
158+ # #@ Plugins
155159
156160.PHONY : plugin
157- plugin : ui/dist
161+ plugin : ui/dist # # build plugin
158162 cp -r ui/dist/app/* server/static
159163 CGO_ENABLED=0 go build -v -ldflags ' ${LDFLAGS}' -o ${DIST_DIR} /${PLUGIN_CLI_NAME} ./cmd/kubectl-argo-rollouts
160164
@@ -163,28 +167,30 @@ ui/dist:
163167 yarn --cwd ui build
164168
165169.PHONY : plugin-linux
166- plugin-linux : ui/dist
170+ plugin-linux : ui/dist # # build plugin for linux
167171 cp -r ui/dist/app/* server/static
168172 CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -ldflags ' ${LDFLAGS}' -o ${DIST_DIR} /${PLUGIN_CLI_NAME} -linux-amd64 ./cmd/kubectl-argo-rollouts
169173 CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -v -ldflags ' ${LDFLAGS}' -o ${DIST_DIR} /${PLUGIN_CLI_NAME} -linux-arm64 ./cmd/kubectl-argo-rollouts
170174
171175.PHONY : plugin-darwin
172- plugin-darwin : ui/dist
176+ plugin-darwin : ui/dist # # build plugin for darwin
173177 cp -r ui/dist/app/* server/static
174178 CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -v -ldflags ' ${LDFLAGS}' -o ${DIST_DIR} /${PLUGIN_CLI_NAME} -darwin-amd64 ./cmd/kubectl-argo-rollouts
175179 CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -v -ldflags ' ${LDFLAGS}' -o ${DIST_DIR} /${PLUGIN_CLI_NAME} -darwin-arm64 ./cmd/kubectl-argo-rollouts
176180
177181.PHONY : plugin-windows
178- plugin-windows : ui/dist
182+ plugin-windows : ui/dist # # build plugin for windows
179183 cp -r ui/dist/app/* server/static
180184 CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -v -ldflags ' ${LDFLAGS}' -o ${DIST_DIR} /${PLUGIN_CLI_NAME} -windows-amd64 ./cmd/kubectl-argo-rollouts
181185
182- .PHONY : docs
183- docs :
184- go run ./hack/gen-docs/main.go
186+ # #@ Build
187+
188+ .PHONY : controller
189+ controller : # # build controller binary
190+ CGO_ENABLED=0 go build -v -ldflags ' ${LDFLAGS}' -o ${DIST_DIR} /rollouts-controller ./cmd/rollouts-controller
185191
186192.PHONY : builder-image
187- builder-image :
193+ builder-image : # # build builder image
188194 DOCKER_BUILDKIT=1 docker build -t $(IMAGE_PREFIX ) argo-rollouts-ci-builder:$(IMAGE_TAG ) --target builder .
189195 @if [ " $( DOCKER_PUSH) " = " true" ] ; then docker push $(IMAGE_PREFIX ) argo-rollouts:$(IMAGE_TAG ) ; fi
190196
@@ -198,95 +204,105 @@ else
198204endif
199205 @if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)argo-rollouts:$(IMAGE_TAG) ; fi
200206
207+
208+ # Build sample plugin with debug info
209+ # https://www.jetbrains.com/help/go/attach-to-running-go-processes-with-debugger.html
210+ .PHONY : build-sample-metric-plugin-debug
211+ build-sample-metric-plugin-debug : # # build sample metric plugin with debug info
212+ go build -gcflags=" all=-N -l" -o metric-plugin test/cmd/metrics-plugin-sample/main.go
213+
214+ .PHONY : build-sample-traffic-plugin-debug
215+ build-sample-traffic-plugin-debug : # # build sample traffic plugin with debug info
216+ go build -gcflags=" all=-N -l" -o traffic-plugin test/cmd/trafficrouter-plugin-sample/main.go
217+
201218.PHONY : plugin-image
202- plugin-image :
219+ plugin-image : # # build plugin image
203220 DOCKER_BUILDKIT=1 docker build --target kubectl-argo-rollouts -t $(IMAGE_PREFIX ) kubectl-argo-rollouts:$(IMAGE_TAG ) .
204221 if [ " $( DOCKER_PUSH) " = " true" ] ; then docker push $( IMAGE_PREFIX) kubectl-argo-rollouts:$( IMAGE_TAG) ; fi
205222
206- .PHONY : lint
207- lint : go-mod-vendor
208- golangci-lint run --fix
223+ # #@ Test
209224
210225.PHONY : test
211- test : test-kustomize
226+ test : test-kustomize # # run all tests
212227 @make test-unit
213228
214229.PHONY : test-kustomize
215- test-kustomize :
230+ test-kustomize : # # run kustomize tests
216231 ./test/kustomize/test.sh
217232
218233.PHONY : start-e2e
219- start-e2e :
234+ start-e2e : # # start e2e test environment
220235 go run ./cmd/rollouts-controller/main.go --instance-id ${E2E_INSTANCE_ID} --loglevel debug --kloglevel 6
221236
222237.PHONY : test-e2e
223238test-e2e : install-devtools-local
224239 ${DIST_DIR} /gotestsum --rerun-fails-report=rerunreport.txt --junitfile=junit.xml --format=testname --packages=" ./test/e2e" --rerun-fails=5 -- -timeout 60m -count 1 --tags e2e -p ${E2E_PARALLEL} -parallel ${E2E_PARALLEL} -v --short ./test/e2e ${E2E_TEST_OPTIONS}
225240
226241.PHONY : test-unit
227- test-unit : install-devtools-local
242+ test-unit : install-devtools-local # # run unit tests
228243 ${DIST_DIR} /gotestsum --junitfile=junit.xml --format=testname -- -covermode=count -coverprofile=coverage.out ` go list ./... | grep -v ./test/cmd/metrics-plugin-sample`
229244
230245
231246.PHONY : coverage
232- coverage : test
247+ coverage : test # # run coverage tests
233248 go tool cover -html=coverage.out -o coverage.html
234249 open coverage.html
235250
236251.PHONY : manifests
237- manifests :
252+ manifests : # # generate manifests e.g. CRD, RBAC etc.
238253 ./hack/update-manifests.sh
239254
240255.PHONY : clean
241- clean :
256+ clean : # # clean up build artifacts
242257 -rm -rf ${CURRENT_DIR} /dist
243258 -rm -rf ${CURRENT_DIR} /ui/dist
244259
245260.PHONY : precheckin
246261precheckin : test lint
247262
263+ # #@ Docs
264+
265+ # convenience target to run `mkdocs serve` using a docker container
266+ .PHONY : serve-docs
267+ serve-docs : docs # # serve docs locally
268+ docker run --rm -it -p 8000:8000 -v ${CURRENT_DIR} :/docs squidfunk/mkdocs-material serve -a 0.0.0.0:8000
269+
270+ .PHONY : docs
271+ docs : # # build docs
272+ go run ./hack/gen-docs/main.go
273+
274+ # #@ Release
275+
248276.PHONY : release-docs
249- release-docs : docs
277+ release-docs : docs # # build and deploy docs
250278 docker run --rm -it \
251279 -v ~ /.ssh:/root/.ssh \
252280 -v ${CURRENT_DIR} :/docs \
253281 -v ~ /.gitconfig:/root/.gitconfig \
254282 squidfunk/mkdocs-material gh-deploy -r ${GIT_REMOTE_REPO}
255283
256- # convenience target to run `mkdocs serve` using a docker container
257- .PHONY : serve-docs
258- serve-docs : docs
259- docker run --rm -it -p 8000:8000 -v ${CURRENT_DIR} :/docs squidfunk/mkdocs-material serve -a 0.0.0.0:8000
260-
261284.PHONY : release-precheck
262- release-precheck : manifests
285+ release-precheck : manifests # # precheck release
263286 @if [ " $( GIT_TREE_STATE) " != " clean" ]; then echo ' git tree state is $(GIT_TREE_STATE)' ; exit 1; fi
264287 @if [ -z " $( GIT_TAG) " ]; then echo ' commit must be tagged to perform release' ; exit 1; fi
265288 @if [ " $( GIT_TAG) " != " v` cat VERSION` " ]; then echo ' VERSION does not match git tag' ; exit 1; fi
266289
267290.PHONY : release-plugins
268- release-plugins :
291+ release-plugins : # # build and push plugins
269292 ./hack/build-release-plugins.sh
270293
271294.PHONY : release
272295release : release-precheck precheckin image plugin-image release-plugins
273296
274297.PHONY : trivy
275- trivy :
298+ trivy : # # run trivy scan
276299 @trivy fs --clear-cache
277300 @trivy fs .
278301
279302.PHONY : checksums
280303checksums :
281304 shasum -a 256 ./dist/kubectl-argo-rollouts-* | awk -F ' ./dist/' ' {print $$1 $$2}' > ./dist/argo-rollouts-checksums.txt
282305
283- # Build sample plugin with debug info
284- # https://www.jetbrains.com/help/go/attach-to-running-go-processes-with-debugger.html
285- .PHONY : build-sample-metric-plugin-debug
286- build-sample-metric-plugin-debug :
287- go build -gcflags=" all=-N -l" -o metric-plugin test/cmd/metrics-plugin-sample/main.go
288-
289- .PHONY : build-sample-traffic-plugin-debug
290- build-sample-traffic-plugin-debug :
291- go build -gcflags=" all=-N -l" -o traffic-plugin test/cmd/trafficrouter-plugin-sample/main.go
292306
307+ help : # # Display this help.
308+ @awk ' BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST )
0 commit comments