From be6fdd18dbcf125f79948cf23fa723fb483f4c81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Ma=C5=82ek?= Date: Mon, 13 May 2024 11:31:03 +0200 Subject: [PATCH] ci: test samples on CI --- .github/workflows/tests.yaml | 42 +++++++++++++++++++++++++----------- Makefile | 15 +++++++++++++ 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 8177fd7c6..a76573ce6 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -25,8 +25,6 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Setup go uses: actions/setup-go@v5 @@ -70,13 +68,40 @@ jobs: max_attempts: 3 command: make verify.generators - install-with-kustomize: + samples: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 + + - name: Setup go + uses: actions/setup-go@v5 with: - fetch-depth: 0 + go-version-file: go.mod + + - name: Create k8s KinD Cluster + uses: helm/kind-action@v1.10.0 + + - uses: jdx/mise-action@v2 + with: + install: false + + # We use install.all to install all CRDs and resources also the ones that are not bundled + # in base kustomization (e.g. currently AIGateway) but which have samples defined. + - name: Verify installing CRDs via kustomize works + run: make install.all + + - name: Install and delete each sample one by one + run: make test.samples + + - name: Verify that uninstalling operator CRDs via kustomize works + run: make uninstall.all + + install-with-kustomize: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 - name: Setup go uses: actions/setup-go@v5 @@ -122,8 +147,6 @@ jobs: steps: - name: checkout repository uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: setup golang uses: actions/setup-go@v5 @@ -198,8 +221,6 @@ jobs: steps: - name: checkout repository uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: setup golang uses: actions/setup-go@v5 @@ -251,8 +272,6 @@ jobs: steps: - name: checkout repository uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: setup golang uses: actions/setup-go@v5 @@ -400,8 +419,6 @@ jobs: - name: checkout repository uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: download tests report id: download-coverage @@ -431,6 +448,7 @@ jobs: - install-with-kustomize - build - unit-tests + - samples # - conformance-tests - integration-tests - integration-tests-bluegreen diff --git a/Makefile b/Makefile index a649f710b..d34a03fde 100644 --- a/Makefile +++ b/Makefile @@ -372,6 +372,10 @@ test.conformance: KGO_RELEASE=$(TAG) GOTESTFLAGS="$(GOTESTFLAGS)" +.PHONY: test.samples +test.samples: kustomize + find ./config/samples -not -name "kustomization.*" -type f | xargs -I{} bash -c "kubectl apply -f {}; kubectl delete -f {}" + # ------------------------------------------------------------------------------ # Gateway API # ------------------------------------------------------------------------------ @@ -492,12 +496,23 @@ debug.skaffold.continuous: _ensure-kong-system-namespace install: manifests kustomize install-gateway-api-crds $(KUSTOMIZE) build config/crd | kubectl apply --server-side -f - +# Install standard and experimental CRDs into the K8s cluster specified in ~/.kube/config. +.PHONY: install.all +install.all: manifests kustomize install-gateway-api-crds + kubectl apply --server-side -f $(PROJECT_DIR)/config/crd/bases/ + # Uninstall CRDs from the K8s cluster specified in ~/.kube/config. # Call with ignore-not-found=true to ignore resource not found errors during deletion. .PHONY: uninstall uninstall: manifests kustomize uninstall-gateway-api-crds $(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f - +# Uninstall standard and experimental CRDs from the K8s cluster specified in ~/.kube/config. +# Call with ignore-not-found=true to ignore resource not found errors during deletion. +.PHONY: uninstall.all +uninstall.all: manifests kustomize uninstall-gateway-api-crds + kubectl delete --ignore-not-found=$(ignore-not-found) -f $(PROJECT_DIR)/config/crd/bases/ + # Deploy controller to the K8s cluster specified in ~/.kube/config. # This will wait for operator's Deployment to get Available. # This uses a temporary directory becuase "kustomize edit set image" would introduce