Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix app chart linting #2985

Merged
merged 3 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@ 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

- name: Run govuk-app-linter
run: |
mkdir lint-tmp
./govuk-app-linter.sh

- name: Helm template
run: |
mkdir helm-dist
Expand Down
42 changes: 42 additions & 0 deletions govuk-app-linter.sh
Original file line number Diff line number Diff line change
@@ -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