From 7644cd7ab7811685418e5c6a549cae0583ddfcad Mon Sep 17 00:00:00 2001 From: odubajDT <93584209+odubajDT@users.noreply.github.com> Date: Wed, 20 Mar 2024 09:04:16 +0100 Subject: [PATCH] chore: introduce script to re-generate helm results (#3297) Signed-off-by: odubajDT Signed-off-by: odubajDT <93584209+odubajDT@users.noreply.github.com> --- .github/scripts/generate-helm-results.sh | 15 +++++++++++++++ .github/scripts/helm-test.sh | 19 ++++--------------- .github/scripts/helm-utils.sh | 19 +++++++++++++++++++ .github/workflows/validate-helm-chart.yml | 2 +- Makefile | 8 ++++++++ 5 files changed, 47 insertions(+), 16 deletions(-) create mode 100755 .github/scripts/generate-helm-results.sh create mode 100755 .github/scripts/helm-utils.sh diff --git a/.github/scripts/generate-helm-results.sh b/.github/scripts/generate-helm-results.sh new file mode 100755 index 0000000000..e155396d78 --- /dev/null +++ b/.github/scripts/generate-helm-results.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +echo "re-generating Helm test results" +tests=$(find ./.github/scripts/.helm-tests -maxdepth 1 -mindepth 1 -type d ) + +# shellcheck source=.github/scripts/helm-utils.sh +source .github/scripts/helm-utils.sh + +performHelmRepoUpdate + +for test in $tests +do + echo "Re-generating $test" + helm template keptn-test --namespace helmtests -f $test/values.yaml ./chart > $test/result.yaml +done diff --git a/.github/scripts/helm-test.sh b/.github/scripts/helm-test.sh index 63bcace618..131e29c055 100755 --- a/.github/scripts/helm-test.sh +++ b/.github/scripts/helm-test.sh @@ -5,6 +5,9 @@ # This script supports the comparison of standard values and expected templated results to helm chart # it is used to make sure changes to the chart are intentional and produce expected outcomes +# shellcheck source=./.github/scripts/helm-utils.sh +source ./.github/scripts/helm-utils.sh + echo "running Helm tests" tests=$(find ./.github/scripts/.helm-tests -maxdepth 1 -mindepth 1 -type d ) @@ -12,21 +15,7 @@ echo "running Helm tests" successful=0 failures="" - helm repo add keptn "https://charts.lifecycle.keptn.sh" - helm repo update - - for chart_dir in ./lifecycle-operator/chart \ - ./metrics-operator/chart \ - ./keptn-cert-manager/chart \ - ./chart; do - # shellcheck disable=SC2164 - cd "$chart_dir" - echo "updating charts for" $chart_dir - helm dependency update - helm dependency build - # shellcheck disable=SC2164 - cd - # Return to the previous directory - done + performHelmRepoUpdate for test in $tests do diff --git a/.github/scripts/helm-utils.sh b/.github/scripts/helm-utils.sh new file mode 100755 index 0000000000..7e28636fe1 --- /dev/null +++ b/.github/scripts/helm-utils.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +performHelmRepoUpdate () { + helm repo add keptn "https://charts.lifecycle.keptn.sh" + helm repo update + + for chart_dir in ./lifecycle-operator/chart \ + ./metrics-operator/chart \ + ./keptn-cert-manager/chart \ + ./chart; do + # shellcheck disable=SC2164 + cd "$chart_dir" + echo "updating charts for" $chart_dir + helm dependency update + helm dependency build + # shellcheck disable=SC2164 + cd - # Return to the previous directory + done +} diff --git a/.github/workflows/validate-helm-chart.yml b/.github/workflows/validate-helm-chart.yml index 1758c5d14f..800a498568 100644 --- a/.github/workflows/validate-helm-chart.yml +++ b/.github/workflows/validate-helm-chart.yml @@ -76,4 +76,4 @@ jobs: uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Check if Helm template is up to date - run: ./.github/scripts/helm-test.sh + run: make helm-test diff --git a/Makefile b/Makefile index 575f94b0f0..3d9f455552 100644 --- a/Makefile +++ b/Makefile @@ -178,6 +178,14 @@ operator-lint: install-golangci-lint scheduler-lint: install-golangci-lint $(MAKE) -C scheduler lint +.PHONY: helm-test +helm-test: + ./.github/scripts/helm-test.sh + +.PHONY: generate-helm-test-results +generate-helm-test-results: + ./.github/scripts/generate-helm-results.sh + .PHONY: lint lint: metrics-operator-lint lint: certmanager-lint