diff --git a/.circleci/config.yml b/.circleci/config.yml index 3dce5ab7a..f3fae42f6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,71 +1,17 @@ version: 2.1 -orbs: - slack: circleci/slack@4.1 -executors: - golang-executor: - docker: - - image: gcr.io/gcr-for-testing/golang:1.20.8 +orbs: + path-filtering: circleci/path-filtering@1.0.0 -jobs: - check-code: - executor: golang-executor - steps: - - setup_remote_docker: - docker_layer_caching: true - - checkout - - run: - name: Install deps - command: | - if [ -z "$CIRCLE_PULL_REQUEST" ]; then - make vendor - make tools-min - exit 0 - fi - apt-get update - apt-get install -y unzip - make init - - run: - name: License check - command: | - if [ -z "$CIRCLE_PULL_REQUEST" ]; then - echo "This is not a pull request. Skipping..." - exit 0 - fi - make license-verify license-range-verify - - run: make fmt-verify - - run: make linter - - run: - name: Unit tests - command: | - if [ -z "$CIRCLE_PULL_REQUEST" ]; then - echo "This is not a pull request. Skipping..." - exit 0 - fi - make run-unit-tests - - run: - name: make bin - command: | - if [ -z "$CIRCLE_PULL_REQUEST" ]; then - echo "This is not a pull request. Skipping..." - exit 0 - fi - make bin - - run: - name: vulncheck - command: | - if [ -z "$CIRCLE_PULL_REQUEST" ]; then - echo "This is not a pull request. Skipping..." - exit 0 - fi - make vulncheck - environment: - GO111MODULES: off +setup: true workflows: - version: 2 - - # Default workflow - run_tests: + always-run: jobs: - - check-code + - path-filtering/filter: + name: check-updated-files + base-revision: master + config-path: .circleci/continue_config.yml + mapping: | + manifests/.* manifests-verify true + chart/.* manifests-verify true diff --git a/.circleci/continue_config.yml b/.circleci/continue_config.yml new file mode 100644 index 000000000..925975768 --- /dev/null +++ b/.circleci/continue_config.yml @@ -0,0 +1,118 @@ +version: 2.1 +orbs: + slack: circleci/slack@4.1 + +parameters: + manifests-verify: + type: boolean + default: false + minikube-version: + type: string + default: v1.31.2 + helm-version: + type: string + default: v3.13.0 + +executors: + golang-executor: + docker: + - image: gcr.io/gcr-for-testing/golang:1.20.8 + machine-executor: + machine: + image: ubuntu-2204:current + docker_layer_caching: true + +jobs: + check-code: + executor: golang-executor + steps: + - setup_remote_docker: + docker_layer_caching: true + - checkout + - run: + name: Install deps + command: | + if [ -z "$CIRCLE_PULL_REQUEST" ]; then + make vendor + make tools-min + exit 0 + fi + apt-get update + apt-get install -y unzip + make init + - run: + name: License check + command: | + if [ -z "$CIRCLE_PULL_REQUEST" ]; then + echo "This is not a pull request. Skipping..." + exit 0 + fi + make license-verify license-range-verify + - run: make fmt-verify + - run: make linter + - run: + name: Unit tests + command: | + if [ -z "$CIRCLE_PULL_REQUEST" ]; then + echo "This is not a pull request. Skipping..." + exit 0 + fi + make run-unit-tests + - run: + name: make bin + command: | + if [ -z "$CIRCLE_PULL_REQUEST" ]; then + echo "This is not a pull request. Skipping..." + exit 0 + fi + make bin + - run: + name: vulncheck + command: | + if [ -z "$CIRCLE_PULL_REQUEST" ]; then + echo "This is not a pull request. Skipping..." + exit 0 + fi + make vulncheck + environment: + GO111MODULES: off + + manifests_verify: + executor: machine-executor + steps: + - checkout + - run: + name: Install Kubectl Executable + command: |- + curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" && + chmod +x kubectl && + sudo mv kubectl /usr/local/bin/ + mkdir -p ${HOME}/.kube && touch ${HOME}/.kube/config + - run: + name: Install Minikube Executable + command: |- + curl -Lo minikube https://github.com/kubernetes/minikube/releases/download/<< pipeline.parameters.minikube-version >>/minikube-linux-amd64 && + chmod +x minikube && + sudo mv minikube /usr/local/bin/ + - run: + name: Install Helm Service + command: |- + export DESIRED_VERSION=<< pipeline.parameters.helm-version >> + curl https://raw.githubusercontent.com/helm/helm/master/scripts/get | bash + - run: + command: make manifests + - run: + command: make manifests-verify + +workflows: + version: 2 + + run_tests: + jobs: + - check-code + + manifests-verify: + when: + equal: [ true, << pipeline.parameters.manifests-verify >> ] + jobs: + - manifests_verify \ No newline at end of file diff --git a/.gitignore b/.gitignore index 7ca7cd613..72c603532 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,5 @@ deps/ enterprise.mk license-header.enterprise.txt local/ +kustomize_test/ tools/codegen/boilerplate.go.txt \ No newline at end of file diff --git a/Makefile b/Makefile index 602a8c828..68fe78550 100644 --- a/Makefile +++ b/Makefile @@ -71,7 +71,7 @@ UPPER_ENV = $(shell echo '$1' | tr '[:lower:]' '[:upper:]' | tr -d '-') .PHONY: helm helm: ifeq ($(HELM),) - $(error Before templating you need to install helm in PATH or export helm binary using "export HELM=") + $(error "Before templating you need to install helm in PATH or export helm binary using 'export HELM='") endif HELM_OPTIONS = --set "operator.image=$(OPERATORIMAGE)" \ @@ -538,6 +538,78 @@ chart-operator: helm manifests: chart-operator +.PHONY: manifests-verify +manifests-verify: + $(MAKE) manifest-verify-plain-ce + $(MAKE) manifest-verify-plain-ee + $(MAKE) manifest-verify-kustomize-ce + $(MAKE) manifest-verify-kustomize-ee + $(MAKE) manifest-verify-helm-ce + $(MAKE) manifest-verify-helm-ee + +manifests-verify-env-reset: + @minikube delete && minikube start + +manifest-verify-plain-ce: manifests-verify-env-reset + @echo "Trying to install via plain manifests" + kubectl apply -f ./manifests/arango-all.yaml + kubectl apply -f ./manifests/arango-apps.yaml + kubectl apply -f ./manifests/arango-backup.yaml + kubectl apply -f ./manifests/arango-crd.yaml + kubectl apply -f ./manifests/arango-deployment.yaml + kubectl apply -f ./manifests/arango-deployment-replication.yaml + kubectl apply -f ./manifests/arango-k2kclustersync.yaml + kubectl apply -f ./manifests/arango-storage.yaml + +manifest-verify-plain-ee: manifests-verify-env-reset + kubectl apply -f ./manifests/enterprise-all.yaml + kubectl apply -f ./manifests/enterprise-apps.yaml + kubectl apply -f ./manifests/enterprise-backup.yaml + kubectl apply -f ./manifests/enterprise-crd.yaml + kubectl apply -f ./manifests/enterprise-deployment.yaml + kubectl apply -f ./manifests/enterprise-deployment-replication.yaml + kubectl apply -f ./manifests/enterprise-k2kclustersync.yaml + kubectl apply -f ./manifests/enterprise-storage.yaml + +define KUSTOMIZE_YAML = +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./all + - ./apps + - ./backup + - ./crd + - ./deployment + - ./deployment-replication + - ./k2kclustersync +endef +export KUSTOMIZE_YAML + +manifest-verify-kustomize-ce: manifests-verify-env-reset + @echo "Trying to install via Kustomize" + @-rm -rf ./kustomize_test + @cp -r ./manifests/kustomize ./kustomize_test + @echo "$$KUSTOMIZE_YAML" > ./kustomize_test/kustomization.yaml + @kubectl create -k ./kustomize_test/ + +manifest-verify-kustomize-ee: manifests-verify-env-reset + @echo "Trying to install via Kustomize" + @-rm -rf ./kustomize_test + @cp -r ./manifests/kustomize-enterprise ./kustomize_test + @echo "$$KUSTOMIZE_YAML" > ./kustomize_test/kustomization.yaml + @kubectl create -k ./kustomize_test/ + +manifest-verify-helm-ce: manifests-verify-env-reset + @echo "Trying to install via Helm charts" + helm install --generate-name --set "operator.features.storage=true" \ + ./bin/charts/kube-arangodb-$(VERSION_MAJOR_MINOR_PATCH).tgz + +manifest-verify-helm-ee: manifests-verify-env-reset + @echo "Trying to install via Helm charts" + helm install --generate-name --set "operator.image=arangodb/kube-arangodb-enterprise:$(VERSION_MAJOR_MINOR_PATCH)" --set "operator.features.storage=true" \ + ./bin/charts/kube-arangodb-$(VERSION_MAJOR_MINOR_PATCH).tgz + + # Testing .PHONY: run-unit-tests diff --git a/manifests/kustomize-enterprise/k2kclustersync/kustomization.yaml b/manifests/kustomize-enterprise/k2kclustersync/kustomization.yaml index e69de29bb..5160054fa 100644 --- a/manifests/kustomize-enterprise/k2kclustersync/kustomization.yaml +++ b/manifests/kustomize-enterprise/k2kclustersync/kustomization.yaml @@ -0,0 +1,4 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - enterprise-k2kclustersync.yaml