-
Notifications
You must be signed in to change notification settings - Fork 5
/
.gitlab-ci.yml
561 lines (494 loc) · 14.8 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
variables:
# https://docs.gitlab.com/ee/ci/docker/using_docker_build.html
#DOCKER_TLS_CERTDIR: "/certs"
#DOCKER_HOST: ""
HAS_ARMADEPLOY: "false"
STAGING_ENVIRONMENT: "invalid"
FINAL_ENVIRONMENT: "invalid"
PYTHONIOENCODING: "UTF-8"
stages:
- minimal_build
- build_prepare
- build_base
- build_main
- build_collect
- test
- pre_stage
- stage
- pre_deploy
- deploy
default:
image: $CI_REGISTRY_IMAGE/armaroot_64@sha256:65ac3e0218fee5748351f69908cc309a71970253e41bb08d7238f711d03055da
interruptible: true
retry:
max: 1
when:
- runner_system_failure
- stuck_or_timeout_failure
- unknown_failure
# common before script: bootstrap, configure, make dist, prepare docker builds
before_script:
- if ! test -d gitlab_build; then
- which docker && docker help > /dev/null
- touch timestamp.tag
- test "x${ARMAGETRONAD_FAKERELEASE}" == "x" && export ARMAGETRONAD_FAKERELEASE=false
- test -r configure || ./bootstrap.sh
- cat version.m4
- mkdir -p gitlab_build
- cd gitlab_build
- . ../docker/scripts/brand.sh .
- ../configure --prefix=/usr/local --disable-glout --disable-sysinstall --disable-desktop progname="${PROGRAM_NAME}" progtitle="${PROGRAM_TITLE}"
- test "x${ARMAGETRONAD_FAKERELEASE}" == "xtrue" && cp ../docker/build/fakerelease_proto.sh docker/build/fakerelease.sh
- cd docker/build
- make CI_prepare -j`nproc || echo 3`
- cd ../../../
- else
- find . -newer timestamp.tag ! -path "./gitlab_build" -exec touch -r timestamp.tag \{\} \;
- ./docker/scripts/fix_gits.sh || exit $?
- fi
# cache git checkouts of repositories we depend on
cache:
paths:
- docker/scripts/.cache
# template rule to maka a job only run on project runners; this implies they can
# only run on protected branches
.project_runner:
tags:
- armagetronad
- linux
rules:
- if: $CI_MERGE_REQUEST_ID
when: never
- if: $CI_COMMIT_REF_PROTECTED == "true"
when: on_success
- when: never
# template rule for job to always run, maybe on shared runners
.merge_request:
tags:
- docker
- linux
rules:
- when: on_success
# keep image dependencies here
.merge_request_64:
extends: .merge_request
image: $CI_REGISTRY_IMAGE/armabuild_64@sha256:8bf6a80efb4a7ad74f61a934e652683fa254e7fc15e800b3b9469791437e8795
.merge_request_32:
extends: .merge_request
image: $CI_REGISTRY_IMAGE/armabuild_32@sha256:4cba0dbf909790c2dbf8fd6e765011f85352e72f043a7dc335580f967b093e03
.merge_request_steam_64:
extends: .merge_request
image: $CI_REGISTRY_IMAGE/armasteam_64@sha256:cae02938a300bf474414d4d2fd78b34cfaf8553d7f7f8f635cd10d02242ef26e
.merge_request_wine:
extends: .merge_request
image: $CI_REGISTRY_IMAGE/armawineblocks@sha256:ad1d8dd164238d321e4ac13aeac48477a278e11976ee9ce89a5587bb7f1512a7
.project_runner_64:
extends: .project_runner
image: $CI_REGISTRY_IMAGE/armabuild_64@sha256:8bf6a80efb4a7ad74f61a934e652683fa254e7fc15e800b3b9469791437e8795
.project_runner_steam_64:
extends: .project_runner
image: $CI_REGISTRY_IMAGE/armasteam_64@sha256:cae02938a300bf474414d4d2fd78b34cfaf8553d7f7f8f635cd10d02242ef26e
.project_runner_32:
extends: .project_runner
image: $CI_REGISTRY_IMAGE/armabuild_32@sha256:4cba0dbf909790c2dbf8fd6e765011f85352e72f043a7dc335580f967b093e03
.project_runner_wine:
extends: .project_runner
image: $CI_REGISTRY_IMAGE/armawineblocks@sha256:ad1d8dd164238d321e4ac13aeac48477a278e11976ee9ce89a5587bb7f1512a7
.project_runner_debian:
extends: .project_runner
image: $CI_REGISTRY_IMAGE/armadeb_64@sha256:ddfd360a4d6cd64d9b61d83f58a3439fb49ac316864106c535e7bbaf9584fa5b
# template rule for deployment jobs
.deploy_base:
retry: 2 # deployments can fail temporarily for a million reasons
image: $CI_REGISTRY_IMAGE/armadeploy_64@sha256:3e3220d3c23db411223bb8c0297f88b5f792f371b4974a2ff8295b52111827e8
interruptible: false
# resource_group: deployment # only ever run one deployment job at a time
tags:
- armagetronad_deploy
rules:
- if: $CI_MERGE_REQUEST_ID
when: never
- if: $CI_COMMIT_REF_PROTECTED == "true"
when: on_success
- when: never
before_script:
- ./docker/scripts/fix_gits.sh || exit $?
- ./docker/deploy/prepare_deploy.sh || exit $?
.deploy_staged:
extends: .deploy_base
environment: $STAGING_ENVIRONMENT
dependencies:
- build_prepare
- build_collect
stage: stage
script:
# now enter the docker build directory and just invoke make there
- cd gitlab_build/docker/build
- make staged_${TARGET} -O -j$(nproc) -k
.deploy_staged_ppa:
extends: .deploy_staged
image: $CI_REGISTRY_IMAGE/armadeb_64@sha256:ddfd360a4d6cd64d9b61d83f58a3439fb49ac316864106c535e7bbaf9584fa5b
.deploy_final:
extends: .deploy_base
environment: $FINAL_ENVIRONMENT
dependencies:
- build_prepare
- build_collect
stage: deploy
script:
# check that no later pipeline already started
- docker/scripts/obsolete.sh || exit 0
# now enter the docker build directory and just invoke make there
- cd gitlab_build/docker/build
- make unstaged_${TARGET} -O -j$(nproc) -k
.deploy_final_ppa:
extends: .deploy_final
image: $CI_REGISTRY_IMAGE/armadeb_64@sha256:ddfd360a4d6cd64d9b61d83f58a3439fb49ac316864106c535e7bbaf9584fa5b
.deploy_final_steam:
extends: .deploy_final
image: $CI_REGISTRY_IMAGE/steamcmd@sha256:a902aefc0718d2fc32101c09d6fca5202d882e68e821ae232423014abba6bc3d
# only run on protected branches or merge requests
workflow:
rules:
- if: $CI_MERGE_REQUEST_ID
when: always
- if: '$CI_COMMIT_REF_PROTECTED == "true" && $CI_COMMIT_TAG'
when: always
variables:
# NOTE these two below will vary with our main branches
# these guard lines are there to prevent spurious merge conflicts
STAGING_ENVIRONMENT : "staging_experimental" # <- "staging"
FINAL_ENVIRONMENT : "experimental" # <- "production"
# NOTE these two above will vary with our main branches
# these guard lines are there to prevent spurious merge conflicts
- if: '$CI_COMMIT_REF_PROTECTED == "true" && $CI_COMMIT_BRANCH'
when: always
variables:
STAGING_ENVIRONMENT : "testing_$CI_COMMIT_BRANCH"
FINAL_ENVIRONMENT : "testing_$CI_COMMIT_BRANCH"
- when: never
# very basic build
build_prepare:
stage: build_prepare
extends: .merge_request
script: [""]
artifacts:
untracked: true
expire_in: 1 day
build_server_32_raw:
stage: build_base
extends: .merge_request_32
script:
- gitlab_build/docker/build/make_ci.sh -k result.build_server_32
after_script:
- rm -rf gitlab_build/docker/build/context*.dir
artifacts:
untracked: true
expire_in: 1 day
build_server_steam_raw:
stage: build_base
extends: .merge_request_steam_64
script:
- ./bootstrap.sh
- gitlab_build/docker/build/make_ci.sh -k result.build_server_steam
artifacts:
untracked: true
expire_in: 1 day
# It seems like GitLab CI, all else being equal, schedules jobs in the order
# listed here. So list the ones that take longest first.
# Windows builds are worst because they have an additional layer of emulation,
# are not parallelized and are client and server build in one.
build_windows:
extends: .merge_request_wine
needs:
- build_server_32_raw
stage: build_main
script:
- gitlab_build/docker/build/make_ci.sh CI_windows
artifacts:
paths:
- gitlab_build/docker/build/
expire_in: 1 day
build_windows_steam:
extends: .project_runner_wine
needs:
- build_server_steam_raw
stage: build_main
script:
- gitlab_build/docker/build/make_ci.sh CI_windows_steam
artifacts:
paths:
- gitlab_build/docker/build/
expire_in: 1 day
# debtest is faster, but also not paralellized
build_debtest:
extends: .project_runner_debian
dependencies:
- build_prepare
stage: build_main
script:
- gitlab_build/docker/build/make_ci.sh CI_debtest
artifacts:
paths:
- gitlab_build/docker/build/
expire_in: 1 day
# steam builds server and client in one go (the server is already pre-built), they are packed together
build_linux_steam:
extends: .project_runner_steam_64
dependencies:
- build_server_steam_raw
stage: build_main
script:
- gitlab_build/docker/build/make_ci.sh CI_linux_steam
artifacts:
paths:
- gitlab_build/docker/build/
expire_in: 1 day
build_client_64:
extends: .merge_request_64
needs:
- build_prepare
stage: build_main
script:
- gitlab_build/docker/build/make_ci.sh CI_linux_client_64
artifacts:
paths:
- gitlab_build/docker/build/
expire_in: 1 day
build_client_32:
extends: .project_runner_32
dependencies:
- build_prepare
stage: build_main
script:
- gitlab_build/docker/build/make_ci.sh CI_linux_client_32
artifacts:
paths:
- gitlab_build/docker/build/
expire_in: 1 day
build_server_64:
extends: .project_runner_64
dependencies:
- build_prepare
stage: build_main
script:
- gitlab_build/docker/build/make_ci.sh CI_linux_server_64
artifacts:
paths:
- gitlab_build/docker/build/
expire_in: 1 day
# this one is special, it can rely on previous build work
build_server_32:
extends: .project_runner_32
dependencies:
- build_server_32_raw
stage: build_main
script:
- gitlab_build/docker/build/make_ci.sh CI_linux_server_32
artifacts:
paths:
- gitlab_build/docker/build/
expire_in: 1 day
# macOS builds need a special runner, but can start early.
# it should build directly from git content, the prepared linux source directories have soft links that won't work.
build_macos:
needs: []
# the mac runner is not always available and may go down while on the job,
# be extra tolerant
retry:
max: 2
when: always
tags:
- macos
- armagetronad
stage: build_main
rules:
- if: $CI_MERGE_REQUEST_ID
when: never
- if: $CI_COMMIT_REF_PROTECTED == "true"
when: on_success
- when: never
script:
- docker/scripts/obsolete.sh || exit 0
- ./bootstrap.sh || exit 0
- date
- sntp -s time.apple.com
- gitlab_build/docker/build/make_ci.sh macOS -j`nproc || echo 3`
artifacts:
paths:
- gitlab_build/docker/build/upload
- gitlab_build/docker/build/macOS/*.tag
expire_in: 1 day
build_collect:
extends: .project_runner_64
stage: build_collect
script:
- gitlab_build/docker/build/make_ci.sh debtest.tag CI reformat.tag || exit $?
- rm -rf src
# consider mac builds newer than anything else, they must not be redone
- if test -d gitlab_build/docker/build/macOS; then touch gitlab_build/docker/build/macOS/*; fi
artifacts:
untracked: true
expire_in: 1 day
# deploy to staged environment
deploy_staged_external:
stage: pre_stage
extends: .deploy_staged
variables:
TARGET: "deploy_external"
deploy_staged_ours:
extends: .deploy_staged
variables:
TARGET: "deploy_ours"
deploy_staged_ppa:
extends: .deploy_staged_ppa
variables:
TARGET: "deploy_ppa"
# does not actually deploy, but tests deployment up to the final 'git push'
deploy_staged_flatpak:
extends: .deploy_staged
variables:
TARGET: "deploy_fp"
# delay full deployment
delay_release:
needs: []
stage: stage
rules:
- if: '$CI_COMMIT_REF_PROTECTED == "true"'
when: delayed
start_in: '16 hours'
- when: never
before_script: [""]
script: [""]
# do the actual release; manually for final releases, delayed to avoid spam for everyone else
deploy_final_external:
stage: pre_deploy
extends: .deploy_final
variables:
TARGET: "deploy_external"
deploy_final_steam:
extends: .deploy_final_steam
variables:
TARGET: "deploy_steam"
deploy_final_ours:
extends: .deploy_final
variables:
TARGET: "deploy_ours"
deploy_final_ppa:
extends: .deploy_final_ppa
variables:
TARGET: "deploy_ppa"
deploy_gitlab:
extends: .deploy_final
variables:
TARGET: "deploy_gitlab"
deploy_itch:
extends: .deploy_final
variables:
TARGET: "deploy_itch"
deploy_final_flatpak:
extends: .deploy_final
variables:
TARGET: "deploy_fp"
# test build docker image (hopefully also initiating the cache for later deployment)
# does not really need debtest, but we want to let the Windows builds go first
build_docker:
extends: .project_runner
stage: build_collect
needs:
- job: build_prepare
- job: build_debtest
artifacts: false
after_script:
- rm -f ~/.docker/config.json
script:
- make -C gitlab_build/docker/build build_docker.tag || exit $?
# deploy docker image to staging
stage_docker:
extends: .project_runner
stage: stage
needs:
- job: build_prepare
- job: build_docker
artifacts: false
after_script:
- rm -f ~/.docker/config.json
script:
- make -C gitlab_build/docker/build staged_deploy_docker.tag || exit $?
# deploy docker image
deploy_docker:
extends: .project_runner
environment: $FINAL_ENVIRONMENT
stage: deploy
needs:
- job: build_prepare
- job: stage_docker
artifacts: false
- job: delay_release
artifacts: false
after_script:
- rm -f ~/.docker/config.json
script:
# test whether we're current
- docker/scripts/obsolete.sh || exit 0
# build
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY 2>&1 | grep -v WARNING\|credential || exit $?
- make -C gitlab_build/docker/build unstaged_deploy_docker.tag || exit $?
# post-build tests that require our own runners (or a docker upgrade on GitLab)
post_test:
retry: 2 # some tests fail spuriously for download failures, always rerun
extends: .project_runner
stage: build_collect
services:
# required for shared runners, does not hurt for our runner (just some diagnostic complaints)
- name: docker:19.03.0-dind
alias: docker
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
script:
- make -C gitlab_build/docker/build appimagetests_ci appimagetests_extra || exit $?
# pack up the downloadable build files in one handy artifact
pack:
extends: .project_runner
stage: pre_stage
needs:
- build_collect
script: [""]
before_script:
# test that everything has been prepared correctly
- if ! test -d gitlab_build; then
- echo "No build yet!"
- exit 1
- fi
- find . -newer timestamp.tag ! -path "./gitlab_build" -exec touch -r timestamp.tag \{\} \;
- if ! make -C gitlab_build/docker/build -q CI_pack.tag; then
- make -d -C gitlab_build/docker/build -q CI_pack.tag || exit $?
- exit 1
- fi
- ./docker/scripts/fix_gits.sh || exit $?
artifacts:
expire_in: 1 day
paths:
- gitlab_build/docker/build/upload
testbuild:
extends: .project_runner
stage: test
rules:
- when: never
script:
- docker build -t armagetronad_server .
# for local testing
complete_build:
extends: .project_runner
stage: build_main
rules:
- when: never
script:
- cd gitlab_build/docker/build
- make -O -j$(nproc) CI_base
- make -O -j$(nproc) CI
artifacts:
expire_in: 1 day
paths:
- gitlab_build/docker/build/upload