From 66171b95ba7ae4a8d4c43fcaf791e04e3660c1e6 Mon Sep 17 00:00:00 2001 From: Zespre Schmidt Date: Mon, 11 Nov 2024 23:36:45 +0800 Subject: [PATCH] ci: add e2e test job Signed-off-by: Zespre Schmidt --- .github/workflows/pull-request.yaml | 5 ++++- Makefile | 20 ++++++++++---------- test/e2e/e2e_suite_test.go | 14 ++------------ 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml index 5042cd3..04c037e 100644 --- a/.github/workflows/pull-request.yaml +++ b/.github/workflows/pull-request.yaml @@ -21,7 +21,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.22' + go-version: '1.23' - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx @@ -61,3 +61,6 @@ jobs: push: false tags: ${{ env.REPO }}/${{ env.AGENT }}:${{ env.VERSION }} labels: ${{ steps.meta.outputs.labels }} + - name: Run end-to-end testing + run: make local-e2e-test + diff --git a/Makefile b/Makefile index 966e681..a9103f5 100644 --- a/Makefile +++ b/Makefile @@ -3,11 +3,19 @@ VERSION ?= $(shell git describe --tags --exact-match 2>/dev/null || echo "$(shell git rev-parse --abbrev-ref HEAD)-head") COMMIT ?= $(shell git rev-parse HEAD) +DIRTY := +ifneq ($(shell git status --porcelain --untracked-files=no),) +DIRTY := -dirty +endif +VERSION := $(VERSION)$(DIRTY) +# Export the tag to be used in the e2e tests +export TAG = $(VERSION) + REPO ?= starbops # Image URL to use all building/pushing image targets -MGR_IMG ?= $(REPO)/virtbmc-controller:$(VERSION) -AGT_IMG ?= $(REPO)/virtbmc:$(VERSION) +MGR_IMG ?= $(REPO)/virtbmc-controller:$(TAG) +AGT_IMG ?= $(REPO)/virtbmc:$(TAG) K8S_VERSION = 1.28.13 KIND_K8S_VERSION = v$(shell echo $(K8S_VERSION)) @@ -95,14 +103,6 @@ golangci-lint: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell dirname $(GOLANGCI_LINT)) $(GOLANGCI_LINT_VERSION) ;\ } -## Decide the image tag based on git state for e2e tests usage -VERSION = $(shell git rev-parse --short HEAD) -DIRTY := -ifneq ($(shell git status --porcelain --untracked-files=no),) - DIRTY := -dirty -endif -export TAG = $(VERSION)$(DIRTY) - .PHONY: e2e-setup e2e-setup: kind ## Setup end-to-end test environment. $(KIND) create cluster --name kvbmc-e2e --config test/e2e/kind-config.yaml --image=kindest/node:$(KIND_K8S_VERSION) diff --git a/test/e2e/e2e_suite_test.go b/test/e2e/e2e_suite_test.go index 5a216aa..88c0a4b 100644 --- a/test/e2e/e2e_suite_test.go +++ b/test/e2e/e2e_suite_test.go @@ -66,18 +66,8 @@ func TestE2E(t *testing.T) { var _ = BeforeSuite(func() { logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))) - By("building the controller-manager image") - cmd := exec.Command("make", "docker-build", fmt.Sprintf("IMG=%s", controllerManagerImage)) - _, err := util.Run(cmd) - Expect(err).ToNot(HaveOccurred()) - - By("building the agent image") - cmd = exec.Command("make", "docker-build-virtbmc", fmt.Sprintf("IMG=%s", agentImage)) - _, err = util.Run(cmd) - Expect(err).ToNot(HaveOccurred()) - By("loading the built images to the Kind cluster") - err = util.LoadImageToKindClusterWithName(controllerManagerImage) + err := util.LoadImageToKindClusterWithName(controllerManagerImage) Expect(err).ToNot(HaveOccurred()) err = util.LoadImageToKindClusterWithName(agentImage) Expect(err).ToNot(HaveOccurred()) @@ -125,7 +115,7 @@ var _ = BeforeSuite(func() { } By("deploying the controller-manager") - cmd = exec.Command("make", "deploy", fmt.Sprintf("IMG=%s", controllerManagerImage)) + cmd := exec.Command("make", "deploy", fmt.Sprintf("IMG=%s", controllerManagerImage)) _, err = util.Run(cmd) Expect(err).ToNot(HaveOccurred()) })