-
Notifications
You must be signed in to change notification settings - Fork 23
518 lines (452 loc) · 16.1 KB
/
turing.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
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
name: Turing CI
on:
# Automatically run CI on Release and Pre-Release tags and main branch
# (except changes to non-relevant paths)
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
branches:
- main
paths-ignore:
- "docs/**"
- "engines/pyfunc-ensembler-job/**"
- "engines/pyfunc-ensembler-service/**"
- "scripts/fluentd-bigquery/**"
- "sdk/**"
- ".github/workflows/pyfunc-ensembler-job.yaml"
- ".github/workflows/pyfunc-ensembler-service.yaml"
- ".github/workflows/sdk.yaml"
- ".github/workflows/cluster-init.yaml"
# Automatically run CI on branches, that have active PR opened
pull_request:
branches:
- main
paths-ignore:
- "docs/**"
- "engines/pyfunc-ensembler-job/**"
- "engines/pyfunc-ensembler-service/**"
- "scripts/fluentd-bigquery/**"
- ".github/workflows/pyfunc-ensembler-job.yaml"
- ".github/workflows/pyfunc-ensembler-service.yaml"
- ".github/workflows/sdk.yaml"
# To make it possible to trigger e2e CI workflow for any arbitrary git ref
workflow_dispatch:
env:
ARTIFACT_RETENTION_DAYS: 7
GO_VERSION: "1.22"
GO_LINT_VERSION: v1.56.2
CLUSTER_NAME: turing-e2e
ISTIO_VERSION: 1.9.9
KNATIVE_VERSION: 1.7.4
KNATIVE_ISTIO_VERSION: 1.7.1
LOCAL_REGISTRY: registry.localhost:5000
jobs:
build-api:
runs-on: ubuntu-latest
outputs:
api-version: ${{ steps.build-image.outputs.api-version }}
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
# This is needed due to the issue raised here: https://github.com/golang/go/issues/61455
- name: Install Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: false
cache-dependency-path: api/go.sum
- name: Build Docker image
id: build-image
working-directory: api
run: |
set -o pipefail
make build-image | tee output.log
echo "::set-output name=api-version::$(sed -n 's%turing-api version: \(.*\)%\1%p' output.log)"
- name: Save Docker image
run: |
docker image save \
--output turing-api.${{ steps.build-image.outputs.api-version }}.tar \
turing-api:${{ steps.build-image.outputs.api-version }}
- name: Publish Artifact
uses: actions/upload-artifact@v4
with:
name: turing-api.${{ steps.build-image.outputs.api-version }}.tar
path: turing-api.${{ steps.build-image.outputs.api-version }}.tar
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
build-router:
runs-on: ubuntu-latest
outputs:
router-version: ${{ steps.build-image.outputs.router-version }}
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
# This is needed due to the issue raised here: https://github.com/golang/go/issues/61455
- name: Install Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: false
cache-dependency-path: api/go.sum
- name: Build Docker image
id: build-image
working-directory: engines/router
run: |
set -o pipefail
make build-image | tee output.log
echo "::set-output name=router-version::$(sed -n 's%turing-router version: \(.*\)%\1%p' output.log)"
- name: Save Docker image
run: |
docker image save \
--output turing-router.${{ steps.build-image.outputs.router-version }}.tar \
turing-router:${{ steps.build-image.outputs.router-version }}
- name: Publish Artifact
uses: actions/upload-artifact@v4
with:
name: turing-router.${{ steps.build-image.outputs.router-version }}.tar
path: turing-router.${{ steps.build-image.outputs.router-version }}.tar
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
build-test-experiment-engine-plugin:
runs-on: ubuntu-latest
env:
VERSION: latest
outputs:
test-experiment-engine-plugin-version: ${{ env.VERSION }}
steps:
- name: Check out code
uses: actions/checkout@v4
# This is needed due to the issue raised here: https://github.com/golang/go/issues/61455
- name: Install Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: false
- name: Build Docker image
working-directory: engines/experiment/examples/plugins/hardcoded
run: |
set -o pipefail
make build-image
- name: Save Docker image
run: |
docker image save \
--output test-experiment-engine-plugin.${{ env.VERSION }}.tar \
plugin-example-engine-plugin:${{ env.VERSION }}
- name: Publish Artifact
uses: actions/upload-artifact@v4
with:
name: test-experiment-engine-plugin.${{ env.VERSION }}.tar
path: test-experiment-engine-plugin.${{ env.VERSION }}.tar
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
build-ui:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ui
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Install system dependencies
run: sudo apt-get install --no-install-recommends gcc make libpng-dev
- name: Set up Node 20.x
uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: yarn
cache-dependency-path: ui/yarn.lock
- name: Install
run: NODE_OPTIONS=--openssl-legacy-provider yarn install --network-concurrency 1
- name: Lint code
run: yarn lint
- name: Build UI
env:
NODE_OPTIONS: "--max_old_space_size=4096"
run: yarn build
- name: Publish Artifact
uses: actions/upload-artifact@v4
with:
name: turing-ui-dist
path: ui/build/
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
build-cluster-init:
runs-on: ubuntu-latest
outputs:
cluster-init-version: ${{ steps.build-cluster-init.outputs.cluster-init-version }}
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run action build-cluster-init
id: build-cluster-init
uses: ./.github/actions/build-cluster-init
with:
artifact_retention_days: ${{ env.ARTIFACT_RETENTION_DAYS }}
test-api:
runs-on: ubuntu-latest
env:
GOPATH: ${{ github.workspace }}/api/.go
needs:
- build-api
services:
postgres:
image: postgres:13-alpine
env:
POSTGRES_DB: turing
POSTGRES_USER: turing-admin
POSTGRES_PASSWORD: secret
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: api/go.sum
- name: Setup
working-directory: api
run: make setup
- name: Run test
working-directory: api
env:
DATABASE_HOST: localhost
DATABASE_NAME: turing
DATABASE_USER: turing-admin
DATABASE_PASSWORD: secret
run: make test
- name: Lint code
uses: golangci/golangci-lint-action@v3
with:
version: ${{ env.GO_LINT_VERSION }}
working-directory: api
args: --timeout 3m --verbose
test-engines-router:
runs-on: ubuntu-latest
defaults:
run:
working-directory: engines/router
env:
GOPATH: ${{ github.workspace }}/engines/router/.go
needs:
- build-router
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: engines/router/go.sum
- name: Setup
run: make setup
- name: Run test
run: make test
- name: Run Benchmark
run: make benchmark
- name: Lint code
uses: golangci/golangci-lint-action@v3
with:
version: ${{ env.GO_LINT_VERSION }}
working-directory: engines/router
skip-go-installation: true
args: --verbose
test-engines-experiment:
runs-on: ubuntu-latest
env:
GOPATH: ${{ github.workspace }}/engines/experiment/.go
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: engines/experiment/go.sum
- name: Run test
working-directory: engines/experiment
run: make test
- name: Lint code
uses: golangci/golangci-lint-action@v2
with:
version: ${{ env.GO_LINT_VERSION }}
working-directory: engines/experiment
skip-go-installation: true
args: --verbose
test-e2e:
runs-on: ubuntu-latest
env:
CLUSTER_INIT_VERSION: ${{ needs.build-cluster-init.outputs.cluster-init-version }}
TURING_API_VERSION: ${{ needs.build-api.outputs.api-version }}
TURING_ROUTER_VERSION: ${{ needs.build-router.outputs.router-version }}
TEST_EXPERIMENT_ENGINE_PLUGIN_VERSION: ${{ needs.build-test-experiment-engine-plugin.outputs.test-experiment-engine-plugin-version }}
needs:
- build-api
- build-router
- build-test-experiment-engine-plugin
- build-cluster-init
strategy:
fail-fast: false
matrix:
name:
[
"In-cluster credentials; API e2e",
"Remote cluster credentials; SDK e2e",
]
include:
- name: "In-cluster credentials; API e2e"
useInClusterConfig: true
valuesFile: "turing.values.in-cluster.yaml"
useSDK: false
- name: "Remote cluster credentials; SDK e2e"
useInClusterConfig: false
valuesFile: "turing.values.remote.yaml"
useSDK: true
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set Up Test Cluster
uses: ./.github/actions/setup-test-cluster
with:
go-version: ${{ env.GO_VERSION }}
turing_api_tar_archive_name: turing-api.${{ env.TURING_API_VERSION }}.tar
turing_router_tar_archive_name: turing-router.${{ env.TURING_ROUTER_VERSION }}.tar
experiment_engine_plugin_archive_name: test-experiment-engine-plugin.${{ env.TEST_EXPERIMENT_ENGINE_PLUGIN_VERSION }}.tar
cluster_init_tar_archive_name: cluster-init.${{ env.CLUSTER_INIT_VERSION }}.tar
use_in_cluster_config: ${{ matrix.useInClusterConfig }}
values_file: ${{ matrix.valuesFile }}
cluster_name: ${{ env.CLUSTER_NAME }}
istio_version: ${{ env.ISTIO_VERSION }}
knative_version: ${{ env.KNATIVE_VERSION }}
knative_istio_version: ${{ env.KNATIVE_ISTIO_VERSION }}
local_registry: ${{ env.LOCAL_REGISTRY }}
cluster_init_version: ${{ env.CLUSTER_INIT_VERSION }}
- name: Set up Go
if: ${{ !matrix.useSDK }}
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: api/go.sum
- name: Setup Python
if: ${{ matrix.useSDK }}
uses: actions/setup-python@v5
with:
python-version: 3.9
cache-dependency-path: sdk/requirements.txt
- name: Install Python dependencies
if: ${{ matrix.useSDK }}
working-directory: sdk
run: make setup
- name: Run End-to-End Test Suite with Turing API
if: ${{ !matrix.useSDK }}
id: run-e2e-test
working-directory: api
env:
GOPATH: ${{ github.workspace }}/api/.go
run: |
make setup-e2e
make test-e2e
- name: Run End-to-End Test Suite with Turing SDK
if: ${{ matrix.useSDK }}
id: run-e2e-test-sdk
working-directory: sdk
env:
GOPATH: ${{ github.workspace }}/api/.go
TEST_ID: ${{ github.run_id }}
MOCKSERVER_HTTP_ENDPOINT: http://mockserver
MOCKSERVER_UPI_CONTROL_ENDPOINT: mockserver-upi-control:80
MOCKSERVER_UPI_A_ENDPOINT: mockserver-upi-a:80
API_BASE_PATH: http://turing-gateway.127.0.0.1.nip.io/api/turing/
MODEL_CLUSTER_NAME: "dev"
PROJECT_ID: "1"
PROJECT_NAME: default
KUBECONFIG_USE_LOCAL: true
TEST_ECHO_IMAGE: eexit/mirror-http-server:1.1.3
KSERVICE_DOMAIN: 127.0.0.1.nip.io
run: make e2e-sdk
- if: (steps.run-e2e-test.outcome == 'failure' || steps.run-e2e-test-sdk.outcome == 'failure') && always()
name: "Debug Deployment Failure"
run: |
echo "::group::describe deployment/turing-mlp"
kubectl describe deployment/turing-mlp
echo "::endgroup::"
echo "::group::describe deployment/turing-merlin"
kubectl describe deployment/turing-merlin
echo "::endgroup::"
echo "::group::describe deployment/turing"
kubectl describe deployment/turing
echo "::endgroup::"
echo "::group::secret/turing-api-config"
kubectl get secret/turing-api-config -o jsonpath='{.data.config\.yaml}' | base64 --decode
echo "::endgroup::"
echo "::group::logs deployment/turing-mlp"
kubectl logs deployment/turing-mlp
echo "::endgroup::"
echo "::group::logs deployment/turing-merlin"
kubectl logs deployment/turing-merlin
echo "::endgroup::"
echo "::group::logs deployment/turing"
kubectl logs deployment/turing
echo "::endgroup::"
echo "::group::kubernetes events"
kubectl get events
echo "::endgroup::"
echo "::group::kubernetes deployment"
kubectl get deploy
echo "::endgroup::"
echo "::group::knative serving deployment"
kubectl get ksvc
echo "::endgroup::"
echo "::group::kubernetes pod describe"
kubectl describe pod
echo "::endgroup::"
echo "::group::kubernetes config map"
kubectl get cm -o yaml
echo "::endgroup::"
echo "::group::kubernetes pod logs"
kubectl get pod | awk '{print $1}' | grep -v "NAME" | while read p; echo "POD LOGS $p"; do kubectl logs "$p" --all-containers; done;
echo "::endgroup::"
release-rules:
runs-on: ubuntu-latest
outputs:
release-type: ${{ steps.release-rules.outputs.release-type }}
steps:
- uses: actions/checkout@v4
- id: release-rules
uses: ./.github/actions/release-rules
publish:
# Automatically publish release and pre-release artifacts.
#
# As for dev releases, make it possible to publish artifacts
# manually by approving 'deployment' in the 'manual' environment.
#
# Dev build can be released either from the 'main' branch or
# by running this workflow manually with `workflow_dispatch` event.
if: >-
contains('release,pre-release', needs.release-rules.outputs.release-type)
|| ( github.event_name != 'pull_request' )
|| ( github.event.pull_request.head.repo.full_name == github.repository )
needs:
- build-router
- build-api
- build-ui
- release-rules
- test-e2e
- test-api
- test-engines-router
- test-engines-experiment
uses: ./.github/workflows/turing-publish.yaml
with:
api_version: ${{ needs.build-api.outputs.api-version }}
router_version: ${{ needs.build-router.outputs.router-version }}
environment: ${{ needs.release-rules.outputs.release-type == 'dev' && 'manual' || '' }}
secrets:
ghcr_token: ${{ secrets.GITHUB_TOKEN }}