Skip to content

Commit

Permalink
ci: add kuberentes version matrix for kind tests
Browse files Browse the repository at this point in the history
Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com>
  • Loading branch information
aramase committed Sep 17, 2021
1 parent 5f67a21 commit d1799d0
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 72 deletions.
1 change: 1 addition & 0 deletions .pipelines/e2e-job-azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pr:
paths:
exclude:
- docs/*
- website/*

pool: staging-pool

Expand Down
76 changes: 33 additions & 43 deletions .pipelines/templates/e2e-test-kind.yaml
Original file line number Diff line number Diff line change
@@ -1,50 +1,43 @@
jobs:
- job:
displayName: e2e_test_kind/helm
timeoutInMinutes: 10
cancelTimeoutInMinutes: 5
dependsOn:
- lint
- scan_images
- unit_test
- build
workspace:
clean: all
variables:
- group: csi-secrets-store-e2e-kind
steps:
- script: |
export REGISTRY="e2e"
export IMAGE_VERSION=e2e-$(git rev-parse --short HEAD)
echo "Image version: ${IMAGE_VERSION}"
echo "##vso[task.setvariable variable=IMAGE_VERSION]${IMAGE_VERSION}"
echo "##vso[task.setvariable variable=REGISTRY]${REGISTRY}"
make e2e-bootstrap
displayName: "Build image"
env:
CI_KIND_CLUSTER: true
- script: |
make e2e-test
displayName: "Run e2e tests on kind cluster"
env:
AZURE_CLIENT_ID: $(AZURE_CLIENT_ID)
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)
KEY_NAME: $(KEY_NAME)
KEY_VERSION: $(KEY_VERSION)
KEYVAULT_NAME: $(KEYVAULT_NAME)
SECRET_NAME: $(SECRET_NAME)
TENANT_ID: $(TENANT_ID)
CI_KIND_CLUSTER: true
AZURE_ENVIRONMENT_FILEPATH: "/etc/kubernetes/custom_environment.json"
strategy:
matrix:
kind_v1_19_11_helm:
KIND_K8S_VERSION: v1.19.11
IS_HELM_TEST: true
kind_v1_20_7_helm:
KIND_K8S_VERSION: v1.20.7
IS_HELM_TEST: true
kind_v1_21_2_helm:
KIND_K8S_VERSION: v1.21.2
IS_HELM_TEST: true
kind_v1_22_0_helm:
KIND_K8S_VERSION: v1.22.0
IS_HELM_TEST: true
kind_v1_19_11_deployment_manifest:
KIND_K8S_VERSION: v1.19.11
IS_HELM_TEST: false
kind_v1_20_7_deployment_manifest:
KIND_K8S_VERSION: v1.20.7
IS_HELM_TEST: false
kind_v1_21_2_deployment_manifest:
KIND_K8S_VERSION: v1.21.2
IS_HELM_TEST: false
kind_v1_22_0_deployment_manifest:
KIND_K8S_VERSION: v1.22.0
IS_HELM_TEST: false

- script: |
make e2e-kind-cleanup
displayName: 'Delete kind cluster'
condition: always()
- job:
displayName: e2e_test_kind/deployment_manifest
timeoutInMinutes: 10
cancelTimeoutInMinutes: 5
workspace:
clean: all
variables:
- group: csi-secrets-store-e2e-kind
steps:
- script: |
export REGISTRY="e2e"
Expand All @@ -58,7 +51,7 @@ jobs:
CI_KIND_CLUSTER: true
- script: |
make e2e-test
displayName: "Run e2e tests on kind cluster"
displayName: Run e2e tests
env:
AZURE_CLIENT_ID: $(AZURE_CLIENT_ID)
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)
Expand All @@ -69,11 +62,8 @@ jobs:
TENANT_ID: $(TENANT_ID)
CI_KIND_CLUSTER: true
AZURE_ENVIRONMENT_FILEPATH: "/etc/kubernetes/custom_environment.json"
IS_HELM_TEST: false
REGISTRY: ${REGISTRY}
IMAGE_VERSION: ${IMAGE_VERSION}
- script: |
make e2e-kind-cleanup
displayName: 'Delete kind cluster'
displayName: Delete kind cluster
condition: always()
54 changes: 34 additions & 20 deletions .pipelines/templates/unit-test.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
jobs:
- job: unit_test
timeoutInMinutes: 10
cancelTimeoutInMinutes: 5
workspace:
clean: all
variables:
- name: TRIVY_VERSION
value: 0.19.2
steps:
- script: make lint
displayName: Run lint
- script: make build build-windows
displayName: Build
- script: make unit-test
displayName: Run unit tests
- script: bash <(curl -s https://codecov.io/bash) -C $(Build.SourceVersion)
displayName: Upload coverage to codecov
- script: make helm-lint
displayName: Run helm lint
- template: scan-images.yaml
- job: scan_images
timeoutInMinutes: 10
workspace:
clean: all
variables:
- name: TRIVY_VERSION
value: 0.19.2
steps:
- template: .pipelines/templates/scan-images.yaml
- job: lint
timeoutInMinutes: 5
workspace:
clean: all
steps:
- script: make lint
displayName: golangci-lint
- script: make helm-lint
displayName: helm lint
- job: build
timeoutInMinutes: 5
workspace:
clean: all
steps:
- script: make build build-windows
displayName: build
- job: unit_test
timeoutInMinutes: 5
workspace:
clean: all
steps:
- script: make unit-test
displayName: unit test
- script: bash <(curl -s https://codecov.io/bash) -C $(Build.SourceVersion)
displayName: Upload coverage to codecov
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ BUILDKIT_VERSION ?= v0.8.1

# E2E test variables
KIND_VERSION ?= 0.11.0
KIND_K8S_VERSION ?= 1.21.2
KIND_K8S_VERSION ?= v1.21.2

$(TOOLS_DIR)/golangci-lint: $(TOOLS_MOD_DIR)/go.mod $(TOOLS_MOD_DIR)/go.sum $(TOOLS_MOD_DIR)/tools.go
cd $(TOOLS_MOD_DIR) && \
Expand Down Expand Up @@ -148,7 +148,7 @@ mod:
.PHONY: e2e-bootstrap
e2e-bootstrap: install-helm
ifdef CI_KIND_CLUSTER
curl -LO https://storage.googleapis.com/kubernetes-release/release/v${KIND_K8S_VERSION}/bin/linux/amd64/kubectl && chmod +x ./kubectl && sudo mv kubectl /usr/local/bin/
curl -LO https://storage.googleapis.com/kubernetes-release/release/${KIND_K8S_VERSION}/bin/linux/amd64/kubectl && chmod +x ./kubectl && sudo mv kubectl /usr/local/bin/
make setup-kind
endif
docker pull $(IMAGE_TAG) || make e2e-container
Expand All @@ -172,15 +172,15 @@ setup-kind:
# Check for existing kind cluster
if [ $$(kind get clusters) ]; then kind delete cluster; fi
# using kind config to create cluster for testing custom cloud environments
TERM=dumb kind create cluster --image kindest/node:v${KIND_K8S_VERSION} --config test/kind-config.yaml
TERM=dumb kind create cluster --image kindest/node:${KIND_K8S_VERSION} --config test/kind-config.yaml

.PHONY: install-helm
install-helm:
helm version --short | grep -q v3 || (curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash)

.PHONY: e2e-local-bootstrap
e2e-local-bootstrap: build
kind create cluster --image kindest/node:v${KIND_K8S_VERSION} --config test/kind-config.yaml
kind create cluster --image kindest/node:${KIND_K8S_VERSION} --config test/kind-config.yaml
make image
kind load docker-image --name kind $(IMAGE_TAG)

Expand Down
6 changes: 1 addition & 5 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
trigger:
branches:
include:
- master
- release-*
trigger: none

pr:
branches:
Expand Down

0 comments on commit d1799d0

Please sign in to comment.