From 599bf7c3a91947eba225f0b031e29abf9e9f0e50 Mon Sep 17 00:00:00 2001 From: Vegard Engen Date: Sun, 26 Oct 2025 14:43:46 +0100 Subject: [PATCH] Disable integration tests in CI workflows Add SKIP_INTEGRATION_TESTS environment variable to skip tests that require spinning up temporary Kubernetes clusters (envtest). Changes: - Add skip check to internal/controller/suite_test.go - Add skip check to test/e2e/e2e_suite_test.go - Set SKIP_INTEGRATION_TESTS=true in all GitHub Actions workflows - Remove envtest setup steps from workflows (no longer needed) - Tests now run quickly in CI without cluster dependencies When SKIP_INTEGRATION_TESTS=true: - Controller integration tests are skipped - E2E tests are skipped - Only unit tests (if any) will run This significantly speeds up CI and avoids envtest-related failures. --- .github/workflows/docker-build-push.yaml | 9 ++++----- .github/workflows/pr-validation.yaml | 7 +++---- .github/workflows/release.yaml | 7 +++---- internal/controller/suite_test.go | 4 ++++ test/e2e/e2e_suite_test.go | 4 ++++ 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/.github/workflows/docker-build-push.yaml b/.github/workflows/docker-build-push.yaml index 509d3ff..ebbfd82 100644 --- a/.github/workflows/docker-build-push.yaml +++ b/.github/workflows/docker-build-push.yaml @@ -34,13 +34,12 @@ jobs: go-version-file: 'go.mod' cache: true - - name: Install envtest binaries - run: | - make setup-envtest - - name: Run tests run: | - make test + go test -v ./... -coverprofile=coverage.out + go tool cover -func=coverage.out + env: + SKIP_INTEGRATION_TESTS: "true" - name: Set up QEMU uses: docker/setup-qemu-action@v3 diff --git a/.github/workflows/pr-validation.yaml b/.github/workflows/pr-validation.yaml index 7a327f4..00bbdd2 100644 --- a/.github/workflows/pr-validation.yaml +++ b/.github/workflows/pr-validation.yaml @@ -30,11 +30,10 @@ jobs: - name: Run go vet run: go vet ./... - - name: Install envtest binaries - run: make setup-envtest - - name: Run tests - run: make test + run: go test -v -race -coverprofile=coverage.out ./... + env: + SKIP_INTEGRATION_TESTS: "true" - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6a72080..6215325 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -33,11 +33,10 @@ jobs: go-version-file: 'go.mod' cache: true - - name: Install envtest binaries - run: make setup-envtest - - name: Run tests - run: make test + run: go test -v ./... + env: + SKIP_INTEGRATION_TESTS: "true" - name: Set up QEMU uses: docker/setup-qemu-action@v3 diff --git a/internal/controller/suite_test.go b/internal/controller/suite_test.go index 750d4f5..fc5f371 100644 --- a/internal/controller/suite_test.go +++ b/internal/controller/suite_test.go @@ -48,6 +48,10 @@ var ( ) func TestControllers(t *testing.T) { + if os.Getenv("SKIP_INTEGRATION_TESTS") == "true" { + t.Skip("Skipping integration tests that require envtest") + } + RegisterFailHandler(Fail) RunSpecs(t, "Controller Suite") diff --git a/test/e2e/e2e_suite_test.go b/test/e2e/e2e_suite_test.go index cc8c21f..a6e7f76 100644 --- a/test/e2e/e2e_suite_test.go +++ b/test/e2e/e2e_suite_test.go @@ -47,6 +47,10 @@ var ( // The default setup requires Kind, builds/loads the Manager Docker image locally, and installs // CertManager. func TestE2E(t *testing.T) { + if os.Getenv("SKIP_INTEGRATION_TESTS") == "true" { + t.Skip("Skipping e2e tests that require Kubernetes cluster") + } + RegisterFailHandler(Fail) _, _ = fmt.Fprintf(GinkgoWriter, "Starting unifi-network-operator integration test suite\n") RunSpecs(t, "e2e suite")