Skip to content

Commit 18fcd64

Browse files
committed
add gh action to validate book helm charts
Signed-off-by: Your Name <[email protected]> generate charts for samples under docs Signed-off-by: Your Name <[email protected]> call chart Signed-off-by: Your Name <[email protected]> fix Signed-off-by: Your Name <[email protected]> generate charts Signed-off-by: Your Name <[email protected]> fix Signed-off-by: Your Name <[email protected]>
1 parent 1836a4e commit 18fcd64

File tree

80 files changed

+14514
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+14514
-3
lines changed
Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
name: Helm Docs Tutorials
2+
3+
on:
4+
push:
5+
paths:
6+
- "docs/book/src/cronjob-tutorial/testdata/project/**"
7+
- "docs/book/src/getting-started/testdata/project/**"
8+
- "docs/book/src/multiversion-tutorial/testdata/project/**"
9+
- ".github/workflows/test-helm-book.yml"
10+
pull_request:
11+
paths:
12+
- "docs/book/src/cronjob-tutorial/testdata/project/** "
13+
- "docs/book/src/getting-started/testdata/project/**"
14+
- "docs/book/src/multiversion-tutorial/testdata/project/**"
15+
- ".github/workflows/test-helm-book.yml"
16+
17+
jobs:
18+
helm-test-getting-started:
19+
runs-on: ubuntu-latest
20+
strategy:
21+
fail-fast: true
22+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
27+
- name: Setup Go
28+
uses: actions/setup-go@v5
29+
with:
30+
go-version-file: go.mod
31+
32+
- name: Install the latest version of kind
33+
run: |
34+
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64
35+
chmod +x ./kind
36+
sudo mv ./kind /usr/local/bin/kind
37+
38+
- name: Verify kind installation
39+
run: kind version
40+
41+
- name: Create kind cluster
42+
run: kind create cluster
43+
44+
- name: Prepare getting-started
45+
run: |
46+
cd docs/book/src/getting-started/testdata/project/
47+
go mod tidy
48+
make docker-build IMG=getting-started:v0.1.0
49+
kind load docker-image getting-started:v0.1.0
50+
51+
- name: Install Helm
52+
run: |
53+
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
54+
55+
- name: Verify Helm installation
56+
run: helm version
57+
58+
- name: Lint Helm chart for getting-started
59+
run: |
60+
helm lint docs/book/src/getting-started/testdata/project/dist/chart
61+
62+
- name: Install Prometheus Operator CRDs
63+
run: |
64+
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
65+
helm repo update
66+
helm install prometheus-crds prometheus-community/prometheus-operator-crds
67+
68+
- name: Install cert-manager via Helm
69+
run: |
70+
helm repo add jetstack https://charts.jetstack.io
71+
helm repo update
72+
helm install cert-manager jetstack/cert-manager --namespace cert-manager --create-namespace --set installCRDs=true
73+
74+
- name: Wait for cert-manager to be ready
75+
run: |
76+
kubectl wait --namespace cert-manager --for=condition=available --timeout=300s deployment/cert-manager
77+
kubectl wait --namespace cert-manager --for=condition=available --timeout=300s deployment/cert-manager-cainjector
78+
kubectl wait --namespace cert-manager --for=condition=available --timeout=300s deployment/cert-manager-webhook
79+
80+
- name: Render Helm chart for getting-started
81+
run: |
82+
helm template docs/book/src/getting-started/testdata/project/dist/chart --namespace=getting-started-system
83+
84+
- name: Install Helm chart for getting-started
85+
run: |
86+
helm install my-release docs/book/src/getting-started/testdata/project/dist/chart --create-namespace --namespace getting-started-system
87+
88+
- name: Check Helm release status
89+
run: |
90+
helm status my-release --namespace getting-started-system
91+
92+
helm-test-cronjob-tutorial:
93+
runs-on: ubuntu-latest
94+
strategy:
95+
fail-fast: true
96+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
97+
steps:
98+
- name: Checkout repository
99+
uses: actions/checkout@v4
100+
101+
- name: Setup Go
102+
uses: actions/setup-go@v5
103+
with:
104+
go-version-file: go.mod
105+
106+
- name: Install the latest version of kind
107+
run: |
108+
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64
109+
chmod +x ./kind
110+
sudo mv ./kind /usr/local/bin/kind
111+
112+
- name: Verify kind installation
113+
run: kind version
114+
115+
- name: Create kind cluster
116+
run: kind create cluster
117+
118+
- name: Prepare cronjob-tutorial
119+
run: |
120+
cd docs/book/src/cronjob-tutorial/testdata/project/
121+
go mod tidy
122+
make docker-build IMG=cronjob-tutorial:v0.1.0
123+
kind load docker-image cronjob-tutorial:v0.1.0
124+
125+
- name: Install Helm
126+
run: |
127+
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
128+
129+
- name: Verify Helm installation
130+
run: helm version
131+
132+
- name: Lint Helm chart for cronjob-tutorial
133+
run: |
134+
helm lint docs/book/src/cronjob-tutorial/testdata/project/dist/chart
135+
136+
- name: Install Prometheus Operator CRDs
137+
run: |
138+
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
139+
helm repo update
140+
helm install prometheus-crds prometheus-community/prometheus-operator-crds
141+
142+
- name: Install cert-manager via Helm
143+
run: |
144+
helm repo add jetstack https://charts.jetstack.io
145+
helm repo update
146+
helm install cert-manager jetstack/cert-manager --namespace cert-manager --create-namespace --set installCRDs=true
147+
148+
- name: Wait for cert-manager to be ready
149+
run: |
150+
kubectl wait --namespace cert-manager --for=condition=available --timeout=300s deployment/cert-manager
151+
kubectl wait --namespace cert-manager --for=condition=available --timeout=300s deployment/cert-manager-cainjector
152+
kubectl wait --namespace cert-manager --for=condition=available --timeout=300s deployment/cert-manager-webhook
153+
154+
- name: Render Helm chart for cronjob-tutorial
155+
run: |
156+
helm template docs/book/src/cronjob-tutorial/testdata/project/dist/chart --namespace=cronjob-tutorial-system
157+
158+
- name: Install Helm chart for cronjob-tutorial
159+
run: |
160+
helm install my-release docs/book/src/cronjob-tutorial/testdata/project/dist/chart --create-namespace --namespace cronjob-tutorial-system
161+
162+
- name: Check Helm release status
163+
run: |
164+
helm status my-release --namespace cronjob-tutorial-system
165+
166+
helm-test-multiversion-tutorial:
167+
runs-on: ubuntu-latest
168+
strategy:
169+
fail-fast: true
170+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
171+
steps:
172+
- name: Checkout repository
173+
uses: actions/checkout@v4
174+
175+
- name: Setup Go
176+
uses: actions/setup-go@v5
177+
with:
178+
go-version-file: go.mod
179+
180+
- name: Install the latest version of kind
181+
run: |
182+
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64
183+
chmod +x ./kind
184+
sudo mv ./kind /usr/local/bin/kind
185+
186+
- name: Verify kind installation
187+
run: kind version
188+
189+
- name: Create kind cluster
190+
run: kind create cluster
191+
192+
- name: Prepare multiversion-tutorial
193+
run: |
194+
cd docs/book/src/multiversion-tutorial/testdata/project/
195+
go mod tidy
196+
make docker-build IMG=multiversion-tutorial:v0.1.0
197+
kind load docker-image multiversion-tutorial:v0.1.0
198+
199+
- name: Install Helm
200+
run: |
201+
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
202+
203+
- name: Verify Helm installation
204+
run: helm version
205+
206+
- name: Lint Helm chart for multiversion-tutorial
207+
run: |
208+
helm lint docs/book/src/multiversion-tutorial/testdata/project/dist/chart
209+
210+
- name: Install Prometheus Operator CRDs
211+
run: |
212+
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
213+
helm repo update
214+
helm install prometheus-crds prometheus-community/prometheus-operator-crds
215+
216+
- name: Install cert-manager via Helm
217+
run: |
218+
helm repo add jetstack https://charts.jetstack.io
219+
helm repo update
220+
helm install cert-manager jetstack/cert-manager --namespace cert-manager --create-namespace --set installCRDs=true
221+
222+
- name: Wait for cert-manager to be ready
223+
run: |
224+
kubectl wait --namespace cert-manager --for=condition=available --timeout=300s deployment/cert-manager
225+
kubectl wait --namespace cert-manager --for=condition=available --timeout=300s deployment/cert-manager-cainjector
226+
kubectl wait --namespace cert-manager --for=condition=available --timeout=300s deployment/cert-manager-webhook
227+
228+
- name: Render Helm chart for multiversion-tutorial
229+
run: |
230+
helm template docs/book/src/multiversion-tutorial/testdata/project/dist/chart --namespace=multiversion-tutorial-system
231+
232+
- name: Install Helm chart for multiversion-tutorial
233+
run: |
234+
helm install my-release docs/book/src/multiversion-tutorial/testdata/project/dist/chart --create-namespace --namespace multiversion-tutorial-system
235+
236+
- name: Check Helm release status
237+
run: |
238+
helm status my-release --namespace multiversion-tutorial-system

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,15 @@ generate-docs: ## Update/generate the docs
8989
./hack/docs/generate.sh
9090

9191
.PHONY: generate-charts
92-
generate-charts: build ## Re-generate the helm chart testdata only
92+
generate-charts: build ## Re-generate the helm chart testdata and docs samples
9393
rm -rf testdata/project-v4-with-plugins/dist/chart
94+
rm -rf docs/book/src/getting-started/testdata/project/dist/chart
95+
rm -rf docs/book/src/cronjob-tutorial/testdata/project/dist/chart
96+
rm -rf docs/book/src/multiversion-tutorial/testdata/project/dist/chart
9497
(cd testdata/project-v4-with-plugins && ../../bin/kubebuilder edit --plugins=helm/v1-alpha)
98+
(cd docs/book/src/getting-started/testdata/project && ../../../../../../bin/kubebuilder edit --plugins=helm/v1-alpha)
99+
(cd docs/book/src/cronjob-tutorial/testdata/project && ../../../../../../bin/kubebuilder edit --plugins=helm/v1-alpha)
100+
(cd docs/book/src/multiversion-tutorial/testdata/project && ../../../../../../bin/kubebuilder edit --plugins=helm/v1-alpha)
95101

96102
.PHONY: check-docs
97103
check-docs: ## Run the script to ensure that the docs are updated
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Test Chart
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
test-e2e:
9+
name: Run on Ubuntu
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Clone the code
13+
uses: actions/checkout@v4
14+
15+
- name: Setup Go
16+
uses: actions/setup-go@v5
17+
with:
18+
go-version-file: go.mod
19+
20+
- name: Install the latest version of kind
21+
run: |
22+
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64
23+
chmod +x ./kind
24+
sudo mv ./kind /usr/local/bin/kind
25+
26+
- name: Verify kind installation
27+
run: kind version
28+
29+
- name: Create kind cluster
30+
run: kind create cluster
31+
32+
- name: Prepare project
33+
run: |
34+
go mod tidy
35+
make docker-build IMG=project:v0.1.0
36+
kind load docker-image project:v0.1.0
37+
38+
- name: Install Helm
39+
run: |
40+
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
41+
42+
- name: Verify Helm installation
43+
run: helm version
44+
45+
- name: Lint Helm Chart
46+
run: |
47+
helm lint ./dist/chart
48+
49+
# TODO: Uncomment if cert-manager is enabled
50+
# - name: Install cert-manager via Helm
51+
# run: |
52+
# helm repo add jetstack https://charts.jetstack.io
53+
# helm repo update
54+
# helm install cert-manager jetstack/cert-manager --namespace cert-manager --create-namespace --set installCRDs=true
55+
#
56+
# - name: Wait for cert-manager to be ready
57+
# run: |
58+
# kubectl wait --namespace cert-manager --for=condition=available --timeout=300s deployment/cert-manager
59+
# kubectl wait --namespace cert-manager --for=condition=available --timeout=300s deployment/cert-manager-cainjector
60+
# kubectl wait --namespace cert-manager --for=condition=available --timeout=300s deployment/cert-manager-webhook
61+
62+
# TODO: Uncomment if Prometheus is enabled
63+
# - name: Install Prometheus Operator CRDs
64+
# run: |
65+
# helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
66+
# helm repo update
67+
# helm install prometheus-crds prometheus-community/prometheus-operator-crds
68+
#
69+
# - name: Install Prometheus via Helm
70+
# run: |
71+
# helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
72+
# helm repo update
73+
# helm install prometheus prometheus-community/prometheus --namespace monitoring --create-namespace
74+
#
75+
# - name: Wait for Prometheus to be ready
76+
# run: |
77+
# kubectl wait --namespace monitoring --for=condition=available --timeout=300s deployment/prometheus-server
78+
79+
- name: Install Helm chart for project
80+
run: |
81+
helm install my-release ./dist/chart --create-namespace --namespace project-system
82+
83+
- name: Check Helm release status
84+
run: |
85+
helm status my-release --namespace project-system
86+
87+
# TODO: Uncomment if prometheus.enabled is set to true to confirm that the ServiceMonitor gets created
88+
# - name: Check Presence of ServiceMonitor
89+
# run: |
90+
# kubectl wait --namespace project-system --for=jsonpath='{.kind}'=ServiceMonitor servicemonitor/project-controller-manager-metrics-monitor

docs/book/src/cronjob-tutorial/testdata/project/PROJECT

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
domain: tutorial.kubebuilder.io
66
layout:
77
- go.kubebuilder.io/v4
8+
plugins:
9+
helm.kubebuilder.io/v1-alpha: {}
810
projectName: project
911
repo: tutorial.kubebuilder.io/project
1012
resources:
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Patterns to ignore when building Helm packages.
2+
# Operating system files
3+
.DS_Store
4+
5+
# Version control directories
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.hg/
10+
.hgignore
11+
.svn/
12+
13+
# Backup and temporary files
14+
*.swp
15+
*.tmp
16+
*.bak
17+
*.orig
18+
*~
19+
20+
# IDE and editor-related files
21+
.idea/
22+
.vscode/
23+
24+
# Helm chart artifacts
25+
dist/chart/*.tgz
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: v2
2+
name: project
3+
description: A Helm chart to distribute the project project
4+
type: application
5+
version: 0.1.0
6+
appVersion: "0.1.0"
7+
icon: "https://example.com/icon.png"

0 commit comments

Comments
 (0)