-
-
Notifications
You must be signed in to change notification settings - Fork 2
195 lines (190 loc) · 7.23 KB
/
helm-charts-test.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
name: "helm-charts/test"
on: pull_request
jobs:
generate-charts:
runs-on: ubuntu-latest
name: Generate Charts
outputs:
deprecated: ${{ steps.deprecated.outputs.charts }}
maintained: ${{ steps.maintained.outputs.charts }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
sparse-checkout: |
charts/
- name: Get values files
uses: tj-actions/glob@v22
id: charts
with:
separator: ","
files: |
charts/${{ matrix.chart }}/**/Chart.yaml
- name: Deprecated Charts
id: deprecated
run: |
printf "charts=%s" $(echo "${{ steps.charts.outputs.paths }}" | docker run -i -q --rm -v $(pwd):$(pwd) -w $(pwd) ghcr.io/wyrihaximusnet/php:8.4-nts-alpine-root php -r 'echo str_replace(["charts", "Chart.yaml", "/", "\\"], "", json_encode(array_values(array_filter(explode(",", trim(fgets(STDIN))), static fn (string $path): bool => str_contains(file_get_contents($path), "deprecated: true") && !str_contains($path, "commons"))))) . "\n";') >> $GITHUB_OUTPUT
- name: Maintained Charts
id: maintained
run: |
printf "charts=%s" $(echo "${{ steps.charts.outputs.paths }}" | docker run -i -q --rm -v $(pwd):$(pwd) -w $(pwd) ghcr.io/wyrihaximusnet/php:8.4-nts-alpine-root php -r 'echo str_replace(["charts", "Chart.yaml", "/", "\\"], "", json_encode(array_values(array_filter(explode(",", trim(fgets(STDIN))), static fn (string $path): bool => !str_contains(file_get_contents($path), "deprecated: true") && !str_contains($path, "commons"))))) . "\n";') >> $GITHUB_OUTPUT
- name: Show chart lists
run: |
echo "Deprecated:"
echo ${{ steps.deprecated.outputs.charts }}
echo "Maintained:"
echo ${{ steps.maintained.outputs.charts }}
ensure-readme-is-up-to-date:
name: Ensure ${{ matrix.chart }} README is up to date
needs:
- generate-charts
strategy:
fail-fast: false
matrix:
chart: ${{ fromJson(needs.generate-charts.outputs.maintained) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Move current README
run: |
mv charts/${{ matrix.chart }}/README.md charts/${{ matrix.chart }}/README.current.md
- name: Generate README.md
run: |
make generate
- name: Check that the files are the exact same
uses: LouisBrunner/[email protected]
with:
old: charts/${{ matrix.chart }}/README.current.md
new: charts/${{ matrix.chart }}/README.md
mode: strict
tolerance: same
token: ${{ secrets.GITHUB_TOKEN }}
notify_check: true
notify_issue: true
validate-values-schema:
runs-on: ubuntu-latest
name: Validate values schema json
needs:
- generate-charts
strategy:
fail-fast: false
matrix:
chart: ${{ fromJson(needs.generate-charts.outputs.maintained) }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
sparse-checkout: |
charts/${{ matrix.chart }}/
- name: Get values files
uses: tj-actions/glob@v22
id: valueFiles
with:
separator: ","
files: |
charts/${{ matrix.chart }}/**/*values.yaml
- name: Validate values schema json
uses: losisin/helm-values-schema-json-action@v1
with:
input: ${{ steps.valueFiles.outputs.paths }}
output: charts/${{ matrix.chart }}/values.schema.json
fail-on-diff: true
lint:
name: Lint
runs-on: ubuntu-latest
needs:
- validate-values-schema
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Fetch history
run: git fetch --prune --unshallow
- name: Install Chart Tester
uses: helm/[email protected]
- name: Add WyriHaximusNet repo
run: helm repo add WyriHaximusNet https://helm.wyrihaximus.net/
- name: Lint charts
id: lint
run: ct lint --all
test:
name: Test on Kubernetes v${{ matrix.k8s }}
runs-on: ubuntu-latest
needs:
- generate-charts
- lint
strategy:
fail-fast: false
matrix:
k8s:
- "1.23"
- "1.24"
- "1.25"
- "1.26"
- "1.27"
- "1.28"
- "1.29"
- "1.30"
- "1.31"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Fetch history
run: git fetch --prune --unshallow
- name: Create kind cluster
uses: helm/[email protected]
with:
node_image: "kindest/node:v${{ matrix.k8s }}.0"
config: etc/kind.yaml
- run: kubectl get nodes --show-labels=true
- run: kubectl get pods -A
- run: kubectl get svc -A
- name: Install PiHole
uses: evryfs/[email protected]
id: helm-pihole
with:
repo: https://mojo2600.github.io/pihole-kubernetes/
chart: pihole
helm: 'helm' # optional, default value is 'helm'
args: '--wait --atomic --timeout 13m' #optional, default value is '--wait --timeout 2m' in order to wait for the chart-install to stabilize into ready state
- run: kubectl get pods -A
- run: kubectl get svc -A
- name: Create PiHole HostName
id: pihole
run: |
echo ::set-output name=hostname::$(echo "${{ steps.helm-pihole.outputs.releaseName }}-web.default" | base64)
- name: Add WyriHaximusNet repo
run: helm repo add WyriHaximusNet https://helm.wyrihaximus.net/
- name: Install Chart Tester
uses: helm/[email protected]
- name: Run List Changed
id: list-changed
run: |
changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }})
if [[ -n "$changed" ]]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Prepare charts
run: |
echo -e " PIHOLE_HOSTNAME: \"${{ steps.pihole.outputs.hostname }}\"\r\n" >> charts/pi-hole-exporter/library-ci/secret.yaml
cp charts/commons/library-ci/*.yaml charts/commons/templates/
cp charts/cron-jobs/library-ci/*.yaml charts/cron-jobs/templates/
cp charts/pi-hole-exporter/library-ci/*.yaml charts/pi-hole-exporter/templates/
sed -i 's/library/application/g' charts/commons/Chart.yaml
sed -i 's/library/application/g' charts/cron-jobs/Chart.yaml
echo '${{ needs.generate-charts.outputs.deprecated }}' >> charts.json
cat charts.json
jq -c '.[]' charts.json | while read chart; do
rm -Rfv $(echo "charts/${chart}" | docker run -i -q --rm ghcr.io/wyrihaximusnet/php:8.4-nts-alpine-root php -r 'echo str_replace("\"", "", fgets(STDIN));')
done
rm -f charts.json
- run: ls -lasth charts/
- run: kubectl get pods -A
- run: kubectl get svc -A
- name: Test Changed Charts
if: steps.list-changed.outputs.changed == 'true'
run: ct install
- name: Test All Charts
if: steps.list-changed.outputs.changed != 'true'
run: ct install --all
- run: kubectl get pods -A
- run: kubectl get svc -A