Skip to content

Commit 8d2b05c

Browse files
Add CI/CD validation workflow for Helm charts
Created .github/workflows/validate-helm-charts.yml to automatically validate Helm chart tgz files and prevent corruption. The workflow runs on: - Pull requests that modify helm-chart files (tgz, Chart.yaml, values.yaml) - Pushes to main/develop that touch helm-chart files - Manual trigger via workflow_dispatch Validation checks: 1. Operator chart tgz structure validation (via tools/validate-helm-charts.sh) - Ensures tgz files contain only splunk-operator/ content - Detects embedded splunk-enterprise chart corruption - Verifies file sizes are reasonable 2. Helm lint on both splunk-operator and splunk-enterprise charts 3. Template rendering tests for common deployment patterns: - Default values - C3 deployment (cluster manager + indexer cluster + search head cluster) - S1 deployment (standalone) Benefits: - Catches corrupted tgz files before merge - Validates template syntax and rendering - Provides early feedback on PRs via automated comments - Prevents helm test failures in CI This would have caught the splunk-operator-3.0.0.tgz corruption before it was merged to develop. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 6fc4cf6 commit 8d2b05c

1 file changed

Lines changed: 85 additions & 0 deletions

File tree

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Validate Helm Charts
2+
permissions:
3+
contents: read
4+
pull-requests: write
5+
on:
6+
pull_request:
7+
paths:
8+
- 'helm-chart/**/*.tgz'
9+
- 'helm-chart/**/Chart.yaml'
10+
- 'helm-chart/**/values.yaml'
11+
- 'tools/validate-helm-charts.sh'
12+
push:
13+
branches:
14+
- main
15+
- develop
16+
paths:
17+
- 'helm-chart/**/*.tgz'
18+
- 'helm-chart/**/Chart.yaml'
19+
- 'helm-chart/**/values.yaml'
20+
- 'tools/validate-helm-charts.sh'
21+
workflow_dispatch:
22+
23+
jobs:
24+
validate-chart-tgz-files:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v2
29+
30+
- name: Validate Helm chart tgz files
31+
run: |
32+
chmod +x tools/validate-helm-charts.sh
33+
./tools/validate-helm-charts.sh
34+
35+
- name: Comment on PR with validation results
36+
if: failure() && github.event_name == 'pull_request'
37+
uses: actions/github-script@v6
38+
with:
39+
script: |
40+
github.rest.issues.createComment({
41+
issue_number: context.issue.number,
42+
owner: context.repo.owner,
43+
repo: context.repo.repo,
44+
body: '❌ **Helm Chart Validation Failed**\n\nThe `tools/validate-helm-charts.sh` script detected issues with Helm chart tgz files.\n\nPlease check the workflow logs for details and ensure:\n- Operator chart tgz files contain only `splunk-operator/` content (not `splunk-enterprise/`)\n- File sizes are reasonable (3.x charts ~5-10KB, 2.x charts ~400-430KB)\n- No tgz files over 1MB\n\nSee workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
45+
})
46+
47+
lint-helm-charts:
48+
runs-on: ubuntu-latest
49+
steps:
50+
- name: Checkout code
51+
uses: actions/checkout@v2
52+
53+
- name: Install Helm
54+
run: |
55+
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
56+
chmod 700 get_helm.sh
57+
DESIRED_VERSION=v3.8.2 bash get_helm.sh
58+
59+
- name: Lint splunk-operator chart
60+
run: |
61+
helm lint helm-chart/splunk-operator
62+
63+
- name: Lint splunk-enterprise chart
64+
run: |
65+
helm lint helm-chart/splunk-enterprise
66+
67+
- name: Test template rendering for common deployments
68+
run: |
69+
# Test default values
70+
helm template test-default helm-chart/splunk-enterprise --dry-run > /dev/null
71+
72+
# Test c3 deployment
73+
helm template test-c3 helm-chart/splunk-enterprise \
74+
--set sva.c3.enabled=true \
75+
--set "sva.c3.indexerClusters[0].name=idx1" \
76+
--set "sva.c3.searchHeadClusters[0].name=shc1" \
77+
--set clusterManager.enabled=true \
78+
--dry-run > /dev/null
79+
80+
# Test s1 deployment
81+
helm template test-s1 helm-chart/splunk-enterprise \
82+
--set sva.s1.enabled=true \
83+
--dry-run > /dev/null
84+
85+
echo "✅ All template rendering tests passed"

0 commit comments

Comments
 (0)