-
-
Notifications
You must be signed in to change notification settings - Fork 29
374 lines (374 loc) · 13.2 KB
/
ci.yml
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
name: Continuous Integration
on:
push:
branches:
- master
pull_request:
jobs:
generate-ref:
name: Generate Ref
runs-on: ubuntu-latest
outputs:
REF: ${{ steps.generate-ref.outputs.ref }}
steps:
- run: helm version
- uses: actions/checkout@v1
- run: helm version
- id: generate-ref
name: Generate Ref
run: |
if [ "${{ github.event_name }}" == "pull_request" ] ; then
ref=$(php -r "echo str_replace('/', '-SLASH-', '${{ github.event.pull_request.head.ref }}');")
echo "$ref"
printf "::set-output name=ref::%s" $ref
exit 0
fi
echo "${GITHUB_REF##*/}"
echo "::set-output name=ref::${GITHUB_REF##*/}"
runner-matrix:
name: Runner Matrix
runs-on: ubuntu-latest
outputs:
runner: ${{ steps.runner-matrix.outputs.runner }}
steps:
- id: runner-matrix
name: Runner Matrix
run: |
echo "::set-output name=runner::[\"ubuntu-latest\"]"
tests-helm-works:
name: "Testing Helm Command: ${{ matrix.exec }} on ${{ matrix.runner }}"
runs-on: ${{ matrix.runner }}
needs:
- runner-matrix
strategy:
matrix:
runner: ${{ fromJson(needs.runner-matrix.outputs.runner) }}
exec:
- "helm version"
- "helm repo add WyriHaximusNet https://helm.wyrihaximus.net/"
- "helm repo add WyriHaximusNet https://helm.wyrihaximus.net/ && helm repo list"
- "helm plugin install https://github.com/hypnoglow/helm-s3.git"
- "helm plugin install https://github.com/hypnoglow/helm-s3.git && helm plugin list"
- "helm env"
steps:
- uses: actions/checkout@v1
- uses: ./
with:
exec: ${{ matrix.exec }}
kubeconfig: tada
tests-helm-output:
name: "Testing Helm Output ${{ matrix.runner }}"
runs-on: ${{ matrix.runner }}
needs:
- runner-matrix
strategy:
matrix:
runner: ${{ fromJson(needs.runner-matrix.outputs.runner) }}
steps:
- uses: actions/checkout@v1
- run: helm version
- uses: ./
id: helm3
with:
exec: helm repo add WyriHaximusNet https://helm.wyrihaximus.net/ && helm repo list
kubeconfig: tada
- run: |
php -r "exit(strpos('${HELM_OUTPUT}', 'WyriHaximusNet') !== false ? 0 : 255);"
env:
HELM_OUTPUT: ${{ steps.helm3.outputs.helm_output }}
- run: |
php -r "exit(strpos('${HELM_OUTPUT}', 'has been added to your repositories') !== false ? 0 : 255);"
env:
HELM_OUTPUT: ${{ steps.helm3.outputs.helm_output }}
- run: |
php -r "exit(strpos('${HELM_OUTPUT}', 'https://helm.wyrihaximus.net/') !== false ? 0 : 255);"
env:
HELM_OUTPUT: ${{ steps.helm3.outputs.helm_output }}
tests-helm-install-input:
name: "Testing Helm Install (input) ${{ matrix.runner }}"
runs-on: ${{ matrix.runner }}
needs:
- runner-matrix
strategy:
matrix:
runner: ${{ fromJson(needs.runner-matrix.outputs.runner) }}
steps:
- uses: actions/checkout@v1
- name: Create k8s Kind Cluster
uses: helm/[email protected]
- name: Get running image ID
id: ps
run: printf "::set-output name=id::%s" $(docker ps --format "{{.ID}}")
env:
IMAGE: ${{ steps.build.outputs.tag }}
- name: Get running image IP
id: inspect
run: printf "::set-output name=ip::%s" $(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${IMAGE_ID})
env:
IMAGE_ID: ${{ steps.ps.outputs.id }}
- run: sed -i "s/127.0.0.1:32768/${KIND_IP}:6443/g" ~/.kube/config
env:
KIND_IP: ${{ steps.inspect.outputs.ip }}
- name: Make kubeconfig available to Helm3 action
run: |
kubeconfig=$(cat ~/.kube/config)
kubeconfig="${kubeconfig//'%'/'%25'}"
kubeconfig="${kubeconfig//$'\n'/'%0A'}"
kubeconfig="${kubeconfig//$'\r'/'%0D'}"
echo "::set-output name=kubeconfig::$kubeconfig"
id: kubeconfig
- name: List installed packages
uses: ./
id: helmlistcountfirst
with:
exec: |
printf "count=%s\n" $(helm list | grep ducker-hub-exporter | wc -l) >> $GITHUB_OUTPUT
kubeconfig: ${{ steps.kubeconfig.outputs.kubeconfig }}
- run: |
php -r "exit(trim('${COUNT}') === '0' ? 0 : 255);"
env:
COUNT: ${{ steps.helmlistcountfirst.outputs.count }}
- name: Install ducker-hub-exporter
uses: ./
id: helm3
with:
exec: |
helm repo add WyriHaximusNet https://helm.wyrihaximus.net/
helm install ducker-hub-exporter WyriHaximusNet/docker-hub-exporter --atomic
kubeconfig: ${{ steps.kubeconfig.outputs.kubeconfig }}
- name: List installed packages
uses: ./
with:
exec: |
helm list
kubeconfig: ${{ steps.kubeconfig.outputs.kubeconfig }}
- name: List installed packages
uses: ./
id: helmlistcountseccond
with:
exec: |
helm list
printf "::set-output name=count::%s" $(helm list | grep ducker-hub-exporter | wc -l)
kubeconfig: ${{ steps.kubeconfig.outputs.kubeconfig }}
- run: |
php -r "exit(trim('${COUNT}') === '1' ? 0 : 255);"
env:
COUNT: ${{ steps.helmlistcountseccond.outputs.count }}
- name: UnInstall ducker-hub-exporter
uses: ./
with:
exec: |
helm uninstall ducker-hub-exporter
kubeconfig: ${{ steps.kubeconfig.outputs.kubeconfig }}
- name: List installed packages
uses: ./
id: helmlistcountthird
with:
exec: |
helm list
printf "::set-output name=count::%s" $(helm list | grep ducker-hub-exporter | wc -l)
kubeconfig: ${{ steps.kubeconfig.outputs.kubeconfig }}
- run: |
php -r "exit(trim('${COUNT}') === '0' ? 0 : 255);"
env:
COUNT: ${{ steps.helmlistcountthird.outputs.count }}
tests-helm-install-input-overruled:
name: "Testing Helm Install (input overruled) ${{ matrix.runner }}"
runs-on: ${{ matrix.runner }}
needs:
- runner-matrix
strategy:
matrix:
runner: ${{ fromJson(needs.runner-matrix.outputs.runner) }}
steps:
- uses: actions/checkout@v1
- name: Create k8s Kind Cluster
uses: helm/[email protected]
- name: Get running image ID
id: ps
run: printf "::set-output name=id::%s" $(docker ps --format "{{.ID}}")
env:
IMAGE: ${{ steps.build.outputs.tag }}
- name: Get running image IP
id: inspect
run: printf "::set-output name=ip::%s" $(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${IMAGE_ID})
env:
IMAGE_ID: ${{ steps.ps.outputs.id }}
- run: sed -i "s/127.0.0.1:32768/${KIND_IP}:6443/g" ~/.kube/config
env:
KIND_IP: ${{ steps.inspect.outputs.ip }}
- name: Make kubeconfig available to Helm3 action
run: |
kubeconfig=$(cat ~/.kube/config)
kubeconfig="${kubeconfig//'%'/'%25'}"
kubeconfig="${kubeconfig//$'\n'/'%0A'}"
kubeconfig="${kubeconfig//$'\r'/'%0D'}"
echo "::set-output name=kubeconfig::$kubeconfig"
id: kubeconfig
- name: List installed packages
uses: ./
id: helmlistcountfirst
with:
exec: |
printf "count=%s\n" $(helm list | grep ducker-hub-exporter | wc -l) >> $GITHUB_OUTPUT
kubeconfig: ${{ steps.kubeconfig.outputs.kubeconfig }}
- run: |
php -r "exit(trim('${COUNT}') === '0' ? 0 : 255);"
env:
COUNT: ${{ steps.helmlistcountfirst.outputs.count }}
- name: Install ducker-hub-exporter
uses: ./
id: helm3
with:
exec: |
helm repo add WyriHaximusNet https://helm.wyrihaximus.net/
helm install ducker-hub-exporter WyriHaximusNet/docker-hub-exporter --atomic
kubeconfig: ${{ steps.kubeconfig.outputs.kubeconfig }}
- name: List installed packages
uses: ./
with:
exec: |
helm list
kubeconfig: ${{ steps.kubeconfig.outputs.kubeconfig }}
- run: |
rm ~/.kube -Rf
mkdir ~/.kube
echo "junk" > ~/.kube/config
- name: Get kubeconfig contents
uses: ./
id: getkubeconfigcontents
with:
exec: |
helm list
printf "::set-output name=cnt::%s" $(cat ~/.kube/config)
kubeconfig: ${{ steps.kubeconfig.outputs.kubeconfig }}
- name: "Assert kubeconfig really contains: junk"
uses: nick-fields/assert-action@v1
with:
expected: junk
actual: ${{ steps.getkubeconfigcontents.outputs.cnt }}
- name: List installed packages through a overruled kubeconfig
uses: ./
id: helmlistcountoverruledkubeconfig
with:
exec: |
helm list
printf "::set-output name=count::%s" $(helm list | grep ducker-hub-exporter | wc -l)
kubeconfig: ${{ steps.kubeconfig.outputs.kubeconfig }}
overrule_existing_kubeconfig: "true"
- run: |
php -r "exit(trim('${COUNT}') === '1' ? 0 : 255);"
env:
COUNT: ${{ steps.helmlistcountoverruledkubeconfig.outputs.count }}
- run: |
rm ~/.kube -Rf
- name: UnInstall ducker-hub-exporter
uses: ./
with:
exec: |
helm uninstall ducker-hub-exporter
kubeconfig: ${{ steps.kubeconfig.outputs.kubeconfig }}
- name: List installed packages
uses: ./
id: helmlistcountthird
with:
exec: |
helm list
printf "::set-output name=count::%s" $(helm list | grep ducker-hub-exporter | wc -l)
kubeconfig: ${{ steps.kubeconfig.outputs.kubeconfig }}
- run: |
php -r "exit(trim('${COUNT}') === '0' ? 0 : 255);"
env:
COUNT: ${{ steps.helmlistcountthird.outputs.count }}
tests-helm-install-file:
name: "Testing Helm Install (file) ${{ matrix.runner }}"
runs-on: ${{ matrix.runner }}
needs:
- runner-matrix
strategy:
matrix:
runner: ${{ fromJson(needs.runner-matrix.outputs.runner) }}
steps:
- uses: actions/checkout@v1
- name: Create k8s Kind Cluster
uses: helm/[email protected]
- name: Get running image ID
id: ps
run: printf "::set-output name=id::%s" $(docker ps --format "{{.ID}}")
env:
IMAGE: ${{ steps.build.outputs.tag }}
- name: Get running image IP
id: inspect
run: printf "::set-output name=ip::%s" $(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${IMAGE_ID})
env:
IMAGE_ID: ${{ steps.ps.outputs.id }}
- run: sed -i "s/127.0.0.1:32768/${KIND_IP}:6443/g" ~/.kube/config
env:
KIND_IP: ${{ steps.inspect.outputs.ip }}
- name: List installed packages
uses: ./
id: helmlistcountfirst
with:
exec: |
helm list | grep ducker-hub-exporter | wc -l
- run: |
php -r "exit(trim('${COUNT}') === '0' ? 0 : 255);"
env:
COUNT: ${{ steps.helmlistcountfirst.outputs.helm_output }}
- name: Install ducker-hub-exporter
uses: ./
id: helm3
with:
exec: |
helm repo add WyriHaximusNet https://helm.wyrihaximus.net/
helm install ducker-hub-exporter WyriHaximusNet/docker-hub-exporter --atomic
- name: List installed packages
uses: ./
with:
exec: |
helm list
- name: List installed packages
uses: ./
id: helmlistcountseccond
with:
exec: |
helm list | grep ducker-hub-exporter | wc -l
- run: |
php -r "exit(trim('${COUNT}') === '1' ? 0 : 255);"
env:
COUNT: ${{ steps.helmlistcountseccond.outputs.helm_output }}
- name: UnInstall ducker-hub-exporter
uses: ./
with:
exec: |
helm uninstall ducker-hub-exporter
- name: List installed packages
uses: ./
id: helmlistcountthird
with:
exec: |
helm list | grep ducker-hub-exporter | wc -l
- run: |
php -r "exit(trim('${COUNT}') === '0' ? 0 : 255);"
env:
COUNT: ${{ steps.helmlistcountthird.outputs.helm_output }}
## Keeping this in for future use, but GitHub Actions doesn't turn this job green so it's considered fail, which it isn't 🤣
# ensure-failure-on-non-0-exit-code:
# name: "Ensure failure on non 0 exit code ${{ matrix.runner }}"
# runs-on: ${{ matrix.runner }}
# continue-on-error: true
# needs:
# - runner-matrix
# strategy:
# matrix:
# runner: ${{ fromJson(needs.runner-matrix.outputs.runner) }}
# steps:
# - uses: actions/checkout@v1
# - name: List installed packages
# uses: ./
# with:
# exec: |
# exit 1
# - run: |
# exit 0
# if: ${{ failure() }}