From 75e870032473256316ba546accda512f7c32872a Mon Sep 17 00:00:00 2001 From: gitbluf Date: Wed, 9 Aug 2023 17:56:35 +0200 Subject: [PATCH] Add: pull-request workflow + e2e --- .github/workflows/pull_request.yaml | 28 +++++ Brewfile | 10 ++ Brewfile.lock.json | 159 ++++++++++++++++++++++++++++ Makefile | 30 +++++- test/kind.yaml | 4 + 5 files changed, 230 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/pull_request.yaml create mode 100644 Brewfile create mode 100644 Brewfile.lock.json create mode 100644 test/kind.yaml diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml new file mode 100644 index 0000000..04d3a71 --- /dev/null +++ b/.github/workflows/pull_request.yaml @@ -0,0 +1,28 @@ +name: E2e Tenant Module + +on: + workflow_dispatch: + pull_request: + push: + branches: + - main + +permissions: + contents: read + +jobs: + e2e: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up Homebrew + uses: Homebrew/actions/setup-homebrew@master + - name: Install cli tools + run: make tools + - name: Run CUE test + run: make test + - name: Create cluster with kind + run: make kind + - name: Deploy tenant + run: make apply diff --git a/Brewfile b/Brewfile new file mode 100644 index 0000000..1277ce4 --- /dev/null +++ b/Brewfile @@ -0,0 +1,10 @@ +# CUE +brew "cue" + +# Kubernetes +brew "kubectl" +brew "kind" + +# Timoni +tap "stefanprodan/tap" +brew "stefanprodan/tap/timoni" diff --git a/Brewfile.lock.json b/Brewfile.lock.json new file mode 100644 index 0000000..d43b31b --- /dev/null +++ b/Brewfile.lock.json @@ -0,0 +1,159 @@ +{ + "entries": { + "brew": { + "cue": { + "version": "0.5.0", + "bottle": { + "rebuild": 0, + "root_url": "https://ghcr.io/v2/homebrew/core", + "files": { + "arm64_ventura": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/cue/blobs/sha256:eef48b4d922c2870039fa0d42ac12072837c81a23f4fa39b12dbdb76e7d30745", + "sha256": "eef48b4d922c2870039fa0d42ac12072837c81a23f4fa39b12dbdb76e7d30745" + }, + "arm64_monterey": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/cue/blobs/sha256:eef48b4d922c2870039fa0d42ac12072837c81a23f4fa39b12dbdb76e7d30745", + "sha256": "eef48b4d922c2870039fa0d42ac12072837c81a23f4fa39b12dbdb76e7d30745" + }, + "arm64_big_sur": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/cue/blobs/sha256:eef48b4d922c2870039fa0d42ac12072837c81a23f4fa39b12dbdb76e7d30745", + "sha256": "eef48b4d922c2870039fa0d42ac12072837c81a23f4fa39b12dbdb76e7d30745" + }, + "ventura": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/cue/blobs/sha256:b93d2c673947508bbf016d34643587317eac120ca432ae22500179478ec4f0f9", + "sha256": "b93d2c673947508bbf016d34643587317eac120ca432ae22500179478ec4f0f9" + }, + "monterey": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/cue/blobs/sha256:b93d2c673947508bbf016d34643587317eac120ca432ae22500179478ec4f0f9", + "sha256": "b93d2c673947508bbf016d34643587317eac120ca432ae22500179478ec4f0f9" + }, + "big_sur": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/cue/blobs/sha256:b93d2c673947508bbf016d34643587317eac120ca432ae22500179478ec4f0f9", + "sha256": "b93d2c673947508bbf016d34643587317eac120ca432ae22500179478ec4f0f9" + }, + "x86_64_linux": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/cue/blobs/sha256:b8192d638e8f9bef5ae570ead1f2bffa26146d889a7eb4d2e83b1ed6348d775b", + "sha256": "b8192d638e8f9bef5ae570ead1f2bffa26146d889a7eb4d2e83b1ed6348d775b" + } + } + } + }, + "kubectl": { + "version": "1.27.4", + "bottle": { + "rebuild": 0, + "root_url": "https://ghcr.io/v2/homebrew/core", + "files": { + "arm64_ventura": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/kubernetes-cli/blobs/sha256:9f9e22602963585f9415691fd23c5603d194b9e4cdfb9187e8b38a451aeb9a67", + "sha256": "9f9e22602963585f9415691fd23c5603d194b9e4cdfb9187e8b38a451aeb9a67" + }, + "arm64_monterey": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/kubernetes-cli/blobs/sha256:922f33e2f38e660e8e8a36188bfefb42682e3883df306e625dc3f990d8b08daf", + "sha256": "922f33e2f38e660e8e8a36188bfefb42682e3883df306e625dc3f990d8b08daf" + }, + "arm64_big_sur": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/kubernetes-cli/blobs/sha256:020a9b8763cf2864ff28f5f92d8380f9a3809cb30431ab8a36aef4c3a85e2a19", + "sha256": "020a9b8763cf2864ff28f5f92d8380f9a3809cb30431ab8a36aef4c3a85e2a19" + }, + "ventura": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/kubernetes-cli/blobs/sha256:edc6ced447d957b366526978d201d962aba11bb2555cfa160012eb56d15c13e5", + "sha256": "edc6ced447d957b366526978d201d962aba11bb2555cfa160012eb56d15c13e5" + }, + "monterey": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/kubernetes-cli/blobs/sha256:2c0eb9dccb44d8f636c4f06e823329e8c24b94e88a5f3f2b72fa603e94ba8ad2", + "sha256": "2c0eb9dccb44d8f636c4f06e823329e8c24b94e88a5f3f2b72fa603e94ba8ad2" + }, + "big_sur": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/kubernetes-cli/blobs/sha256:5811cd0ddeee8a0bd155e843b29a65260e4cd3a0fd0a9750acc562f1a60a76ec", + "sha256": "5811cd0ddeee8a0bd155e843b29a65260e4cd3a0fd0a9750acc562f1a60a76ec" + }, + "x86_64_linux": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/kubernetes-cli/blobs/sha256:a9d2d80152b16d4c6438b4f7075e43b3cd3cc5b03bf5ff1d76abb0b2b766c730", + "sha256": "a9d2d80152b16d4c6438b4f7075e43b3cd3cc5b03bf5ff1d76abb0b2b766c730" + } + } + } + }, + "kind": { + "version": "0.20.0", + "bottle": { + "rebuild": 0, + "root_url": "https://ghcr.io/v2/homebrew/core", + "files": { + "arm64_ventura": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/kind/blobs/sha256:2f2e8574b476dd2d7390de002bf8ff24c2135f83dd273cebd4e8a52c93d212db", + "sha256": "2f2e8574b476dd2d7390de002bf8ff24c2135f83dd273cebd4e8a52c93d212db" + }, + "arm64_monterey": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/kind/blobs/sha256:2f2e8574b476dd2d7390de002bf8ff24c2135f83dd273cebd4e8a52c93d212db", + "sha256": "2f2e8574b476dd2d7390de002bf8ff24c2135f83dd273cebd4e8a52c93d212db" + }, + "arm64_big_sur": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/kind/blobs/sha256:2f2e8574b476dd2d7390de002bf8ff24c2135f83dd273cebd4e8a52c93d212db", + "sha256": "2f2e8574b476dd2d7390de002bf8ff24c2135f83dd273cebd4e8a52c93d212db" + }, + "ventura": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/kind/blobs/sha256:c008b4119ddbf085efee3a446f9a882b5612bf833f8970ac7a91820c51737a82", + "sha256": "c008b4119ddbf085efee3a446f9a882b5612bf833f8970ac7a91820c51737a82" + }, + "monterey": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/kind/blobs/sha256:c008b4119ddbf085efee3a446f9a882b5612bf833f8970ac7a91820c51737a82", + "sha256": "c008b4119ddbf085efee3a446f9a882b5612bf833f8970ac7a91820c51737a82" + }, + "big_sur": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/kind/blobs/sha256:c008b4119ddbf085efee3a446f9a882b5612bf833f8970ac7a91820c51737a82", + "sha256": "c008b4119ddbf085efee3a446f9a882b5612bf833f8970ac7a91820c51737a82" + }, + "x86_64_linux": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/kind/blobs/sha256:50ca9034652e3b16335dc18f5262d9e6e2ecc29fa27207d12ec005a0b5b894b2", + "sha256": "50ca9034652e3b16335dc18f5262d9e6e2ecc29fa27207d12ec005a0b5b894b2" + } + } + } + }, + "stefanprodan/tap/timoni": { + "version": "0.11.0", + "bottle": false + } + }, + "tap": { + "stefanprodan/tap": { + "revision": "dca951d44ace59645985d48dd39dc01d73da8380" + } + } + }, + "system": { + "macos": { + "ventura": { + "HOMEBREW_VERSION": "4.1.1", + "HOMEBREW_PREFIX": "/opt/homebrew", + "Homebrew/homebrew-core": "api", + "CLT": "14.3.0.0.1.1679647830", + "Xcode": "14.3.1", + "macOS": "13.5" + } + } + } +} diff --git a/Makefile b/Makefile index 3cfdc35..563ddbf 100644 --- a/Makefile +++ b/Makefile @@ -6,18 +6,46 @@ DEFAULT=help MODULE=tenant -.PHONY: help test build push +.PHONY: help test build push tools help: ## Display this help @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) +tools: ## Install cue, kind, Timoni + brew bundle + +get: ## Update Kubernetes API CUE definitions + @go mod init + @go get -u k8s.io/api/... + @go get -u k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1 + @cue get go k8s.io/api/core/v1 + @cue get go k8s.io/api/apps/v1 + @cue get go k8s.io/api/rbac/v1 + @cue get go k8s.io/apimachinery/pkg/apis/meta/v1 + @cue get go k8s.io/apimachinery/pkg/runtime + @cue get go k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1 + @rm go.mod go.sum + +vet: ## Format and vet all CUE definitions + @cue fmt ./... && cue vet --all-errors --concrete ./... + test: ## Build with test_tool.cue + test_values.cue @cue -t test build . +gen: vet ## Print the CUE generated objects + @cd modules/flux-aio + @cue gen + +kind: ## Create kind cluster + @kind create cluster --config ./test/kind.yaml build: ## Build with timoni with ns+name provided as arg/flag @timoni build -n testing test . +apply: ## Apply the module with default values + @kubectl create ns test + @timoni apply -n test test-tenant ./ --timeout=1m + push: ## Push the module with timoni @timoni mod push . \ oci://ghcr.io/${OWNER}/cue-modules/$(MODULE) \ diff --git a/test/kind.yaml b/test/kind.yaml new file mode 100644 index 0000000..e4b6ef9 --- /dev/null +++ b/test/kind.yaml @@ -0,0 +1,4 @@ +--- +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +name: test-cluster