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