forked from tarantool/tarantool
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
316 lines (291 loc) · 8.67 KB
/
Copy path.gitlab-ci.yml
File metadata and controls
316 lines (291 loc) · 8.67 KB
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
default:
tags:
- docker
image:
name: docker-public.binary.picodata.io/tarantool-testing:${BASE_IMAGE_TAG}
pull_policy: always
retry:
max: 1
when:
- scheduler_failure
- runner_system_failure
- stuck_or_timeout_failure
- api_failure
variables:
# set larger git depth, so git describe works properly
GIT_DEPTH: 0
USER: 'tarantool'
DOCKER_REGISTRY_PUB: docker-public.binary.picodata.io
DOCKER_AUTH_CONFIG: $DOCKER_AUTH_RW
KANIKO_REGISTRY_MIRROR: docker-proxy.binary.picodata.io
BASE_IMAGE_LATEST: latest
BASE_IMAGE_TAG: ${BASE_IMAGE_LATEST}
MAIN_BRANCH: &main-branch 2.11.8-picodata
# k8s runner config
KUBERNETES_CPU_REQUEST: 6
KUBERNETES_CPU_LIMIT: 6
KUBERNETES_MEMORY_REQUEST: "6Gi"
# Helps to tolerate spurious network failures
GET_SOURCES_ATTEMPTS: 3
# 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
changes:
# implies compare_to HEAD~1
paths: &build-base-changes-paths
- docker/**
- .gitlab-ci.yml
- &if-build-base-changes-on-dev-branch
if: $CI_COMMIT_BRANCH != $MAIN_BRANCH
changes:
compare_to: *main-branch
paths: *build-base-changes-paths
- &else {}
.base_cache_def: &base_cache_def
paths:
- .cmake-downloads/
key: "base_cache-$CI_COMMIT_REF_SLUG"
fallback_keys:
- base_cache-$MAIN_BRANCH
.base_cache_template:
cache:
<<: *base_cache_def
policy: pull
stages:
- build-base-image
- test
- build
- pack
- docker
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: never
- if: $CI_PIPELINE_SOURCE == "push"
- if: $CI_PIPELINE_SOURCE == "web"
.test:
extends:
- .base_cache_template
rules:
- <<: *if-build-base-changes-on-master-branch
variables:
BASE_IMAGE_TAG: ${BASE_IMAGE_LATEST}
- <<: *if-build-base-changes-on-dev-branch
variables:
BASE_IMAGE_TAG: ${CI_COMMIT_SHA}
- <<: *else
variables:
BASE_IMAGE_TAG: ${BASE_IMAGE_LATEST}
stage: test
interruptible: true
variables:
GIT_STRATEGY: clone
GIT_DEPTH: 0
GIT_SUBMODULE_STRATEGY: recursive
before_script:
- mkdir -p test/artifacts/
artifacts:
when: always
paths:
- test/artifacts/
.parallel:
parallel:
matrix:
- BUILD_PROFILE: [release, debug]
luacheck:
extends: .test
script:
- make -f .test.mk luacheck
.test-ubuntu:
extends:
- .test
variables:
TEST_RUN_RETRIES: 3
SERVER_START_TIMEOUT: 400
REPLICATION_SYNC_TIMEOUT: 400
NO_OUTPUT_TIMEOUT: 440
TEST_TIMEOUT: 420
script:
- make -f .test.mk test-$BUILD_PROFILE
after_script:
- find /tmp/t/ -type s -delete
- mv /tmp/t test/artifacts
test-ubuntu:
extends:
- .test-ubuntu
- .parallel
cache:
<<: *base_cache_def
policy: pull-push
test-ubuntu-asan:
extends:
- .test-ubuntu
variables:
BUILD_PROFILE: debug-asan
CXX: clang++-18
CC: clang-18
when: manual
test-mac-m1:
extends: .test
tags: [mac-dev-m1]
script:
- ulimit -n 10240
- sudo mkdir -p /private/tmp/t
- sudo chown -R $(id -u) /private/tmp/t
- make -f .test.mk build
checkpatch:
extends: .test
tags: [shell_p_t]
script:
- git clone --depth 1 git@github.com:tarantool/checkpatch.git
- git fetch origin $MAIN_BRANCH
- COUNT_COMMIT=$(git log --pretty=oneline HEAD...origin/$MAIN_BRANCH | wc -l)
- CHECKPATCH_IGNORE=$(python3 extra/pico_parse_git_log.py --git HEAD~${COUNT_COMMIT}..HEAD)
- checkpatch/checkpatch.pl --show-types --ignore DEEP_INDENTATION,NEW_TYPEDEFS,ASSIGN_IN_IF,${CHECKPATCH_IGNORE} --color=always --git HEAD~${COUNT_COMMIT}..HEAD
rules:
# skip for tags
- if: $CI_COMMIT_TAG
when: never
# execute for non-main branches (regular merge requests)
- if: $CI_COMMIT_BRANCH != $MAIN_BRANCH
when: on_success
# skip for main branch
- when: never
# run long tests and coverage on release build
coverage:
extends: .test
stage: build
rules:
- if: $CI_COMMIT_TAG
variables:
BASE_IMAGE_TAG: ${BASE_IMAGE_LATEST}
- if: $CI_PIPELINE_SOURCE == "web"
variables:
BASE_IMAGE_TAG: ${CI_COMMIT_SHA}
- <<: *else
when: never
retry: 2
variables:
TEST_RUN_RETRIES: 3
SERVER_START_TIMEOUT: 400
REPLICATION_SYNC_TIMEOUT: 400
TEST_TIMEOUT: 420
NO_OUTPUT_TIMEOUT: 440
script:
- make -f .test.mk test-coverage
# TODO: move out shared setup for fuzzing jobs
# Check that fuzzing works
fuzz-check-build:
extends: .test
tags: [shell_p_t]
script:
# Clone oss-fuzz instead of adding it as a submodule
# as we don't want it to be checked by static analyzers - it's used only for fuzzing
- git clone --depth=1 https://github.com/google/oss-fuzz.git
- cd oss-fuzz
# Checkout a fixed oss-fuzz commit to guarantee reproducible builds
- git fetch --depth=1 origin e8e124996508f1e4ffe566896638c7213ab440d5
- git checkout e8e124996508f1e4ffe566896638c7213ab440d5
- python3 infra/helper.py build_fuzzers --external .. --sanitizer=address
- python3 infra/helper.py check_build --external .. --sanitizer=address
# Generate coverage report
fuzz-coverage:
extends: .test
tags: [shell_p_t]
when: manual
script:
# Clone oss-fuzz instead of adding it as a submodule
# as we don't want it to be checked by static analyzers - it's used only for fuzzing
- git clone --depth=1 https://github.com/google/oss-fuzz.git
- cd oss-fuzz
# Checkout a fixed oss-fuzz commit to guarantee reproducible builds
- git fetch --depth=1 origin e8e124996508f1e4ffe566896638c7213ab440d5
- git checkout e8e124996508f1e4ffe566896638c7213ab440d5
- python3 infra/helper.py build_fuzzers --external .. --sanitizer=coverage
# `coverage` command requires corpus folders to be located in
# `oss-fuzz/build/corpus/{project_name}`
# TODO: find out why they are not located there by default
- mkdir -p build/corpus/tarantool
- cp -r ../test/static/corpus/* build/corpus/tarantool
# add `_fuzzer` postfix to corpus folders
- (cd build/corpus/tarantool && for i in *; do mv "$i" "${i%.}_fuzzer"; done)
- python3 infra/helper.py coverage --no-serve --external ..
artifacts:
paths:
- oss-fuzz/build/out/tarantool/report
pack-on-tag:
stage: pack
rules:
- if: $CI_COMMIT_TAG
variables:
PROJECT_TARGET: 'tarantool-picodata'
TYPE: 'RELEASE'
BRANCH_TARGET: '$CI_COMMIT_TAG'
inherit:
variables:
- TYPE
- PROJECT_TARGET
- BRANCH_TARGET
trigger:
project: 'picodata/devops/builder'
strategy: depend
.kaniko-image:
image:
name: docker-public.binary.picodata.io/kaniko-project/executor:v1.23.1-debug
entrypoint: ['']
pull_policy: [if-not-present]
before_script:
- mkdir -p /kaniko/.docker
- echo "$DOCKER_AUTH_CONFIG" > /kaniko/.docker/config.json
script:
- >
/kaniko/executor --context $CI_PROJECT_DIR --dockerfile ${DOCKERFILE}
--build-arg TARANTOOL_VERSION=$CI_COMMIT_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:
extends: .kaniko-image
interruptible: true
stage: build-base-image
rules:
- <<: *if-build-base-changes-on-master-branch
variables:
BASE_IMAGE_TAG: ${BASE_IMAGE_LATEST}
- <<: *if-build-base-changes-on-dev-branch
variables:
BASE_IMAGE_TAG: ${CI_COMMIT_SHA}
- if: $CI_COMMIT_TAG
variables:
BASE_IMAGE_TAG: ${BASE_IMAGE_LATEST}
- <<: *else
when: never
variables:
DOCKERFILE: docker/Dockerfile.ci
DESTINATION: $DOCKER_REGISTRY_PUB/tarantool-testing:${BASE_IMAGE_TAG}
PUSH_DOCKER: ""
build-docker-on-tag:
stage: docker
extends: .kaniko-image
rules:
- if: $CI_COMMIT_TAG
needs:
- pack-on-tag
variables:
PUSH_DOCKER: ""
DOCKERFILE: docker/Dockerfile.release
DESTINATION: $DOCKER_REGISTRY_PUB/tarantool:latest --destination $DOCKER_REGISTRY_PUB/tarantool:$CI_COMMIT_TAG