From 2bffecdb7bbcf90e0ddac154518b7b5a0acf4447 Mon Sep 17 00:00:00 2001 From: Richard Kovacs Date: Wed, 31 Jan 2024 06:43:20 +0100 Subject: [PATCH] Use Tilt for provisioning on CI --- .github/workflows/build_test_ci.yml | 11 +++++++++-- .husky/hooks/pre-push | 2 +- .tilt/ctlptl-config.yaml | 1 + Makefile | 14 ++++++-------- Tiltfile | 6 +++--- e2e/kuttl-config.yaml | 9 --------- 6 files changed, 20 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build_test_ci.yml b/.github/workflows/build_test_ci.yml index 2f3046410..ffb633ddf 100644 --- a/.github/workflows/build_test_ci.yml +++ b/.github/workflows/build_test_ci.yml @@ -132,12 +132,19 @@ jobs: - name: E2E test run: make e2etest + env: + GITHUB_TOKEN: ${{ secrets.github_token }} + LINODE_TOKEN: ${{ secrets.LINODE_TOKEN }} + + - name: Copy logs + if: ${{ always() }} + run: docker cp tilt-control-plane:/var/log .logs - uses: actions/upload-artifact@v4 if: ${{ always() }} with: - name: kind-logs - path: .kind/kind-logs-* + name: logs + path: .logs/* docker-build: runs-on: ubuntu-latest diff --git a/.husky/hooks/pre-push b/.husky/hooks/pre-push index b6d65f136..49e0f6034 100755 --- a/.husky/hooks/pre-push +++ b/.husky/hooks/pre-push @@ -13,7 +13,7 @@ if git status --short | grep -qv "??"; then trap unstash EXIT fi -make generate manifests _setImage +make generate manifests git diff --exit-code --quiet || (git status && exit 1) make lint gosec nilcheck test diff --git a/.tilt/ctlptl-config.yaml b/.tilt/ctlptl-config.yaml index bef997e59..75b0354ed 100644 --- a/.tilt/ctlptl-config.yaml +++ b/.tilt/ctlptl-config.yaml @@ -2,6 +2,7 @@ apiVersion: ctlptl.dev/v1alpha1 kind: Cluster product: kind +registry: ctlptl-registry kindV1Alpha4Cluster: name: tilt nodes: diff --git a/Makefile b/Makefile index 43946e6cc..702e969b5 100644 --- a/Makefile +++ b/Makefile @@ -89,11 +89,11 @@ test: manifests generate fmt vet envtest ## Run tests. KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test -race -timeout 60s ./... -coverprofile cover.out .PHONY: e2etest -e2etest: kind kuttl kustomize clusterctl manifests generate docker-build +e2etest: kind ctlptl tilt kuttl kustomize clusterctl manifests generate @echo -n "LINODE_TOKEN=$(LINODE_TOKEN)" > config/default/.env.linode - @$(CONTAINER_TOOL) tag ${IMG} capli-controller:e2e - IMG=capli-controller:e2e $(KUTTL) test --config e2e/kuttl-config.yaml - make _setImage + $(CTLPTL) apply -f .tilt/ctlptl-config.yaml + $(TILT) ci --timeout 180s -f Tiltfile + $(KUTTL) test --config e2e/kuttl-config.yaml ##@ Build @@ -147,11 +147,9 @@ install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~ uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion. $(KUSTOMIZE) build config/crd | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f - -_setImage: kustomize - cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} - .PHONY: deploy -deploy: manifests kustomize _setImage ## Deploy controller to the K8s cluster specified in ~/.kube/config. +deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config. + cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} $(KUSTOMIZE) build config/default | $(KUBECTL) apply -f - .PHONY: undeploy diff --git a/Tiltfile b/Tiltfile index 4cec7014f..d67d27d0a 100644 --- a/Tiltfile +++ b/Tiltfile @@ -1,8 +1,8 @@ -docker_build("controller", ".", only=("vendor","go.mod", "go.sum", "./api", "./cloud","./cmd", "./controller", "./util")) +docker_build("controller", ".", only=("Dockerfile", "Makefile", "vendor","go.mod", "go.sum", "./api", "./cloud","./cmd", "./controller", "./util")) local_resource( - 'capi-controller-manager', - cmd='clusterctl init', + 'capi-controller-manager', + cmd='clusterctl init', ) k8s_yaml(kustomize('config/default')) diff --git a/e2e/kuttl-config.yaml b/e2e/kuttl-config.yaml index f9ddb49a7..b06687408 100644 --- a/e2e/kuttl-config.yaml +++ b/e2e/kuttl-config.yaml @@ -3,13 +3,4 @@ kind: TestSuite testDirs: - e2e/basic kindConfig: e2e/kind-config.yaml -kindContext: kuttl -startKIND: true -kindNodeCache: true -kindContainers: -- capli-controller:e2e -artifactsDir: .kind timeout: 120 -commands: - - command: clusterctl init - - command: make deploy