@@ -92,6 +92,33 @@ ifeq ($(PROFILE),sso)
92
92
AUTH_MODE := sso
93
93
endif
94
94
95
+ ifndef $(GOPATH)
96
+ GOPATH:=$(shell go env GOPATH)
97
+ export GOPATH
98
+ endif
99
+
100
+ # Makefile managed tools
101
+ TOOL_MOCKERY := $(GOPATH ) /bin/mockery
102
+ TOOL_CONTROLLER_GEN := $(GOPATH ) /bin/controller-gen
103
+ TOOL_GO_TO_PROTOBUF := $(GOPATH ) /bin/go-to-protobuf
104
+ TOOL_PROTOC_GEN_GOGO := $(GOPATH ) /bin/protoc-gen-gogo
105
+ TOOL_PROTOC_GEN_GOGOFAST := $(GOPATH ) /bin/protoc-gen-gogofast
106
+ TOOL_PROTOC_GEN_GRPC_GATEWAY: = $(GOPATH ) /bin/protoc-gen-grpc-gateway
107
+ TOOL_PROTOC_GEN_SWAGGER := $(GOPATH ) /bin/protoc-gen-swagger
108
+ TOOL_OPENAPI_GEN := $(GOPATH ) /bin/openapi-gen
109
+ TOOL_SWAGGER := $(GOPATH ) /bin/swagger
110
+ TOOL_GOIMPORTS := $(GOPATH ) /bin/goimports
111
+ TOOL_GOLANGCI_LINT := $(GOPATH ) /bin/golangci-lint
112
+
113
+ # npm bin -g will do this on later npms than we have
114
+ NVM_BIN ?= $(shell npm config get prefix) /bin
115
+ TOOL_CLANG_FORMAT := /usr/local/bin/clang-format
116
+ TOOL_MDSPELL := $(NVM_BIN ) /mdspell
117
+ TOOL_MARKDOWN_LINK_CHECK := $(NVM_BIN ) /markdown-link-check
118
+ TOOL_MARKDOWNLINT := $(NVM_BIN ) /markdownlint
119
+ TOOL_MKDOCS_DIR := $(HOME ) /.venv/mkdocs
120
+ TOOL_MKDOCS := $(TOOL_MKDOCS_DIR ) /bin/mkdocs
121
+
95
122
$(info GIT_COMMIT=$(GIT_COMMIT) GIT_BRANCH=$(GIT_BRANCH) GIT_TAG=$(GIT_TAG) GIT_TREE_STATE=$(GIT_TREE_STATE) RELEASE_TAG=$(RELEASE_TAG) DEV_BRANCH=$(DEV_BRANCH) VERSION=$(VERSION))
96
123
$(info KUBECTX=$(KUBECTX) K3D=$(K3D) DOCKER_PUSH=$(DOCKER_PUSH) TARGET_PLATFORM=$(TARGET_PLATFORM))
97
124
$(info RUN_MODE=$(RUN_MODE) PROFILE=$(PROFILE) AUTH_MODE=$(AUTH_MODE) SECURE=$(SECURE) STATIC_FILES=$(STATIC_FILES) ALWAYS_OFFLOAD_NODE_STATUS=$(ALWAYS_OFFLOAD_NODE_STATUS) UPPERIO_DB_DEBUG=$(UPPERIO_DB_DEBUG) LOG_LEVEL=$(LOG_LEVEL) NAMESPACED=$(NAMESPACED))
@@ -106,11 +133,6 @@ ifneq ($(GIT_TAG),)
106
133
override LDFLAGS += -X github.com/argoproj/argo-workflows/v3.gitTag=${GIT_TAG}
107
134
endif
108
135
109
- ifndef $(GOPATH)
110
- GOPATH:=$(shell go env GOPATH)
111
- export GOPATH
112
- endif
113
-
114
136
# -- file lists
115
137
# These variables are only used as prereqs for the below targets, and we don't want to run them for other targets
116
138
# because the "go list" calls are very slow
@@ -146,7 +168,7 @@ SWAGGER_FILES := pkg/apiclient/_.primary.swagger.json \
146
168
pkg/apiclient/workflow/workflow.swagger.json \
147
169
pkg/apiclient/workflowarchive/workflow-archive.swagger.json \
148
170
pkg/apiclient/workflowtemplate/workflow-template.swagger.json
149
- PROTO_BINARIES := $(GOPATH ) /bin/protoc-gen-gogo $(GOPATH ) /bin/protoc-gen-gogofast $(GOPATH ) /bin/goimports $(GOPATH ) /bin/protoc-gen-grpc-gateway $(GOPATH ) /bin/protoc-gen-swagger /usr/local/bin/clang-format
171
+ PROTO_BINARIES := $(TOOL_PROTOC_GEN_GOGO ) $(TOOL_PROTOC_GEN_GOGOFAST ) $(TOOL_GOIMPORTS ) $(TOOL_PROTOC_GEN_GRPC_GATEWAY ) $(TOOL_PROTOC_GEN_SWAGGER ) $( TOOL_CLANG_FORMAT )
150
172
151
173
# protoc,my.proto
152
174
define protoc
@@ -260,7 +282,7 @@ argoexec-image:
260
282
if [ $( DOCKER_PUSH) = true ] && [ $( IMAGE_NAMESPACE) != argoproj ] ; then docker push $( IMAGE_NAMESPACE) /$* :$( VERSION) ; fi
261
283
262
284
.PHONY : codegen
263
- codegen : types swagger manifests $(GOPATH ) /bin/mockery docs/fields.md docs/cli/argo.md
285
+ codegen : types swagger manifests $(TOOL_MOCKERY ) docs/fields.md docs/cli/argo.md
264
286
go generate ./...
265
287
make --directory sdks/java USE_NIX=$(USE_NIX ) generate
266
288
make --directory sdks/python USE_NIX=$(USE_NIX ) generate
@@ -292,17 +314,17 @@ swagger: \
292
314
api/jsonschema/schema.json
293
315
294
316
295
- $(GOPATH ) /bin/mockery : Makefile
317
+ $(TOOL_MOCKERY ) : Makefile
296
318
# update this in Nix when upgrading it here
297
319
ifneq ($(USE_NIX ) , true)
298
320
go install github.com/vektra/mockery/
[email protected]
299
321
endif
300
- $(GOPATH ) /bin/controller-gen : Makefile
322
+ $(TOOL_CONTROLLER_GEN ) : Makefile
301
323
# update this in Nix when upgrading it here
302
324
ifneq ($(USE_NIX ) , true)
303
325
go install sigs.k8s.io/controller-tools/cmd/
[email protected]
304
326
endif
305
- $(GOPATH ) /bin/go-to-protobuf : Makefile
327
+ $(TOOL_GO_TO_PROTOBUF ) : Makefile
306
328
# update this in Nix when upgrading it here
307
329
ifneq ($(USE_NIX ) , true)
308
330
# TODO: currently fails on v0.30.3 with
@@ -314,43 +336,43 @@ $(GOPATH)/src/github.com/gogo/protobuf: Makefile
314
336
ifneq ($(USE_NIX ) , true)
315
337
[ -e $@ ] || git clone --depth 1 https://github.com/gogo/protobuf.git -b v1.3.2 $@
316
338
endif
317
- $(GOPATH ) /bin/protoc-gen-gogo : Makefile
339
+ $(TOOL_PROTOC_GEN_GOGO ) : Makefile
318
340
# update this in Nix when upgrading it here
319
341
ifneq ($(USE_NIX ) , true)
320
342
go install github.com/gogo/protobuf/
[email protected]
321
343
endif
322
- $(GOPATH ) /bin/protoc-gen-gogofast : Makefile
344
+ $(TOOL_PROTOC_GEN_GOGOFAST ) : Makefile
323
345
# update this in Nix when upgrading it here
324
346
ifneq ($(USE_NIX ) , true)
325
347
go install github.com/gogo/protobuf/
[email protected]
326
348
endif
327
- $(GOPATH ) /bin/protoc-gen-grpc-gateway : Makefile
349
+ $(TOOL_PROTOC_GEN_GRPC_GATEWAY ) : Makefile
328
350
# update this in Nix when upgrading it here
329
351
ifneq ($(USE_NIX ) , true)
330
352
go install github.com/grpc-ecosystem/grpc-gateway/
[email protected]
331
353
endif
332
- $(GOPATH ) /bin/protoc-gen-swagger : Makefile
354
+ $(TOOL_PROTOC_GEN_SWAGGER ) : Makefile
333
355
# update this in Nix when upgrading it here
334
356
ifneq ($(USE_NIX ) , true)
335
357
go install github.com/grpc-ecosystem/grpc-gateway/
[email protected]
336
358
endif
337
- $(GOPATH ) /bin/openapi-gen : Makefile
359
+ $(TOOL_OPENAPI_GEN ) : Makefile
338
360
# update this in Nix when upgrading it here
339
361
ifneq ($(USE_NIX ) , true)
340
362
go install k8s.io/kube-openapi/cmd/
[email protected]
341
363
endif
342
- $(GOPATH ) /bin/swagger : Makefile
364
+ $(TOOL_SWAGGER ) : Makefile
343
365
# update this in Nix when upgrading it here
344
366
ifneq ($(USE_NIX ) , true)
345
367
go install github.com/go-swagger/go-swagger/cmd/
[email protected]
346
368
endif
347
- $(GOPATH ) /bin/goimports : Makefile
369
+ $(TOOL_GOIMPORTS ) : Makefile
348
370
# update this in Nix when upgrading it here
349
371
ifneq ($(USE_NIX ) , true)
350
372
go install golang.org/x/tools/cmd/
[email protected]
351
373
endif
352
374
353
- /usr/local/bin/clang-format :
375
+ $( TOOL_CLANG_FORMAT ) :
354
376
ifeq (, $(shell which clang-format) )
355
377
ifeq ($(shell uname) ,Darwin)
356
378
brew install clang-format
@@ -360,13 +382,13 @@ else
360
382
endif
361
383
endif
362
384
363
- pkg/apis/workflow/v1alpha1/generated.proto : $(GOPATH ) /bin/go-to-protobuf $(PROTO_BINARIES ) $(TYPES ) $(GOPATH ) /src/github.com/gogo/protobuf
385
+ pkg/apis/workflow/v1alpha1/generated.proto : $(TOOL_GO_TO_PROTOBUF ) $(PROTO_BINARIES ) $(TYPES ) $(GOPATH ) /src/github.com/gogo/protobuf
364
386
# These files are generated on a v3/ folder by the tool. Link them to the root folder
365
387
[ -e ./v3 ] || ln -s . v3
366
388
# Format proto files. Formatting changes generated code, so we do it here, rather that at lint time.
367
389
# Why clang-format? Google uses it.
368
390
find pkg/apiclient -name ' *.proto' | xargs clang-format -i
369
- $(GOPATH ) /bin/go-to-protobuf \
391
+ $(TOOL_GO_TO_PROTOBUF ) \
370
392
--go-header-file=./hack/custom-boilerplate.go.txt \
371
393
--packages=github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1 \
372
394
--apimachinery-packages=+k8s.io/apimachinery/pkg/util/intstr,+k8s.io/apimachinery/pkg/api/resource,k8s.io/apimachinery/pkg/runtime/schema,+k8s.io/apimachinery/pkg/runtime,k8s.io/apimachinery/pkg/apis/meta/v1,k8s.io/api/core/v1,k8s.io/api/policy/v1 \
@@ -405,7 +427,7 @@ pkg/apiclient/workflowtemplate/workflow-template.swagger.json: $(PROTO_BINARIES)
405
427
$(call protoc,pkg/apiclient/workflowtemplate/workflow-template.proto)
406
428
407
429
# generate other files for other CRDs
408
- manifests/base/crds/full/argoproj.io_workflows.yaml : $(GOPATH ) /bin/controller-gen $(TYPES ) ./hack/manifests/crdgen.sh ./hack/manifests/crds.go
430
+ manifests/base/crds/full/argoproj.io_workflows.yaml : $(TOOL_CONTROLLER_GEN ) $(TYPES ) ./hack/manifests/crdgen.sh ./hack/manifests/crds.go
409
431
./hack/manifests/crdgen.sh
410
432
411
433
.PHONY : manifests
@@ -451,11 +473,11 @@ dist/manifests/%: manifests/%
451
473
manifests-validate :
452
474
kubectl apply --server-side --validate=strict --dry-run=server -f ' manifests/*.yaml'
453
475
454
- $(GOPATH ) /bin/golangci-lint : Makefile
476
+ $(TOOL_GOLANGCI_LINT ) : Makefile
455
477
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ` go env GOPATH` /bin v1.61.0
456
478
457
479
.PHONY : lint
458
- lint : ui/dist/app/index.html $(GOPATH ) /bin/golangci-lint
480
+ lint : ui/dist/app/index.html $(TOOL_GOLANGCI_LINT )
459
481
rm -Rf v3 vendor
460
482
# If you're using `woc.wf.Spec` or `woc.execWf.Status` your code probably won't work with WorkflowTemplate.
461
483
# * Change `woc.wf.Spec` to `woc.execWf.Spec`.
@@ -464,7 +486,7 @@ lint: ui/dist/app/index.html $(GOPATH)/bin/golangci-lint
464
486
# Tidy Go modules
465
487
go mod tidy
466
488
# Lint Go files
467
- $(GOPATH ) /bin/golangci-lint run --fix --verbose
489
+ $(TOOL_GOLANGCI_LINT ) run --fix --verbose
468
490
# Lint the UI
469
491
if [ -e ui/node_modules ]; then yarn --cwd ui lint ; fi
470
492
# Deduplicate Node modules
@@ -631,10 +653,10 @@ util/telemetry/attributes.go: $(TELEMETRY_BUILDER) util/telemetry/builder/values
631
653
go run ./util/telemetry/builder --attributesGo $@
632
654
633
655
# swagger
634
- pkg/apis/workflow/v1alpha1/openapi_generated.go : $(GOPATH ) /bin/openapi-gen $(TYPES )
656
+ pkg/apis/workflow/v1alpha1/openapi_generated.go : $(TOOL_OPENAPI_GEN ) $(TYPES )
635
657
# These files are generated on a v3/ folder by the tool. Link them to the root folder
636
658
[ -e ./v3 ] || ln -s . v3
637
- $(GOPATH ) /bin/openapi-gen \
659
+ $(TOOL_OPENAPI_GEN ) \
638
660
--go-header-file ./hack/custom-boilerplate.go.txt \
639
661
--input-dirs github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1 \
640
662
--output-package github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1 \
@@ -647,7 +669,7 @@ pkg/apis/workflow/v1alpha1/openapi_generated.go: $(GOPATH)/bin/openapi-gen $(TYP
647
669
648
670
# generates many other files (listers, informers, client etc).
649
671
.PRECIOUS : pkg/apis/workflow/v1alpha1/zz_generated.deepcopy.go
650
- pkg/apis/workflow/v1alpha1/zz_generated.deepcopy.go : $(GOPATH ) /bin/go-to-protobuf $(TYPES )
672
+ pkg/apis/workflow/v1alpha1/zz_generated.deepcopy.go : $(TOOL_GO_TO_PROTOBUF ) $(TYPES )
651
673
# These files are generated on a v3/ folder by the tool. Link them to the root folder
652
674
[ -e ./v3 ] || ln -s . v3
653
675
bash
$(GOPATH ) /pkg/mod/k8s.io/
[email protected] /generate-groups.sh
\
@@ -672,10 +694,10 @@ pkg/apiclient/_.secondary.swagger.json: hack/api/swagger/secondaryswaggergen.go
672
694
go run ./hack/api/swagger secondaryswaggergen
673
695
674
696
# we always ignore the conflicts, so lets automated figuring out how many there will be and just use that
675
- dist/swagger-conflicts : $(GOPATH ) /bin/swagger $(SWAGGER_FILES )
697
+ dist/swagger-conflicts : $(TOOL_SWAGGER ) $(SWAGGER_FILES )
676
698
swagger mixin $(SWAGGER_FILES ) 2>&1 | grep -c skipping > dist/swagger-conflicts || true
677
699
678
- dist/mixed.swagger.json : $(GOPATH ) /bin/swagger $(SWAGGER_FILES ) dist/swagger-conflicts
700
+ dist/mixed.swagger.json : $(TOOL_SWAGGER ) $(SWAGGER_FILES ) dist/swagger-conflicts
679
701
swagger mixin -c $(shell cat dist/swagger-conflicts) $(SWAGGER_FILES ) -o dist/mixed.swagger.json
680
702
681
703
dist/swaggifed.swagger.json : dist/mixed.swagger.json hack/api/swagger/swaggify.sh
@@ -684,11 +706,11 @@ dist/swaggifed.swagger.json: dist/mixed.swagger.json hack/api/swagger/swaggify.s
684
706
dist/kubeified.swagger.json : dist/swaggifed.swagger.json dist/kubernetes.swagger.json
685
707
go run ./hack/api/swagger kubeifyswagger dist/swaggifed.swagger.json dist/kubeified.swagger.json
686
708
687
- dist/swagger.0.json : $(GOPATH ) /bin/swagger dist/kubeified.swagger.json
688
- swagger flatten --with-flatten minimal --with-flatten remove-unused dist/kubeified.swagger.json -o dist/swagger.0.json
709
+ dist/swagger.0.json : $(TOOL_SWAGGER ) dist/kubeified.swagger.json
710
+ $( TOOL_SWAGGER ) flatten --with-flatten minimal --with-flatten remove-unused dist/kubeified.swagger.json -o dist/swagger.0.json
689
711
690
- api/openapi-spec/swagger.json : $(GOPATH ) /bin/swagger dist/swagger.0.json
691
- swagger flatten --with-flatten remove-unused dist/swagger.0.json -o api/openapi-spec/swagger.json
712
+ api/openapi-spec/swagger.json : $(TOOL_SWAGGER ) dist/swagger.0.json
713
+ $( TOOL_SWAGGER ) flatten --with-flatten remove-unused dist/swagger.0.json -o api/openapi-spec/swagger.json
692
714
693
715
api/jsonschema/schema.json : api/openapi-spec/swagger.json hack/api/jsonschema/main.go
694
716
go run ./hack/api/jsonschema
@@ -709,50 +731,51 @@ docs/cli/argo.md: $(CLI_PKG_FILES) go.sum ui/dist/app/index.html hack/docs/cli.g
709
731
710
732
# docs
711
733
712
- /usr/local/bin/mdspell : Makefile
734
+ $( TOOL_MDSPELL ) : Makefile
713
735
# update this in Nix when upgrading it here
714
736
ifneq ($(USE_NIX ) , true)
715
737
npm list -g
[email protected] > /dev/null || npm i -g
[email protected]
716
738
endif
717
739
718
740
.PHONY : docs-spellcheck
719
- docs-spellcheck : /usr/local/bin/mdspell docs/metrics.md
741
+ docs-spellcheck : $( TOOL_MDSPELL ) docs/metrics.md
720
742
# check docs for spelling mistakes
721
- mdspell --ignore-numbers --ignore-acronyms --en-us --no-suggestions --report $(shell find docs -name '* .md' -not -name upgrading.md -not -name README.md -not -name fields.md -not -name upgrading.md -not -name executor_swagger.md -not -path '* /cli/* ' -not -name tested-kubernetes-versions.md)
743
+ $( TOOL_MDSPELL ) --ignore-numbers --ignore-acronyms --en-us --no-suggestions --report $(shell find docs -name '* .md' -not -name upgrading.md -not -name README.md -not -name fields.md -not -name upgrading.md -not -name executor_swagger.md -not -path '* /cli/* ' -not -name tested-kubernetes-versions.md)
722
744
# alphabetize spelling file -- ignore first line (comment), then sort the rest case-sensitive and remove duplicates
723
745
$(shell cat .spelling | awk 'NR<2{ print $0; next } { print $0 | "LC_COLLATE=C sort" }' | uniq | tee .spelling > /dev/null)
724
746
725
- /usr/local/bin/markdown-link-check :
747
+ $( TOOL_MARKDOWN_LINK_CHECK ) : Makefile
726
748
# update this in Nix when upgrading it here
727
749
ifneq ($(USE_NIX ) , true)
728
750
npm list -g
[email protected] > /dev/null || npm i -g
[email protected]
729
751
endif
730
752
731
753
.PHONY : docs-linkcheck
732
- docs-linkcheck : /usr/local/bin/markdown-link-check
754
+ docs-linkcheck : $( TOOL_MARKDOWN_LINK_CHECK )
733
755
# check docs for broken links
734
- markdown-link-check -q -c .mlc_config.json $(shell find docs -name '* .md' -not -name fields.md -not -name executor_swagger.md)
756
+ $( TOOL_MARKDOWN_LINK_CHECK ) -q -c .mlc_config.json $(shell find docs -name '* .md' -not -name fields.md -not -name executor_swagger.md)
735
757
736
- /usr/local/bin/markdownlint :
758
+ $( TOOL_MARKDOWNLINT ) : Makefile
737
759
# update this in Nix when upgrading it here
738
760
ifneq ($(USE_NIX ) , true)
739
761
npm list -g
[email protected] > /dev/null || npm i -g
[email protected]
740
762
endif
741
763
742
764
743
765
.PHONY : docs-lint
744
- docs-lint : /usr/local/bin/markdownlint docs/metrics.md
766
+ docs-lint : $( TOOL_MARKDOWNLINT ) docs/metrics.md
745
767
# lint docs
746
- markdownlint docs --fix --ignore docs/fields.md --ignore docs/executor_swagger.md --ignore docs/cli --ignore docs/walk-through/the-structure-of-workflow-specs.md --ignore docs/tested-kubernetes-versions.md
768
+ $( TOOL_MARKDOWNLINT ) docs --fix --ignore docs/fields.md --ignore docs/executor_swagger.md --ignore docs/cli --ignore docs/walk-through/the-structure-of-workflow-specs.md --ignore docs/tested-kubernetes-versions.md
747
769
748
- /usr/local/bin/mkdocs :
770
+ $( TOOL_MKDOCS ) : docs/requirements.txt
749
771
# update this in Nix when upgrading it here
750
772
ifneq ($(USE_NIX ) , true)
751
- python -m pip install --no-cache-dir -r docs/requirements.txt
773
+ python3 -m venv $(TOOL_MKDOCS_DIR)
774
+ $(TOOL_MKDOCS_DIR)/bin/pip install --no-cache-dir -r $<
752
775
endif
753
776
754
777
.PHONY : docs
755
- docs : /usr/local/bin/mkdocs \
778
+ docs : $( TOOL_MKDOCS ) \
756
779
docs-spellcheck \
757
780
docs-lint \
758
781
# TODO: This is temporarily disabled to unblock merging PRs.
@@ -765,13 +788,13 @@ docs: /usr/local/bin/mkdocs \
765
788
ifeq ($(shell echo $(GIT_BRANCH ) | head -c 8) ,release-)
766
789
./hack/docs/tested-versions.sh > docs/tested-kubernetes-versions.md
767
790
endif
768
- TZ=UTC mkdocs build --strict
791
+ TZ=UTC $(TOOL_MKDOCS) build --strict
769
792
# tell the user the fastest way to edit docs
770
793
@echo "ℹ️ If you want to preview your docs, open site/index.html. If you want to edit them with hot-reload, run 'make docs-serve' to start mkdocs on port 8000"
771
794
772
795
.PHONY : docs-serve
773
796
docs-serve : docs
774
- mkdocs serve
797
+ $( TOOL_MKDOCS ) serve
775
798
776
799
# pre-commit checks
777
800
0 commit comments