This repository has been archived by the owner on Feb 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
454 lines (364 loc) · 12.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
# Globals ----------------------------------------------------------------- {{{1
#
variables:
GIT_DEPTH: 1 # clone only the current commit
GIT_STRATEGY: clone # make a fresh `git clone` of the repo for every new CI job
GIT_SUBMODULE_STRATEGY: normal # init and check out submodules
CENTOS_RELEASE: 7
DOCKER_REGISTRY: registry.gitlab.mero.colo.seagate.com
M0_VG_NO_SYMLINKS: "true"
WORKSPACE_NAME: "${CI_PROJECT_NAME}${CI_PIPELINE_ID}"
WORKSPACE_DIR: "/home/gitlab-runner/workspaces/${CI_PROJECT_NAME}${CI_PIPELINE_ID}"
stages:
- build
- test
- cleanup
before_script:
- date -u -Isec
- git log -1 --pretty=fuller
- printenv
after_script:
- date -u -Isec
# Build ------------------------------------------------------------------- {{{1
#
build:
stage: build
tags: [ m0vg ]
except: [ tags ]
script:
# can't be defined in the 'variables:' section because it supports only
# sinle level of variable expansion, e.g. A=$VAR; B=$A won't work for B
- export JOB_NAME="${WORKSPACE_NAME}-build"
- sudo rm -rf ${WORKSPACE_DIR}
- mkdir -p ${WORKSPACE_DIR}
- cp -a ../${CI_PROJECT_NAME} ${WORKSPACE_DIR}
- cd ${WORKSPACE_DIR}
# get fresh Mero copy
- git clone --recursive --depth 1 --shallow-submodules http://gitlab.mero.colo.seagate.com/mero/mero.git
# make sure that build images are up to date
- docker pull $DOCKER_REGISTRY/mero/mero:$CENTOS_RELEASE
- docker pull $DOCKER_REGISTRY/mero/halon:$CENTOS_RELEASE
# build Mero
- time docker run --rm --name ${JOB_NAME}
-v ~+:/data -w /data/mero
$DOCKER_REGISTRY/mero/mero:$CENTOS_RELEASE
bash -c "KERNEL=/lib/modules/\$(yum list installed kernel | tail -n1 | awk '{ print \$2 }').x86_64/build ;
./autogen.sh &&
./configure --with-linux=\$KERNEL &&
make -j10"
# build Halon
- time docker run --rm --name ${JOB_NAME}
-v ~+:/data -w /data/${CI_PROJECT_NAME}
$DOCKER_REGISTRY/mero/halon:$CENTOS_RELEASE
./scripts/h0 make -j10
# containers run commands as 'root' user, seize ownershipt back
- sudo chown -R $(id -u):$(id -g) .
# rpmbuild check ---------------------------------------------------------- {{{1
#
rpmbuild:
stage: test
tags: [ docker-build ]
except: [ tags ]
# TODO: revert back to $CENTOS_RELEASE when we have new binary complete OS
# image, temporary use special EOS docker image that matches the old
# Jenkins base VM, untill we have the new OS image
image: $DOCKER_REGISTRY/mero/halon:eos
#image: $DOCKER_REGISTRY/mero/halon:$CENTOS_RELEASE
script:
- export RELEASE_DIR="$(ls -td /releases/master/B* | head -n1)"
- yum install -y $RELEASE_DIR/eos-core{,-devel}-[0-9]*.rpm
- time make rpms
# Unit Tests -------------------------------------------------------------- {{{1
#
UT:
stage: test
tags: [ m0vg ]
except: [ tags ]
variables:
M0VG: ./m0vg-ut/scripts/m0vg
before_script:
# can't be defined in the 'variables:' section because it supports only
# sinle level of variable expansion, e.g. A=$VAR; B=$A won't work for B
- export JOB_NAME="${WORKSPACE_NAME}-ut"
- date -u -Isec
- git log -1 --pretty=fuller
- printenv
- cd ${WORKSPACE_DIR}
- |
test -d m0vg-ut ||
git clone --recursive --depth 1 --shallow-submodules \
http://gitlab.mero.colo.seagate.com/mero/mero.git \
m0vg-ut
# prepare m0vg ut VM
- |
$M0VG env add <<EOF
M0_VM_BOX=centos75/dev-halon
M0_VM_BOX_URL='http://ci-storage.mero.colo.seagate.com/vagrant/centos75/dev-halon'
M0_VM_CMU_MEM_MB=4096
M0_VM_NAME_PREFIX=${JOB_NAME}
M0_VM_HOSTNAME_PREFIX=${JOB_NAME}
EOF
- time $M0VG up --no-provision cmu
- time $M0VG reload --no-provision cmu
script:
- date -u -Isec
- time $M0VG run /data/halon/scripts/h0 test
after_script:
- date -u -Isec
- cd ${WORKSPACE_DIR}
# clean up (ensures that VMs are destroyed in case of a manual job restart,
# when global 'cleanup' stage is not performed)
- $M0VG destroy -f || true
# System Tests (singlenode) ----------------------------------------------- {{{1
#
ST singlenode:
stage: test
tags: [ m0vg ]
except: [ tags ]
variables:
M0VG: ./m0vg-single/scripts/m0vg
before_script:
# can't be defined in the 'variables:' section because it supports only
# sinle level of variable expansion, e.g. A=$VAR; B=$A won't work for B
- export JOB_NAME="${WORKSPACE_NAME}-s"
- date -u -Isec
- git log -1 --pretty=fuller
- printenv
- cd ${WORKSPACE_DIR}
- |
test -d m0vg-single ||
git clone --recursive --depth 1 --shallow-submodules \
http://gitlab.mero.colo.seagate.com/mero/mero.git \
m0vg-single
# prepare m0vg singlenode
- |
$M0VG env add <<EOF
M0_VM_BOX=centos75/dev-halon
M0_VM_BOX_URL='http://ci-storage.mero.colo.seagate.com/vagrant/centos75/dev-halon'
M0_VM_CMU_MEM_MB=4096
M0_VM_NAME_PREFIX=${JOB_NAME}
M0_VM_HOSTNAME_PREFIX=${JOB_NAME}
EOF
- time $M0VG up --no-provision cmu
- time $M0VG reload --no-provision cmu
script:
- date -u -Isec
- time $M0VG run "${M0_VERBOSE:+M0_VERBOSE=1}
/data/halon/scripts/h0 run-st"
after_script:
- PREFIX='st-single_'
- date -u -Isec
- cd ${WORKSPACE_DIR}
# fetch syslog
- $M0VG run sudo journalctl --no-pager --full --utc --boot
--output short-precise
> $CI_PROJECT_DIR/${PREFIX}syslog.log
# fetch halon.decision.log
- $M0VG scp cmu:/var/log/halon.decision.log\*
$CI_PROJECT_DIR/${PREFIX}halon.decision.log
# fetch m0trace
- |
out=${PREFIX}halond.m0trace.txt.xz
$M0VG run -f <<EOF
trace=\$(ls -t /var/lib/halon/m0trace.* 2>/dev/null | head -1)
if [[ -n \$trace ]]; then
sudo /data/mero/utils/trace/m0trace -w0 -i \$trace | sort -n |
xz > /data/$out
fi
EOF
[[ -f $out ]] && mv -v $out $CI_PROJECT_DIR/
# collect m0reportbug archives
- |
$M0VG run sudo /data/mero/utils/m0reportbug
$M0VG scp cmu:m0reportbug-\*.tar.xz $CI_PROJECT_DIR/
( cd $CI_PROJECT_DIR/
for f in m0reportbug-*.tar.xz; do mv -v {,$PREFIX}$f; done )
# clean up (ensures that VMs are destroyed in case of a manual job restart,
# when global 'cleanup' stage is not performed)
- $M0VG destroy -f || true
artifacts:
name: "$CI_PROJECT_NAME job $CI_JOB_ID ($CI_JOB_NAME) logs"
when: always # whenever the job has failed or succeeded
paths:
- st-single_syslog.log
- st-single_halon.decision.log
- st-single_halond.m0trace.txt.xz
- st-single_m0reportbug-data.tar.xz
- st-single_m0reportbug-traces.tar.xz
# st-single_m0reportbug-cores.tar.xz # NB cores are not being fetched
# System Tests (multinode) ------------------------------------------------ {{{1
#
ST multinode:
stage: test
tags: [ m0vg ]
except: [ tags ]
variables:
M0VG: ./m0vg-multi/scripts/m0vg
before_script:
# can't be defined in the 'variables:' section because it supports only
# sinle level of variable expansion, e.g. A=$VAR; B=$A won't work for B
- export JOB_NAME="${WORKSPACE_NAME}-m"
- date -u -Isec
- git log -1 --pretty=fuller
- printenv
- cd ${WORKSPACE_DIR}
- |
test -d m0vg-multi ||
git clone --recursive --depth 1 --shallow-submodules \
http://gitlab.mero.colo.seagate.com/mero/mero.git \
m0vg-multi
# prepare m0vg cluster
- |
$M0VG env add <<EOF
M0_VM_BOX=centos75/dev-halon
M0_VM_BOX_URL='http://ci-storage.mero.colo.seagate.com/vagrant/centos75/dev-halon'
M0_VM_CMU_MEM_MB=4096
M0_VM_NAME_PREFIX=${JOB_NAME}
M0_VM_HOSTNAME_PREFIX=${JOB_NAME}
EOF
- time $M0VG up --no-provision cmu /ssu/ /client/
- time $M0VG reload --no-provision cmu /ssu/ /client/
# generate m0genfacts cluster config
- |
cat <<EOF > m0-cluster.yaml
confds: [ ${JOB_NAME}-cmu.local ]
ssus:
- host: ${JOB_NAME}-ssu1.local
disks: /dev/vd[b-g]
- host: ${JOB_NAME}-ssu2.local
disks: /dev/vd[b-g]
clients: [ ${JOB_NAME}-client1.local ]
clovis-apps: [ ${JOB_NAME}-client1.local ]
EOF
- cat m0-cluster.yaml
script:
- date -u -Isec
- time $M0VG run "${M0_VERBOSE:+M0_VERBOSE=1}
M0_CLUSTER=/data/m0-cluster.yaml
SAT=${JOB_NAME}-ssu1
/data/halon/scripts/h0 run-st 'multinode.t_*'"
after_script:
- PREFIX='st-multi_'
- date -u -Isec
- cd ${WORKSPACE_DIR}
# fetch syslog
- for host in cmu ssu1 ssu2 client1; do
$M0VG run --vm $host
sudo journalctl --no-pager --full --utc --boot
--output short-precise
> $CI_PROJECT_DIR/${PREFIX}syslog.$host.log;
done
# fetch halon.decision.log
- $M0VG scp cmu:/var/log/halon.decision.log\*
$CI_PROJECT_DIR/${PREFIX}halon.decision.log
# clean up (ensures that VMs are destroyed in case of a manual job restart,
# when global 'cleanup' stage is not performed)
- $M0VG destroy -f || true
artifacts:
name: "$CI_PROJECT_NAME job $CI_JOB_ID ($CI_JOB_NAME) logs"
when: always # whenever the job has failed or succeeded
paths:
- st-multi_syslog.*.log
- st-multi_halon.decision.log
# Cleanup ----------------------------------------------------------------- {{{1
#
cleanup:
stage: cleanup
tags: [ m0vg ]
except: [ tags ]
when: always
dependencies: [] # empty deps list prevents unneeded artifacts downloading
variables:
# If a branch is updated while CI tests for the older commit are still
# being run, the checkout phase of 'cleanup' job will fail (thus cleanup
# script will not run) unless GIT_DEPTH is deep enough to include the older
# commit. Cloning 30 latest commits seems to be good enough - it's quite
# rare for people to push more than 30 new commits in one go.
GIT_DEPTH: 30
script:
- cd ${WORKSPACE_DIR}
- ./m0vg-ut/scripts/m0vg destroy -f || true
- ./m0vg-single/scripts/m0vg destroy -f || true
- ./m0vg-multi/scripts/m0vg destroy -f || true
# Docker images ----------------------------------------------------------- {{{1
#
docker:rebuild-images:
stage: build
tags: [ docker-image-build ]
when: manual
variables:
DOCKER_IMAGE_TAG: 7
script:
- make docker-image-${DOCKER_IMAGE_TAG}
- make docker-push tag="${DOCKER_IMAGE_TAG}*"
docker:rebuild-images:76:
extends: docker:rebuild-images
variables:
DOCKER_IMAGE_TAG: '7.6'
docker:rebuild-images:75:
extends: docker:rebuild-images
variables:
DOCKER_IMAGE_TAG: '7.5'
docker:rebuild-images:sage:
extends: docker:rebuild-images
variables:
DOCKER_IMAGE_TAG: sage
docker:rebuild-images:sage-vm:
extends: docker:rebuild-images
variables:
DOCKER_IMAGE_TAG: sage-vm
docker:rebuild-images:eos:
extends: docker:rebuild-images
variables:
DOCKER_IMAGE_TAG: eos
# Vagrant boxes ----------------------------------------------------------- {{{1
#
vagrant:rebuild-box:
stage: build
tags: [ m0vg ]
when: manual
only:
changes:
- stack.yaml
variables:
M0VG: ./m0vg/scripts/m0vg
script:
- export JOB_NAME="${WORKSPACE_NAME}-box"
- mkdir -p ${WORKSPACE_DIR}
- cd ${WORKSPACE_DIR}
- |
test -d m0vg ||
git clone --recursive --depth 1 --shallow-submodules \
http://gitlab.mero.colo.seagate.com/mero/mero.git \
m0vg
- |
$M0VG env add <<EOF
M0_VM_BOX_BUILDER_MODE=yes
M0_VM_BOX=centos75/dev
M0_VM_BOX_URL='http://ci-storage.mero.colo.seagate.com/vagrant/centos75/dev'
M0_VM_NAME_PREFIX=${JOB_NAME}
M0_VM_HOSTNAME_PREFIX=${JOB_NAME}
EOF
- $M0VG box update
- $M0VG up --no-provision devbox
# TODO: use `h0 make --only-dependencies` instead of raw `stack build`
# (requires that `h0` could skip 'assert_mero')
- |
$M0VG run --vm devbox -f <<EOF
cd /data/halon
stack build --only-dependencies --ghc-options='-g -j2 -O0'
EOF
- $M0VG halt devbox
# package a box
- export BOX_VERSION=$(date +%y%m%d)
- export BOX=centos75-dev-halon-$BOX_VERSION-libvirt.box
- sudo $M0VG package --output $BOX devbox
# move to the box storage
- export BOX_DIR=/mnt/ci-storage/vagrant/boxes/centos75/dev-halon/$BOX_VERSION/libvirt/
- mkdir -p $BOX_DIR
- mv -v ./m0vg/scripts/provisioning/$BOX $BOX_DIR
after_script:
- date -u -Isec
- cd ${WORKSPACE_DIR}
- $M0VG destroy -f || true
# vim: foldmethod=marker shiftwidth=2 tabstop=2 expandtab