mirror of
https://github.com/stakater/Reloader.git
synced 2026-05-19 07:06:38 +00:00
feat: Initial e2e tests and migrate old ones into e2e
This commit is contained in:
61
Makefile
61
Makefile
@@ -14,6 +14,9 @@ DOCKER_IMAGE ?= ghcr.io/stakater/reloader
|
||||
# Default value "dev"
|
||||
VERSION ?= 0.0.1
|
||||
|
||||
# Full image reference (used for docker-build)
|
||||
IMG ?= $(DOCKER_IMAGE):v$(VERSION)
|
||||
|
||||
REPOSITORY_GENERIC = ${DOCKER_IMAGE}:${VERSION}
|
||||
REPOSITORY_ARCH = ${DOCKER_IMAGE}:v${VERSION}-${ARCH}
|
||||
BUILD=
|
||||
@@ -140,7 +143,63 @@ manifest:
|
||||
docker manifest annotate --arch $(ARCH) $(REPOSITORY_GENERIC) $(REPOSITORY_ARCH)
|
||||
|
||||
test:
|
||||
"$(GOCMD)" test -timeout 1800s -v ./...
|
||||
"$(GOCMD)" test -timeout 1800s -v -short ./internal/... ./test/e2e/utils/...
|
||||
|
||||
##@ E2E Tests
|
||||
|
||||
E2E_IMG ?= ghcr.io/stakater/reloader:test
|
||||
E2E_TIMEOUT ?= 45m
|
||||
KIND_CLUSTER ?= kind
|
||||
|
||||
# Detect container runtime (docker or podman)
|
||||
CONTAINER_RUNTIME ?= $(shell command -v docker 2>/dev/null || command -v podman 2>/dev/null)
|
||||
|
||||
.PHONY: e2e-build
|
||||
e2e-build: ## Build container image for e2e testing (uses docker or podman)
|
||||
$(CONTAINER_RUNTIME) build -t $(E2E_IMG) -f Dockerfile .
|
||||
|
||||
.PHONY: e2e-load
|
||||
e2e-load: ## Load e2e image to Kind cluster (handles both docker and podman)
|
||||
ifeq ($(notdir $(CONTAINER_RUNTIME)),podman)
|
||||
@echo "Using podman: loading via image-archive..."
|
||||
$(CONTAINER_RUNTIME) save $(E2E_IMG) -o /tmp/reloader-e2e.tar
|
||||
kind load image-archive /tmp/reloader-e2e.tar --name $(KIND_CLUSTER)
|
||||
rm -f /tmp/reloader-e2e.tar
|
||||
else
|
||||
kind load docker-image $(E2E_IMG) --name $(KIND_CLUSTER)
|
||||
endif
|
||||
|
||||
.PHONY: e2e-setup
|
||||
e2e-setup: e2e-build e2e-load ## Build image and load to Kind (run once before tests)
|
||||
@echo "E2E setup complete. Image $(E2E_IMG) loaded to Kind cluster $(KIND_CLUSTER)"
|
||||
|
||||
.PHONY: e2e-cluster-setup
|
||||
e2e-cluster-setup: ## Setup e2e cluster prerequisites (Argo Rollouts, etc.)
|
||||
./scripts/e2e-cluster-setup.sh
|
||||
|
||||
.PHONY: e2e-cluster-cleanup
|
||||
e2e-cluster-cleanup: ## Cleanup e2e cluster resources (Argo Rollouts, test namespaces, etc.)
|
||||
./scripts/e2e-cluster-cleanup.sh
|
||||
|
||||
.PHONY: e2e
|
||||
e2e: e2e-setup e2e-cluster-setup ## Run all e2e tests (builds image, loads to Kind, sets up cluster, runs tests)
|
||||
SKIP_BUILD=true RELOADER_IMAGE=$(E2E_IMG) "$(GOCMD)" test -v -count=1 -p 1 -timeout $(E2E_TIMEOUT) ./test/e2e/...
|
||||
@echo "E2E tests complete. Run 'make e2e-cluster-cleanup' to cleanup cluster resources."
|
||||
|
||||
.PHONY: e2e-kind-create
|
||||
e2e-kind-create: ## Create Kind cluster for e2e tests
|
||||
kind create cluster --name $(KIND_CLUSTER) || true
|
||||
|
||||
.PHONY: e2e-ci
|
||||
e2e-ci: e2e-kind-create e2e e2e-cluster-cleanup ## Full CI pipeline: create Kind cluster, build, load, run tests, cleanup
|
||||
|
||||
.PHONY: e2e-kind-delete
|
||||
e2e-kind-delete: ## Delete Kind cluster used for e2e tests
|
||||
kind delete cluster --name $(KIND_CLUSTER)
|
||||
|
||||
.PHONY: docker-build
|
||||
docker-build: ## Build Docker image
|
||||
$(CONTAINER_RUNTIME) build -t $(IMG) -f Dockerfile .
|
||||
|
||||
stop:
|
||||
@docker stop "${BINARY}"
|
||||
|
||||
Reference in New Issue
Block a user