Skip to content

Commit dd689e3

Browse files
committed
workflows: Ensure we don't break the help templates
We must ensure that no commit will break our templates, and the cheapest way todo so is using a GitHub Action. This helm validation workflow has been entirely vibe generated using Cursor AI. Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
1 parent c32bffb commit dd689e3

File tree

1 file changed

+166
-0
lines changed

1 file changed

+166
-0
lines changed
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
name: Helm Chart Validation
2+
3+
on:
4+
pull_request:
5+
types:
6+
- edited
7+
- opened
8+
- reopened
9+
- synchronize
10+
11+
jobs:
12+
validate-templates:
13+
name: Validate Helm Templates
14+
runs-on: ubuntu-22.04
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Helm
20+
uses: azure/setup-helm@v4
21+
with:
22+
version: 'latest'
23+
24+
- name: Update Helm dependencies
25+
run: |
26+
echo "📦 Updating Helm dependencies..."
27+
helm dependency update
28+
echo "✅ Dependencies updated"
29+
30+
- name: Test default template rendering
31+
id: default
32+
run: |
33+
echo "🔍 Testing default template rendering..."
34+
if helm template test-release . > /tmp/default-output.yaml 2> /tmp/default-error.txt; then
35+
echo "✅ Default template renders successfully"
36+
echo "result=success" >> $GITHUB_OUTPUT
37+
else
38+
echo "❌ Default template rendering failed"
39+
echo "result=failed" >> $GITHUB_OUTPUT
40+
echo "::error::Default template rendering failed. See job output for details."
41+
exit 1
42+
fi
43+
44+
- name: Show default rendering errors (if any)
45+
if: failure() && steps.default.outputs.result == 'failed'
46+
run: |
47+
echo "## ❌ Default Template Rendering Failed" >> $GITHUB_STEP_SUMMARY
48+
echo "" >> $GITHUB_STEP_SUMMARY
49+
echo "### Error Output:" >> $GITHUB_STEP_SUMMARY
50+
echo '```' >> $GITHUB_STEP_SUMMARY
51+
cat /tmp/default-error.txt >> $GITHUB_STEP_SUMMARY
52+
echo '```' >> $GITHUB_STEP_SUMMARY
53+
echo "" >> $GITHUB_STEP_SUMMARY
54+
echo "### How to Fix:" >> $GITHUB_STEP_SUMMARY
55+
echo "1. Run \`helm template test-release .\` locally to reproduce" >> $GITHUB_STEP_SUMMARY
56+
echo "2. Check the error message above for syntax or template errors" >> $GITHUB_STEP_SUMMARY
57+
echo "3. Validate your changes with \`helm lint .\`" >> $GITHUB_STEP_SUMMARY
58+
echo "4. Ensure all template variables are properly defined in values.yaml" >> $GITHUB_STEP_SUMMARY
59+
60+
echo ""
61+
echo "Error details:"
62+
cat /tmp/default-error.txt
63+
64+
- name: Test x86_64 architecture
65+
run: |
66+
echo "🔍 Testing x86_64 architecture..."
67+
helm template test-release . \
68+
--set architecture=x86_64 \
69+
> /tmp/x86_64-output.yaml
70+
echo "✅ x86_64 template renders successfully"
71+
72+
- name: Test s390x architecture
73+
run: |
74+
echo "🔍 Testing s390x architecture..."
75+
helm template test-release . \
76+
-f values/kata-s390x.yaml \
77+
> /tmp/s390x-output.yaml
78+
echo "✅ s390x template renders successfully"
79+
80+
- name: Test aarch64 architecture
81+
run: |
82+
echo "🔍 Testing aarch64 architecture..."
83+
helm template test-release . \
84+
-f values/kata-aarch64.yaml \
85+
> /tmp/aarch64-output.yaml
86+
echo "✅ aarch64 template renders successfully"
87+
88+
- name: Test remote (peer-pods) architecture
89+
run: |
90+
echo "🔍 Testing remote (peer-pods) architecture..."
91+
helm template test-release . \
92+
-f values/kata-remote.yaml \
93+
> /tmp/remote-output.yaml
94+
echo "✅ remote template renders successfully"
95+
96+
- name: Validation Summary
97+
if: success()
98+
run: |
99+
echo "## ✅ All Template Validations Passed" >> $GITHUB_STEP_SUMMARY
100+
echo "" >> $GITHUB_STEP_SUMMARY
101+
echo "Tested configurations:" >> $GITHUB_STEP_SUMMARY
102+
echo "- ✅ Default (x86_64)" >> $GITHUB_STEP_SUMMARY
103+
echo "- ✅ s390x architecture" >> $GITHUB_STEP_SUMMARY
104+
echo "- ✅ aarch64 architecture" >> $GITHUB_STEP_SUMMARY
105+
echo "- ✅ remote (peer-pods)" >> $GITHUB_STEP_SUMMARY
106+
107+
helm-lint:
108+
name: Helm Lint
109+
runs-on: ubuntu-22.04
110+
steps:
111+
- name: Checkout code
112+
uses: actions/checkout@v4
113+
114+
- name: Set up Helm
115+
uses: azure/setup-helm@v4
116+
with:
117+
version: 'latest'
118+
119+
- name: Update Helm dependencies
120+
run: |
121+
echo "📦 Updating Helm dependencies..."
122+
helm dependency update
123+
echo "✅ Dependencies updated"
124+
125+
- name: Run helm lint
126+
id: lint
127+
run: |
128+
echo "🔍 Running helm lint..."
129+
if helm lint . > /tmp/lint-output.txt 2>&1; then
130+
echo "✅ Helm lint passed"
131+
cat /tmp/lint-output.txt
132+
echo "result=success" >> $GITHUB_OUTPUT
133+
else
134+
echo "❌ Helm lint failed"
135+
echo "result=failed" >> $GITHUB_OUTPUT
136+
echo "::error::Helm lint failed. See job output for details."
137+
exit 1
138+
fi
139+
140+
- name: Show lint errors (if any)
141+
if: failure() && steps.lint.outputs.result == 'failed'
142+
run: |
143+
echo "## ❌ Helm Lint Failed" >> $GITHUB_STEP_SUMMARY
144+
echo "" >> $GITHUB_STEP_SUMMARY
145+
echo "### Lint Output:" >> $GITHUB_STEP_SUMMARY
146+
echo '```' >> $GITHUB_STEP_SUMMARY
147+
cat /tmp/lint-output.txt >> $GITHUB_STEP_SUMMARY
148+
echo '```' >> $GITHUB_STEP_SUMMARY
149+
echo "" >> $GITHUB_STEP_SUMMARY
150+
echo "### How to Fix:" >> $GITHUB_STEP_SUMMARY
151+
echo "1. Run \`helm lint .\` locally to reproduce" >> $GITHUB_STEP_SUMMARY
152+
echo "2. Fix the issues reported in the lint output" >> $GITHUB_STEP_SUMMARY
153+
echo "3. Common issues:" >> $GITHUB_STEP_SUMMARY
154+
echo " - Missing required values in values.yaml" >> $GITHUB_STEP_SUMMARY
155+
echo " - Invalid YAML syntax in templates" >> $GITHUB_STEP_SUMMARY
156+
echo " - Undefined template variables" >> $GITHUB_STEP_SUMMARY
157+
echo " - Chart.yaml validation errors" >> $GITHUB_STEP_SUMMARY
158+
159+
cat /tmp/lint-output.txt
160+
161+
- name: Lint Summary
162+
if: success()
163+
run: |
164+
echo "## ✅ Helm Lint Passed" >> $GITHUB_STEP_SUMMARY
165+
echo "" >> $GITHUB_STEP_SUMMARY
166+
cat /tmp/lint-output.txt >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)