-
Notifications
You must be signed in to change notification settings - Fork 34
415 lines (386 loc) · 13.8 KB
/
common_library_tests.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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
name: Common Library Tests
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
env:
DATREE_TOKEN: ${{ secrets.DATREE_TOKEN }}
jobs:
lint:
name: Lint Common
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
helm-version:
- v3.12.3
- v3.14.0
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 1
- name: Install Helm
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # tag=v3
with:
version: ${{ matrix.helm-version }}
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5
with:
python-version: "3.10"
- name: Set up chart-testing
uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 # v2.6.1
- name: Run chart-testing (lint)
id: lint
run: |
ct lint --config .github/ct-install-config/ct-lint.yaml \
--lint-conf .github/ct-install-config/lint-conf.yaml \
--charts library/common-test \
--debug
unittest:
needs:
- lint
name: Unit Tests
runs-on: ubuntu-22.04
env:
helmUnitVersion: 0.4.1
strategy:
fail-fast: false
matrix:
helm-version:
- v3.12.3
- v3.14.0
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 1
- name: Install Helm
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3
with:
version: ${{ matrix.helm-version }}
- name: Cache helm plugins
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4
with:
path: |
/home/runner/.local/share/helm/plugins/helm-unittest
/tmp/_dist/
key: helm-${{ matrix.helm-version }}-unittest-v${{ env.helmUnitVersion }}
restore-keys: |
helm-${{ matrix.helm-version }}-unittest-v${{ env.helmUnitVersion }}
- name: Run Unittests
shell: bash
run: |
(helm unittest -h > /dev/null) || helm plugin install https://github.com/helm-unittest/helm-unittest --version v${helmUnitVersion} || (sleep 10 && helm plugin install https://github.com/helm-unittest/helm-unittest --version v${helmUnitVersion}) || echo "finished unittest reinstall tries"
# Run tests
cd library/common-test/
helm dependency update
helm unittest -f "tests/**/*.yaml" .
install:
needs:
- lint
name: Install Charts
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
# We run tests on k3s version of latest SCALE release and SCALE nightly
k3s-version:
- v1.26
- v1.27
- v1.28
# We run tests on Helm version of latest SCALE, fluxcd and latest helm release
helm-version:
- v3.12.3
- v3.14.0
values:
- basic-values.yaml
- configmap-values.yaml
- secrets-values.yaml
- imagePullSecret-values.yaml
- daemonset-values.yaml
- job-values.yaml
- cron-values.yaml
- statefulset-values.yaml
- persistence-values.yaml
- extra-containers-values.yaml
- rbac-values.yaml
- ingress-values.yaml
- networkPolicy-values.yaml
# TODO: broken
# - codeserver-values.yaml
- netshoot-values.yaml
- metrics-values.yaml
- cnpg-values.yaml
- cnpg-multi-values.yaml
- register-operator-values.yaml
- portal-svc-values.yaml
- portal-ingress-values.yaml
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 1
- name: Install Helm
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3
with:
version: ${{ matrix.helm-version }}
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5
with:
python-version: "3.10"
- name: Set up chart-testing
uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 # v2.6.1
- name: Create k3d cluster - Attempt 1/3
continue-on-error: true
id: createc1
uses: nolar/setup-k3d-k3s@293b8e5822a20bc0d5bcdd4826f1a665e72aba96 # tag=v1.0.9
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
version: ${{ matrix.k3s-version }}
# Flags found here https://github.com/k3d-io/k3d
k3d-args: --k3s-arg --disable=metrics-server@server:*
- name: Wait 10 second to retry
if: steps.createc1.outcome=='failure'
run: |
sleep 10
- name: Create k3d cluster - Attempt 2/3
continue-on-error: true
if: steps.createc1.outcome=='failure'
id: createc2
uses: nolar/setup-k3d-k3s@293b8e5822a20bc0d5bcdd4826f1a665e72aba96 # tag=v1.0.9
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
version: ${{ matrix.k3s-version }}
# Flags found here https://github.com/k3d-io/k3d
k3d-args: --k3s-arg --disable=metrics-server@server:*
- name: Wait 10 second to retry
if: steps.createc2.outcome=='failure'
run: |
sleep 10
- name: Create k3d cluster - Attempt 3/3
id: createc3
if: steps.createc2.outcome=='failure'
uses: nolar/setup-k3d-k3s@293b8e5822a20bc0d5bcdd4826f1a665e72aba96 # tag=v1.0.9
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
version: ${{ matrix.k3s-version }}
# Flags found here https://github.com/k3d-io/k3d
k3d-args: --k3s-arg --disable=metrics-server@server:*
# Install Kail to grab logs from tests, as there are cases ct-install fail to output logs
- name: Install Kail
run: |
export KAIL_VERSION=v0.16.1
wget https://github.com/boz/kail/releases/download/${KAIL_VERSION}/kail_${KAIL_VERSION}_linux_amd64.tar.gz
tar -xvzf kail_${KAIL_VERSION}_linux_amd64.tar.gz
chmod +x kail
- name: Prep Helm
run: |
helm repo add truecharts-deps https://deps.truecharts.org
helm repo update
- name: Add Dependencies
run: |
if [[ "${{ matrix.values }}" =~ (metrics|cnpg).*-values.yaml ]]; then
helm install prometheus-operator oci://tccr.io/truecharts/prometheus-operator --namespace prometheus-operator --create-namespace --wait
fi
if [[ "${{ matrix.values }}" =~ cnpg.*-values.yaml ]]; then
helm install cloudnative-pg oci://tccr.io/truecharts/cloudnative-pg --namespace cloudnative-pg --create-namespace --wait
fi
if [[ "${{ matrix.values }}" =~ ingress.*-values.yaml ]]; then
helm install cert-manager oci://tccr.io/truecharts/cert-manager --namespace cert-manager --create-namespace --wait
helm install traefik oci://tccr.io/truecharts/traefik --namespace traefik --create-namespace --wait \
--set service.main.type=ClusterIP --set service.tcp.type=ClusterIP
fi
- name: Run chart-testing (install)
run: |
# Move all ci values on a temp location (or skip if already moved from another matrix job)
mv library/common-test/ci library/common-test/runtests || echo "Nothing to move"
# Move one values.yaml to the correct location to run the test
mv -f library/common-test/runtests/${{ matrix.values }} library/common-test/values.yaml
# Stat kail on the background to grab logs from tests
./kail --ignore-ns kube-system --ignore-ns cert-manager --ignore-ns metallb-system --ignore-ns prometheus-operator >> /tmp/output.log &
# Actually run the test
ct install --config .github/ct-install-config/ct-install.yaml \
--charts library/common-test \
--debug || (echo -e "\n\n--===PODLOGS===--\n\n" && \
cat /tmp/output.log && \
rm -f /tmp/output.log && exit 1)
kill $!
echo -e "\n\n--===PODLOGS===--\n\n"
cat /tmp/output.log
rm -f /tmp/output.log
# security:
# needs:
# - lint
# name: Security Scans
# runs-on: ubuntu-22.04
# strategy:
# fail-fast: false
# matrix:
# # We run tests on k3s version of latest SCALE release and SCALE nightly
# k3s-version:
# - v1.26
# - v1.27
# - v1.28
# # We run tests on Helm version of latest SCALE release
# helm-version:
# - v3.12.3
# - v3.14.0
# values:
# - basic-values.yaml
# - configmap-values.yaml
# - secrets-values.yaml
# - imagePullSecret-values.yaml
# - daemonset-values.yaml
# - job-values.yaml
# - cron-values.yaml
# - statefulset-values.yaml
# - persistence-values.yaml
# - extra-containers-values.yaml
# - rbac-values.yaml
# - networkPolicy-values.yaml
# - register-operator-values.yaml
# # Runs as root, so test results become obviously red
# # - codeserver-values.yaml
# # - netshoot-values.yaml
#
#
# steps:
# - name: Install Helm
# uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3
# with:
# version: ${{ matrix.helm-version }}
#
# - name: Checkout
# uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
# with:
# fetch-depth: 1
#
# - name: build helm deps
# run: |
# cd library/common-test
# helm dependency update
# cd -
# - name: Add namespace
# run: |
# echo "namespace: common-test" >> library/common-test/ci/${{ matrix.values }}
#
# - name: Run Security Scan
# uses: datreeio/action-datree@main
# with:
# path: 'library/common-test'
# cliArguments: '--ignore-missing-schemas --policy CommonBasic'
# isHelmChart: true
# helmArguments: '--values library/common-test/ci/${{ matrix.values }}'
#
# security-man:
# needs:
# - lint
# name: Security Scans (manifests)
# runs-on: ubuntu-22.04
# strategy:
# fail-fast: false
# matrix:
# # We run tests on k3s version of latest SCALE release and SCALE nightly
# k3s-version:
# - v1.26
# - v1.27
# - v1.28
# # We run tests on Helm version of latest SCALE release
# helm-version:
# - v3.12.3
# - v3.14.0
# values:
# - ingress-values.yaml
# - metrics-values.yaml
# # - cnpg-values.yaml
# # - cnpg-multi-values.yaml
#
# steps:
# - name: Install Helm
# uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3
# with:
# version: ${{ matrix.helm-version }}
#
# - name: Prep Helm
# run: |
# helm repo add truecharts-deps https://deps.truecharts.org
# helm repo update
# - name: Add Dependencies
# run: |
# helm install prometheus-operator oci://tccr.io/truecharts/prometheus-operator --namespace prometheus-operator --create-namespace --wait
# helm install cloudnative-pg oci://tccr.io/truecharts/cloudnative-pg --namespace cloudnative-pg --create-namespace --wait
# helm install traefik oci://tccr.io/truecharts/traefik --namespace traefik --create-namespace --wait \
# --set service.main.type=ClusterIP --set service.tcp.type=ClusterIP
#
# - name: Checkout
# uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
# with:
# fetch-depth: 1
#
# - name: build helm deps
# run: |
# cd library/common-test
# helm dependency update
# cd -
#
# - name: Run Security Scan
# uses: datreeio/action-datree@main
# with:
# path: 'library/common-test'
# cliArguments: '--ignore-missing-schemas --policy ManifestManager'
# isHelmChart: true
# helmArguments: '--values library/common-test/ci/${{ matrix.values }}'
#
# security-vpn:
# needs:
# - lint
# name: Security Scans (vpn)
# runs-on: ubuntu-22.04
# strategy:
# fail-fast: false
# matrix:
# # We run tests on k3s version of latest SCALE release and SCALE nightly
# k3s-version:
# - v1.26
# - v1.27
# - v1.28
# # We run tests on Helm version of latest SCALE release
# helm-version:
# - v3.12.3
# - v3.14.0
# values:
# - vpn-gluetun-values.yaml
# - vpn-tailscale-values.yaml
# # Is deprecated and runs as root, skipping for now
# # - vpn-openvpn-values.yaml
# - vpn-wireguard-values.yaml
#
# steps:
# - name: Install Helm
# uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3
# with:
# version: ${{ matrix.helm-version }}
#
# - name: Checkout
# uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
# with:
# fetch-depth: 1
#
# - name: build helm deps
# run: |
# cd library/common-test
# helm dependency update
# cd -
#
# - name: Run Security Scan
# uses: datreeio/action-datree@main
# with:
# path: 'library/common-test'
# cliArguments: '--ignore-missing-schemas --policy WithVPN'
# isHelmChart: true
# helmArguments: '--values library/common-test/ci/${{ matrix.values }}'