From 0d7e0a814f4e98e274b8eef7228e8877840fa078 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Thu, 30 Apr 2026 20:14:38 +0800 Subject: [PATCH] test(ci): cover Helm Recreate strategy rendering (#2752) --- .github/workflows/helm-package.yml | 3 +++ scripts/test_helm_templates.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100755 scripts/test_helm_templates.sh diff --git a/.github/workflows/helm-package.yml b/.github/workflows/helm-package.yml index 0c1bf93cc..d0b2e6f11 100644 --- a/.github/workflows/helm-package.yml +++ b/.github/workflows/helm-package.yml @@ -80,6 +80,9 @@ jobs: - name: Set up Helm uses: azure/setup-helm@v4.3.0 + - name: Test Helm Chart Templates + run: ./scripts/test_helm_templates.sh + - name: Package Helm Chart run: | set -eux diff --git a/scripts/test_helm_templates.sh b/scripts/test_helm_templates.sh new file mode 100755 index 000000000..a4609b88d --- /dev/null +++ b/scripts/test_helm_templates.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) +CHART_DIR="$ROOT_DIR/helm/rustfs" + +render_standalone_deployment() { + helm template rustfs "$CHART_DIR" \ + --namespace rustfs \ + --set mode.distributed.enabled=false \ + --set mode.standalone.enabled=true \ + "$@" | + awk ' + /^# Source: rustfs\/templates\/deployment.yaml$/ { in_deployment = 1 } + in_deployment && /^---$/ { exit } + in_deployment { print } + ' +} + +recreate_output=$(render_standalone_deployment --set mode.standalone.strategy.type=Recreate) +grep -q "type: Recreate" <<<"$recreate_output" +if grep -q "rollingUpdate:" <<<"$recreate_output"; then + echo "Recreate strategy must not render rollingUpdate fields" >&2 + exit 1 +fi + +rolling_output=$(render_standalone_deployment) +grep -q "type: RollingUpdate" <<<"$rolling_output" +grep -q "rollingUpdate:" <<<"$rolling_output"