Makefile 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. MAKEFLAGS += --warn-undefined-variables
  2. SHELL := /usr/bin/env bash
  3. .SHELLFLAGS := -euo pipefail -c
  4. KIND_IMG = "kindest/node:v1.33.4@sha256:25a6018e48dfcaee478f4a59af81157a437f15e6e140bf103f85a2e7cd0cbbf2"
  5. DOCKER_BUILD_ARGS ?=
  6. export E2E_IMAGE_NAME ?= ghcr.io/external-secrets/external-secrets-e2e
  7. export GINKGO_LABELS ?= !managed
  8. export TEST_SUITES ?= provider generator flux argocd
  9. # Leave the global addons installed on the way out. Only for a cluster you are
  10. # about to delete. Off by default; CI sets it per leg.
  11. export E2E_SKIP_GLOBAL_TEARDOWN ?=
  12. export OCI_IMAGE_NAME = ghcr.io/external-secrets/external-secrets
  13. # Directory where test.build writes the docker-saved image tarballs and where
  14. # test.run loads them from. Lets CI hand images between a build job and a
  15. # separate test job as artifacts instead of rebuilding on the test runner.
  16. E2E_ARTIFACT_DIR ?= $(shell pwd)/image-artifacts
  17. start-kind: ## Start kind cluster
  18. kind create cluster \
  19. --name external-secrets \
  20. --config kind.yaml \
  21. --retain \
  22. --image "$(KIND_IMG)"
  23. stop-kind: ## Stop kind cluster
  24. kind delete cluster \
  25. --name external-secrets \
  26. test: ## Build images and run the e2e suite on the current runner (local convenience)
  27. $(MAKE) test.build
  28. $(MAKE) test.run
  29. test.build: e2e-image ## Build the e2e + controller images and export them as tarballs
  30. $(MAKE) -C ../ docker.build \
  31. IMAGE_NAME=$(OCI_IMAGE_NAME) \
  32. VERSION=$(VERSION) \
  33. ARCH=amd64 \
  34. DOCKER_BUILD_ARGS="${DOCKER_BUILD_ARGS} --build-arg TARGETARCH=amd64 --build-arg TARGETOS=linux"
  35. mkdir -p $(E2E_ARTIFACT_DIR)
  36. docker save -o $(E2E_ARTIFACT_DIR)/eso.tar $(OCI_IMAGE_NAME):$(VERSION)
  37. docker save -o $(E2E_ARTIFACT_DIR)/e2e.tar $(E2E_IMAGE_NAME):$(VERSION)
  38. test.run: ## Load prebuilt image tarballs into kind and run the e2e suite
  39. kind load image-archive --name="external-secrets" $(E2E_ARTIFACT_DIR)/eso.tar
  40. kind load image-archive --name="external-secrets" $(E2E_ARTIFACT_DIR)/e2e.tar
  41. ./run.sh
  42. # Runs against the current kube context, which is not ours to leave dirty.
  43. # override beats both an inherited and a command-line value.
  44. test.managed: override E2E_SKIP_GLOBAL_TEARDOWN =
  45. test.managed: e2e-image ## Run e2e tests against current kube context
  46. $(MAKE) -C ../ docker.build \
  47. VERSION=$(VERSION) \
  48. ARCH=amd64 \
  49. DOCKER_BUILD_ARGS="${DOCKER_BUILD_ARGS} --build-arg TARGETARCH=amd64 --build-arg TARGETOS=linux"
  50. $(MAKE) -C ../ docker.build \
  51. IMAGE_NAME=$(OCI_IMAGE_NAME) \
  52. VERSION=$(VERSION) \
  53. ARCH=amd64 \
  54. DOCKER_BUILD_ARGS="${DOCKER_BUILD_ARGS} --build-arg TARGETARCH=amd64 --build-arg TARGETOS=linux"
  55. $(MAKE) -C ../ docker.push \
  56. VERSION=$(VERSION)
  57. $(MAKE) -C ../ docker.push \
  58. IMAGE_NAME=$(OCI_IMAGE_NAME) \
  59. VERSION=$(VERSION)
  60. $(MAKE) -C ../ docker.push \
  61. IMAGE_NAME=$(E2E_IMAGE_NAME) \
  62. VERSION=$(VERSION)
  63. ./run.sh
  64. matrix.check: ## Validate matrix.yaml (coverage, secret scoping consistency)
  65. ./matrix.py check
  66. matrix.plan: ## Show the credential env vars each enabled e2e leg receives
  67. ./matrix.py plan
  68. e2e-bin: install-ginkgo
  69. CGO_ENABLED=0 GOOS=linux GOARCH=amd64 ginkgo build ./suites/...
  70. e2e-image: e2e-bin
  71. -rm -rf ./k8s/deploy
  72. mkdir -p k8s
  73. $(MAKE) -C ../ helm.generate
  74. cp -r ../deploy ./k8s
  75. docker build $(DOCKER_BUILD_ARGS) -t $(E2E_IMAGE_NAME):$(VERSION) -f Dockerfile ..
  76. GINKGO_VERSION := $(shell grep 'github.com/onsi/ginkgo/v2' go.mod | awk '{print $$2}')
  77. install-ginkgo:
  78. @echo "Installing ginkgo version $(GINKGO_VERSION) from go.mod"
  79. go install github.com/onsi/ginkgo/v2/ginkgo@$(GINKGO_VERSION)
  80. help: ## displays this help message
  81. @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_\/-]+:.*?## / {printf "\033[34m%-18s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | \
  82. sort | \
  83. grep -v '#'