Makefile 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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:
  69. GOWORK=off CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go tool 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. help: ## displays this help message
  77. @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_\/-]+:.*?## / {printf "\033[34m%-18s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | \
  78. sort | \
  79. grep -v '#'