diff --git a/.github/workflows/test-suite.yaml b/.github/workflows/test-suite.yaml new file mode 100644 index 0000000..9024cd0 --- /dev/null +++ b/.github/workflows/test-suite.yaml @@ -0,0 +1,53 @@ +name: Lagoon tests + +on: pull_request + +jobs: + # runs for lagoon-core, lagoon-remote, lagoon-test + test-suite: + runs-on: ubuntu-latest + strategy: + fail-fast: false + + steps: + # Continue after getting a shell via: `touch continue` + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + timeout-minutes: 1 + continue-on-error: true + + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: "0" + + - name: Configure kind network + run: | + docker network create kind + + - name: Create kind cluster + uses: helm/kind-action@v1.9.0 + with: + version: v0.22.0 + node_image: kindest/node:v1.28.7@sha256:9bc6c451a289cf96ad0bbaf33d416901de6fd632415b076ab05f5fa7e4f65c58 + kubectl_version: v1.28.7 + cluster_name: kind + config: kind-config.yaml + + - name: Install gojq + run: | + cd /tmp + curl -sSLO https://github.com/itchyny/gojq/releases/download/v0.12.13/gojq_v0.12.13_linux_amd64.tar.gz + tar -xf ./gojq_v0.12.13_linux_amd64.tar.gz + sudo cp /tmp/gojq_v0.12.13_linux_amd64/gojq /usr/local/bin/jq + + - name: Install kubens and kubectl alias + run: | + cd /tmp + curl -sSLO https://github.com/ahmetb/kubectx/releases/download/v0.9.5/kubens_v0.9.5_linux_x86_64.tar.gz + tar -xf ./kubens_v0.9.5_linux_x86_64.tar.gz + sudo cp /tmp/kubens /usr/local/bin/kubens + sudo ln -s $(which kubectl) /usr/local/bin/kc + + - name: Run github/test-e2e + run: make github/test-e2e diff --git a/Makefile b/Makefile index 79934b0..18b6bfa 100644 --- a/Makefile +++ b/Makefile @@ -64,9 +64,23 @@ vet: ## Run go vet against code. test: manifests generate fmt vet envtest ## Run tests. KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test $$(go list ./... | grep -v /e2e) -coverprofile cover.out +.PHONY: create-kind-cluster +create-kind-cluster: + docker network inspect kind >/dev/null || docker network create kind + kind create cluster --wait=60s --config=kind-config.yaml + +.PHONY: delete-kind-cluster +delete-kind-cluster: + kind delete cluster --name=kind + docker network rm kind + # Utilize Kind or modify the e2e tests to load the image locally, enabling compatibility with other vendors. -.PHONY: test-e2e # Run the e2e tests against a Kind k8s instance that is spun up. -test-e2e: +.PHONY: github/test-e2e # Run the e2e tests against a Kind k8s instance that is spun up inside github action. +github/test-e2e: + go test ./test/e2e/ -v -ginkgo.v + +.PHONY: local-kind/test-e2e # Run the e2e tests against a Kind k8s instance that is spun up locally +local-kind/test-e2e: create-kind-cluster kind export kubeconfig --name=kind go test ./test/e2e/ -v -ginkgo.v @@ -201,4 +215,4 @@ echo "Downloading $${package}" ;\ GOBIN=$(LOCALBIN) go install $${package} ;\ mv "$$(echo "$(1)" | sed "s/-$(3)$$//")" $(1) ;\ } -endef +endef \ No newline at end of file diff --git a/kind-config.yaml b/kind-config.yaml index 45dc76c..752e993 100644 --- a/kind-config.yaml +++ b/kind-config.yaml @@ -1,8 +1,6 @@ kind: Cluster apiVersion: kind.x-k8s.io/v1alpha4 -name: dbaas-controller-cluster nodes: - role: control-plane - role: worker - role: worker -image: kindest/node:v1.29.2 \ No newline at end of file