From 957c1450539c45fc91cbb50f3c74d9e7c0493a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E7=8E=AE=E6=96=87?= Date: Fri, 9 Aug 2024 11:25:49 +0800 Subject: [PATCH] add scripts for helm testing --- hack/check-helm.sh | 18 ++++++++++++++++++ test/install-or-upgrade.sh | 19 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100755 hack/check-helm.sh create mode 100755 test/install-or-upgrade.sh diff --git a/hack/check-helm.sh b/hack/check-helm.sh new file mode 100755 index 000000000..91a53bf8d --- /dev/null +++ b/hack/check-helm.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# We need a clean Kubernetes cluster to run this script. + +set -e + +cd deploy/chart + +kubectl create -f ./crds + +helm lint +helm install alibaba-cloud-csi-driver . --namespace kube-system --dry-run=server + +for v in values-*.yaml; do + helm lint --values "$v" + helm install alibaba-cloud-csi-driver . --namespace kube-system --dry-run=server --values "$v" +done + +kubectl delete -f ./crds diff --git a/test/install-or-upgrade.sh b/test/install-or-upgrade.sh new file mode 100755 index 000000000..ab2d6647a --- /dev/null +++ b/test/install-or-upgrade.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# If helm chart is changed, try install upstream version, then upgrade to local version, +# to ensure all changes are valid. e.g. we don't change some immutable fields. + +set -e + +UPSTREAM=${UPSTREAM:-"origin/master"} + +if ! git diff --exit-code --stat "$UPSTREAM" HEAD -- deploy/chart; then + echo "helm chart is changed, installing $UPSTREAM version first" + git worktree add --detach --no-checkout ../upstream "$UPSTREAM" + ( cd ../upstream && git checkout HEAD -- deploy/chart ) + + helm install --namespace kube-system alibaba-cloud-csi-driver ../upstream/deploy/chart "$@" + git worktree remove --force ../upstream +fi + +echo installing local version +helm upgrade --install --namespace kube-system alibaba-cloud-csi-driver ./deploy/chart "$@"