From 5d4c4a13fa40bdcb6558c2b0e71f0d43ed98fc54 Mon Sep 17 00:00:00 2001 From: kentsanggds Date: Thu, 6 Feb 2025 15:34:43 +0000 Subject: [PATCH 1/3] Update chart testing version --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a7efd6ad688..e87a1558dd9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: - name: Set up chart-testing uses: helm/chart-testing-action@v2 with: - version: v3.8.0 + version: v3.12.0 - name: Run chart-testing (lint) run: ct lint --config ct.yml From 967a5ec74b7de56ed13e5edefd9dde1fd68befdb Mon Sep 17 00:00:00 2001 From: kentsanggds Date: Fri, 7 Feb 2025 15:16:53 +0000 Subject: [PATCH 2/3] Add govuk-app-linter.sh --- govuk-app-linter.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 govuk-app-linter.sh diff --git a/govuk-app-linter.sh b/govuk-app-linter.sh new file mode 100755 index 00000000000..d80d10f3052 --- /dev/null +++ b/govuk-app-linter.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# set -e + +ENVIRONMENTS=("integration" "staging" "production") + +for env in "${ENVIRONMENTS[@]}"; do + values_filename="./charts/app-config/values-$env.yaml"; + + array_length=$(yq e ".govukApplications | length - 1" "$values_filename") + + if [ "$array_length" -le 0 ] ; then + continue; + fi + + echo "=================== $env ==================="; + + declare -i errors=0; + + # expand all the aliases + yq 'explode(.)' "./charts/app-config/values-$env.yaml" > "lint-tmp/$env-exploded.yaml" + + for app_index in $(seq 0 "$array_length");do + filename="./lint-tmp/$(yq ".govukApplications[$app_index].name" "$values_filename")-chart.yaml" + chart_path=$(yq ".govukApplications[$app_index].chartPath // \"charts/generic-govuk-app\"" "$values_filename"); + + echo "$app_index/$array_length: linting $filename against $chart_path"; + + yq ".govukApplications[$app_index].helmValues" "lint-tmp/$env-exploded.yaml" > "$filename"; + + output=$(helm lint --quiet -f "$filename" "$chart_path"); + if [[ "$output" == *"[ERROR]"* ]]; then + echo "$output"; + errors+=1; + fi + done + + if [[ errors -gt 0 ]]; then + echo "$errors lint errors found in $env values"; + exit 1 + fi + +done From 8b7bf2b274643c5604da7ec094bcb3da9d751fba Mon Sep 17 00:00:00 2001 From: kentsanggds Date: Fri, 7 Feb 2025 15:18:16 +0000 Subject: [PATCH 3/3] Update ci.yml to run govuk-app-linter.sh --- .github/workflows/ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e87a1558dd9..ef69705151c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,6 +24,11 @@ jobs: - name: Run chart-testing (lint) run: ct lint --config ct.yml + - name: Run govuk-app-linter + run: | + mkdir lint-tmp + ./govuk-app-linter.sh + - name: Helm template run: | mkdir helm-dist