Skip to content

Commit

Permalink
Add CircleCI workflow to verify manifests
Browse files Browse the repository at this point in the history
  • Loading branch information
nikita-vanyasin committed Oct 10, 2023
1 parent 73d56f0 commit 012fce2
Show file tree
Hide file tree
Showing 5 changed files with 207 additions and 66 deletions.
76 changes: 11 additions & 65 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,71 +1,17 @@
version: 2.1
orbs:
slack: circleci/[email protected]

executors:
golang-executor:
docker:
- image: gcr.io/gcr-for-testing/golang:1.20.8
orbs:
path-filtering: circleci/[email protected]

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
118 changes: 118 additions & 0 deletions .circleci/continue_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
version: 2.1
orbs:
slack: circleci/[email protected]

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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ deps/
enterprise.mk
license-header.enterprise.txt
local/
kustomize_test/
tools/codegen/boilerplate.go.txt
74 changes: 73 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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=<path to helm>")
$(error "Before templating you need to install helm in PATH or export helm binary using 'export HELM=<path to helm>'")
endif

HELM_OPTIONS = --set "operator.image=$(OPERATORIMAGE)" \
Expand Down Expand Up @@ -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:1.2.33" --set "operator.features.storage=true" \
./bin/charts/kube-arangodb-$(VERSION_MAJOR_MINOR_PATCH).tgz


# Testing

.PHONY: run-unit-tests
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- enterprise-k2kclustersync.yaml

0 comments on commit 012fce2

Please sign in to comment.