Skip to content

Commit f369ffb

Browse files
authored
Chart: Improve CI. (#12003)
1 parent 24a9f97 commit f369ffb

File tree

51 files changed

+307
-585
lines changed

Some content is hidden

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

51 files changed

+307
-585
lines changed

.github/workflows/chart.yaml

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Chart
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- release-*
8+
paths:
9+
- charts/ingress-nginx/Chart.yaml
10+
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
release:
18+
name: Release
19+
runs-on: ubuntu-latest
20+
21+
permissions:
22+
contents: write
23+
24+
steps:
25+
- name: Set up Python
26+
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
27+
with:
28+
python-version: 3.x
29+
30+
- name: Set up Helm
31+
uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0
32+
33+
- name: Set up Helm Chart Testing
34+
uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 # v2.6.1
35+
36+
- name: Set up Artifact Hub
37+
run: |
38+
curl --fail --location https://github.com/artifacthub/hub/releases/download/v1.19.0/ah_1.19.0_linux_amd64.tar.gz --output /tmp/ah.tar.gz
39+
echo "0e430493521ce387ca04d79b26646a86f92886dbcceb44985bb71082a9530ca5 /tmp/ah.tar.gz" | shasum --check
40+
sudo tar --extract --file /tmp/ah.tar.gz --directory /usr/local/bin ah
41+
42+
- name: Set up Git
43+
run: |
44+
git config --global user.name "${GITHUB_ACTOR}"
45+
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
46+
47+
- name: Checkout code
48+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
49+
with:
50+
fetch-depth: 0
51+
52+
- name: Lint chart
53+
run: |
54+
ct lint --config .ct.yaml
55+
ah lint --path charts/ingress-nginx
56+
57+
- name: Release chart
58+
uses: helm/chart-releaser-action@a917fd15b20e8b64b94d9158ad54cd6345335584 # v1.6.0
59+
env:
60+
CR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
CR_RELEASE_NAME_TEMPLATE: helm-chart-{{ .Version }}
62+
CR_SKIP_EXISTING: true
63+
with:
64+
charts_dir: charts

.github/workflows/ci.yaml

+44-68
Original file line numberDiff line numberDiff line change
@@ -208,112 +208,88 @@ jobs:
208208
path: docker.tar.gz
209209
retention-days: 5
210210

211-
helm-lint:
212-
name: Helm chart lint
211+
chart-lint:
212+
name: Chart / Lint
213213
runs-on: ubuntu-latest
214214
needs:
215215
- changes
216-
if: |
217-
(needs.changes.outputs.charts == 'true') || (needs.changes.outputs.baseimage == 'true') || ${{ github.event.workflow_dispatch.run_e2e == 'true' }}
216+
217+
if: fromJSON(needs.changes.outputs.charts) || fromJSON(needs.changes.outputs.baseimage) || fromJSON(github.event.workflow_dispatch.run_e2e)
218218

219219
steps:
220-
- name: Checkout
221-
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
220+
- name: Set up Python
221+
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
222222
with:
223-
fetch-depth: 0
223+
python-version: 3.x
224224

225225
- name: Set up Helm
226226
uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0
227227

228-
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
229-
with:
230-
python-version: '3.x'
231-
232-
- name: Set up chart-testing
228+
- name: Set up Helm Chart Testing
233229
uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 # v2.6.1
234230

235-
- name: Install Helm Unit Test Plugin
231+
- name: Set up Artifact Hub
236232
run: |
237-
helm plugin install https://github.com/helm-unittest/helm-unittest
233+
curl --fail --location https://github.com/artifacthub/hub/releases/download/v1.19.0/ah_1.19.0_linux_amd64.tar.gz --output /tmp/ah.tar.gz
234+
echo "0e430493521ce387ca04d79b26646a86f92886dbcceb44985bb71082a9530ca5 /tmp/ah.tar.gz" | shasum --check
235+
sudo tar --extract --file /tmp/ah.tar.gz --directory /usr/local/bin ah
238236
239-
- name: Run Helm Unit Tests
240-
run: |
241-
helm unittest charts/ingress-nginx -d
237+
- name: Set up Helm Docs
238+
uses: gabe565/setup-helm-docs-action@d5c35bdc9133cfbea3b671acadf50a29029e87c2 # v1.0.4
242239

243-
- name: Run chart-testing (lint)
244-
run: ct lint --config ./.ct.yaml
240+
- name: Set up Helm Unit Test
241+
run: helm plugin install https://github.com/helm-unittest/helm-unittest
245242

246-
- name: Run helm-docs
243+
- name: Checkout code
244+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
245+
with:
246+
fetch-depth: 0
247+
248+
- name: Lint chart
247249
run: |
248-
GOBIN=$PWD GO111MODULE=on go install github.com/norwoodj/helm-docs/cmd/[email protected]
249-
./helm-docs --chart-search-root=${GITHUB_WORKSPACE}/charts
250-
DIFF=$(git diff ${GITHUB_WORKSPACE}/charts/ingress-nginx/README.md)
251-
if [ ! -z "$DIFF" ]; then
252-
echo "Please use helm-docs in your clone, of your fork, of the project, and commit a updated README.md for the chart. https://github.com/kubernetes/ingress-nginx/blob/main/RELEASE.md#d-edit-the-valuesyaml-and-run-helm-docs"
253-
fi
254-
git diff --exit-code
255-
rm -f ./helm-docs
256-
257-
- name: Run Artifact Hub lint
250+
ct lint --config .ct.yaml
251+
ah lint --path charts/ingress-nginx
252+
253+
- name: Check docs
258254
run: |
259-
wget https://github.com/artifacthub/hub/releases/download/v1.5.0/ah_1.5.0_linux_amd64.tar.gz
260-
echo 'ad0e44c6ea058ab6b85dbf582e88bad9fdbc64ded0d1dd4edbac65133e5c87da *ah_1.5.0_linux_amd64.tar.gz' | shasum -c
261-
tar -xzvf ah_1.5.0_linux_amd64.tar.gz ah
262-
./ah lint -p charts/ingress-nginx || exit 1
263-
rm -f ./ah ./ah_1.5.0_linux_amd64.tar.gz
264-
265-
helm-test:
266-
name: Helm chart testing
255+
helm-docs --chart-search-root charts
256+
git diff --exit-code charts/ingress-nginx/README.md
257+
258+
- name: Run tests
259+
run: helm unittest charts/ingress-nginx
260+
261+
chart-test:
262+
name: Chart / Test
267263
runs-on: ubuntu-latest
268264
needs:
269265
- changes
270266
- build
271-
- helm-lint
272-
if: |
273-
(needs.changes.outputs.charts == 'true') || (needs.changes.outputs.baseimage == 'true') || ${{ github.event.workflow_dispatch.run_e2e == 'true' }}
267+
- chart-lint
268+
269+
if: fromJSON(needs.changes.outputs.charts) || fromJSON(needs.changes.outputs.baseimage) || fromJSON(github.event.workflow_dispatch.run_e2e)
274270

275271
strategy:
276272
matrix:
277273
k8s: [v1.28.13, v1.29.8, v1.30.4, v1.31.0]
278274

279275
steps:
280-
- name: Checkout
276+
- name: Checkout code
281277
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
282278

283-
- name: Setup Go
284-
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
285-
with:
286-
go-version: ${{ needs.build.outputs.golangversion }}
287-
check-latest: true
288-
289-
- name: cache
279+
- name: Download cache
290280
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
291281
with:
292282
name: docker.tar.gz
293283

294-
- name: fix permissions
295-
run: |
296-
sudo mkdir -p $HOME/.kube
297-
sudo chmod -R 777 $HOME/.kube
298-
299-
- name: Create Kubernetes ${{ matrix.k8s }} cluster
300-
id: kind
301-
run: |
302-
kind create cluster --image=kindest/node:${{ matrix.k8s }}
303-
304-
- name: Load images from cache
305-
run: |
306-
echo "loading docker images..."
307-
gzip -dc docker.tar.gz | docker load
284+
- name: Load cache
285+
run: gzip --decompress --stdout docker.tar.gz | docker load
308286

309-
- name: Test
287+
- name: Run tests
310288
env:
311-
KIND_CLUSTER_NAME: kind
312-
SKIP_CLUSTER_CREATION: true
289+
K8S_VERSION: ${{ matrix.k8s }}
313290
SKIP_IMAGE_CREATION: true
314-
SKIP_INGRESS_IMAGE_CREATION: true
315291
run: |
316-
kind get kubeconfig > $HOME/.kube/kind-config-kind
292+
sudo mkdir -pm 777 "${HOME}/.kube"
317293
make kind-e2e-chart-tests
318294
319295
kubernetes:

.github/workflows/helm.yaml

-88
This file was deleted.

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
helm-docs
21
# OSX
32
._*
43
.DS_Store

MANUAL_RELEASE.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -226,19 +226,18 @@ Promoting the images basically means that images, that were pushed to staging co
226226
```
227227
228228
### d. Edit the values.yaml and run helm-docs
229+
229230
- [Fields to edit in values.yaml](https://github.com/kubernetes/ingress-nginx/blob/main/charts/ingress-nginx/values.yaml)
230231
231232
- tag
232233
- digest
233234
234-
- [helm-docs](https://github.com/norwoodj/helm-docs) is a tool that generates the README.md for a helm-chart automatically. In the CI pipeline workflow of github actions (/.github/workflows/ci.yaml), you can see how helm-docs is used. But the CI pipeline is not designed to make commits back into the project. So we need to run helm-docs manually, and check in the resulting autogenerated README.md at the path /charts/ingress-nginx/README.md
235+
- [helm-docs](https://github.com/norwoodj/helm-docs) is a tool that generates the README.md for a Helm chart automatically. In the CI pipeline workflow of GitHub actions (.github/workflows/ci.yaml), you can see how helm-docs is used. The CI pipeline is not designed to make commits back into the project, so we need to run helm-docs manually and commit the resulting generated README.md. You can obtain a recent version of the helm-docs binary here: https://github.com/norwoodj/helm-docs/releases.
235236
```
236-
GOBIN=$PWD GO111MODULE=on go install github.com/norwoodj/helm-docs/cmd/[email protected]
237-
./helm-docs --chart-search-root=${GITHUB_WORKSPACE}/charts
238-
git diff --exit-code
239-
rm -f ./helm-docs
237+
helm-docs --chart-search-root charts
238+
git diff charts/ingress-nginx/README.md
240239
```
241-
Watchout for mistakes like leaving the helm-docs executable in your clone workspace or not checking the new README.md manually etc.
240+
Take care of not leaving the helm-docs executable in your clone workspace or not committing the new README.md.
242241
243242
### e. Edit the static manifests
244243
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
controller:
2-
kind: DaemonSet
32
image:
43
repository: ingress-controller/controller
54
tag: 1.0.0-dev
65
digest: null
7-
admissionWebhooks:
8-
enabled: false
6+
97
service:
108
type: ClusterIP
9+
10+
admissionWebhooks:
11+
certManager:
12+
enabled: true

charts/ingress-nginx/ci/controller-admission-tls-cert-manager-values.yaml

-6
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
controller:
2+
image:
3+
repository: ingress-controller/controller
4+
tag: 1.0.0-dev
5+
digest: null
6+
7+
service:
8+
type: ClusterIP
9+
10+
addHeaders:
11+
X-Frame-Options: deny
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
controller:
2+
image:
3+
repository: ingress-controller/controller
4+
tag: 1.0.0-dev
5+
digest: null
6+
7+
service:
8+
type: ClusterIP
9+
10+
proxySetHeaders:
11+
X-Forwarded-Proto: https

0 commit comments

Comments
 (0)