-
-
Notifications
You must be signed in to change notification settings - Fork 28
483 lines (471 loc) · 15.7 KB
/
python-tester.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
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
name: pytest and try it yourself example
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build_test_image:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: PyServer Test Image meta
id: test_image_meta
uses: docker/metadata-action@v5
with:
flavor: |
latest=false
images: |
gefyra/pyserver
tags: |
type=ref,event=pr,enable=${{ !!github.event.pull_request }}
type=raw,value=test-run-${{ github.run_id }},enable=${{ !github.event.pull_request }}
labels: |
quay.expires-after=24h
- name: Build and push
uses: docker/build-push-action@v6
env:
DOCKER_BUILD_NO_SUMMARY: true
with:
context: testing/images/
platforms: linux/amd64
push: false
load: true
file: testing/images/Dockerfile.local
tags: pyserver
outputs: type=docker,dest=/tmp/pyserver.tar
- name: Upload pyserver image
uses: actions/upload-artifact@v4
with:
name: pyserver
path: /tmp/pyserver.tar
build_operator:
runs-on: ubuntu-latest
outputs:
tags: ${{ steps.operator_meta.outputs.tags }}
steps:
- name: Checkout
uses: actions/checkout@v4
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Login to quay.io
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_ROBOT }}
password: ${{ secrets.QUAY_ROBOT_TOKEN }}
#
# Gefyra Operator
#
- name: Operator Image meta
id: operator_meta
uses: docker/metadata-action@v5
with:
flavor: |
latest=false
images: |
quay.io/gefyra/operator
tags: |
type=raw,value=test-run-${{ github.run_id }},enable=${{ !github.event.pull_request }}
type=ref,event=pr,enable=${{ !!github.event.pull_request }}
labels: |
quay.expires-after=24h
- name: Build and push
uses: docker/build-push-action@v6
env:
DOCKER_BUILD_NO_SUMMARY: true
with:
context: operator/
platforms: linux/amd64
push: true
load: false
tags: ${{ steps.operator_meta.outputs.tags }}
labels: ${{ steps.operator_meta.outputs.labels }}
cache-from: type=registry,ref=quay.io/gefyra/operator:latest
outputs: type=docker,dest=/tmp/operator.tar
- name: Upload operator image
uses: actions/upload-artifact@v4
with:
name: operator
path: /tmp/operator.tar
build_cargo:
runs-on: ubuntu-latest
outputs:
tags: ${{ steps.cargo_meta.outputs.tags }}
steps:
- name: Checkout
uses: actions/checkout@v4
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
#
# Gefyra Cargo
#
- name: Cargo Image meta
id: cargo_meta
uses: docker/metadata-action@v5
with:
flavor: |
latest=false
images: |
quay.io/gefyra/cargo
tags: |
type=raw,value=test-run-${{ github.run_id }},enable=${{ !github.event.pull_request }}
type=ref,event=pr,enable=${{ !!github.event.pull_request }}
labels: |
quay.expires-after=24h
- name: Build and push
uses: docker/build-push-action@v6
env:
DOCKER_BUILD_NO_SUMMARY: true
with:
context: cargo/
platforms: linux/amd64
push: false
target: cargo
tags: ${{ steps.cargo_meta.outputs.tags }}
labels: ${{ steps.cargo_meta.outputs.labels }}
cache-from: type=registry,ref=quay.io/gefyra/cargo:latest
outputs: type=docker,dest=/tmp/cargo.tar
- name: Upload cargo image
uses: actions/upload-artifact@v4
with:
name: cargo
path: /tmp/cargo.tar
test_python:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set fake kubeconfig
shell: bash
run: |
mkdir -p ~/.kube/
cd ~/.kube
touch config
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Set Gefyra tracking config / fake kubeconfig
shell: bash
run: |
mkdir -p ~/.gefyra
cd ~/.gefyra
touch config.ini
echo "[telemetry]" >> config.ini
echo "track = False" >> config.ini
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Install dependencies
working-directory: ./client
run: poetry install --with dev --no-interaction --no-root
- name: Install k3d
run: curl --silent --fail https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | TAG=v5.5.1 bash
- name: Run PyTest
working-directory: ./client
run: poetry run coverage run -m pytest tests/unit/
- name: Upload coverage data to coveralls.io
if: github.repository == 'gefyrahq/gefyra'
working-directory: ./client
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
COVERALLS_FLAG_NAME: client
COVERALLS_PARALLEL: true
run: poetry run coveralls --service=github-actions
- uses: actions/upload-artifact@v4
with:
name: coverage_data
path: ./client/.coverage*
test_minikube:
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
driver: ''
kubectl_os: linux
- os: macos-13
driver: virtualbox
kubectl_os: darwin
needs:
- build_operator
- build_cargo
- build_test_image
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
# https://github.com/opensafely-core/job-server/issues/3429
- run: brew install docker
if: ${{ matrix.os == 'macos-13' }}
- name: Install QEMU 9.0.2
uses: docker/actions-toolkit/.github/actions/macos-setup-qemu@8e475672d005e1bef9417c8cdd16b6c512d1cab7
if: ${{ matrix.os == 'macos-13' }}
- name: Set up Docker
uses: crazy-max/ghaction-setup-docker@v3
if: ${{ matrix.os == 'macos-13' }}
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Set Gefyra tracking config / fake kubeconfig
shell: bash
run: |
mkdir -p ~/.gefyra
mkdir -p ~/.kube
cd ~/.gefyra
touch config.ini
echo "[telemetry]" >> config.ini
echo "track = False" >> config.ini
cd ~/.kube
touch config
- name: Download artifact
uses: actions/download-artifact@v4
with:
path: /tmp
- name: start minikube
id: minikube
uses: medyagh/setup-minikube@latest
with:
start-args: --ports 127.0.0.1:31820:31820/udp
- name: Load Gefyra images
run: |
eval $(minikube docker-env)
docker load --input /tmp/pyserver/pyserver.tar
docker load --input /tmp/cargo/cargo.tar
docker load --input /tmp/operator/operator.tar
docker tag ${{ needs.build_operator.outputs.tags }} quay.io/gefyra/operator:2.1.6
docker image ls -a
- name: Install dependencies
working-directory: ./client
run: poetry install --with dev --no-interaction --no-root
- name: Run gefyra up
timeout-minutes: 8
working-directory: ./client
run: |
poetry run coverage run -a -m gefyra.cli.main --debug up --minikube
- name: Show cargo logs
working-directory: ./client
if: ${{ failure() }}
run: |
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/${{ matrix.kubectl_os }}/amd64/kubectl"
chmod +x ./kubectl
./kubectl get pod -n gefyra
./kubectl logs -n gefyra gefyra-stowaway-0
./kubectl logs --previous -n gefyra deploy/gefyra-operator-webhook
./kubectl logs -n gefyra deploy/gefyra-operator-webhook
./kubectl describe pods -n gefyra -l gefyra.dev/role=webhook
./kubectl logs -n gefyra deploy/gefyra-operator
docker inspect minikube
docker inspect gefyra-cargo-default
docker logs gefyra-cargo-default
- name: Show coverage report
working-directory: ./client
run: |
poetry run coverage report
- name: Upload coverage data to coveralls.io
if: github.repository == 'gefyrahq/gefyra'
working-directory: ./client
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
COVERALLS_FLAG_NAME: client
COVERALLS_PARALLEL: true
run: |
poetry run coveralls --service=github-actions
- uses: actions/upload-artifact@v4
with:
name: coverage_data-${{ matrix.os }}
path: ./client/.coverage*
test:
strategy:
fail-fast: false
matrix:
k3d: [v1.25.16-k3s4, v1.26.15-k3s1, v1.27.14-k3s1, v1.28.10-k3s1, v1.29.5-k3s1, v1.30.1-k3s1]
needs:
- build_cargo
- build_operator
- build_test_image
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- name: Checkout
uses: actions/checkout@v4
# https://github.com/docker/setup-qemu-action
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Set Gefyra tracking config / fake kubeconfig
shell: bash
run: |
mkdir -p ~/.gefyra
mkdir -p ~/.kube
cd ~/.gefyra
touch config.ini
echo "[telemetry]" >> config.ini
echo "track = False" >> config.ini
cd ~/.kube
touch config
#
# Create a cluster with registry
#
- uses: AbsaOSS/k3d-action@v2
name: Create Single Cluster
with:
cluster-name: "mycluster"
k3d-version: v5.5.1
args: >-
--agents 1
-p "31820:31820/UDP@agent:0"
--image docker.io/rancher/k3s:${{ matrix.k3d }}
--kubeconfig-update-default
--kubeconfig-switch-context
- name: Download artifact
uses: actions/download-artifact@v4
with:
path: /tmp
- name: Load Operator image
run: |
docker load --input /tmp/pyserver/pyserver.tar
docker load --input /tmp/cargo/cargo.tar
docker load --input /tmp/operator/operator.tar
docker image ls -a
docker tag ${{ needs.build_operator.outputs.tags }} quay.io/gefyra/operator:2.1.6
- name: Import Operator to k3d
run: |
k3d image import quay.io/gefyra/operator:2.1.6 -c mycluster --verbose
- name: Pytest
working-directory: ./client
run: poetry install --with dev --no-interaction --no-root
# Run the 'Try it yourself'
- name: Apply some workload
run: |
kubectl apply -f testing/workloads/hello.yaml
- name: Run Gefyra K3D Tests
working-directory: ./client
run: |
poetry run coverage run -m pytest -vvv -s -x --full-trace --timeout=240 tests/e2e/
- name: Show gefyra-operator logs
working-directory: ./client
if: ${{ failure() }}
run: |
kubectl get pods -n gefyra
kubectl describe deployment -n gefyra gefyra-operator
kubectl describe deployment -n gefyra gefyra-operator-webhook
kubectl logs -n gefyra deployment/gefyra-operator
kubectl logs -n gefyra deployment/gefyra-operator-webhook
kubectl get -A ValidatingWebhookConfiguration
kubectl get cm -n gefyra
kubectl describe cm -n gefyra gefyra-stowaway-proxyroutes
kubectl describe cm -n gefyra gefyra-stowaway-config
kubectl describe pod -n gefyra gefyra-stowaway-0
kubectl logs -n gefyra pod/gefyra-stowaway-0
kubectl get pvc -A
kubectl describe -n gefyra pvc stowaway-config-gefyra-stowaway-0
- name: Show coverage report
working-directory: ./client
run: |
poetry run coverage report
- name: Upload coverage data to coveralls.io
if: github.repository == 'gefyrahq/gefyra'
working-directory: ./client
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
COVERALLS_FLAG_NAME: client
COVERALLS_PARALLEL: true
run: |
poetry run coveralls --service=github-actions
- uses: actions/upload-artifact@v4
with:
name: coverage_data-${{ matrix.k3d }}
path: ./client/.coverage*
test_operator:
name: Test Gefyra Operator
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Checkout
uses: actions/checkout@v4
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Install dependencies
working-directory: ./operator
run: poetry install --with dev --no-interaction --no-root
- name: Install k3d
run: curl --silent --fail https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | TAG=v5.5.1 bash
- name: Run PyTest
working-directory: ./operator
run: poetry run coverage run -m pytest -s -x --retries 5
- name: Upload coverage data to coveralls.io
if: github.repository == 'gefyrahq/gefyra'
working-directory: ./operator
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
COVERALLS_FLAG_NAME: operator
COVERALLS_PARALLEL: true
run: poetry run coveralls --service=github-actions
coveralls:
name: Indicate completion to coveralls.io
if: github.repository == 'gefyrahq/gefyra'
# need secrets.GITHUB_TOKEN
needs:
- test
- test_minikube
- test_python
- test_operator
runs-on: ubuntu-latest
container: python:3-slim
steps:
- name: Finished
run: |
pip3 install --upgrade coveralls
coveralls --service=github-actions --finish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}