forked from picodata/picodata
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
758 lines (709 loc) · 21.9 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
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
default:
tags:
- docker-picodata
image:
name: ${BASE_IMAGE}:${BASE_IMAGE_TAG}
pull_policy: always
interruptible: true
retry:
max: 1
when:
- scheduler_failure
- runner_system_failure
- stuck_or_timeout_failure
- api_failure
stages:
- build-base-image
- test
- pack
- docker
- build-stress-image
- stress-test
- deploy
workflow:
# See https://docs.gitlab.com/ee/ci/jobs/job_control.html#avoid-duplicate-pipelines
rules:
# To avoid duplicate pipelines we disable merge request events,
# leaving only pushes and manual triggering.
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: never
- if: $CI_PIPELINE_SOURCE == "push"
- if: $CI_PIPELINE_SOURCE == "web"
- if: $CI_PIPELINE_SOURCE == "schedule"
variables:
REGISTRY: docker-public.binary.picodata.io
BASE_IMAGE: ${CI_REGISTRY_IMAGE}/picodata-build-base
BASE_IMAGE_LATEST: latest
BASE_IMAGE_TAG: ${BASE_IMAGE_LATEST}
MAIN_BRANCH: &main-branch master
CARGO_HOME: $CI_PROJECT_DIR/.cargo
KANIKO_REGISTRY_MIRROR: docker-proxy.binary.picodata.io
FF_USE_FASTZIP: "true"
CACHE_COMPRESSION_LEVEL: "fastest"
CACHE_POLICY: pull-push
GIT_DEPTH: 1
GET_SOURCES_ATTEMPTS: 3
PICODATA_DESCRIBE: "24.7.0"
PARENT_BRANCH: $CI_COMMIT_REF_NAME
PARENT_CI_COMMIT_SHA: $CI_COMMIT_SHA
PARENT_PROJECT_PATH: ${CI_PROJECT_PATH}.git
TARANTOOL_VERSION: 2.11.2.159
RUST_VERSION: 1.76.0
FF_NETWORK_PER_BUILD: 1
RAW_REGISTRY: $RAW_PRIVATE_REGISTRY
CI_DEBUG_SERVICES: "true"
# k8s runner config
KUBERNETES_CPU_REQUEST: 2
KUBERNETES_MEMORY_REQUEST: "4Gi"
# job:rules explained:
#
# - if build-base changes on master branch (compared to HEAD~1)
# * build-base-image (with tag latest) and push
# * test (on base-image:latest)
# - if build-base changes on development branch (compared to master)
# * build-base-image (with tag sha)
# * test (on base-image:sha)
# - else (if build-base doesn't change)
# * skip build-base-image
# * just test (on base-image:latest)
#
# Anchor syntax explained here:
# https://docs.gitlab.com/ee/ci/yaml/yaml_optimization.html
#
.rules:
- &if-build-base-changes-on-master-branch
if: ($CI_COMMIT_BRANCH == $MAIN_BRANCH) && ($CI_PIPELINE_SOURCE != "schedule")
changes:
paths: &build-base-changes-paths
- docker-build-base/**
- .gitlab-ci.yml
- &if-build-base-changes-on-dev-branch
if: ($CI_COMMIT_BRANCH != $MAIN_BRANCH) && ($CI_PIPELINE_SOURCE != "schedule")
changes:
paths:
- docker-build-base/**
- .gitlab-ci.yml
compare_to: *main-branch
- &else {}
.base_cache: &base_cache
paths:
- .cargo/
- target/${TARGET}/
key:
files:
- Cargo.lock
prefix: "base_cache${TARGET}"
.base_node: &base_node
paths:
- webui/node_modules/
key:
files:
- webui/yarn.lock
prefix: "base_node"
.py_cache: &py_cache
paths:
- .venv
key:
files:
- poetry.lock
prefix: "py_cache"
.kaniko_image: &kaniko_image
image:
name: docker-public.binary.picodata.io/kaniko-project/executor:v1.23.1-debug
entrypoint: [""]
pull_policy: [if-not-present]
tags:
- docker-k8s
variables:
GIT_USERNAME: $CI_REGISTRY_USER
GIT_PASSWORD: $CI_REGISTRY_PASSWORD
script:
- >
/kaniko/executor --context $CI_PROJECT_DIR --dockerfile ${DOCKERFILE}
--build-arg TARANTOOL_VERSION=${TARANTOOL_VERSION}
--build-arg RUST_VERSION=${RUST_VERSION}
--build-arg BASE_IMAGE=${BASE_IMAGE}
--build-arg BASE_IMAGE_TAG=${BASE_IMAGE_TAG}
${PUSH_DOCKER}
--cache=false --cache-run-layers=true --single-snapshot --compressed-caching=false --use-new-run --snapshot-mode=redo --cleanup
--destination ${DESTINATION}
build-base-image:
stage: build-base-image
<<: *kaniko_image
rules:
- <<: *if-build-base-changes-on-master-branch
- <<: *if-build-base-changes-on-dev-branch
variables:
BASE_IMAGE_TAG: ${PARENT_CI_COMMIT_SHA}
- when: manual
allow_failure: true
variables:
BASE_IMAGE_TAG: ${BASE_IMAGE_LATEST}
variables:
DOCKERFILE: docker-build-base/Dockerfile
DESTINATION: ${BASE_IMAGE}:${BASE_IMAGE_TAG}
build-stress-image:
stage: build-stress-image
<<: *kaniko_image
rules:
- <<: *if-build-base-changes-on-dev-branch
variables:
BASE_IMAGE_TAG: ${PARENT_CI_COMMIT_SHA}
needs: ["build-base-image"]
- when: manual
allow_failure: true
variables:
DOCKERFILE: docker-build-base/stress.Dockerfile
DESTINATION: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
.test:
stage: test
variables:
GIT_SUBMODULE_STRATEGY: recursive
GIT_STRATEGY: fetch
GIT_DESCRIBE: $PICODATA_DESCRIBE
SUBMODULES_TO_FETCH_TAGS: "tarantool-sys,tarantool-sys/third_party/luajit"
RUST_BACKTRACE: full
KUBERNETES_CPU_REQUEST: 6
KUBERNETES_MEMORY_REQUEST: "6Gi"
before_script:
# Gitlab CI implicitly clones specific refs (e.g. `refs/pipelines/xxxxxxx`),
# but it doesn't imply fetching tags. We clone them manually with the
# `git fetch` command.
#
# Tags in `tarantool-sys` and `luajit` submodules are necessary for
# the build scripts. Without them the job fails.
- &fetch-tags |
ci-log-section start "fetch-submodule-tags" Fetching tags for submodules
./tools/get_tags.py
ci-log-section end "fetch-submodule-tags"
# By default "fast-release" profile is used, because of its faster
# compilation time compared to the "release" profile, which includes
# additional optimizations.
# The actual "release" profile is only used when running on master branch.
rules:
- if: $CI_COMMIT_BRANCH == $MAIN_BRANCH
variables:
RELEASE_PROFILE: &release-profile "release"
RELEASE_TARGET: &release-target "release"
- if: $CI_COMMIT_BRANCH != $MAIN_BRANCH
variables:
RELEASE_PROFILE: &release-profile "fast-release"
RELEASE_TARGET: &release-target "fast-release"
.parallel:
parallel:
matrix:
- BUILD_PROFILE: *release-profile
TARGET: *release-target
- BUILD_PROFILE: dev
TARGET: debug
.poetry-install: &poetry-install |
# Poetry install
ci-log-section start "poetry-install" Installing python dependencies ...
POETRY_VIRTUALENVS_IN_PROJECT=1 PIP_NO_CACHE_DIR=true poetry install --no-interaction --ansi
ci-log-section end "poetry-install"
test-linux:
extends:
- .test
- .parallel
rules:
- <<: *if-build-base-changes-on-dev-branch
variables:
BASE_IMAGE_TAG: ${CI_COMMIT_SHA}
CACHE_POLICY: pull
- if: $CI_COMMIT_BRANCH == $MAIN_BRANCH
variables:
CACHE_POLICY: pull-push
- <<: *else
variables:
CACHE_POLICY: pull
cache:
- <<: *py_cache
policy: $CACHE_POLICY
- <<: *base_cache
policy: $CACHE_POLICY
- <<: *base_node
policy: $CACHE_POLICY
script:
- tools/check_rust.sh
- cargo -V
- *poetry-install
- pushd sbroad && make test
- make bench_check; popd
- |
ci-log-section start "build" Build
make build-$BUILD_PROFILE CARGO_FLAGS_EXTRA="--timings"
ci-log-section end "build"
- |
ci-log-section start "test" Test
make test \
PYTEST_FLAGS="--junitxml=junit_pytest.xml --with-webui -n$KUBERNETES_CPU_REQUEST" \
CARGO_FLAGS_EXTRA="--profile=$BUILD_PROFILE"
ci-log-section end "test"
artifacts:
when: always
paths:
- junit_pytest.xml
- ./target/cargo-timings/cargo-timing.html
- core*
- target/$TARGET/picodata
reports:
junit: junit_pytest.xml
lint:
stage: test
rules:
- <<: *if-build-base-changes-on-dev-branch
variables:
BASE_IMAGE_TAG: ${CI_COMMIT_SHA}
- <<: *else
variables:
BASE_IMAGE_TAG: ${BASE_IMAGE_LATEST}
variables:
GIT_SUBMODULE_STRATEGY: recursive
GIT_DESCRIBE: $PICODATA_DESCRIBE
SUBMODULES_TO_FETCH_TAGS: "tarantool-sys,tarantool-sys/third_party/luajit"
TARGET: debug
cache:
- <<: *py_cache
policy: pull
- <<: *base_cache
policy: pull
- <<: *base_node
policy: pull
script:
- *fetch-tags
- *poetry-install
- make lint
- pushd webui && yarn lint; popd
- pushd sbroad && make lint
.test-patch-rules: &test-patch-rules
rules:
- if: ($CI_COMMIT_BRANCH == $MAIN_BRANCH) && ($CI_PIPELINE_SOURCE == "schedule")
- <<: *if-build-base-changes-on-dev-branch
when: manual
allow_failure: true
variables:
BASE_IMAGE_TAG: ${CI_COMMIT_SHA}
- when: manual
allow_failure: true
test-patch-picodata:
extends: .test
<<: *test-patch-rules
variables:
GIT_SUBMODULE_STRATEGY: recursive
BUILD_PROFILE: release
KUBERNETES_CPU_REQUEST: 8
KUBERNETES_MEMORY_REQUEST: "8Gi"
cache:
- <<: *py_cache
policy: pull
- <<: *base_cache
policy: pull
- <<: *base_node
policy: pull
script:
- *poetry-install
- ./tools/prepare_source_tree_for_stat_analysis.py apply
- make build-$BUILD_PROFILE CARGO_FLAGS_EXTRA="--features webui,dynamic_build"
- |
make test \
PYTEST_FLAGS="--junitxml=junit_pytest.xml --with-webui" \
CARGO_FLAGS_EXTRA="--profile=$BUILD_PROFILE --features dynamic_build"
test-patch-tarantool:
extends: .test
<<: *test-patch-rules
variables:
GIT_SUBMODULE_STRATEGY: recursive
script:
- ./tools/prepare_source_tree_for_stat_analysis.py apply
- pushd tarantool-sys/ && make -f .test.mk test-release;
after_script:
- find /tmp/t/ -type s -delete
- mv /tmp/t tarantool-sys/test/artifacts
artifacts:
when: always
paths:
- tarantool-sys/test/artifacts/
test-mac-m1:
extends: .test
tags:
- mac-dev-m1
timeout: 30m
script:
# Gitlab doesnt know about $HOME. If specified in variables it becomes empty
- export CARGO_HOME=$HOME/.cargo
- cargo -V
- cargo build --locked
- cargo build --features webui --locked
# There are no Rust tests for `webui` feature.
# It will be checked during integration tests.
- cargo test --locked
- cargo fmt -- -v --check
- cargo clippy --version
- cargo clippy --features "load_test webui error_injection" -- --deny clippy::all --no-deps
# - *poetry-install
# - poetry run pytest --numprocesses auto -v
# - make lint
# - |
.helm:
stage: test
needs: []
rules:
- if: $CI_COMMIT_BRANCH != $MAIN_BRANCH
changes:
compare_to: *main-branch
paths:
- docker/picodata.Dockerfile
- docker/picodata-distroless.Dockerfile
- docker/docker-compose.yml
variables:
PUSH_DOCKER: "--no-push"
- if: ($CI_COMMIT_BRANCH == $MAIN_BRANCH) && ($CI_PIPELINE_SOURCE == "schedule")
when: on_success
variables:
PUSH_DOCKER: ""
- when: manual
allow_failure: true
helm-image:
extends: .helm
variables:
KUBERNETES_CPU_REQUEST: 8
KUBERNETES_MEMORY_REQUEST: "8Gi"
MULTIARCH: "true"
parallel:
matrix:
- DOCKERFILE: docker/picodata.Dockerfile
DESTINATION: ${REGISTRY}/picodata:master
- DOCKERFILE: docker/picodata-distroless.Dockerfile
DESTINATION: ${REGISTRY}/picodata:master-distroless
trigger:
project: picodata/devops/picodata-in-docker
branch: main
strategy: depend
gamayun-prepare:
extends: .test
when: manual
rules:
- <<: *if-build-base-changes-on-dev-branch
variables:
BASE_IMAGE_TAG: ${CI_COMMIT_SHA}
- when: manual
script:
- export CARGO_HOME=$HOME/.cargo
- cargo -V
- cargo clippy --locked --message-format=json > clippy.json
artifacts:
when: always
paths:
- clippy.json
gamayun-run:
extends: .test
needs: ["gamayun-prepare"]
tags:
- picodata-shell
script:
# create an ssh tunnel to gamayun server to allow the report uploading
- TUNNEL="ssh -4 -L 9000:localhost:9000 sonar-reports -N -f"
- eval $TUNNEL
- ls -la
- |
# svace patches is more iportant than gamayun and order of applying is important
# first - svace, second - gamayun
./tools/prepare_source_tree_for_stat_analysis.py apply
- |
# TODO consider moving this to the script as well, this may delete some html
# license files which is probably not intended
find . -type d -name 'test*' -o -name 'doc' -o -name 'docs' | xargs -n1 rm -rvf
find tarantool-sys/third_party/ -type f -name '*.htm*' | xargs -n 1 rm -rfv
find tarantool-sys/vendor/ -type f -name '*.htm*' | xargs -n 1 rm -rfv
find . -type d -name stress-test | xargs -n 1 rm -rvf
find . -type d -name integration-tests | xargs -n 1 rm -rvf
find . -type d -name 'example*' | xargs -n 1 rm -rvf
find . -type d -name 'docsrc' | xargs -n 1 rm -rvf
find . -name '*.md' | xargs -n 1 rm -rvf
find http tarantool-sys vshard -type d -name .github | xargs -n 1 rm -rfv
- |
docker run --rm -t \
-v $PWD:/tmp/src:rw \
-e "SONAR_OPS=-Dsonar.python.version=3 -Dsonar.login=${SONAR} -Dsonar.projectKey=Picodata-CI -Dsonar.exclusions=**/*.mod,osv-sonar.json" \
-e "SONAR_SCANNER_OPTS="-Xmx4096m"" \
-e "CARGO_CLIPPY_FILE=clippy.json" \
-u $(id -u):$(id -g) --ulimit nofile=100000:100000 --network=host \
docker.binary.picodata.io/gamayun
build-vm-image:
stage: test
when: manual
inherit:
variables: false
variables:
# Not CI_COMMIT_BRANCH because CI_COMMIT_BRANCH is not available for tags
BRANCH: $CI_COMMIT_REF_NAME
trigger:
project: picodata/picodata/picodata-fstek-vmbuilder
branch: main
strategy: depend
pack-on-tag:
stage: pack
rules:
- if: $CI_PIPELINE_SOURCE == "web"
- if: $CI_COMMIT_TAG
variables:
PROJECT_TARGET: "picodata"
TYPE: "RELEASE"
BRANCH_TARGET: $CI_COMMIT_TAG
inherit:
variables:
- TYPE
- PROJECT_TARGET
- BRANCH_TARGET
trigger:
project: "picodata/devops/builder"
strategy: depend
.deploy-docker-tmpl:
stage: docker
variables:
PUSH_DOCKER: ""
MULTIARCH: "true"
rules:
- if: $CI_COMMIT_TAG
variables:
PARENT_BRANCH: ${CI_COMMIT_TAG}
deploy-docker:
extends: .deploy-docker-tmpl
parallel:
matrix:
- DOCKERFILE: docker/picodata.Dockerfile
DESTINATION: ${REGISTRY}/picodata:${CI_COMMIT_TAG}
- DOCKERFILE: docker/picodata-distroless.Dockerfile
DESTINATION: ${REGISTRY}/picodata:${CI_COMMIT_TAG}-distroless
trigger:
project: picodata/devops/picodata-in-docker
branch: main
strategy: depend
docker-compose:
stage: docker
needs:
["helm-image: [docker/picodata.Dockerfile, ${REGISTRY}/picodata:master]"]
tags:
- picodata-shell
rules:
- if: ($CI_COMMIT_BRANCH != $MAIN_BRANCH) && ($CI_PIPELINE_SOURCE == "schedule")
changes:
compare_to: *main-branch
paths:
- docker/docker-compose.yml
- if: ($CI_COMMIT_BRANCH == $MAIN_BRANCH) && ($CI_PIPELINE_SOURCE == "schedule")
when: on_success
- when: manual
allow_failure: true
script:
- mkdir --mode=777 pico/
- docker-compose -f docker/docker-compose.yml up -d --wait
- sleep 30 # the cluster does not manage to assemble quickly enough
- count=$(psql "user=admin host=127.0.0.1 port=55432 password=T0psecret sslmode=disable" -t -A -c "select count(*) from \"_pico_instance\"") && if [[ $count -eq 4 ]] ; then echo "OK"; else echo count=$count; exit 2; fi
after_script:
- docker-compose -f docker/docker-compose.yml rm -fsv
- sudo rm -rf pico/
# Stages of independent stress testing in downstream pipeline
# We cannot move artefacts to the downstream pipeline, so we need to build and upload them to our repo
.upload-picodata-to-binary:
variables:
VER: $CI_COMMIT_SHORT_SHA
GIT_SUBMODULE_STRATEGY: recursive
GIT_DESCRIBE: $PICODATA_DESCRIBE
before_script:
# To conduct stress tests, we require the most recent picodata tag. However,
# creating a shallow copy with $GIT_DEPTH commits might not include this tag.
# Fetching all commits takes too much time, so we incrementally download more
# chunks of commits until we find the required tag.
- *fetch-tags
script:
- cargo build --locked --release --features webui
- mv target/release/picodata target/release/picodata-$VER
- curl -v --upload-file target/release/picodata-$VER $RAW_NT_REGISTRY
upload-picodata-to-binary-stress-test:
stage: stress-test
extends: .upload-picodata-to-binary
rules:
- if: $CI_COMMIT_BRANCH == $MAIN_BRANCH
when: always
- if: $CI_COMMIT_BRANCH != $MAIN_BRANCH
when: manual
allow_failure: true
downstream-stress-test:
# See https://docs.gitlab.com/ee/ci/pipelines/downstream_pipelines.html
stage: stress-test
rules:
- if: $CI_COMMIT_BRANCH == $MAIN_BRANCH
when: always
- if: $CI_COMMIT_BRANCH != $MAIN_BRANCH
when: manual
allow_failure: true
trigger:
project: picodata/devops/proxmox/sbroad-nt
branch: main
strategy: depend
variables:
VER: $CI_COMMIT_SHORT_SHA
needs:
- job: upload-picodata-to-binary-stress-test
upload-picodata-to-binary-front-deploy:
stage: deploy
extends: .upload-picodata-to-binary
needs: []
when: manual
downstream-front-deploy:
# See https://docs.gitlab.com/ee/ci/pipelines/downstream_pipelines.html
stage: deploy
allow_failure: true
trigger:
project: picodata/devops/pico-servers/front
branch: main
strategy: depend
variables:
VER: $CI_COMMIT_SHORT_SHA
needs:
- job: upload-picodata-to-binary-front-deploy
publish-picodata-plugin:
stage: pack
when: manual
rules:
- <<: *if-build-base-changes-on-dev-branch
variables:
BASE_IMAGE_TAG: ${CI_COMMIT_SHA}
script:
- if [ -z "$CARGO_REGISTRY_TOKEN" ]; then echo "Variable CARGO_TOKEN must be available, check that branch is protected" 1>&2 && exit 1; fi
- make publish-picodata-plugin
.test-sbroad:
stage: test
tags:
- docker-k8s
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"
before_script:
- pushd sbroad
integration-sbroad:
extends: .test-sbroad
variables:
KUBERNETES_CPU_REQUEST: 6
KUBERNETES_MEMORY_REQUEST: "6Gi"
rules:
- <<: *if-build-base-changes-on-dev-branch
variables:
BASE_IMAGE_TAG: ${CI_COMMIT_SHA}
- <<: *else
variables:
BASE_IMAGE_TAG: ${BASE_IMAGE_LATEST}
tags:
- docker-k8s
script:
- make test_integration
artifacts:
paths:
- sbroad-cartridge/test_app/tmp/tarantool.log
expire_in: 1 week
stress_tests:
parallel:
matrix:
- STRESS_TEST:
- projection
- projection_wide
- groupby
- insert
tags:
- docker-k8s
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"
variables:
TNT_HOST: tarantool
STRESS_TEST: insert
KUBERNETES_CPU_REQUEST: 6
KUBERNETES_MEMORY_REQUEST: "6Gi"
services:
- name: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
alias: tarantool
pull_policy: always
image: docker-public.binary.picodata.io/k6_tnt:latest
stage: stress-test
allow_failure: true
script:
- echo "STRESS_TEST=${STRESS_TEST}"
# wait while tnt cluster is started
- ./tools/check_tnt.sh
- mkdir -p sbroad/sbroad-cartridge/stress-test/$CI_COMMIT_BRANCH/${STRESS_TEST}/
- k6 run -u 10 -d 1m -e HOST=${TNT_HOST} sbroad/sbroad-cartridge/stress-test/${STRESS_TEST}/k6.js --summary-export sbroad/sbroad-cartridge/stress-test/$CI_COMMIT_BRANCH/${STRESS_TEST}/k6_summary.json
needs: [build-stress-image]
artifacts:
paths:
- sbroad/sbroad-cartridge/stress-test/$CI_COMMIT_BRANCH/${STRESS_TEST}/k6_summary.json
expire_in: 1 hour
when: always
store-stress-results-for-main:
rules:
- if: ($CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH) && ($CI_PIPELINE_SOURCE != "schedule")
stage: stress-test
script:
- |
tar -czvf sbroad-main-test-results.tgz -C sbroad/sbroad-cartridge/stress-test/ .
curl -f -H "Authorization: Basic $RAW_AUTH_RW" --upload-file sbroad-main-test-results.tgz $RAW_REGISTRY/sbroad-stress-tests/
needs:
- "stress_tests: [projection]"
- "stress_tests: [projection_wide]"
- "stress_tests: [groupby]"
- "stress_tests: [insert]"
diff_stress-results:
stage: stress-test
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"
when: manual
allow_failure: true
variables:
FARCH: "sbroad-main-test-results.tgz"
script:
- |
curl $RAW_REGISTRY/sbroad-stress-tests/$FARCH -o $FARCH
file $FARCH
set -x
if [ ! -f ${FARCH} -o $(file -i ${FARCH} | grep gzip | wc -l) -eq 0 ] ; then
echo "Error: archive ${FARCH} not found on binary"
exit 1
fi
tar -xvf $FARCH -C sbroad/sbroad-cartridge/stress-test/
cd sbroad/sbroad-cartridge/stress-test/
find -name k6_summary.json
for D in $(find . -name k6_summary.json -exec sh -c "dirname {} | sed 's/.*\///g'" \; ); do
echo "Branch = $D"
if [ "$D" != "main" -a -f main/$D/k6_summary.json -a -f $CI_COMMIT_BRANCH/$D/k6_summary.json ]; then
tarantool compare.lua main/$D/k6_summary.json $CI_COMMIT_BRANCH/$D/k6_summary.json
elif [ "$D" == main ]; then
echo "skipped"
else
echo "Error: stress-test results not found!"; exit 2;
fi
done
needs:
- "stress_tests: [projection]"
- "stress_tests: [projection_wide]"
- "stress_tests: [groupby]"
- "stress_tests: [insert]"
artifacts:
paths:
- sbroad-cartridge/stress-test/**/**/k6_summary.json
expire_in: 1 week
when: always
deploy-luarocks:
stage: deploy
rules:
- if: $CI_COMMIT_TAG
before_script:
- eval $(ssh-agent -s)
- echo "$DEPLOY_PROD_SSH_KEY" | base64 -d | ssh-add -
- |
if [ "$DEPLOY_PROD_SSH_KEY" == "" ]; then
echo "Error: Access to push in docker registry only for protected tag or branch!"
exit 1
fi
script:
- make release_rock
- echo "Deploying luarocks..."
- scp -o stricthostkeychecking=no sbroad*rock [email protected]:/data/nginx/www/packrepo/luarocks
- ssh -o stricthostkeychecking=no [email protected] "luarocks-admin make_manifest /data/nginx/www/packrepo/luarocks"