forked from argoproj/argo-workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
1136 lines (978 loc) · 48.7 KB
/
Copy pathMakefile
File metadata and controls
1136 lines (978 loc) · 48.7 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
export SHELL:=bash
export SHELLOPTS:=$(if $(SHELLOPTS),$(SHELLOPTS):)pipefail:errexit
# k8s v0.35 moved ProtoMessage() behind a build tag. We need it unconditionally
# for gogo protobuf + grpc-gateway v1 compatibility (gRPC codec requires proto.Message).
export GOFLAGS += -tags=kubernetes_protomessage_one_more_release
.PHONY: help
help: ## Showcase the help instructions for all documented `make` commands (not an exhaustive list)
@echo "Find more help on how to contribute at docs/contributing.md and running locally at docs/running-locally.md"
@echo ""
@echo "Documented make targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
# NOTE: Please ensure dependencies are synced with the flake.nix file in dev/nix/flake.nix before upgrading
# any external dependency. There is documentation on how to do this under the Developer Guide
USE_NIX ?= false
ifeq ($(USE_NIX), true)
GOPATH ?= .go
endif
ifndef GOPATH
GOPATH := $(shell go env GOPATH)
export GOPATH
endif
# https://stackoverflow.com/questions/4122831/disable-make-builtin-rules-and-variables-from-inside-the-make-file
MAKEFLAGS += --no-builtin-rules
.SUFFIXES:
# -- build metadata
BUILD_DATE := $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
# below 3 are copied verbatim to release.yaml
GIT_COMMIT := $(shell git rev-parse HEAD || echo unknown)
GIT_TAG := $(shell git describe --exact-match --tags --abbrev=0 2> /dev/null || echo untagged)
GIT_TREE_STATE := $(shell if [ -z "`git status --porcelain`" ]; then echo "clean" ; else echo "dirty"; fi)
GIT_REMOTE := origin
GIT_BRANCH := $(shell git rev-parse --symbolic-full-name --verify --quiet --abbrev-ref HEAD)
RELEASE_TAG := $(shell if [[ "$(GIT_TAG)" =~ ^v[0-9]+\.[0-9]+\.[0-9]+.*$$ ]]; then echo "true"; else echo "false"; fi)
DEV_BRANCH := $(shell [ "$(GIT_BRANCH)" = main ] || [ `echo $(GIT_BRANCH) | cut -c -8` = release- ] || [ `echo $(GIT_BRANCH) | cut -c -4` = dev- ] || [ $(RELEASE_TAG) = true ] && echo false || echo true)
ifneq ($(USE_NIX), true)
SRC := $(GOPATH)/src/github.com/argoproj/argo-workflows
endif
VERSION := latest
# VERSION is the version to be used for files in manifests and should always be latest unless we are releasing
# we assume HEAD means you are on a tag
ifeq ($(RELEASE_TAG),true)
VERSION := $(GIT_TAG)
endif
# -- docker image publishing options
IMAGE_NAMESPACE ?= quay.io/argoproj
DOCKER_PUSH ?= false
TARGET_PLATFORM ?= linux/$(shell go env GOARCH)
K3D_CLUSTER_NAME ?= k3s-default # declares which cluster to import to in case it's not the default name
# -- dev container options
DEVCONTAINER_PUSH ?= false
# Extract image name from devcontainer.json
DEVCONTAINER_IMAGE ?= $(shell sed --quiet 's/^ *"image": "\([^"]*\)",/\1/p' .devcontainer/devcontainer.json)
ifeq ($(DEVCONTAINER_PUSH),true)
# Export both image and cache to the registry using zstd, since that produces much smaller images than gzip.
# Docs: https://docs.docker.com/build/exporters/image-registry/ and https://docs.docker.com/build/cache/backends/registry/
DEVCONTAINER_EXPORTER_COMMON_FLAGS ?= type=registry,compression=zstd,force-compression=true,oci-mediatypes=true
DEVCONTAINER_FLAGS ?= --output $(DEVCONTAINER_EXPORTER_COMMON_FLAGS) \
--cache-to $(DEVCONTAINER_EXPORTER_COMMON_FLAGS),ref=$(DEVCONTAINER_IMAGE):cache,mode=max
else
DEVCONTAINER_FLAGS ?= --output type=cacheonly
endif
# -- test options
E2E_WAIT_TIMEOUT ?= 90s # timeout for wait conditions
E2E_PARALLEL ?= 20
E2E_SUITE_TIMEOUT ?= 30m
TEST_RETRIES ?= 2
JSON_TEST_OUTPUT := test/reports/json
# gotest function: gotest(packages, name, parameters)
# packages: passed to gotestsum via --packages parameter
# name: not used currently
# parameters: passed to go test after the --
$(JSON_TEST_OUTPUT):
mkdir -p $(JSON_TEST_OUTPUT)
define gotest
$(TOOL_GOTESTSUM) --rerun-fails-run-root-test --rerun-fails=$(TEST_RETRIES) --jsonfile=$(JSON_TEST_OUTPUT)/$(2).json --format=testname --packages $(1) -- $(3)
endef
ALL_BUILD_TAGS ?= api,cli,cron,executor,examples,corefunctional,functional,plugins
BENCHMARK_COUNT ?= 6
# should we build the static files?
ifneq (,$(filter $(MAKECMDGOALS),codegen lint test docs start))
STATIC_FILES := false
else
STATIC_FILES ?= $(shell [ $(DEV_BRANCH) = true ] && echo false || echo true)
endif
# -- install & run options
PROFILE ?= minimal
KUBE_NAMESPACE ?= argo # namespace where Kubernetes resources/RBAC will be installed
PLUGINS ?= $(shell [ $(PROFILE) = plugins ] && echo true || echo false)
INITLESS ?= false # enable opt-in init-less pod layout (requires K8s image volumes — Beta in 1.33 behind a feature gate, GA in 1.36)
ifeq ($(INITLESS),true)
INSTALL_PROFILE := $(PROFILE)-initless
else
INSTALL_PROFILE := $(PROFILE)
endif
UI_SECURE ?= false # start the UI with HTTPS
API ?= true# deploy the Argo Server (API=false skips it)
# -- SSO options
# Need to rewrite the SSO redirect URL referenced in ConfigMaps when UI_SECURE and/or BASE_HREF is set.
# Can't use "kustomize" or "kubectl patch" because the SSO config is a YAML string in those ConfigMaps.
SSO_REDIRECT_URL := http
SSO_ISSUER_URL := http://dex:5556/dex
ifeq ($(UI_SECURE),true)
SSO_REDIRECT_URL := https
SSO_ISSUER_URL := https://dex:5554/dex
endif
ifeq ($(BASE_HREF),)
BASE_HREF := /
else
# Ensure base URL has a single trailing/leading slash to match the logic in getIndexData() in server/static/static.go
override BASE_HREF := /$(BASE_HREF:/%=%)
override BASE_HREF := $(BASE_HREF:%/=%)/
endif
SSO_REDIRECT_URL := $(SSO_REDIRECT_URL)://localhost:8080$(BASE_HREF)oauth2/callback
KUBECTX := $(shell [[ "`which kubectl`" != '' ]] && kubectl config current-context || echo none)
K3D := $(shell [[ "$(KUBECTX)" == "k3d-"* ]] && echo true || echo false)
# -- controller + server + executor env vars
LOG_LEVEL := debug
UPPERIO_DB_DEBUG := 0
DEFAULT_REQUEUE_TIME ?= 1s # by keeping this short we speed up tests
ALWAYS_OFFLOAD_NODE_STATUS := false
POD_STATUS_CAPTURE_FINALIZER ?= true
DEBUG ?= # run components under Delve, e.g. DEBUG=controller,server
NAMESPACED := true
MANAGED_NAMESPACE ?= $(KUBE_NAMESPACE)
SECURE ?= false# whether or not to start Argo in TLS mode
AUTH_MODE := hybrid
ifeq ($(PROFILE),sso)
AUTH_MODE := sso
endif
# Makefile managed tools
ifeq ($(USE_NIX), true)
TOOL_MOCKERY := mockery
TOOL_CONTROLLER_GEN := controller-gen
TOOL_GO_TO_PROTOBUF := go-to-protobuf
TOOL_PROTOC_GEN_GOGO := protoc-gen-gogo
TOOL_PROTOC_GEN_GOGOFAST := protoc-gen-gogofast
TOOL_PROTOC_GEN_GRPC_GATEWAY:= protoc-gen-grpc-gateway
TOOL_PROTOC_GEN_SWAGGER := protoc-gen-swagger
TOOL_OPENAPI_GEN := openapi-gen
TOOL_SWAGGER := swagger
TOOL_GOIMPORTS := goimports
TOOL_GOLANGCI_LINT := golangci-lint
TOOL_GOTESTSUM := gotestsum
TOOL_BUF := buf
else
TOOL_MOCKERY := $(GOPATH)/bin/mockery
TOOL_CONTROLLER_GEN := $(GOPATH)/bin/controller-gen
TOOL_GO_TO_PROTOBUF := $(GOPATH)/bin/go-to-protobuf
TOOL_PROTOC_GEN_GOGO := $(GOPATH)/bin/protoc-gen-gogo
TOOL_PROTOC_GEN_GOGOFAST := $(GOPATH)/bin/protoc-gen-gogofast
TOOL_PROTOC_GEN_GRPC_GATEWAY:= $(GOPATH)/bin/protoc-gen-grpc-gateway
TOOL_PROTOC_GEN_SWAGGER := $(GOPATH)/bin/protoc-gen-swagger
TOOL_OPENAPI_GEN := $(GOPATH)/bin/openapi-gen
TOOL_SWAGGER := $(GOPATH)/bin/swagger
TOOL_GOIMPORTS := $(GOPATH)/bin/goimports
TOOL_GOLANGCI_LINT := $(GOPATH)/bin/golangci-lint
TOOL_GOTESTSUM := $(GOPATH)/bin/gotestsum
TOOL_BUF := $(GOPATH)/bin/buf
endif
# Extract custom build tags for linting (excluding platform-specific ones)
GO_BUILD_TAGS := $(shell grep -rh '//go:build' --include='*.go' --exclude-dir=vendor --exclude-dir=".??*" . 2>/dev/null | grep -v vendor | sed 's|.*//go:build ||' | tr '&|!() ' '\n' | grep -v '^$$' | grep -vE '^(windows|darwin|linux|ignore_autogenerated)$$' | sort -u | tr '\n' ',' | sed 's/,$$//')
TOOL_EMBEDDOC := hack/embeddoc/embeddoc
# npm bin -g will do this on later npms than we have
NVM_BIN ?= $(shell npm config get prefix)/bin
ifeq ($(USE_NIX), true)
TOOL_CLANG_FORMAT := clang-format
TOOL_TYPOS := typos
TOOL_CSPELL := cspell
TOOL_MARKDOWN_LINK_CHECK := markdown-link-check
TOOL_MARKDOWNLINT := markdownlint
TOOL_DEVCONTAINER := devcontainer
TOOL_PROPERDOCS := properdocs
else
TOOL_CLANG_FORMAT := /usr/local/bin/clang-format
TOOL_TYPOS := $(GOPATH)/bin/typos
TOOL_CSPELL := $(NVM_BIN)/cspell
TOOL_MARKDOWN_LINK_CHECK := $(NVM_BIN)/markdown-link-check
TOOL_MARKDOWNLINT := $(NVM_BIN)/markdownlint
TOOL_DEVCONTAINER := $(NVM_BIN)/devcontainer
TOOL_PROPERDOCS_DIR := $(HOME)/.venv/properdocs
TOOL_PROPERDOCS := $(TOOL_PROPERDOCS_DIR)/bin/properdocs
endif
# Spell-check tool versions. Sourced from nixpkgs under USE_NIX; pinned here for
# the npm/binary installs below. Keep aligned with dev/nix when bumping.
CSPELL_VERSION := 9.7.0
TYPOS_VERSION := 1.47.0
# Map `uname` output to the target triple used by typos' release tarballs.
TYPOS_UNAME_ARCH := $(shell uname -m)
ifeq ($(TYPOS_UNAME_ARCH),arm64)
TYPOS_ARCH := aarch64
else
TYPOS_ARCH := $(TYPOS_UNAME_ARCH)
endif
ifeq ($(shell uname -s),Darwin)
TYPOS_TARGET := $(TYPOS_ARCH)-apple-darwin
else
TYPOS_TARGET := $(TYPOS_ARCH)-unknown-linux-musl
endif
.PHONY: print-variables
print-variables: ## Print Makefile variables
@echo 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)
@echo KUBECTX=$(KUBECTX) K3D=$(K3D) DOCKER_PUSH=$(DOCKER_PUSH) TARGET_PLATFORM=$(TARGET_PLATFORM)
@echo 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) BASE_HREF=$(BASE_HREF) GOPATH=$(GOPATH)
ifneq ($(USE_NIX), true)
proto_vendor: $(TOOL_BUF)
endif
proto_vendor: argo-proto.yaml
GOFLAGS="$(GOFLAGS) -mod=mod" go run hack/proto-export/*.go --out proto_vendor
touch proto_vendor
.PHONY: proto-vendor
proto-vendor: proto_vendor
override LDFLAGS += \
-X github.com/argoproj/argo-workflows/v4.version=$(VERSION) \
-X github.com/argoproj/argo-workflows/v4.buildDate=$(BUILD_DATE) \
-X github.com/argoproj/argo-workflows/v4.gitCommit=$(GIT_COMMIT) \
-X github.com/argoproj/argo-workflows/v4.gitTreeState=$(GIT_TREE_STATE)
ifneq ($(GIT_TAG),)
override LDFLAGS += -X github.com/argoproj/argo-workflows/v4.gitTag=${GIT_TAG}
endif
# -- file lists
# These variables are only used as prereqs for the below targets, and we don't want to run them for other targets
# because the "go list" calls are very slow
ifneq (,$(filter dist/argoexec dist/workflow-controller dist/argo dist/argo-% docs/cli/argo.md,$(MAKECMDGOALS)))
HACK_PKG_FILES_AS_PKGS ?= false
ifeq ($(HACK_PKG_FILES_AS_PKGS),false)
ARGOEXEC_PKG_FILES := $(shell go list -f '{{ join .Deps "\n" }}' ./cmd/argoexec/ | grep 'argoproj/argo-workflows/v4/' | xargs go list -f '{{ range $$file := .GoFiles }}{{ print $$.ImportPath "/" $$file "\n" }}{{ end }}' | cut -c 39-)
CLI_PKG_FILES := $(shell [ -f ui/dist/app/index.html ] || (mkdir -p ui/dist/app && touch ui/dist/app/placeholder); go list -f '{{ join .Deps "\n" }}' ./cmd/argo/ | grep 'argoproj/argo-workflows/v4/' | xargs go list -f '{{ range $$file := .GoFiles }}{{ print $$.ImportPath "/" $$file "\n" }}{{ end }}' | cut -c 39-)
CONTROLLER_PKG_FILES := $(shell go list -f '{{ join .Deps "\n" }}' ./cmd/workflow-controller/ | grep 'argoproj/argo-workflows/v4/' | xargs go list -f '{{ range $$file := .GoFiles }}{{ print $$.ImportPath "/" $$file "\n" }}{{ end }}' | cut -c 39-)
else
# Building argoexec on windows cannot rebuild the openapi, we need to fall back to the old
# behaviour where we fake dependencies and therefore don't rebuild
ARGOEXEC_PKG_FILES := $(shell echo cmd/argoexec && go list -f '{{ join .Deps "\n" }}' ./cmd/argoexec/ | grep 'argoproj/argo-workflows/v4/' | cut -c 39-)
CLI_PKG_FILES := $(shell echo cmd/argo && go list -f '{{ join .Deps "\n" }}' ./cmd/argo/ | grep 'argoproj/argo-workflows/v4/' | cut -c 39-)
CONTROLLER_PKG_FILES := $(shell echo cmd/workflow-controller && go list -f '{{ join .Deps "\n" }}' ./cmd/workflow-controller/ | grep 'argoproj/argo-workflows/v4/' | cut -c 39-)
endif
else
ARGOEXEC_PKG_FILES :=
CLI_PKG_FILES :=
CONTROLLER_PKG_FILES :=
endif
TYPES := $(shell find pkg/apis/workflow/v1alpha1 -type f -name '*.go' -not -name openapi_generated.go -not -name '*generated*' -not -name '*test.go')
CRDS := $(shell find manifests/base/crds -type f -name 'argoproj.io_*.yaml')
SWAGGER_FILES := pkg/apiclient/_.primary.swagger.json \
pkg/apiclient/_.secondary.swagger.json \
pkg/apiclient/clusterworkflowtemplate/cluster-workflow-template.swagger.json \
pkg/apiclient/cronworkflow/cron-workflow.swagger.json \
pkg/apiclient/event/event.swagger.json \
pkg/apiclient/eventsource/eventsource.swagger.json \
pkg/apiclient/info/info.swagger.json \
pkg/apiclient/sensor/sensor.swagger.json \
pkg/apiclient/workflow/workflow.swagger.json \
pkg/apiclient/workflowarchive/workflow-archive.swagger.json \
pkg/apiclient/workflowtemplate/workflow-template.swagger.json \
pkg/apiclient/sync/sync.swagger.json
PROTO_BINARIES := $(TOOL_PROTOC_GEN_GOGO) $(TOOL_PROTOC_GEN_GOGOFAST) $(TOOL_GOIMPORTS) $(TOOL_PROTOC_GEN_GRPC_GATEWAY) $(TOOL_PROTOC_GEN_SWAGGER) $(TOOL_CLANG_FORMAT)
ifneq ($(USE_NIX), true)
pkg/apiclient/%.swagger.json: $(PROTO_BINARIES)
endif
QUICK_GENERATED_DOCS := docs/metrics.md docs/tracing.md docs/database-migrations.md docs/variable-flow/variables.md
GENERATED_DOCS := $(QUICK_GENERATED_DOCS) docs/fields.md docs/cli/argo.md docs/workflow-controller-configmap.md docs/go-sdk-guide.md
# `go mod vendor` rewrites vendor/modules.txt on every run
# so depend on vendor/modules.txt in places where we want it up to date
vendor/modules.txt: go.mod go.sum
go mod vendor
@touch $@
# Targets generated via $(call protoc) need a fresh vendor tree.
# _.primary/_.secondary.swagger.json are not built via protoc, so are excluded.
$(filter-out pkg/apiclient/_.%,$(SWAGGER_FILES)) pkg/apiclient/artifact/artifact.swagger.json: vendor/modules.txt
# protoc,my.proto
define protoc
# protoc $(1)
[ -e ./proto_vendor ] || $(MAKE) proto-vendor
mkdir -p $(GOPATH)/src github.com/argoproj
[ -e github.com/argoproj/argo-workflows ] || ln -s ../.. github.com/argoproj/argo-workflows
[ -e v4 ] || ln -s . v4
protoc \
-I /usr/local/include \
-I $(CURDIR) \
-I $(CURDIR)/proto_vendor \
--gogofast_out=plugins=grpc:$(GOPATH)/src \
--grpc-gateway_out=logtostderr=true:$(GOPATH)/src \
--swagger_out=logtostderr=true,fqn_for_swagger_name=true:. \
$(1)
perl -i -pe 's|argoproj/argo-workflows/(?!v4/)|argoproj/argo-workflows/v4/|g' `echo "$(1)" | sed 's/proto/pb.go/g'`
rm -rf github.com v4
endef
# cli
.PHONY: cli
cli: dist/argo ## Build the CLI
ui/dist/app/index.html: $(shell find ui/src -type f && find ui -maxdepth 1 -type f)
ifeq ($(STATIC_FILES),true)
# `yarn install` is fast (~2s), so you can call it safely.
JOBS=max yarn --cwd ui install
# `yarn build` is slow, so we guard it with a up-to-date check.
JOBS=max yarn --cwd ui build
else
@mkdir -p ui/dist/app
touch ui/dist/app/index.html
endif
dist/argo-linux-amd64: GOARGS = GOOS=linux GOARCH=amd64
dist/argo-linux-arm64: GOARGS = GOOS=linux GOARCH=arm64
dist/argo-linux-ppc64le: GOARGS = GOOS=linux GOARCH=ppc64le
dist/argo-linux-riscv64: GOARGS = GOOS=linux GOARCH=riscv64
dist/argo-linux-s390x: GOARGS = GOOS=linux GOARCH=s390x
dist/argo-darwin-amd64: GOARGS = GOOS=darwin GOARCH=amd64
dist/argo-darwin-arm64: GOARGS = GOOS=darwin GOARCH=arm64
dist/argo-windows-amd64: GOARGS = GOOS=windows GOARCH=amd64
dist/argo-windows-%.gz: dist/argo-windows-%
gzip --force --keep dist/argo-windows-$*.exe
dist/argo-windows-%: ui/dist/app/index.html $(CLI_PKG_FILES) vendor/modules.txt
CGO_ENABLED=0 $(GOARGS) go build -v -gcflags '${GCFLAGS}' -ldflags '${LDFLAGS} -extldflags -static' -o $@.exe ./cmd/argo
dist/argo-%.gz: dist/argo-%
gzip --force --keep dist/argo-$*
dist/argo-%: ui/dist/app/index.html $(CLI_PKG_FILES) vendor/modules.txt
CGO_ENABLED=0 $(GOARGS) go build -v -gcflags '${GCFLAGS}' -ldflags '${LDFLAGS} -extldflags -static' -o $@ ./cmd/argo
dist/argo: ui/dist/app/index.html $(CLI_PKG_FILES) vendor/modules.txt
ifeq ($(shell uname -s),Darwin)
# if local, then build fast: use CGO and dynamic-linking
go build -v -gcflags '${GCFLAGS}' -ldflags '${LDFLAGS}' -o $@ ./cmd/argo
else
CGO_ENABLED=0 go build -gcflags '${GCFLAGS}' -v -ldflags '${LDFLAGS} -extldflags -static' -o $@ ./cmd/argo
endif
argocli-image:
.PHONY: clis
clis: dist/argo-linux-amd64.gz dist/argo-linux-arm64.gz dist/argo-linux-ppc64le.gz dist/argo-linux-riscv64.gz dist/argo-linux-s390x.gz dist/argo-darwin-amd64.gz dist/argo-darwin-arm64.gz dist/argo-windows-amd64.gz
# controller
.PHONY: controller
controller: dist/workflow-controller ## Build the workflow controller
dist/workflow-controller: $(CONTROLLER_PKG_FILES) vendor/modules.txt
ifeq ($(shell uname -s),Darwin)
# if local, then build fast: use CGO and dynamic-linking
go build -gcflags '${GCFLAGS}' -v -ldflags '${LDFLAGS}' -o $@ ./cmd/workflow-controller
else
CGO_ENABLED=0 go build -gcflags '${GCFLAGS}' -v -ldflags '${LDFLAGS} -extldflags -static' -o $@ ./cmd/workflow-controller
endif
workflow-controller-image:
# argoexec
dist/argoexec: $(ARGOEXEC_PKG_FILES) vendor/modules.txt
ifeq ($(shell uname -s),Darwin)
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -gcflags '${GCFLAGS}' -v -ldflags '${LDFLAGS} -extldflags -static' -o $@ ./cmd/argoexec
else
CGO_ENABLED=0 go build -v -gcflags '${GCFLAGS}' -ldflags '${LDFLAGS} -extldflags -static' -o $@ ./cmd/argoexec
endif
argoexec-image: ## Build the executor image
argoexec-nonroot-image:
%-image:
[ ! -e dist/$* ] || mv dist/$* .
# Special handling for argoexec-nonroot to create argoexec:VERSION-nonroot instead of argoexec-nonroot:VERSION
if [ "$*" = "argoexec-nonroot" ]; then \
image_name="$(IMAGE_NAMESPACE)/argoexec:$(VERSION)-nonroot"; \
else \
image_name="$(IMAGE_NAMESPACE)/$*:$(VERSION)"; \
fi; \
docker buildx build \
--platform $(TARGET_PLATFORM) \
--build-arg GIT_COMMIT=$(GIT_COMMIT) \
--build-arg GIT_TAG=$(GIT_TAG) \
--build-arg GIT_TREE_STATE=$(GIT_TREE_STATE) \
-t $$image_name \
--target $* \
--load \
.; \
[ ! -e $* ] || mv $* dist/; \
docker run --rm -t $$image_name version; \
if [ $(K3D) = true ]; then \
k3d image import -c $(K3D_CLUSTER_NAME) $$image_name; \
fi; \
if [ $(DOCKER_PUSH) = true ] && [ $(IMAGE_NAMESPACE) != argoproj ] ; then \
docker push $$image_name; \
fi
.PHONY: codegen
ifneq ($(USE_NIX), true)
codegen: $(TOOL_MOCKERY) $(TOOL_BUF)
endif
codegen: types swagger manifests $(GENERATED_DOCS) vendor/modules.txt ## Generate code via `go generate`, as well as SDKs
go generate ./...
$(TOOL_MOCKERY) --config .mockery.yaml
make --directory sdks/java USE_NIX=$(USE_NIX) generate
.PHONY: check-pwd
check-pwd:
ifneq ($(USE_NIX), true)
ifneq ($(SRC),$(PWD))
@echo "⚠️ Code generation will not work if code in not checked out into $(SRC)" >&2
endif
endif
.PHONY: types
types: check-pwd pkg/apis/workflow/v1alpha1/generated.proto pkg/apis/workflow/v1alpha1/openapi_generated.go pkg/apis/workflow/v1alpha1/zz_generated.deepcopy.go
.PHONY: swagger
swagger: \
pkg/apiclient/clusterworkflowtemplate/cluster-workflow-template.swagger.json \
pkg/apiclient/cronworkflow/cron-workflow.swagger.json \
pkg/apiclient/event/event.swagger.json \
pkg/apiclient/eventsource/eventsource.swagger.json \
pkg/apiclient/info/info.swagger.json \
pkg/apiclient/sensor/sensor.swagger.json \
pkg/apiclient/workflow/workflow.swagger.json \
pkg/apiclient/workflowarchive/workflow-archive.swagger.json \
pkg/apiclient/workflowtemplate/workflow-template.swagger.json \
pkg/apiclient/sync/sync.swagger.json \
manifests/base/crds/full/argoproj.io_workflows.yaml \
manifests \
api/openapi-spec/swagger.json \
api/jsonschema/schema.json
$(TOOL_MOCKERY): Makefile
# update this in Nix when upgrading it here
ifneq ($(USE_NIX), true)
GOTOOLCHAIN=go1.26.1 go install github.com/vektra/mockery/v3@v3.5.1
endif
$(TOOL_CONTROLLER_GEN): Makefile
# update this in Nix when upgrading it here
ifneq ($(USE_NIX), true)
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.18.0
endif
$(TOOL_GO_TO_PROTOBUF): Makefile
# update this in Nix when upgrading it here
ifneq ($(USE_NIX), true)
go install k8s.io/code-generator/cmd/go-to-protobuf@v0.35.1
endif
$(TOOL_PROTOC_GEN_GOGO): Makefile
# update this in Nix when upgrading it here
ifneq ($(USE_NIX), true)
go install github.com/gogo/protobuf/protoc-gen-gogo@v1.3.2
endif
$(TOOL_PROTOC_GEN_GOGOFAST): Makefile
# update this in Nix when upgrading it here
ifneq ($(USE_NIX), true)
go install github.com/gogo/protobuf/protoc-gen-gogofast@v1.3.2
endif
$(TOOL_PROTOC_GEN_GRPC_GATEWAY): Makefile
# update this in Nix when upgrading it here
ifneq ($(USE_NIX), true)
go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@v1.16.0
endif
$(TOOL_PROTOC_GEN_SWAGGER): Makefile
# update this in Nix when upgrading it here
ifneq ($(USE_NIX), true)
go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@v1.16.0
endif
$(TOOL_OPENAPI_GEN): Makefile
# update this in Nix when upgrading it here
ifneq ($(USE_NIX), true)
go install k8s.io/kube-openapi/cmd/openapi-gen@v0.0.0-20220124234850-424119656bbf
endif
$(TOOL_SWAGGER): Makefile
# update this in Nix when upgrading it here
ifneq ($(USE_NIX), true)
go install github.com/go-swagger/go-swagger/cmd/swagger@v0.33.1
endif
$(TOOL_GOIMPORTS): Makefile
# update this in Nix when upgrading it here
ifneq ($(USE_NIX), true)
go install golang.org/x/tools/cmd/goimports@v0.35.0
endif
$(TOOL_GOTESTSUM): Makefile
# update this in Nix when upgrading it here
ifneq ($(USE_NIX), true)
go install gotest.tools/gotestsum@v1.12.3
endif
$(TOOL_BUF): Makefile
# update this in Nix when upgrading it here
ifneq ($(USE_NIX), true)
go install github.com/bufbuild/buf/cmd/buf@v1.65.0
endif
$(TOOL_EMBEDDOC): hack/embeddoc/main.go hack/embeddoc/go.mod
cd hack/embeddoc && go build -o embeddoc .
$(TOOL_CLANG_FORMAT):
ifeq (, $(shell which clang-format))
ifeq ($(shell uname),Darwin)
brew install clang-format
else
sudo apt update
sudo apt install -y clang-format
endif
endif
# go-to-protobuf fails with mysterious errors on code that doesn't compile
ifneq ($(USE_NIX), true)
pkg/apis/workflow/v1alpha1/generated.proto: $(TOOL_GO_TO_PROTOBUF) $(PROTO_BINARIES)
endif
pkg/apis/workflow/v1alpha1/generated.proto: $(TYPES) proto-vendor vendor/modules.txt
# These files are generated on a v4/ folder by the tool. Link them to the root folder
mkdir -p github.com/argoproj
[ -e github.com/argoproj/argo-workflows ] || ln -s ../.. github.com/argoproj/argo-workflows
[ -e v4 ] || ln -s . v4
# Format proto files. Formatting changes generated code, so we do it here, rather that at lint time.
# Why clang-format? Google uses it.
@echo "*** This will fail if your code has compilation errors, without reporting those as the cause."
@echo "*** So fix them first."
find pkg/apiclient -name '*.proto'|xargs clang-format -i
GOFLAGS="$(GOFLAGS) -mod=vendor" $(TOOL_GO_TO_PROTOBUF) \
--go-header-file=$(CURDIR)/hack/custom-boilerplate.go.txt \
--packages=github.com/argoproj/argo-workflows/v4/pkg/apis/workflow/v1alpha1 \
--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 \
--proto-import $(CURDIR) \
--proto-import $(CURDIR)/proto_vendor
# go-to-protobuf v0.35 puts ProtoMessage() methods in generated.protomessage.pb.go
# behind a build tag. Strip it so codegen tools (mockery, etc.) can compile without
# requiring the tag. Runtime builds use GOFLAGS for k8s vendor types instead.
perl -i -ne 'print unless /kubernetes_protomessage_one_more_release/' pkg/apis/workflow/v1alpha1/generated.protomessage.pb.go
# Delete the link and created k8s.io directory
rm -rf github.com v4 k8s.io
# Restore vendor if go-to-protobuf deleted files
go mod vendor
touch $@
# this target will also create a .pb.go and a .pb.gw.go file, but in Make 3 we cannot use _grouped target_, instead we must choose
# on file to represent all of them
pkg/apiclient/clusterworkflowtemplate/cluster-workflow-template.swagger.json: $(TYPES) pkg/apiclient/clusterworkflowtemplate/cluster-workflow-template.proto
$(call protoc,pkg/apiclient/clusterworkflowtemplate/cluster-workflow-template.proto)
pkg/apiclient/cronworkflow/cron-workflow.swagger.json: $(TYPES) pkg/apiclient/cronworkflow/cron-workflow.proto
$(call protoc,pkg/apiclient/cronworkflow/cron-workflow.proto)
pkg/apiclient/event/event.swagger.json: $(TYPES) pkg/apiclient/event/event.proto
$(call protoc,pkg/apiclient/event/event.proto)
pkg/apiclient/eventsource/eventsource.swagger.json: $(TYPES) pkg/apiclient/eventsource/eventsource.proto
$(call protoc,pkg/apiclient/eventsource/eventsource.proto)
pkg/apiclient/info/info.swagger.json: $(TYPES) pkg/apiclient/info/info.proto
$(call protoc,pkg/apiclient/info/info.proto)
pkg/apiclient/sensor/sensor.swagger.json: $(TYPES) pkg/apiclient/sensor/sensor.proto
$(call protoc,pkg/apiclient/sensor/sensor.proto)
pkg/apiclient/workflow/workflow.swagger.json: $(TYPES) pkg/apiclient/workflow/workflow.proto
$(call protoc,pkg/apiclient/workflow/workflow.proto)
perl -i -pe 's/return resp\.Recv\(\) \}, mux\.GetForwardResponseOptions\(\)\.\.\.\)/return wrapEventAsProtoMessage(resp.Recv()) }, mux.GetForwardResponseOptions()...)/ if /forward_WorkflowService_WatchEvents_0/' pkg/apiclient/workflow/workflow.pb.gw.go
pkg/apiclient/workflowarchive/workflow-archive.swagger.json: $(TYPES) pkg/apiclient/workflowarchive/workflow-archive.proto
$(call protoc,pkg/apiclient/workflowarchive/workflow-archive.proto)
pkg/apiclient/workflowtemplate/workflow-template.swagger.json: $(TYPES) pkg/apiclient/workflowtemplate/workflow-template.proto
$(call protoc,pkg/apiclient/workflowtemplate/workflow-template.proto)
pkg/apiclient/sync/sync.swagger.json: $(TYPES) pkg/apiclient/sync/sync.proto
$(call protoc,pkg/apiclient/sync/sync.proto)
# generate other files for other CRDs
ifneq ($(USE_NIX), true)
manifests/base/crds/full/argoproj.io_workflows.yaml: $(TOOL_CONTROLLER_GEN)
endif
manifests/base/crds/full/argoproj.io_workflows.yaml: $(TYPES) ./hack/manifests/crdgen.sh ./hack/manifests/crds.go
./hack/manifests/crdgen.sh
.PHONY: manifests
manifests: \
manifests/install.yaml \
manifests/namespace-install.yaml \
manifests/quick-start-minimal.yaml \
manifests/quick-start-mysql.yaml \
manifests/quick-start-postgres.yaml \
manifests/quick-start-telemetry.yaml \
dist/manifests/install.yaml \
dist/manifests/namespace-install.yaml \
dist/manifests/quick-start-minimal.yaml \
dist/manifests/quick-start-mysql.yaml \
dist/manifests/quick-start-postgres.yaml \
dist/manifests/quick-start-telemetry.yaml
.PHONY: manifests/install.yaml
manifests/install.yaml: /dev/null
kubectl kustomize --load-restrictor=LoadRestrictionsNone manifests/cluster-install | ./hack/manifests/auto-gen-msg.sh > manifests/install.yaml
.PHONY: manifests/namespace-install.yaml
manifests/namespace-install.yaml: /dev/null
kubectl kustomize --load-restrictor=LoadRestrictionsNone manifests/namespace-install | ./hack/manifests/auto-gen-msg.sh > manifests/namespace-install.yaml
.PHONY: manifests/quick-start-minimal.yaml
manifests/quick-start-minimal.yaml: /dev/null
kubectl kustomize --load-restrictor=LoadRestrictionsNone manifests/quick-start/minimal | ./hack/manifests/auto-gen-msg.sh > manifests/quick-start-minimal.yaml
.PHONY: manifests/quick-start-mysql.yaml
manifests/quick-start-mysql.yaml: /dev/null
kubectl kustomize --load-restrictor=LoadRestrictionsNone manifests/quick-start/mysql | ./hack/manifests/auto-gen-msg.sh > manifests/quick-start-mysql.yaml
.PHONY: manifests/quick-start-postgres.yaml
manifests/quick-start-postgres.yaml: /dev/null
kubectl kustomize --load-restrictor=LoadRestrictionsNone manifests/quick-start/postgres | ./hack/manifests/auto-gen-msg.sh > manifests/quick-start-postgres.yaml
.PHONY: manifests/quick-start-telemetry.yaml
manifests/quick-start-telemetry.yaml: /dev/null
kubectl kustomize --load-restrictor=LoadRestrictionsNone manifests/quick-start/telemetry | ./hack/manifests/auto-gen-msg.sh > manifests/quick-start-telemetry.yaml
dist/manifests/%: manifests/%
@mkdir -p dist/manifests
sed 's/:latest/:$(VERSION)/' manifests/$* > $@
# lint/test/etc
.PHONE: manifests-validate
manifests-validate:
kubectl apply --server-side --validate=strict --dry-run=server -f 'manifests/*.yaml'
$(TOOL_GOLANGCI_LINT): Makefile
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b `go env GOPATH`/bin v2.11.3
.PHONY: lint lint-go lint-ui
lint: lint-go lint-ui features-validate ## Lint the project
ifneq ($(USE_NIX), true)
# golangci-lint loads packages in implicit vendor mode, so the vendor tree must
# be fresh. Skipped under Nix, which deletes vendor/ in the recipe below.
lint-go: $(TOOL_GOLANGCI_LINT) vendor/modules.txt
endif
lint-go: ui/dist/app/index.html
ifeq ($(USE_NIX), true)
rm -Rf v3 vendor
endif
# If you're using `woc.wf.Spec` or `woc.execWf.Status` your code probably won't work with WorkflowTemplate.
# * Change `woc.wf.Spec` to `woc.execWf.Spec`.
# * Change `woc.execWf.Status` to `woc.wf.Status`.
@awk '(/woc.wf.Spec/ || /woc.execWf.Status/) && !/not-woc-misuse/ {print FILENAME ":" FNR "\t" $0 ; exit 1}' $(shell find workflow/controller -type f -name '*.go' -not -name '*test*')
# Tidy Go modules
go mod tidy
ifneq ($(USE_NIX), true)
# Re-vendor if tidy changed go.mod or go.sum, so the lint below sees a consistent tree
[ vendor/modules.txt -nt go.mod ] && [ vendor/modules.txt -nt go.sum ] || go mod vendor
endif
# Lint Go files (with auto-discovered build tags)
$(TOOL_GOLANGCI_LINT) run --fix --verbose --build-tags="$(GO_BUILD_TAGS)"
lint-ui: ui/dist/app/index.html
# Lint the UI
if [ -e ui/node_modules ]; then yarn --cwd ui lint ; fi
# Deduplicate Node modules
if [ -e ui/node_modules ]; then yarn --cwd ui deduplicate ; fi
# for local we have a faster target that prints to stdout, does not use json, and can cache because it has no coverage
.PHONY: test
ifneq ($(USE_NIX), true)
test: $(TOOL_GOTESTSUM) $(TOOL_BUF)
endif
test: ui/dist/app/index.html $(JSON_TEST_OUTPUT) ## Run tests
ifneq ($(USE_NIX), true)
go mod vendor
go build -mod=vendor ./...
else
go build ./...
endif
env KUBECONFIG=/dev/null $(call gotest,./...,unit,-p 20)
# marker file, based on it's modification time, we know how long ago this target was run
@mkdir -p dist
touch dist/test
.PHONY: install
install: githooks ## Install Argo to the current Kubernetes cluster
kubectl get ns $(KUBE_NAMESPACE) || kubectl create ns $(KUBE_NAMESPACE)
kubectl config set-context --current --namespace=$(KUBE_NAMESPACE)
@echo "installing PROFILE=$(PROFILE) INITLESS=$(INITLESS) (manifests=$(INSTALL_PROFILE))"
kubectl kustomize --load-restrictor=LoadRestrictionsNone test/e2e/manifests/$(INSTALL_PROFILE) \
| sed 's|quay.io/argoproj/|$(IMAGE_NAMESPACE)/|' \
| sed 's/namespace: argo/namespace: $(KUBE_NAMESPACE)/' \
| sed 's|http://localhost:8080/oauth2/callback|$(SSO_REDIRECT_URL)|' \
| sed 's|http://dex:5556/dex|$(SSO_ISSUER_URL)|' \
| KUBECTL_APPLYSET=true kubectl -n $(KUBE_NAMESPACE) apply --applyset=configmaps/install --server-side --prune -f -
ifeq ($(PROFILE),stress)
kubectl -n $(KUBE_NAMESPACE) apply -f test/stress/massive-workflow.yaml
endif
.PHONY: argosay
argosay:
ifeq ($(DOCKER_PUSH),true)
cd test/e2e/images/argosay/v2 && \
docker buildx build \
--platform linux/amd64,linux/arm64 \
-t argoproj/argosay:v2 \
--push \
.
else
cd test/e2e/images/argosay/v2 && \
docker build . -t argoproj/argosay:v2
endif
ifeq ($(K3D),true)
k3d image import -c $(K3D_CLUSTER_NAME) argoproj/argosay:v2
endif
.PHONY: argosayv1
argosayv1:
ifeq ($(DOCKER_PUSH),true)
cd test/e2e/images/argosay/v1 && \
docker buildx build \
--platform linux/amd64,linux/arm64 \
-t argoproj/argosay:v1 \
--push \
.
else
cd test/e2e/images/argosay/v1 && \
docker build . -t argoproj/argosay:v1
endif
dist/argosay:
mkdir -p dist
cp test/e2e/images/argosay/v2/argosay dist/
# renovate: datasource=github-releases depName=tilt-dev/tilt
TILT_VERSION ?= 0.37.3
.PHONY: tilt
tilt: ## Install the pinned Tilt to $(GOPATH)/bin if not already present
@if tilt version 2>/dev/null | grep -q "v$(TILT_VERSION)," ; then \
echo "tilt v$(TILT_VERSION) already installed" ; \
else \
os=$$(uname -s | tr 'A-Z' 'a-z') ; [ "$$os" = darwin ] && os=mac ; \
arch=$$(uname -m) ; [ "$$arch" = aarch64 ] && arch=arm64 ; \
dir=$$(go env GOPATH)/bin ; mkdir -p "$$dir" ; \
echo "installing tilt v$(TILT_VERSION) to $$dir" ; \
: "tilt can't be go installed (its go.mod has replace directives), so it" ; \
: "comes from GitHub's release CDN. CI builds it once (the e2e-tools job)" ; \
: "and shares it across the matrix, rather than fetching it in 14 parallel" ; \
: "jobs (which throttles the CDN) — so no download retries are needed." ; \
: "Download to a temp file so a truncated download fails tar cleanly." ; \
tmp=$$(mktemp) ; \
curl -fsSL "https://github.com/tilt-dev/tilt/releases/download/v$(TILT_VERSION)/tilt.$(TILT_VERSION).$$os.$$arch.tar.gz" -o "$$tmp" \
&& tar -xzf "$$tmp" -C "$$dir" tilt && rm -f "$$tmp" ; \
fi
.PHONY: k3d
k3d: ## Install the pinned k3d to $(GOPATH)/bin if not already present
@. hack/k8s-versions.sh && if k3d version 2>/dev/null | grep -q "k3d version v$${K3D_VERSION}" ; then \
echo "k3d v$${K3D_VERSION} already installed" ; \
else \
echo "installing k3d v$${K3D_VERSION}" ; \
: "go install pulls from the module proxy (proxy.golang.org), which is" ; \
: "far more reliable under CI load than GitHub's release-asset CDN. The" ; \
: "ldflags stamp the version k3d reports and uses to tag its helper image" ; \
go install -ldflags "-X github.com/k3d-io/k3d/v5/version.Version=v$${K3D_VERSION}" \
github.com/k3d-io/k3d/v5@v$${K3D_VERSION} ; \
fi
.PHONY: k3d-up
k3d-up: ## Create the k3d cluster used by Tilt
K3D_CLUSTER_NAME=$(K3D_CLUSTER_NAME) ./hack/tilt/k3d-up.sh
.PHONY: k3d-down
k3d-down: ## Delete the k3d cluster used by Tilt
K3D_CLUSTER_NAME=$(K3D_CLUSTER_NAME) ./hack/tilt/k3d-down.sh
.PHONY: start
start: tilt k3d-up ## Start the dev stack in-cluster via Tilt
# --host=0.0.0.0 binds the Tilt web UI to all interfaces so it is reachable
# via the container IP in a devcontainer (the devcontainer CLI doesn't
# forward ports). The argo server/UI/metrics forwards bind 0.0.0.0 too.
tilt up --host=0.0.0.0 -- --profile=$(PROFILE) --auth-mode=$(AUTH_MODE) \
--secure=$(SECURE) --api=$(API) --initless=$(INITLESS) \
--pod-status-capture-finalizer=$(POD_STATUS_CAPTURE_FINALIZER) \
$(if $(DEBUG),--debug=$(DEBUG))
.PHONY: postgres-cli
postgres-cli:
kubectl exec -ti svc/postgres -- psql -U postgres
.PHONY: postgres-dump
postgres-dump:
@mkdir -p db-dumps
kubectl exec svc/postgres -- pg_dump --clean -U postgres > "db-dumps/postgres-$(BUILD_DATE).sql"
.PHONY: mysql-cli
mysql-cli:
kubectl exec -ti svc/mysql -- mysql -u mysql -ppassword argo
.PHONY: mysql-dump
mysql-dump:
@mkdir -p db-dumps
kubectl exec svc/mysql -- mysqldump --no-tablespaces -u mysql -ppassword argo > "db-dumps/mysql-$(BUILD_DATE).sql"
test-cli: ./dist/argo
test-%: $(TOOL_GOTESTSUM) $(JSON_TEST_OUTPUT) vendor/modules.txt
E2E_WAIT_TIMEOUT=$(E2E_WAIT_TIMEOUT) E2E_INITLESS=$(INITLESS) $(call gotest,./test/e2e,$@,-timeout $(E2E_SUITE_TIMEOUT) --tags $*)
.PHONY: test-%-sdk
test-%-sdk:
make --directory sdks/$* install test -B
Test%: $(TOOL_GOTESTSUM) $(JSON_TEST_OUTPUT) vendor/modules.txt
E2E_WAIT_TIMEOUT=$(E2E_WAIT_TIMEOUT) E2E_INITLESS=$(INITLESS) $(call gotest,./test/e2e,$@,-timeout $(E2E_SUITE_TIMEOUT) -count 1 --tags $(ALL_BUILD_TAGS) -parallel $(E2E_PARALLEL) -run='.*/$*')
Benchmark%: $(TOOL_GOTESTSUM) $(JSON_TEST_OUTPUT) vendor/modules.txt
$(call gotest,./test/e2e,$@,--tags $(ALL_BUILD_TAGS) -run='$@' -benchmem -count=$(BENCHMARK_COUNT) -bench .)
# clean
.PHONY: clean
clean: ## Clean the directory of build files
go clean
rm -Rf test/reports test-results node_modules vendor v2 v3 v4 argoexec-linux-amd64 dist/* ui/dist
# Build telemetry files
# Telemetry Go files generated via go generate, run as part of codegen.
TELEMETRY_BUILDER := $(shell find util/telemetry/builder -type f -name '*.go')
docs/metrics.md: $(TELEMETRY_BUILDER) util/telemetry/builder/values.yaml vendor/modules.txt
@echo Rebuilding $@
go run ./util/telemetry/builder --metricsDocs $@
docs/tracing.md: $(TELEMETRY_BUILDER) util/telemetry/builder/values.yaml vendor/modules.txt
@echo Rebuilding $@
go run ./util/telemetry/builder --tracingDocs $@
docs/database-migrations.md: persist/sqldb/migrate.go util/sync/db/migrate.go hack/docs/migrations/main.go
GOFLAGS="$(GOFLAGS) -mod=mod" go run ./hack/docs/migrations
docs/variable-flow/variables.md: $(wildcard util/variables/*.go) $(wildcard util/variables/keys/*.go) vendor/modules.txt
@echo Rebuilding $@
go test -run TestGenerateMarkdown -count=1 ./util/variables/ -args -write
# swagger
ifneq ($(USE_NIX), true)
pkg/apis/workflow/v1alpha1/openapi_generated.go: $(TOOL_OPENAPI_GEN)
endif
pkg/apis/workflow/v1alpha1/openapi_generated.go: $(TYPES) vendor/modules.txt
# These files are generated on a v4/ folder by the tool. Link them to the root folder
[ -e ./v4 ] || ln -s . v4
$(TOOL_OPENAPI_GEN) \
--go-header-file ./hack/custom-boilerplate.go.txt \
--input-dirs github.com/argoproj/argo-workflows/v4/pkg/apis/workflow/v1alpha1 \
--output-package github.com/argoproj/argo-workflows/v4/pkg/apis/workflow/v1alpha1 \
--report-filename pkg/apis/api-rules/violation_exceptions.list
# Force the timestamp to be up to date
touch $@
# Delete the link
[ -e ./v4 ] && rm -rf v4
# generates many other files (listers, informers, client etc).
.PRECIOUS: pkg/apis/workflow/v1alpha1/zz_generated.deepcopy.go
ifneq ($(USE_NIX), true)
pkg/apis/workflow/v1alpha1/zz_generated.deepcopy.go: $(TOOL_GO_TO_PROTOBUF)
endif
pkg/apis/workflow/v1alpha1/zz_generated.deepcopy.go: $(TYPES) vendor/modules.txt
CODEGEN_DIR=$$(go list -mod=mod -m -f '{{.Dir}}' k8s.io/code-generator@v0.35.1); \
bash -c "source $$CODEGEN_DIR/kube_codegen.sh && \
kube::codegen::gen_helpers \
--boilerplate ./hack/custom-boilerplate.go.txt \
./pkg/apis && \
kube::codegen::gen_client \
--boilerplate ./hack/custom-boilerplate.go.txt \
--output-dir ./pkg/client \
--output-pkg github.com/argoproj/argo-workflows/v4/pkg/client \
--with-watch \
./pkg/apis"
# Force the timestamp to be up to date
touch $@
dist/kubernetes.swagger.json: Makefile
@mkdir -p dist
# recurl will only fetch if the file doesn't exist, so delete it
rm -f $@
./hack/recurl.sh $@ https://raw.githubusercontent.com/kubernetes/kubernetes/v1.35.1/api/openapi-spec/swagger.json
pkg/apiclient/_.secondary.swagger.json: hack/api/swagger/secondaryswaggergen.go pkg/apis/workflow/v1alpha1/openapi_generated.go dist/kubernetes.swagger.json
# We have `hack/api/swagger` so that most hack script do not depend on the whole code base and are therefore slow.
GOFLAGS="$(GOFLAGS) -mod=mod" go run ./hack/api/swagger secondaryswaggergen
# we always ignore the conflicts, so lets automated figuring out how many there will be and just use that
dist/swagger-conflicts: $(TOOL_SWAGGER) $(SWAGGER_FILES)
swagger mixin $(SWAGGER_FILES) 2>&1 | grep -c skipping > dist/swagger-conflicts || true
dist/mixed.swagger.json: $(TOOL_SWAGGER) $(SWAGGER_FILES) dist/swagger-conflicts
swagger mixin -c $(shell cat dist/swagger-conflicts) $(SWAGGER_FILES) -o dist/mixed.swagger.json
dist/swaggifed.swagger.json: dist/mixed.swagger.json hack/api/swagger/swaggify.sh
cat dist/mixed.swagger.json | ./hack/api/swagger/swaggify.sh > dist/swaggifed.swagger.json
dist/kubeified.swagger.json: dist/swaggifed.swagger.json dist/kubernetes.swagger.json
GOFLAGS="$(GOFLAGS) -mod=mod" go run ./hack/api/swagger kubeifyswagger dist/swaggifed.swagger.json dist/kubeified.swagger.json
dist/swagger.0.json: $(TOOL_SWAGGER) dist/kubeified.swagger.json
$(TOOL_SWAGGER) flatten --with-flatten minimal --with-flatten remove-unused dist/kubeified.swagger.json -o dist/swagger.0.json
api/openapi-spec/swagger.json: $(TOOL_SWAGGER) dist/swagger.0.json
$(TOOL_SWAGGER) flatten --with-flatten remove-unused dist/swagger.0.json -o api/openapi-spec/swagger.json
api/jsonschema/schema.json: api/openapi-spec/swagger.json hack/api/jsonschema/main.go
GOFLAGS="$(GOFLAGS) -mod=mod" go run ./hack/api/jsonschema
go-diagrams/diagram.dot: ./hack/docs/diagram.go
rm -Rf go-diagrams
GOFLAGS="$(GOFLAGS) -mod=mod" go run ./hack/docs diagram
docs/assets/diagram.png: go-diagrams/diagram.dot
cd go-diagrams && dot -Tpng diagram.dot -o ../docs/assets/diagram.png
docs/fields.md: api/openapi-spec/swagger.json $(shell find examples -type f) ui/dist/app/index.html hack/docs/fields.go
env ARGO_SECURE=false ARGO_INSECURE_SKIP_VERIFY=false ARGO_SERVER= ARGO_INSTANCEID= GOFLAGS="$(GOFLAGS) -mod=mod" go run ./hack/docs fields
docs/workflow-controller-configmap.md: config/*.go hack/docs/workflow-controller-configmap.md hack/docs/configdoc.go
GOFLAGS="$(GOFLAGS) -mod=mod" go run ./hack/docs configdoc
# generates several other files
docs/cli/argo.md: $(CLI_PKG_FILES) go.sum ui/dist/app/index.html hack/docs/cli.go
GOFLAGS="$(GOFLAGS) -mod=mod" go run ./hack/docs cli
docs/go-sdk-guide.md: $(TOOL_EMBEDDOC)
$(TOOL_EMBEDDOC)
$(TOOL_CSPELL): Makefile
# update this in Nix when upgrading it here
ifneq ($(USE_NIX), true)
npm list -g cspell@$(CSPELL_VERSION) > /dev/null || npm i -g cspell@$(CSPELL_VERSION)
endif
$(TOOL_TYPOS): Makefile
# update this in Nix when upgrading it here
ifneq ($(USE_NIX), true)
# typos has no npm package; install the prebuilt static binary
mkdir -p $(GOPATH)/bin
curl -sSfL https://github.com/crate-ci/typos/releases/download/v$(TYPOS_VERSION)/typos-v$(TYPOS_VERSION)-$(TYPOS_TARGET).tar.gz | tar -xz -C $(GOPATH)/bin ./typos
endif
# Markdown to spell-check: all tracked Markdown except SDKs, changelogs and the
# generated API reference docs (whose typos come from upstream/vendored comments).
SPELLCHECK_MD = $(shell git ls-files '*.md' | grep -vE '^(sdks/|CHANGELOG|USERS\.md|docs/(fields|executor_swagger)\.md)')
.PHONY: docs-spellcheck
ifneq ($(USE_NIX), true)
docs-spellcheck: $(TOOL_TYPOS) $(TOOL_CSPELL)
endif
docs-spellcheck: $(QUICK_GENERATED_DOCS) ## Spell check docs
# catch common misspellings across all docs (config: _typos.toml)
$(TOOL_TYPOS) $(SPELLCHECK_MD)
# dictionary-based spell check of prose docs (config: .cspell.json)
$(TOOL_CSPELL) lint --no-progress --config .cspell.json "docs/**/*.md"
$(TOOL_MARKDOWN_LINK_CHECK): Makefile
# update this in Nix when upgrading it here
ifneq ($(USE_NIX), true)
npm list -g markdown-link-check@3.11.1 > /dev/null || npm i -g markdown-link-check@3.11.1
endif
.PHONY: docs-linkcheck
ifneq ($(USE_NIX), true)
docs-linkcheck: $(TOOL_MARKDOWN_LINK_CHECK)
endif
docs-linkcheck:
# check docs for broken links
$(TOOL_MARKDOWN_LINK_CHECK) -q -c .mlc_config.json $(shell find docs -name '*.md' -not -name fields.md -not -name executor_swagger.md)
$(TOOL_MARKDOWNLINT): Makefile
# update this in Nix when upgrading it here
ifneq ($(USE_NIX), true)
npm list -g markdownlint-cli@0.33.0 > /dev/null || npm i -g markdownlint-cli@0.33.0
endif