-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy path.gitlab-ci.yml
618 lines (588 loc) · 21.4 KB
/
.gitlab-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
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
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
include:
- project: "waldur/waldur-pipelines"
file: "/templates/stages.yml"
- project: "waldur/waldur-pipelines"
file: "/templates/test/check-merge-compatibility.yml"
- project: "waldur/waldur-pipelines"
file: "/templates/release/publish-multiarch.yml"
- project: "waldur/waldur-pipelines"
file: "/templates/validate/docker-compose-trigger.yml"
- project: "waldur/waldur-pipelines"
file: "/templates/test/lint-docker-image.yaml"
- project: "waldur/waldur-pipelines"
file: "/templates/test/lint-dockerfile.yaml"
- project: "waldur/waldur-pipelines"
file: "/templates/test/lint-md-files.yml"
- project: "waldur/waldur-pipelines"
file: "/templates/deploy/dev-env-update.yml"
- project: "waldur/waldur-pipelines"
file: "/templates/sbom/generate-python-codebase-sbom.yml"
- project: "waldur/waldur-pipelines"
file: "/templates/sbom/upload-sboms-to-docs.yml"
- project: "waldur/waldur-pipelines"
file: "/templates/sbom/generate-image-sbom.yml"
before_script:
- export
Run linters:
image: registry.hpc.ut.ee/mirror/library/python:3.11-bullseye
stage: test
interruptible: true
rules:
# Skip tests if said so
- if: '$SKIP_TESTS == "true" || $SKIP_TESTS == "yes"'
when: never
- if: '$CI_COMMIT_BRANCH == "develop"'
# If tagged release
- if: '$CI_COMMIT_TAG =~ /^\d+\.\d+\.\d+$/'
# If event is related to a created merge request
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
script:
- pip install pre-commit
- pre-commit run --all
.Unit test runner:
image: registry.hpc.ut.ee/mirror/$WALDUR_MASTERMIND_TEST_IMAGE
stage: test
interruptible: true
rules:
# Skip tests if said so
- if: '$SKIP_TESTS == "true" || $SKIP_TESTS == "yes"'
when: never
- if: '$CI_COMMIT_BRANCH == "develop"'
# If tagged release
- if: '$CI_COMMIT_TAG =~ /^\d+\.\d+\.\d+$/'
# If event is related to a created merge request
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
changes:
- src/**/*
- pyproject.toml
- poetry.lock
- gitlab-ci-test/**/*
services:
- name: "registry.hpc.ut.ee/mirror/library/postgres:15-alpine"
alias: postgres
command:
[
"postgres",
"-cfsync=off",
"-cfull_page_writes=off",
"-cmax_connections=1000",
"-cshared_buffers=1GB",
"-ceffective_cache_size=4GB",
"-cwork_mem=32MB",
"-cmaintenance_work_mem=32MB",
"-ctemp_buffers=16MB",
"-cwal_buffers=48MB",
]
variables:
POSTGRES_DB: test_waldur
POSTGRES_USER: runner
POSTGRES_PASSWORD: waldur
Run unit tests:
extends: .Unit test runner
script:
- |
# Check merge compatibility only it is not a tagged release
if [ "$CI_PIPELINE_SOURCE" == "merge_request_event" ]; then
echo "[+] Add dummy user $GIT_USER_NAME ($GIT_USER_EMAIL)"
git config user.name $GIT_USER_NAME
git config user.email $GIT_USER_EMAIL
echo "[+] Merging branches $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME and origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME"
git merge --no-ff origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
fi
- gitlab-ci-test/waldur-test
- coverage xml
- coverage report
coverage: "/TOTAL.+ ([0-9]{1,3}%)/"
artifacts:
when: always
reports:
junit: report.xml
coverage_report:
coverage_format: cobertura
path: coverage.xml
parallel: 10
Run management command test:
extends: .Unit test runner
script:
- gitlab-ci-test/waldur-test MANAGEMENT
Try building docker image:
image:
name: "gcr.io/kaniko-project/executor:debug"
entrypoint: [""]
stage: test
interruptible: true
rules:
# Skip tests if said so
- if: '$SKIP_TESTS == "true" || $SKIP_TESTS == "yes"'
when: never
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
changes:
- Dockerfile
- docker/**/*
# TODO: drop after testing
- .gitlab-ci.yml
variables:
DOCKER_REGISTRY: registry.hpc.ut.ee/mirror/
script:
- /kaniko/executor
--context "${CI_PROJECT_DIR}"
--dockerfile "${CI_PROJECT_DIR}/Dockerfile"
--build-arg DOCKER_REGISTRY=$DOCKER_REGISTRY
--destination "waldur-mastermind:$CI_COMMIT_REF_SLUG"
--no-push
Generate Image SBOM:
extends: .Generate Image SBOM template
variables:
PROJECT_NAME: "waldur-mastermind"
Generate Codebase SBOM:
extends: .Generate Codebase SBOM template
variables:
PROJECT_NAME: "waldur-mastermind"
before_script:
- apt-get update
- apt-get install -y gcc libldap2-dev libsasl2-dev libssl-dev libdb-dev
Build docker image for tests:
stage: build
interruptible: true
image:
name: "gcr.io/kaniko-project/executor:debug"
entrypoint: [ "" ]
rules:
# If scheduled pipeline for 'develop' branch is set up
- if: '$CI_COMMIT_BRANCH == "develop" && $CI_PIPELINE_SOURCE == "schedule"'
variables:
DOCKER_REGISTRY: registry.hpc.ut.ee/mirror/
script:
- echo $CI_COMMIT_SHA > docker/rootfs/COMMIT
- cat docker/rootfs/COMMIT
- AUTH=$(echo -n "${WALDUR_DOCKER_HUB_USER}:${WALDUR_DOCKER_HUB_PASSWORD}" | base64)
- |
cat << EOF > /kaniko/.docker/config.json
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "${AUTH}"
}
}
}
EOF
- /kaniko/executor
--context "${CI_PROJECT_DIR}"
--dockerfile "${CI_PROJECT_DIR}/gitlab-ci-test/Dockerfile"
--build-arg DOCKER_REGISTRY=$DOCKER_REGISTRY
--destination "$WALDUR_MASTERMIND_TEST_IMAGE"
Publish the latest multiarch docker image:
extends: .Publish multiarch latest docker image template
before_script:
# Merge the before_script from the template
- !reference [.Publish multiarch latest docker image template, before_script]
- echo '[+] Build and publish latest docker image'
- echo $CI_COMMIT_SHA > docker/rootfs/COMMIT_SHA
Publish multiarch docker image with specific version:
extends: .Publish multiarch docker image with specific version template
before_script:
# Merge the before_script from the template
- !reference [.Publish multiarch docker image with specific version template, before_script]
- echo "[+] Build and publish $CI_COMMIT_TAG docker image"
- echo $CI_COMMIT_TAG > docker/rootfs/COMMIT_TAG
- sed -i "s/version = \"0.0.0\"/version = \"$CI_COMMIT_TAG\"/" pyproject.toml
Test Multi-arch docker image build:
stage: test
interruptible: true
image: registry.hpc.ut.ee/mirror/docker:latest
services:
- name: "docker:dind"
command: ["--mtu=1400"]
rules:
# Skip tests if said so
- if: '$SKIP_TESTS == "true" || $SKIP_TESTS == "yes"'
when: never
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
changes:
- Dockerfile
- docker/**/*
- .gitlab-ci.yml
variables:
DOCKER_DRIVER: overlay2
DOCKER_REGISTRY: registry.hpc.ut.ee/mirror/
DOCKER_HUB_REGISTRY: "docker.io"
cache: []
before_script:
- apk update
- apk add --no-cache gcc python3-dev musl-dev linux-headers openldap-dev openssl libffi-dev libjpeg-turbo-dev libxml2-dev libxslt-dev
- echo "$CI_REGISTRY_PASSWORD" | docker login $CI_REGISTRY --username "$CI_REGISTRY_USER" --password-stdin
script:
- docker context create builder
- docker buildx version
- docker buildx create builder --use
- docker buildx build --platform linux/amd64,linux/arm64 --build-arg DOCKER_REGISTRY=$DOCKER_REGISTRY -t ${CI_REGISTRY_IMAGE}:${CI_MERGE_REQUEST_ID}-multiarch --push .
- docker buildx imagetools inspect ${CI_REGISTRY_IMAGE}:${CI_MERGE_REQUEST_ID}-multiarch
- docker pull ${CI_REGISTRY_IMAGE}:${CI_MERGE_REQUEST_ID}-multiarch
- docker image inspect ${CI_REGISTRY_IMAGE}:${CI_MERGE_REQUEST_ID}-multiarch
Lint docker image:
extends: .Lint docker image template
variables:
IMAGE: opennode/waldur-mastermind:latest
Lint dockerfile:
extends: .Lint dockerfile template
variables:
DOCKERFILE: Dockerfile
HADOLINT_CONFIG: |
ignored:
- DL3003 # "WORKDIR" warning
- DL3008 # "versions for `apt install`" warning
- DL3015 # "--no-install-recommends" info
- SC2094 # "read and write the same file in the same pipeline" info
Upload Image SBOM:
extends: .Upload SBOM template
needs:
- Generate Image SBOM
variables:
PROJECT_NAME: "waldur-mastermind"
SBOM_TYPE: "image"
SBOM_DIR: "images"
Upload Source SBOM:
extends: .Upload SBOM template
needs:
- Generate Codebase SBOM
variables:
PROJECT_NAME: "waldur-mastermind"
SBOM_TYPE: "source"
SBOM_DIR: "source"
Upload configuration guide:
stage: deploy
interruptible: true
rules:
- if: '$CI_COMMIT_BRANCH == "develop" && $CI_PIPELINE_SOURCE == "schedule"'
image: registry.hpc.ut.ee/mirror/$WALDUR_MASTERMIND_TEST_IMAGE
variables:
CONF_GUIDE_PATH: docs/admin-guide/mastermind-configuration/configuration-guide.md
CLI_GUIDE_PATH: docs/admin-guide/mastermind-configuration/cli-guide.md
FEATURES_GUIDE_PATH: docs/admin-guide/mastermind-configuration/features.md
NOTIFICATIONS_GUIDE_PATH: docs/admin-guide/mastermind-configuration/notifications.md
TEMPLATES_LIST_PATH: docs/admin-guide/mastermind-configuration/templates.md
DEVELOPER_DOCS_PATH: docs/developer-guide
DJANGO_SETTINGS_MODULE: waldur_core.server.doc_settings
script:
- poetry install
- cd /tmp/
- git clone "https://gitlab-ci-token:$GITLAB_TOKEN@$CI_SERVER_HOST/waldur/waldur-docs.git"
- git config --global user.name "$GITLAB_USER_NAME"
- git config --global user.email "$GITLAB_USER_EMAIL"
- cd waldur-docs
- waldur print_settings > $CONF_GUIDE_PATH
- waldur print_features_docs > $FEATURES_GUIDE_PATH
- waldur print_notifications > $NOTIFICATIONS_GUIDE_PATH
- waldur print_commands > $CLI_GUIDE_PATH
- waldur print_events > $CI_PROJECT_DIR/docs/events.md
- waldur print_templates > $TEMPLATES_LIST_PATH
- waldur graph_models structure -I Customer,Project,OrganizationGroup,ProjectType,User -o $DEVELOPER_DOCS_PATH/core_structure.png
- waldur graph_models permissions -I User,Role,UserRole,RolePermission -o $DEVELOPER_DOCS_PATH/core_permissions.png
- waldur graph_models marketplace -I CategoryGroup,Category,CategoryColumn,Section,Attribute,AttributeOption,CategoryComponent,CategoryComponentUsage,Offering,OfferingComponent,Plan,PlanComponent,Resource,Order -o $DEVELOPER_DOCS_PATH/marketplace.png
- cp -rv $CI_PROJECT_DIR/docs/* $DEVELOPER_DOCS_PATH
- git add $CONF_GUIDE_PATH $FEATURES_GUIDE_PATH $CLI_GUIDE_PATH $DEVELOPER_DOCS_PATH $TEMPLATES_LIST_PATH $NOTIFICATIONS_GUIDE_PATH
- git commit -m "Update configuration, CLI and developer guide" || exit 0
- git branch new-configuration-guide
- git push --set-upstream origin new-configuration-guide:master
before_script: []
Upload HomePort enums:
stage: deploy
interruptible: true
rules:
- if: '$CI_COMMIT_BRANCH == "develop" && $CI_PIPELINE_SOURCE == "schedule"'
image: registry.hpc.ut.ee/mirror/$WALDUR_MASTERMIND_TEST_IMAGE
variables:
DJANGO_SETTINGS_MODULE: waldur_core.server.doc_settings
script:
- poetry install
- cd src/waldur_core/permissions
- python print_permission_enums.py > /tmp/permission_enums.ts
- cd /tmp/
- git clone "https://homeport-updates:$HOMEPORT_ACCESS_TOKEN@$CI_SERVER_HOST/waldur/waldur-homeport.git"
- git config --global user.name "$GITLAB_USER_NAME"
- git config --global user.email "$GITLAB_USER_EMAIL"
- cd waldur-homeport
- git checkout develop
- mv /tmp/permission_enums.ts src/permissions/enums.ts
- waldur print_events_enums > src/EventsEnums.ts
- waldur print_features_enums > src/FeaturesEnums.ts
- waldur print_features_description > src/features/FeaturesDescription.ts
- waldur print_settings_description > src/SettingsDescription.ts
- waldur print_permissions_description > src/administration/roles/PermissionOptions.tsx
- git add src/
- git commit -m "Update enums" || exit 0
- git branch new-enums
- git push --set-upstream origin new-enums:develop
before_script: []
Upload MCP metadata:
stage: deploy
interruptible: true
rules:
- if: '$CI_COMMIT_BRANCH == "develop" && $CI_PIPELINE_SOURCE == "schedule"'
image: registry.hpc.ut.ee/mirror/$WALDUR_MASTERMIND_TEST_IMAGE
variables:
DJANGO_SETTINGS_MODULE: waldur_core.server.doc_settings
script:
- poetry install
- waldur export_model_metadata > /tmp/meta.yaml
- cd /tmp/
- git clone "https://mastermind:$MCP_ACCESS_TOKEN@$CI_SERVER_HOST/waldur/waldur-mcp-server.git"
- git config --global user.name "$GITLAB_USER_NAME"
- git config --global user.email "$GITLAB_USER_EMAIL"
- cd waldur-mcp-server
- git checkout main
- mv /tmp/meta.yaml src/waldur_mcp_server/meta.yaml
- git add src/waldur_mcp_server/meta.yaml
- git commit -m "Update metadata" || exit 0
- git branch new-metadata
- git push --set-upstream origin new-metadata:main
before_script: []
Lint MD links:
before_script:
- touch docs/core_structure.png
- touch docs/core_permissions.png
- touch docs/marketplace.png
Generate OpenAPI schema:
stage: deploy
interruptible: true
rules:
- if: '$CI_COMMIT_BRANCH == "develop" && $CI_PIPELINE_SOURCE == "schedule"'
- if: '$CI_COMMIT_TAG =~ /^\d+\.\d+\.\d+$/'
image: registry.hpc.ut.ee/mirror/$WALDUR_MASTERMIND_TEST_IMAGE
variables:
DJANGO_SETTINGS_MODULE: waldur_core.server.doc_settings
script:
- poetry install
- waldur spectacular --file waldur-openapi-schema.yaml --fail-on-warn
artifacts:
paths:
- waldur-openapi-schema.yaml
expire_in: 1 day
before_script: []
Generate TypeScript SDK:
stage: deploy
interruptible: true
rules:
- if: '$CI_COMMIT_BRANCH == "develop" && $CI_PIPELINE_SOURCE == "schedule"'
image: registry.hpc.ut.ee/mirror/library/node:lts-alpine
needs:
- Generate OpenAPI schema
script: |
npx --yes @hey-api/openapi-ts -c @hey-api/client-fetch -i waldur-openapi-schema.yaml -o waldur-typescript-sdk
# drop querySerializer because it is producing explode: false for multiple choice filter
sed -i '/querySerializer: {/,/},/d' waldur-typescript-sdk/sdk.gen.ts
ls -l waldur-typescript-sdk
artifacts:
paths:
- waldur-typescript-sdk/
expire_in: 1 day
Generate Python SDK:
stage: deploy
interruptible: true
rules:
- if: '$CI_COMMIT_BRANCH == "develop" && $CI_PIPELINE_SOURCE == "schedule"'
image: registry.hpc.ut.ee/mirror/library/python:3.11-bullseye
needs:
- Generate OpenAPI schema
script: |
pip install openapi-python-client
openapi-python-client generate --path waldur-openapi-schema.yaml --output-path py-client --overwrite
artifacts:
paths:
- py-client/
expire_in: 1 day
Generate Go SDK:
stage: deploy
interruptible: true
rules:
- if: '$CI_COMMIT_BRANCH == "develop" && $CI_PIPELINE_SOURCE == "schedule"'
image: registry.hpc.ut.ee/mirror/library/golang:tip-alpine
needs:
- Generate OpenAPI schema
script: |
go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@latest
oapi-codegen --package client --generate types,client -o client.go waldur-openapi-schema.yaml
ls -l client.go
artifacts:
paths:
- client.go
expire_in: 1 day
Upload Go SDK:
stage: deploy
interruptible: true
rules:
- if: '$CI_COMMIT_BRANCH == "develop" && $CI_PIPELINE_SOURCE == "schedule"'
image:
name: registry.hpc.ut.ee/mirror/alpine/git:latest
entrypoint: [""]
needs:
- Generate Go SDK
script:
- cd /tmp/
- git clone [email protected]:waldur/go-client.git
- cd go-client
- git pull
- cp $CI_PROJECT_DIR/client.go client.go
- git add client.go
- git commit -m "Update Waldur Go SDK" || exit 0
- git push
before_script:
- echo "[+] Adding ssh keys to the home directory"
- mkdir -p ~/.ssh
- cat $SSH_JENKINS_GITHUB_PRIVATE_KEY | tr -d '\r' > ~/.ssh/id_rsa
- cat $SSH_JENKINS_GITHUB_PUBLIC_KEY | tr -d '\r' > ~/.ssh/id_rsa.pub
- chmod 600 ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa.pub
- ssh-keygen -lf ~/.ssh/id_rsa.pub
- ssh-keyscan -H "github.com" >> ~/.ssh/known_hosts
- git config --global user.email "[email protected]"
- git config --global user.name "Waldur Gitlab Runner"
Upload Python SDK:
stage: deploy
interruptible: true
rules:
- if: '$CI_COMMIT_BRANCH == "develop" && $CI_PIPELINE_SOURCE == "schedule"'
image:
name: registry.hpc.ut.ee/mirror/alpine/git:latest
entrypoint: [""]
needs:
- Generate Python SDK
script:
- cd /tmp/
- git clone --branch main [email protected]:waldur/py-client.git
- cd py-client
- git pull
- rm -rf waldur_api_client && cp -a "$CI_PROJECT_DIR/py-client/waldur_api_client" waldur_api_client
- git add waldur_api_client
- git commit -m "Update Waldur Go SDK" || exit 0
- git push
before_script:
- echo "[+] Adding ssh keys to the home directory"
- mkdir -p ~/.ssh
- cat $SSH_JENKINS_GITHUB_PRIVATE_KEY | tr -d '\r' > ~/.ssh/id_rsa
- cat $SSH_JENKINS_GITHUB_PUBLIC_KEY | tr -d '\r' > ~/.ssh/id_rsa.pub
- chmod 600 ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa.pub
- ssh-keygen -lf ~/.ssh/id_rsa.pub
- ssh-keyscan -H "github.com" >> ~/.ssh/known_hosts
- git config --global user.email "[email protected]"
- git config --global user.name "Waldur Gitlab Runner"
Generate OpenAPI schema diff:
stage: deploy
interruptible: true
image:
name: registry.hpc.ut.ee/mirror/openapitools/openapi-diff:2.0.1
entrypoint: [""]
needs:
- Generate OpenAPI schema
rules:
- if: '$CI_COMMIT_TAG =~ /^\d+\.\d+\.\d+$/'
before_script:
- apt update
- apt install -y git
script:
- ls -la
- echo "Cloning docs repository"
- git clone "https://github.com/waldur/waldur-docs.git"
- ls waldur-docs
- PREV_SCHEMA=$(ls -v waldur-docs/docs/API/waldur-openapi-schema-*.yaml 2>/dev/null | tail -n 1 || echo "")
- echo "Previous schema $PREV_SCHEMA"
- |
if [ -z "$PREV_SCHEMA" ]; then
echo "No previous schema found. Skipping diff generation."
touch $CI_PROJECT_DIR/openapi-diff.md
else
echo "Previous schema found: $PREV_SCHEMA"
java -jar /app/openapi-diff.jar "$PREV_SCHEMA" "$CI_PROJECT_DIR/waldur-openapi-schema.yaml" --markdown $CI_PROJECT_DIR/openapi-diff.md
ls -la $CI_PROJECT_DIR/openapi-diff.md
head -n 30 $CI_PROJECT_DIR/openapi-diff.md || true
fi
artifacts:
paths:
- openapi-diff.md
expire_in: 1 day
Upload OpenAPI schema diff to docs:
stage: deploy
interruptible: true
needs:
- Generate OpenAPI schema
- Generate OpenAPI schema diff
rules:
- if: '$CI_COMMIT_TAG =~ /^\d+\.\d+\.\d+$/'
image:
name: registry.hpc.ut.ee/mirror/alpine/git:latest
entrypoint: [""]
script:
- cd /tmp/
- git clone "https://gitlab-ci-token:$GITLAB_TOKEN@$CI_SERVER_HOST/waldur/waldur-docs.git"
- git config --global user.name "$GITLAB_USER_NAME"
- git config --global user.email "$GITLAB_USER_EMAIL"
- cd waldur-docs
- mkdir -p docs/about/api-changes
- |
if [ -s "$CI_PROJECT_DIR/openapi-diff.md" ]; then
cp $CI_PROJECT_DIR/openapi-diff.md docs/about/api-changes/waldur-openapi-schema-${CI_COMMIT_TAG}-diff.md
else
echo "No API changes detected, skipping diff file upload"
fi
- ls -la docs/about/api-changes
- git add docs/about/api-changes
- git commit -m "Add Waldur OpenAPI schema diff for ${CI_COMMIT_TAG}" || exit 0
- git branch new-api-schema-diff-${CI_COMMIT_TAG}
- git push --set-upstream origin new-api-schema-diff-${CI_COMMIT_TAG}:master
before_script: []
Upload TypeScript SDK:
stage: deploy
interruptible: true
rules:
- if: '$CI_COMMIT_BRANCH == "develop" && $CI_PIPELINE_SOURCE == "schedule"'
image:
name: registry.hpc.ut.ee/mirror/alpine/git:latest
entrypoint: [""]
needs:
- Generate TypeScript SDK
script:
- cd /tmp/
- git clone --branch main [email protected]:waldur/js-client.git
- cd js-client
- git pull
- rm -rf src/
- mv $CI_PROJECT_DIR/waldur-typescript-sdk src
- git add src
- git commit -m "Update Waldur TypeScript SDK" || exit 0
- git push
before_script:
- echo "[+] Adding ssh keys to the home directory"
- mkdir -p ~/.ssh
- cat $SSH_JENKINS_GITHUB_PRIVATE_KEY | tr -d '\r' > ~/.ssh/id_rsa
- cat $SSH_JENKINS_GITHUB_PUBLIC_KEY | tr -d '\r' > ~/.ssh/id_rsa.pub
- chmod 600 ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa.pub
- ssh-keygen -lf ~/.ssh/id_rsa.pub
- ssh-keyscan -H "github.com" >> ~/.ssh/known_hosts
- git config --global user.email "[email protected]"
- git config --global user.name "Waldur Gitlab Runner"
Upload OpenAPI schema to docs:
stage: postdeploy
interruptible: true
needs:
- Generate OpenAPI schema
rules:
- if: '$CI_COMMIT_TAG =~ /^\d+\.\d+\.\d+$/'
image:
name: registry.hpc.ut.ee/mirror/alpine/git:latest
entrypoint: [""]
script:
- cd /tmp/
- git clone "https://gitlab-ci-token:$GITLAB_TOKEN@$CI_SERVER_HOST/waldur/waldur-docs.git"
- git config --global user.name "$GITLAB_USER_NAME"
- git config --global user.email "$GITLAB_USER_EMAIL"
- cd waldur-docs
- mkdir -p docs/API
- cp $CI_PROJECT_DIR/waldur-openapi-schema.yaml docs/API/waldur-openapi-schema-${CI_COMMIT_TAG}.yaml
- ls -la docs/API
- git add docs/API
- git commit -m "Add Waldur OpenAPI schema for ${CI_COMMIT_TAG}" || exit 0
- git branch new-api-schema-${CI_COMMIT_TAG}
- git push --set-upstream origin new-api-schema-${CI_COMMIT_TAG}:master
before_script: []