github.com/argoproj/argo-cd/v2@v2.10.9/Makefile (about)

     1  PACKAGE=github.com/argoproj/argo-cd/v2/common
     2  CURRENT_DIR=$(shell pwd)
     3  DIST_DIR=${CURRENT_DIR}/dist
     4  CLI_NAME=argocd
     5  BIN_NAME=argocd
     6  
     7  GEN_RESOURCES_CLI_NAME=argocd-resources-gen
     8  
     9  HOST_OS:=$(shell go env GOOS)
    10  HOST_ARCH:=$(shell go env GOARCH)
    11  
    12  TARGET_ARCH?=linux/amd64
    13  
    14  VERSION=$(shell cat ${CURRENT_DIR}/VERSION)
    15  BUILD_DATE:=$(if $(BUILD_DATE),$(BUILD_DATE),$(shell date -u +'%Y-%m-%dT%H:%M:%SZ'))
    16  GIT_COMMIT:=$(if $(GIT_COMMIT),$(GIT_COMMIT),$(shell git rev-parse HEAD))
    17  GIT_TAG:=$(if $(GIT_TAG),$(GIT_TAG),$(shell if [ -z "`git status --porcelain`" ]; then git describe --exact-match --tags HEAD 2>/dev/null; fi))
    18  GIT_TREE_STATE:=$(if $(GIT_TREE_STATE),$(GIT_TREE_STATE),$(shell if [ -z "`git status --porcelain`" ]; then echo "clean" ; else echo "dirty"; fi))
    19  VOLUME_MOUNT=$(shell if test "$(go env GOOS)" = "darwin"; then echo ":delegated"; elif test selinuxenabled; then echo ":delegated"; else echo ""; fi)
    20  KUBECTL_VERSION=$(shell go list -m k8s.io/client-go | head -n 1 | rev | cut -d' ' -f1 | rev)
    21  
    22  GOPATH?=$(shell if test -x `which go`; then go env GOPATH; else echo "$(HOME)/go"; fi)
    23  GOCACHE?=$(HOME)/.cache/go-build
    24  
    25  DOCKER_SRCDIR?=$(GOPATH)/src
    26  DOCKER_WORKDIR?=/go/src/github.com/argoproj/argo-cd
    27  
    28  ARGOCD_PROCFILE?=Procfile
    29  
    30  # Strict mode has been disabled in latest versions of mkdocs-material.
    31  # Thus pointing to the older image of mkdocs-material matching the version used by argo-cd.
    32  MKDOCS_DOCKER_IMAGE?=squidfunk/mkdocs-material:4.1.1
    33  MKDOCS_RUN_ARGS?=
    34  
    35  # Configuration for building argocd-test-tools image
    36  TEST_TOOLS_NAMESPACE?=
    37  TEST_TOOLS_IMAGE=argocd-test-tools
    38  TEST_TOOLS_TAG?=latest
    39  ifdef TEST_TOOLS_NAMESPACE
    40  TEST_TOOLS_PREFIX=${TEST_TOOLS_NAMESPACE}/
    41  endif
    42  
    43  # You can change the ports where ArgoCD components will be listening on by
    44  # setting the appropriate environment variables before running make.
    45  ARGOCD_E2E_APISERVER_PORT?=8080
    46  ARGOCD_E2E_REPOSERVER_PORT?=8081
    47  ARGOCD_E2E_REDIS_PORT?=6379
    48  ARGOCD_E2E_DEX_PORT?=5556
    49  ARGOCD_E2E_YARN_HOST?=localhost
    50  ARGOCD_E2E_DISABLE_AUTH?=
    51  
    52  ARGOCD_E2E_TEST_TIMEOUT?=90m
    53  
    54  ARGOCD_IN_CI?=false
    55  ARGOCD_TEST_E2E?=true
    56  ARGOCD_BIN_MODE?=true
    57  
    58  ARGOCD_LINT_GOGC?=20
    59  
    60  # Depending on where we are (legacy or non-legacy pwd), we need to use
    61  # different Docker volume mounts for our source tree
    62  LEGACY_PATH=$(GOPATH)/src/github.com/argoproj/argo-cd
    63  ifeq ("$(PWD)","$(LEGACY_PATH)")
    64  DOCKER_SRC_MOUNT="$(DOCKER_SRCDIR):/go/src$(VOLUME_MOUNT)"
    65  else
    66  DOCKER_SRC_MOUNT="$(PWD):/go/src/github.com/argoproj/argo-cd$(VOLUME_MOUNT)"
    67  endif
    68  
    69  # User and group IDs to map to the test container
    70  CONTAINER_UID=$(shell id -u)
    71  CONTAINER_GID=$(shell id -g)
    72  
    73  # Set SUDO to sudo to run privileged commands with sudo
    74  SUDO?=
    75  
    76  # Runs any command in the argocd-test-utils container in server mode
    77  # Server mode container will start with uid 0 and drop privileges during runtime
    78  define run-in-test-server
    79  	$(SUDO) docker run --rm -it \
    80  		--name argocd-test-server \
    81  		-u $(CONTAINER_UID):$(CONTAINER_GID) \
    82  		-e USER_ID=$(CONTAINER_UID) \
    83  		-e HOME=/home/user \
    84  		-e GOPATH=/go \
    85  		-e GOCACHE=/tmp/go-build-cache \
    86  		-e ARGOCD_IN_CI=$(ARGOCD_IN_CI) \
    87  		-e ARGOCD_E2E_TEST=$(ARGOCD_E2E_TEST) \
    88  		-e ARGOCD_E2E_YARN_HOST=$(ARGOCD_E2E_YARN_HOST) \
    89  		-e ARGOCD_E2E_DISABLE_AUTH=$(ARGOCD_E2E_DISABLE_AUTH) \
    90  		-e ARGOCD_TLS_DATA_PATH=${ARGOCD_TLS_DATA_PATH:-/tmp/argocd-local/tls} \
    91  		-e ARGOCD_SSH_DATA_PATH=${ARGOCD_SSH_DATA_PATH:-/tmp/argocd-local/ssh} \
    92  		-e ARGOCD_GPG_DATA_PATH=${ARGOCD_GPG_DATA_PATH:-/tmp/argocd-local/gpg/source} \
    93  		-e ARGOCD_APPLICATION_NAMESPACES \
    94  		-e GITHUB_TOKEN \
    95  		-v ${DOCKER_SRC_MOUNT} \
    96  		-v ${GOPATH}/pkg/mod:/go/pkg/mod${VOLUME_MOUNT} \
    97  		-v ${GOCACHE}:/tmp/go-build-cache${VOLUME_MOUNT} \
    98  		-v ${HOME}/.kube:/home/user/.kube${VOLUME_MOUNT} \
    99  		-v /tmp:/tmp${VOLUME_MOUNT} \
   100  		-w ${DOCKER_WORKDIR} \
   101  		-p ${ARGOCD_E2E_APISERVER_PORT}:8080 \
   102  		-p 4000:4000 \
   103  		-p 5000:5000 \
   104  		$(TEST_TOOLS_PREFIX)$(TEST_TOOLS_IMAGE):$(TEST_TOOLS_TAG) \
   105  		bash -c "$(1)"
   106  endef
   107  
   108  # Runs any command in the argocd-test-utils container in client mode
   109  define run-in-test-client
   110  	$(SUDO) docker run --rm -it \
   111  	  --name argocd-test-client \
   112  		-u $(CONTAINER_UID):$(CONTAINER_GID) \
   113  		-e HOME=/home/user \
   114  		-e GOPATH=/go \
   115  		-e ARGOCD_E2E_K3S=$(ARGOCD_E2E_K3S) \
   116  		-e GITHUB_TOKEN \
   117  		-e GOCACHE=/tmp/go-build-cache \
   118  		-e ARGOCD_LINT_GOGC=$(ARGOCD_LINT_GOGC) \
   119  		-v ${DOCKER_SRC_MOUNT} \
   120  		-v ${GOPATH}/pkg/mod:/go/pkg/mod${VOLUME_MOUNT} \
   121  		-v ${GOCACHE}:/tmp/go-build-cache${VOLUME_MOUNT} \
   122  		-v ${HOME}/.kube:/home/user/.kube${VOLUME_MOUNT} \
   123  		-v /tmp:/tmp${VOLUME_MOUNT} \
   124  		-w ${DOCKER_WORKDIR} \
   125  		$(TEST_TOOLS_PREFIX)$(TEST_TOOLS_IMAGE):$(TEST_TOOLS_TAG) \
   126  		bash -c "$(1)"
   127  endef
   128  
   129  #
   130  define exec-in-test-server
   131  	$(SUDO) docker exec -it -u $(CONTAINER_UID):$(CONTAINER_GID) -e ARGOCD_E2E_RECORD=$(ARGOCD_E2E_RECORD) -e ARGOCD_E2E_K3S=$(ARGOCD_E2E_K3S) argocd-test-server $(1)
   132  endef
   133  
   134  PATH:=$(PATH):$(PWD)/hack
   135  
   136  # docker image publishing options
   137  DOCKER_PUSH?=false
   138  IMAGE_NAMESPACE?=
   139  # perform static compilation
   140  STATIC_BUILD?=true
   141  # build development images
   142  DEV_IMAGE?=false
   143  ARGOCD_GPG_ENABLED?=true
   144  ARGOCD_E2E_APISERVER_PORT?=8080
   145  
   146  override LDFLAGS += \
   147    -X ${PACKAGE}.version=${VERSION} \
   148    -X ${PACKAGE}.buildDate=${BUILD_DATE} \
   149    -X ${PACKAGE}.gitCommit=${GIT_COMMIT} \
   150    -X ${PACKAGE}.gitTreeState=${GIT_TREE_STATE}\
   151    -X ${PACKAGE}.kubectlVersion=${KUBECTL_VERSION}\
   152    -X "${PACKAGE}.extraBuildInfo=${EXTRA_BUILD_INFO}"
   153  
   154  ifeq (${STATIC_BUILD}, true)
   155  override LDFLAGS += -extldflags "-static"
   156  endif
   157  
   158  ifneq (${GIT_TAG},)
   159  IMAGE_TAG=${GIT_TAG}
   160  LDFLAGS += -X ${PACKAGE}.gitTag=${GIT_TAG}
   161  else
   162  IMAGE_TAG?=latest
   163  endif
   164  
   165  ifeq (${DOCKER_PUSH},true)
   166  ifndef IMAGE_NAMESPACE
   167  $(error IMAGE_NAMESPACE must be set to push images (e.g. IMAGE_NAMESPACE=argoproj))
   168  endif
   169  endif
   170  
   171  ifdef IMAGE_NAMESPACE
   172  IMAGE_PREFIX=${IMAGE_NAMESPACE}/
   173  endif
   174  
   175  .PHONY: all
   176  all: cli image
   177  
   178  # We have some legacy requirements for being checked out within $GOPATH.
   179  # The ensure-gopath target can be used as dependency to ensure we are running
   180  # within these boundaries.
   181  .PHONY: ensure-gopath
   182  ensure-gopath:
   183  ifneq ("$(PWD)","$(LEGACY_PATH)")
   184  	@echo "Due to legacy requirements for codegen, repository needs to be checked out within \$$GOPATH"
   185  	@echo "Location of this repo should be '$(LEGACY_PATH)' but is '$(PWD)'"
   186  	@exit 1
   187  endif
   188  
   189  .PHONY: gogen
   190  gogen: ensure-gopath
   191  	export GO111MODULE=off
   192  	go generate ./util/argo/...
   193  
   194  .PHONY: protogen
   195  protogen: ensure-gopath mod-vendor-local
   196  	export GO111MODULE=off
   197  	./hack/generate-proto.sh
   198  
   199  .PHONY: openapigen
   200  openapigen: ensure-gopath
   201  	export GO111MODULE=off
   202  	./hack/update-openapi.sh
   203  
   204  .PHONY: notification-catalog
   205  notification-catalog:
   206  	go run ./hack/gen-catalog catalog
   207  
   208  .PHONY: notification-docs
   209  notification-docs:
   210  	go run ./hack/gen-docs
   211  	go run ./hack/gen-catalog docs
   212  
   213  
   214  .PHONY: clientgen
   215  clientgen: ensure-gopath
   216  	export GO111MODULE=off
   217  	./hack/update-codegen.sh
   218  
   219  .PHONY: clidocsgen
   220  clidocsgen: ensure-gopath
   221  	go run tools/cmd-docs/main.go
   222  
   223  
   224  .PHONY: codegen-local
   225  codegen-local: ensure-gopath mod-vendor-local gogen protogen clientgen openapigen clidocsgen manifests-local notification-docs notification-catalog
   226  	rm -rf vendor/
   227  
   228  .PHONY: codegen
   229  codegen: test-tools-image
   230  	$(call run-in-test-client,make codegen-local)
   231  
   232  .PHONY: cli
   233  cli: test-tools-image
   234  	$(call run-in-test-client, GOOS=${HOST_OS} GOARCH=${HOST_ARCH} make cli-local)
   235  
   236  .PHONY: cli-local
   237  cli-local: clean-debug
   238  	CGO_ENABLED=0 GODEBUG="tarinsecurepath=0,zipinsecurepath=0" go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/${CLI_NAME} ./cmd
   239  
   240  .PHONY: gen-resources-cli-local
   241  gen-resources-cli-local: clean-debug
   242  	CGO_ENABLED=0 GODEBUG="tarinsecurepath=0,zipinsecurepath=0" go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/${GEN_RESOURCES_CLI_NAME} ./hack/gen-resources/cmd
   243  
   244  .PHONY: release-cli
   245  release-cli: clean-debug build-ui
   246  	make BIN_NAME=argocd-darwin-amd64 GOOS=darwin argocd-all
   247  	make BIN_NAME=argocd-darwin-arm64 GOOS=darwin GOARCH=arm64 argocd-all
   248  	make BIN_NAME=argocd-linux-amd64 GOOS=linux argocd-all
   249  	make BIN_NAME=argocd-linux-arm64 GOOS=linux GOARCH=arm64 argocd-all
   250  	make BIN_NAME=argocd-linux-ppc64le GOOS=linux GOARCH=ppc64le argocd-all
   251  	make BIN_NAME=argocd-linux-s390x GOOS=linux GOARCH=s390x argocd-all
   252  	make BIN_NAME=argocd-windows-amd64.exe GOOS=windows argocd-all
   253  
   254  .PHONY: test-tools-image
   255  test-tools-image:
   256  ifndef SKIP_TEST_TOOLS_IMAGE
   257  	$(SUDO) docker build --build-arg UID=$(CONTAINER_UID) -t $(TEST_TOOLS_PREFIX)$(TEST_TOOLS_IMAGE) -f test/container/Dockerfile .
   258  	$(SUDO) docker tag $(TEST_TOOLS_PREFIX)$(TEST_TOOLS_IMAGE) $(TEST_TOOLS_PREFIX)$(TEST_TOOLS_IMAGE):$(TEST_TOOLS_TAG)
   259  endif
   260  
   261  .PHONY: manifests-local
   262  manifests-local:
   263  	./hack/update-manifests.sh
   264  
   265  .PHONY: manifests
   266  manifests: test-tools-image
   267  	$(call run-in-test-client,make manifests-local IMAGE_NAMESPACE='${IMAGE_NAMESPACE}' IMAGE_TAG='${IMAGE_TAG}')
   268  
   269  # consolidated binary for cli, util, server, repo-server, controller
   270  .PHONY: argocd-all
   271  argocd-all: clean-debug
   272  	CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} GODEBUG="tarinsecurepath=0,zipinsecurepath=0" go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/${BIN_NAME} ./cmd
   273  
   274  .PHONY: server
   275  server: clean-debug
   276  	CGO_ENABLED=0 GODEBUG="tarinsecurepath=0,zipinsecurepath=0" go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/argocd-server ./cmd
   277  
   278  .PHONY: repo-server
   279  repo-server:
   280  	CGO_ENABLED=0 GODEBUG="tarinsecurepath=0,zipinsecurepath=0" go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/argocd-repo-server ./cmd
   281  
   282  .PHONY: controller
   283  controller:
   284  	CGO_ENABLED=0 GODEBUG="tarinsecurepath=0,zipinsecurepath=0" go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/argocd-application-controller ./cmd
   285  
   286  .PHONY: build-ui
   287  build-ui:
   288  	DOCKER_BUILDKIT=1 docker build -t argocd-ui --platform=$(TARGET_ARCH) --target argocd-ui .
   289  	find ./ui/dist -type f -not -name gitkeep -delete
   290  	docker run -v ${CURRENT_DIR}/ui/dist/app:/tmp/app --rm -t argocd-ui sh -c 'cp -r ./dist/app/* /tmp/app/'
   291  
   292  .PHONY: image
   293  ifeq ($(DEV_IMAGE), true)
   294  # The "dev" image builds the binaries from the users desktop environment (instead of in Docker)
   295  # which speeds up builds. Dockerfile.dev needs to be copied into dist to perform the build, since
   296  # the dist directory is under .dockerignore.
   297  IMAGE_TAG="dev-$(shell git describe --always --dirty)"
   298  image: build-ui
   299  	DOCKER_BUILDKIT=1 docker build --platform=$(TARGET_ARCH) -t argocd-base --target argocd-base .
   300  	CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GODEBUG="tarinsecurepath=0,zipinsecurepath=0" go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/argocd ./cmd
   301  	ln -sfn ${DIST_DIR}/argocd ${DIST_DIR}/argocd-server
   302  	ln -sfn ${DIST_DIR}/argocd ${DIST_DIR}/argocd-application-controller
   303  	ln -sfn ${DIST_DIR}/argocd ${DIST_DIR}/argocd-repo-server
   304  	ln -sfn ${DIST_DIR}/argocd ${DIST_DIR}/argocd-cmp-server
   305  	ln -sfn ${DIST_DIR}/argocd ${DIST_DIR}/argocd-dex
   306  	cp Dockerfile.dev dist
   307  	DOCKER_BUILDKIT=1 docker build --platform=$(TARGET_ARCH) -t $(IMAGE_PREFIX)argocd:$(IMAGE_TAG) -f dist/Dockerfile.dev dist
   308  else
   309  image:
   310  	DOCKER_BUILDKIT=1 docker build -t $(IMAGE_PREFIX)argocd:$(IMAGE_TAG) --platform=$(TARGET_ARCH) .
   311  endif
   312  	@if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)argocd:$(IMAGE_TAG) ; fi
   313  
   314  .PHONY: armimage
   315  armimage:
   316  	docker build -t $(IMAGE_PREFIX)argocd:$(IMAGE_TAG)-arm .
   317  
   318  .PHONY: builder-image
   319  builder-image:
   320  	docker build  -t $(IMAGE_PREFIX)argo-cd-ci-builder:$(IMAGE_TAG) --target builder .
   321  	@if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)argo-cd-ci-builder:$(IMAGE_TAG) ; fi
   322  
   323  .PHONY: mod-download
   324  mod-download: test-tools-image
   325  	$(call run-in-test-client,go mod download)
   326  
   327  .PHONY: mod-download-local
   328  mod-download-local:
   329  	go mod download && go mod tidy # go mod download changes go.sum https://github.com/golang/go/issues/42970
   330  
   331  .PHONY: mod-vendor
   332  mod-vendor: test-tools-image
   333  	$(call run-in-test-client,go mod vendor)
   334  
   335  .PHONY: mod-vendor-local
   336  mod-vendor-local: mod-download-local
   337  	go mod vendor
   338  
   339  # Deprecated - replace by install-tools-local
   340  .PHONY: install-lint-tools
   341  install-lint-tools:
   342  	./hack/install.sh lint-tools
   343  
   344  # Run linter on the code
   345  .PHONY: lint
   346  lint: test-tools-image
   347  	$(call run-in-test-client,make lint-local)
   348  
   349  # Run linter on the code (local version)
   350  .PHONY: lint-local
   351  lint-local:
   352  	golangci-lint --version
   353  	# NOTE: If you get a "Killed" OOM message, try reducing the value of GOGC
   354  	# See https://github.com/golangci/golangci-lint#memory-usage-of-golangci-lint
   355  	GOGC=$(ARGOCD_LINT_GOGC) GOMAXPROCS=2 golangci-lint run --enable gofmt --fix --verbose --timeout 3000s --max-issues-per-linter 0 --max-same-issues 0
   356  
   357  .PHONY: lint-ui
   358  lint-ui: test-tools-image
   359  	$(call run-in-test-client,make lint-ui-local)
   360  
   361  .PHONY: lint-ui-local
   362  lint-ui-local:
   363  	cd ui && yarn lint
   364  
   365  # Build all Go code
   366  .PHONY: build
   367  build: test-tools-image
   368  	mkdir -p $(GOCACHE)
   369  	$(call run-in-test-client, make build-local)
   370  
   371  # Build all Go code (local version)
   372  .PHONY: build-local
   373  build-local:
   374  	GODEBUG="tarinsecurepath=0,zipinsecurepath=0" go build -v `go list ./... | grep -v 'resource_customizations\|test/e2e'`
   375  
   376  # Run all unit tests
   377  #
   378  # If TEST_MODULE is set (to fully qualified module name), only this specific
   379  # module will be tested.
   380  .PHONY: test
   381  test: test-tools-image
   382  	mkdir -p $(GOCACHE)
   383  	$(call run-in-test-client,make TEST_MODULE=$(TEST_MODULE) test-local)
   384  
   385  # Run all unit tests (local version)
   386  .PHONY: test-local
   387  test-local:
   388  	if test "$(TEST_MODULE)" = ""; then \
   389  		DIST_DIR=${DIST_DIR} RERUN_FAILS=0 PACKAGES=`go list ./... | grep -v 'test/e2e'` ./hack/test.sh -coverprofile=coverage.out; \
   390  	else \
   391  		DIST_DIR=${DIST_DIR} RERUN_FAILS=0 PACKAGES="$(TEST_MODULE)" ./hack/test.sh -coverprofile=coverage.out "$(TEST_MODULE)"; \
   392  	fi
   393  
   394  .PHONY: test-race
   395  test-race: test-tools-image
   396  	mkdir -p $(GOCACHE)
   397  	$(call run-in-test-client,make TEST_MODULE=$(TEST_MODULE) test-race-local)
   398  
   399  # Run all unit tests, with data race detection, skipping known failures (local version)
   400  .PHONY: test-race-local
   401  test-race-local:
   402  	if test "$(TEST_MODULE)" = ""; then \
   403  		DIST_DIR=${DIST_DIR} RERUN_FAILS=0 PACKAGES=`go list ./... | grep -v 'test/e2e'` ./hack/test.sh -race -coverprofile=coverage.out; \
   404  	else \
   405  		DIST_DIR=${DIST_DIR} RERUN_FAILS=0 PACKAGES="$(TEST_MODULE)" ./hack/test.sh -race -coverprofile=coverage.out; \
   406  	fi
   407  
   408  # Run the E2E test suite. E2E test servers (see start-e2e target) must be
   409  # started before.
   410  .PHONY: test-e2e
   411  test-e2e:
   412  	$(call exec-in-test-server,make test-e2e-local)
   413  
   414  # Run the E2E test suite (local version)
   415  .PHONY: test-e2e-local
   416  test-e2e-local: cli-local
   417  	# NO_PROXY ensures all tests don't go out through a proxy if one is configured on the test system
   418  	export GO111MODULE=off
   419  	DIST_DIR=${DIST_DIR} RERUN_FAILS=5 PACKAGES="./test/e2e" ARGOCD_E2E_RECORD=${ARGOCD_E2E_RECORD} ARGOCD_GPG_ENABLED=true NO_PROXY=* ./hack/test.sh -timeout $(ARGOCD_E2E_TEST_TIMEOUT) -v
   420  
   421  # Spawns a shell in the test server container for debugging purposes
   422  debug-test-server: test-tools-image
   423  	$(call run-in-test-server,/bin/bash)
   424  
   425  # Spawns a shell in the test client container for debugging purposes
   426  debug-test-client: test-tools-image
   427  	$(call run-in-test-client,/bin/bash)
   428  
   429  # Starts e2e server in a container
   430  .PHONY: start-e2e
   431  start-e2e: test-tools-image
   432  	docker version
   433  	mkdir -p ${GOCACHE}
   434  	$(call run-in-test-server,make ARGOCD_PROCFILE=test/container/Procfile start-e2e-local)
   435  
   436  # Starts e2e server locally (or within a container)
   437  .PHONY: start-e2e-local
   438  start-e2e-local: mod-vendor-local dep-ui-local cli-local
   439  	kubectl create ns argocd-e2e || true
   440  	kubectl create ns argocd-e2e-external || true
   441  	kubectl create ns argocd-e2e-external-2 || true
   442  	kubectl config set-context --current --namespace=argocd-e2e
   443  	kustomize build test/manifests/base | kubectl apply -f -
   444  	kubectl apply -f https://raw.githubusercontent.com/open-cluster-management/api/a6845f2ebcb186ec26b832f60c988537a58f3859/cluster/v1alpha1/0000_04_clusters.open-cluster-management.io_placementdecisions.crd.yaml
   445  	# Create GPG keys and source directories
   446  	if test -d /tmp/argo-e2e/app/config/gpg; then rm -rf /tmp/argo-e2e/app/config/gpg/*; fi
   447  	mkdir -p /tmp/argo-e2e/app/config/gpg/keys && chmod 0700 /tmp/argo-e2e/app/config/gpg/keys
   448  	mkdir -p /tmp/argo-e2e/app/config/gpg/source && chmod 0700 /tmp/argo-e2e/app/config/gpg/source
   449  	mkdir -p /tmp/argo-e2e/app/config/plugin && chmod 0700 /tmp/argo-e2e/app/config/plugin
   450  	# set paths for locally managed ssh known hosts and tls certs data
   451  	ARGOCD_SSH_DATA_PATH=/tmp/argo-e2e/app/config/ssh \
   452  	ARGOCD_TLS_DATA_PATH=/tmp/argo-e2e/app/config/tls \
   453  	ARGOCD_GPG_DATA_PATH=/tmp/argo-e2e/app/config/gpg/source \
   454  	ARGOCD_GNUPGHOME=/tmp/argo-e2e/app/config/gpg/keys \
   455  	ARGOCD_GPG_ENABLED=$(ARGOCD_GPG_ENABLED) \
   456  	ARGOCD_PLUGINCONFIGFILEPATH=/tmp/argo-e2e/app/config/plugin \
   457  	ARGOCD_PLUGINSOCKFILEPATH=/tmp/argo-e2e/app/config/plugin \
   458  	ARGOCD_E2E_DISABLE_AUTH=false \
   459  	ARGOCD_ZJWT_FEATURE_FLAG=always \
   460  	ARGOCD_IN_CI=$(ARGOCD_IN_CI) \
   461  	BIN_MODE=$(ARGOCD_BIN_MODE) \
   462  	ARGOCD_APPLICATION_NAMESPACES=argocd-e2e-external,argocd-e2e-external-2 \
   463  	ARGOCD_APPLICATIONSET_CONTROLLER_NAMESPACES=argocd-e2e-external,argocd-e2e-external-2 \
   464  	ARGOCD_APPLICATIONSET_CONTROLLER_ALLOWED_SCM_PROVIDERS=http://127.0.0.1:8341,http://127.0.0.1:8342,http://127.0.0.1:8343,http://127.0.0.1:8344 \
   465  	ARGOCD_E2E_TEST=true \
   466  		goreman -f $(ARGOCD_PROCFILE) start ${ARGOCD_START}
   467  
   468  # Cleans VSCode debug.test files from sub-dirs to prevent them from being included in by golang embed
   469  .PHONY: clean-debug
   470  clean-debug:
   471  	-find ${CURRENT_DIR} -name debug.test -exec rm -f {} +
   472  
   473  .PHONY: clean
   474  clean: clean-debug
   475  	-rm -rf ${CURRENT_DIR}/dist
   476  
   477  .PHONY: start
   478  start: test-tools-image
   479  	docker version
   480  	$(call run-in-test-server,make ARGOCD_PROCFILE=test/container/Procfile start-local ARGOCD_START=${ARGOCD_START})
   481  
   482  # Starts a local instance of ArgoCD
   483  .PHONY: start-local
   484  start-local: mod-vendor-local dep-ui-local cli-local
   485  	# check we can connect to Docker to start Redis
   486  	killall goreman || true
   487  	kubectl create ns argocd || true
   488  	rm -rf /tmp/argocd-local
   489  	mkdir -p /tmp/argocd-local
   490  	mkdir -p /tmp/argocd-local/gpg/keys && chmod 0700 /tmp/argocd-local/gpg/keys
   491  	mkdir -p /tmp/argocd-local/gpg/source
   492  	ARGOCD_ZJWT_FEATURE_FLAG=always \
   493  	ARGOCD_IN_CI=false \
   494  	ARGOCD_GPG_ENABLED=$(ARGOCD_GPG_ENABLED) \
   495  	BIN_MODE=$(ARGOCD_BIN_MODE) \
   496  	ARGOCD_E2E_TEST=false \
   497  	ARGOCD_APPLICATION_NAMESPACES=$(ARGOCD_APPLICATION_NAMESPACES) \
   498  		goreman -f $(ARGOCD_PROCFILE) start ${ARGOCD_START}
   499  
   500  # Run goreman start with exclude option , provide exclude env variable with list of services
   501  .PHONY: run
   502  run:
   503  	bash ./hack/goreman-start.sh
   504  
   505  
   506  # Runs pre-commit validation with the virtualized toolchain
   507  .PHONY: pre-commit
   508  pre-commit: codegen build lint test
   509  
   510  # Runs pre-commit validation with the local toolchain
   511  .PHONY: pre-commit-local
   512  pre-commit-local: codegen-local build-local lint-local test-local
   513  
   514  .PHONY: release-precheck
   515  release-precheck: manifests
   516  	@if [ "$(GIT_TREE_STATE)" != "clean" ]; then echo 'git tree state is $(GIT_TREE_STATE)' ; exit 1; fi
   517  	@if [ -z "$(GIT_TAG)" ]; then echo 'commit must be tagged to perform release' ; exit 1; fi
   518  	@if [ "$(GIT_TAG)" != "v`cat VERSION`" ]; then echo 'VERSION does not match git tag'; exit 1; fi
   519  
   520  .PHONY: release
   521  release: pre-commit release-precheck image release-cli
   522  
   523  .PHONY: build-docs-local
   524  build-docs-local:
   525  	mkdocs build
   526  
   527  .PHONY: build-docs
   528  build-docs:
   529  	docker run ${MKDOCS_RUN_ARGS} --rm -it -v ${CURRENT_DIR}:/docs --entrypoint "" ${MKDOCS_DOCKER_IMAGE} sh -c 'pip install -r docs/requirements.txt; mkdocs build'
   530  
   531  .PHONY: serve-docs-local
   532  serve-docs-local:
   533  	mkdocs serve
   534  
   535  .PHONY: serve-docs
   536  serve-docs:
   537  	docker run ${MKDOCS_RUN_ARGS} --rm -it -p 8000:8000 -v ${CURRENT_DIR}/site:/site -w /site --entrypoint "" ${MKDOCS_DOCKER_IMAGE} python3 -m http.server --bind 0.0.0.0 8000
   538  
   539  
   540  # Verify that kubectl can connect to your K8s cluster from Docker
   541  .PHONY: verify-kube-connect
   542  verify-kube-connect: test-tools-image
   543  	$(call run-in-test-client,kubectl version)
   544  
   545  # Show the Go version of local and virtualized environments
   546  .PHONY: show-go-version
   547  show-go-version: test-tools-image
   548  	@echo -n "Local Go version: "
   549  	@go version
   550  	@echo -n "Docker Go version: "
   551  	$(call run-in-test-client,go version)
   552  
   553  # Installs all tools required to build and test ArgoCD locally
   554  .PHONY: install-tools-local
   555  install-tools-local: install-test-tools-local install-codegen-tools-local install-go-tools-local
   556  
   557  # Installs all tools required for running unit & end-to-end tests (Linux packages)
   558  .PHONY: install-test-tools-local
   559  install-test-tools-local:
   560  	./hack/install.sh kustomize
   561  	./hack/install.sh helm-linux
   562  	./hack/install.sh gotestsum
   563  
   564  # Installs all tools required for running codegen (Linux packages)
   565  .PHONY: install-codegen-tools-local
   566  install-codegen-tools-local:
   567  	./hack/install.sh codegen-tools
   568  
   569  # Installs all tools required for running codegen (Go packages)
   570  .PHONY: install-go-tools-local
   571  install-go-tools-local:
   572  	./hack/install.sh codegen-go-tools
   573  
   574  .PHONY: dep-ui
   575  dep-ui: test-tools-image
   576  	$(call run-in-test-client,make dep-ui-local)
   577  
   578  dep-ui-local:
   579  	cd ui && yarn install
   580  
   581  start-test-k8s:
   582  	go run ./hack/k8s
   583  
   584  .PHONY: list
   585  list:
   586  	@LC_ALL=C $(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$'
   587  
   588  .PHONY: applicationset-controller
   589  applicationset-controller:
   590  	GODEBUG="tarinsecurepath=0,zipinsecurepath=0" CGO_ENABLED=0 go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/argocd-applicationset-controller ./cmd
   591  
   592  .PHONY: checksums
   593  checksums:
   594  	sha256sum ./dist/$(BIN_NAME)-* | awk -F './dist/' '{print $$1 $$2}' > ./dist/$(BIN_NAME)-$(TARGET_VERSION)-checksums.txt
   595  
   596  .PHONY: snyk-container-tests
   597  snyk-container-tests:
   598  	./hack/snyk-container-tests.sh
   599  
   600  .PHONY: snyk-non-container-tests
   601  snyk-non-container-tests:
   602  	./hack/snyk-non-container-tests.sh
   603  
   604  .PHONY: snyk-report
   605  snyk-report:
   606  	./hack/snyk-report.sh $(target_branch)
   607  
   608  .PHONY: help
   609  help:
   610  	@echo 'Note: Generally an item w/ (-local) will run inside docker unless you use the -local variant'
   611  	@echo
   612  	@echo 'Common targets'
   613  	@echo
   614  	@echo 'all -- make cli and image'
   615  	@echo
   616  	@echo 'components:'
   617  	@echo '  applicationset-controller -- applicationset controller'
   618  	@echo '  cli(-local)               -- argocd cli program'
   619  	@echo '  controller                -- controller (orchestrator)'
   620  	@echo '  repo-server               -- repo server (manage repository instances)'
   621  	@echo '  server                    -- argocd web application'
   622  	@echo
   623  	@echo 'build:'
   624  	@echo '  image                     -- make image of the following items'
   625  	@echo '  build(-local)             -- compile go'
   626  	@echo '  build-docs(-local)        -- build docs'
   627  	@echo '  build-ui                  -- compile typescript'
   628  	@echo
   629  	@echo 'run:'
   630  	@echo '  run                       -- run the components locally'
   631  	@echo '  serve-docs(-local)        -- expose the documents for viewing in a browser'
   632  	@echo
   633  	@echo 'release:'
   634  	@echo '  release-cli'
   635  	@echo '  release-precheck'
   636  	@echo '  checksums'
   637  	@echo
   638  	@echo 'docs:'
   639  	@echo '  build-docs(-local)'
   640  	@echo '  serve-docs(-local)'
   641  	@echo '  notification-docs'
   642  	@echo '  clidocsgen'
   643  	@echo
   644  	@echo 'testing:'
   645  	@echo '  test(-local)'
   646  	@echo '  start-e2e(-local)'
   647  	@echo '  test-e2e(-local)'
   648  	@echo '  test-race(-local)'
   649  	@echo
   650  	@echo 'debug:'
   651  	@echo '  list -- list all make targets'
   652  	@echo '  install-tools-local -- install all the tools below'
   653  	@echo '  install-lint-tools(-local)'
   654  	@echo
   655  	@echo 'codegen:'
   656  	@echo '  codegen(-local) -- if using -local, run the following targets first'
   657  	@echo '  install-codegen-tools-local -- run this to install the codegen tools'
   658  	@echo '  install-go-tools-local -- run this to install go libraries for codegen'