forked from castle-engine/castle-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
601 lines (583 loc) · 24.5 KB
/
Jenkinsfile
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
/* -*- mode: groovy -*-
Configure how to run our job in Jenkins.
See https://castle-engine.io/jenkins .
*/
pipeline {
options {
/* While concurrent builds of CGE work OK,
they stuck Jenkins much with too many long-running builds.
Better to wait for previous build to finish. */
disableConcurrentBuilds()
/* Trying to resume builds when controller restarts usually results
in job just being stuck forever. So we disable it. */
disableResume()
/* Makes failure in any paralel job to stop the build,
instead of needlessly trying to finish on one node,
when another node already failed. */
parallelsAlwaysFailFast()
}
/* This job works on a few agents in parallel */
agent none
parameters {
booleanParam(name: 'jenkins_fast', defaultValue: false, description: 'Use at emergencies, to make pipeline build faster')
}
stages {
/* Build for each platform in parallel.
See https://stackoverflow.com/questions/43913698/jenkinsfile-parallel-directive
https://www.jenkins.io/blog/2017/09/25/declarative-1/
for parallel syntax. */
stage('Run parallel builds') {
parallel {
stage('Docker (Linux)') {
agent {
docker {
image 'kambi/castle-engine-cloud-builds-tools:cge-none'
}
}
environment {
/* Used by CGE build tool ("castle-engine").
Define env based on another env variable.
According to https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/110
this should be supported. */
CASTLE_ENGINE_PATH = "${WORKSPACE}"
}
stages {
stage('(Docker) Cleanup') {
steps {
sh "repository_cleanup . --remove-unversioned"
}
}
stage('(Docker) Shell Tests') {
steps {
sh "./tools/internal/cge_shell_tests"
}
}
/* Commands with default FPC version
(latest stable FPC, most of the time; see https://castle-engine.io/docker ). */
stage('(Docker) Build Tools (Default FPC)') {
steps {
sh 'make clean tools'
}
}
stage('(Docker) Build Examples (Default FPC)') {
when { not { expression { return params.jenkins_fast } } }
steps {
/* clean 1st, to make sure it's OK even when state is "clean" before "make examples" */
sh 'make clean examples'
}
}
stage('(Docker) Build Examples Using Lazarus (Default FPC/Lazarus)') {
when { not { expression { return params.jenkins_fast } } }
steps {
sh 'make clean examples-laz'
}
}
stage('(Docker) Build And Run Auto-Tests (Default FPC)') {
steps {
sh 'make clean tests'
}
}
stage('(Docker) Build Using FpMake (Default FPC)') {
steps {
sh 'make clean test-fpmake'
}
}
/* Same with FPC 3.2.0.
We could use a script to reuse the code,
but then the detailed time breakdown/statistics would not be available in Jenkins. */
stage('(Docker) Build Tools (FPC 3.2.0)') {
steps {
sh 'source /usr/local/fpclazarus/bin/setup.sh 3.2.0 && make clean tools'
}
}
stage('(Docker) Build Examples (FPC 3.2.0)') {
when { not { expression { return params.jenkins_fast } } }
steps {
/* clean 1st, to make sure it's OK even when state is "clean" before "make examples" */
sh 'source /usr/local/fpclazarus/bin/setup.sh 3.2.0 && make clean examples'
}
}
stage('(Docker) Build Examples Using Lazarus (FPC 3.2.0/Lazarus)') {
when { not { expression { return params.jenkins_fast } } }
steps {
sh 'source /usr/local/fpclazarus/bin/setup.sh 3.2.0 && make clean examples-laz'
}
}
stage('(Docker) Build And Run Auto-Tests (FPC 3.2.0)') {
steps {
sh 'source /usr/local/fpclazarus/bin/setup.sh 3.2.0 && make clean tests'
}
}
stage('(Docker) Build Using FpMake (FPC 3.2.0)') {
steps {
sh 'source /usr/local/fpclazarus/bin/setup.sh 3.2.0 && make clean test-fpmake'
}
}
/* Same with FPC trunk.
We could use a script to reuse the code,
but then the detailed time breakdown/statistics would not be available in Jenkins. */
stage('(Docker) Build Tools (FPC trunk)') {
steps {
sh 'source /usr/local/fpclazarus/bin/setup.sh trunk && make clean tools'
}
}
stage('(Docker) Build Examples (FPC trunk)') {
when { not { expression { return params.jenkins_fast } } }
steps {
/* clean 1st, to make sure it's OK even when state is "clean" before "make examples" */
sh 'source /usr/local/fpclazarus/bin/setup.sh trunk && make clean examples'
}
}
stage('(Docker) Build Examples Using Lazarus (FPC trunk/Lazarus)') {
when { not { expression { return params.jenkins_fast } } }
steps {
sh 'source /usr/local/fpclazarus/bin/setup.sh trunk && make clean examples-laz'
}
}
stage('(Docker) Build And Run Auto-Tests (FPC trunk)') {
steps {
sh 'source /usr/local/fpclazarus/bin/setup.sh trunk && make clean tests'
}
}
/* fpmake compilation with FPC 3.3.1 from 2022-12-27 is broken,
TODO investigate and report.
stage('(Docker) Build Using FpMake (FPC trunk)') {
steps {
sh 'source /usr/local/fpclazarus/bin/setup.sh trunk && make clean test-fpmake'
}
}
*/
stage('(Docker) Pack Release (for Windows and Linux)') {
steps {
/* remove previous artifacts */
sh 'rm -f castle-engine*.zip'
/* build for all targets supported in Docker (Linux and Windows) */
sh './tools/internal/pack_release/pack_release.sh'
/* build a "bundle" version (with FPC) */
copyArtifacts(projectName: 'castle_game_engine_organization/cge-fpc/master', filter: 'fpc-*.zip')
sh 'CGE_PACK_BUNDLE=yes ./tools/internal/pack_release/pack_release.sh win64 x86_64'
sh 'CGE_PACK_BUNDLE=yes ./tools/internal/pack_release/pack_release.sh linux x86_64'
archiveArtifacts artifacts: 'castle-engine*.zip'
}
}
}
}
stage('Raspberry Pi') {
/* Raspberry Pi is very slow and overloaded, rebuild for it only on master */
when { branch "master" }
agent {
label 'raspberry-pi-cge-builder'
}
environment {
/* Used by CGE build tool ("castle-engine").
Define env based on another env variable.
According to https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/110
this should be supported. */
CASTLE_ENGINE_PATH = "${WORKSPACE}"
PATH = "${PATH}:${CASTLE_ENGINE_PATH}/installed/bin/"
}
stages {
stage('(RPi) Info') {
steps {
// check versions (and availability) of our requirements early
sh 'fpc -iV'
sh 'lazbuild --version'
sh 'make --version'
}
}
stage('(RPi) Cleanup') {
steps {
sh "repository_cleanup . --remove-unversioned"
}
}
stage('(RPi) Build Tools') {
steps {
sh 'rm -Rf installed/'
sh 'mkdir -p installed/'
sh 'make clean tools install PREFIX=${CASTLE_ENGINE_PATH}/installed/'
}
}
stage('(RPi) Build Examples') {
when { not { expression { return params.jenkins_fast } } }
steps {
sh 'make clean examples CASTLE_CONSERVE_DISK_SPACE=true'
}
}
stage('(RPi) Build And Run Auto-Tests') {
when { not { expression { return params.jenkins_fast } } }
steps {
sh 'make tests'
}
}
stage('(RPi) Build Using FpMake') {
when { not { expression { return params.jenkins_fast } } }
steps {
sh 'make clean test-fpmake'
}
}
stage('(RPi) Pack Release') {
steps {
sh 'rm -f castle-engine*.zip' /* remove previous artifacts */
sh './tools/internal/pack_release/pack_release.sh linux arm'
archiveArtifacts artifacts: 'castle-engine*.zip'
}
}
}
}
stage('macOS') {
agent {
label 'mac-cge-builder'
}
environment {
/* Used by CGE build tool ("castle-engine").
Define env based on another env variable.
According to https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/110
this should be supported. */
CASTLE_ENGINE_PATH = "${WORKSPACE}"
CGE_INSTALL_PREFIX = "${CASTLE_ENGINE_PATH}/jenkins-installed/"
PATH = "${PATH}:${CGE_INSTALL_PREFIX}/bin/:${WORKSPACE}/pasdoc/bin/"
/* By default old Lazarus wanted to build with Carbon, which is 32-bit only and deprecated by Apple.
No longer necessary with Lazarus 2.2.2. */
// CASTLE_LAZBUILD_OPTIONS = "--widgetset=cocoa"
}
stages {
stage('(macOS) Info') {
steps {
// check versions (and availability) of our requirements early
sh 'fpc -iV'
sh 'lazbuild --version'
sh 'make --version'
}
}
stage('(macOS) Cleanup') {
steps {
sh "repository_cleanup . --remove-unversioned"
}
}
stage('(macOS) Build Tools') {
steps {
sh 'rm -Rf ${CGE_INSTALL_PREFIX}'
sh 'mkdir -p ${CGE_INSTALL_PREFIX}'
sh 'make clean tools install PREFIX=${CGE_INSTALL_PREFIX}'
}
}
stage('(macOS) Build Examples') {
when { not { expression { return params.jenkins_fast } } }
steps {
sh 'make clean examples'
}
}
stage('(macOS) Build And Run Auto-Tests') {
steps {
sh 'make tests'
}
}
/*
// TODO: ignore fpmake test, we don't have fpmake "opengl" package ok after installing on macOS using fpcupdeluxe?
stage('Build Using FpMake') {
steps {
sh 'make clean test-fpmake'
}
}
*/
stage('(macOS) Build Lazarus Packages') {
steps {
sh 'lazbuild $CASTLE_LAZBUILD_OPTIONS packages/castle_base.lpk'
sh 'lazbuild $CASTLE_LAZBUILD_OPTIONS packages/castle_window.lpk'
sh 'lazbuild $CASTLE_LAZBUILD_OPTIONS packages/castle_components.lpk'
sh 'lazbuild $CASTLE_LAZBUILD_OPTIONS packages/castle_editor_components.lpk'
sh 'lazbuild $CASTLE_LAZBUILD_OPTIONS packages/alternative_castle_window_based_on_lcl.lpk'
}
}
stage('(macOS) Build Editor') {
steps {
dir ('tools/castle-editor/') {
sh 'castle-engine package'
}
}
}
stage('(macOS) Get PasDoc') {
steps {
/* remove older PasDoc versions, so that later "pasdoc-*-darwin-x86_64.zip"
expands "pasdoc-*-darwin-x86_64.zip" only to one file.
This matters when PasDoc version change, e.g. from 0.15.0 to 0.16.0. */
sh 'rm -f pasdoc-*-darwin-x86_64.zip'
/* Use https://plugins.jenkins.io/copyartifact/ plugin to copy last pasdoc build into this build. */
copyArtifacts(projectName: 'pasdoc_organization/pasdoc/master', filter: 'pasdoc-*-darwin-x86_64.zip')
sh 'unzip pasdoc-*-darwin-x86_64.zip'
}
}
stage('(macOS) Pack Release') {
steps {
sh 'rm -f castle-engine*.zip' /* remove previous artifacts */
sh './tools/internal/pack_release/pack_release.sh darwin x86_64'
archiveArtifacts artifacts: 'castle-engine*.zip'
}
}
}
}
stage('Windows (FPC)') {
agent {
label 'windows-cge-builder'
}
environment {
/* Used by CGE build tool ("castle-engine").
Define env based on another env variable.
According to https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/110
this should be supported. */
CASTLE_ENGINE_PATH = "${WORKSPACE}"
PATH = "${PATH};${CASTLE_ENGINE_PATH}/installed/bin/;${WORKSPACE}/pasdoc/bin/" // Note: on Windows, PATH is separated by ;
}
stages {
stage('(Windows) Info') {
steps {
// check versions (and availability) of our requirements early
sh 'fpc -iV'
sh 'lazbuild --version'
sh 'make --version'
}
}
stage('(Windows) Cleanup') {
steps {
sh "repository_cleanup . --remove-unversioned"
}
}
stage('(Windows) Build Tools') {
when { not { expression { return params.jenkins_fast } } }
steps {
sh 'rm -Rf installed/'
sh 'mkdir -p installed/'
/* TODO: do not use "make install" command, as somewhere the Windows path gets
messed up and in the end we have created files like this:
"tools/build-tool/data/E\357\200\272jworkspacecastle_game_engine_delphi_master/installed/share/castle-engine/android/integrated-services/google_play_games/app/src/main/java/net/sourceforge/castleengine/ServiceGooglePlayGames.java"
*/
// sh 'make clean tools install PREFIX=${CASTLE_ENGINE_PATH}/installed/'
sh 'make clean tools'
sh 'mkdir -p ${CASTLE_ENGINE_PATH}/installed/bin/'
sh 'cp tools/build-tool/castle-engine.exe ${CASTLE_ENGINE_PATH}/installed/bin/'
}
}
stage('(Windows) Build Examples') {
when { not { expression { return params.jenkins_fast } } }
steps {
sh 'make clean examples'
}
}
stage('(Windows) Build And Run Auto-Tests') {
when { not { expression { return params.jenkins_fast } } }
steps {
sh 'make tests'
}
}
stage('(Windows) Build Using FpMake') {
when { not { expression { return params.jenkins_fast } } }
steps {
sh 'make clean test-fpmake'
}
}
stage('(Windows) Get PasDoc') {
steps {
/* remove older PasDoc versions, so that later "pasdoc-*-win64.zip"
expands "pasdoc-*-win64.zip" only to one file.
This matters when PasDoc version change, e.g. from 0.15.0 to 0.16.0. */
sh 'rm -f pasdoc-*-win64.zip'
/* Use https://plugins.jenkins.io/copyartifact/ plugin to copy last pasdoc build into this build. */
copyArtifacts(projectName: 'pasdoc_organization/pasdoc/master', filter: 'pasdoc-*-win64.zip')
sh 'unzip pasdoc-*-win64.zip'
}
}
/* Pack Windows installer on Windows node.
Note that Windows zip is packed inside Docker (on Linux). */
stage('(Windows) Pack Windows Installer') {
steps {
copyArtifacts(projectName: 'castle_game_engine_organization/cge-fpc/master', filter: 'fpc-*.zip')
sh 'CGE_PACK_BUNDLE=yes ./tools/internal/pack_release/pack_release.sh windows_installer'
archiveArtifacts artifacts: 'castle-engine-setup-*.exe'
}
}
}
}
stage('Delphi on Windows') {
agent {
label 'windows-cge-builder'
}
environment {
/* Used by CGE build tool ("castle-engine").
Define env based on another env variable.
According to https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/110
this should be supported. */
CASTLE_ENGINE_PATH = "${WORKSPACE}"
PATH = "${PATH};${CASTLE_ENGINE_PATH}/installed/bin/" // Note: on Windows, PATH is separated by ;
}
stages {
stage('(Delphi) Info') {
steps {
/* Check versions (and availability) of our requirements early.
Note that we need FPC for Delphi test too, since our internal tools are compiled with FPC. */
sh 'fpc -iV'
sh 'lazbuild --version'
// We want GNU make, not Embarcadero make
sh 'make --version'
}
}
stage('(Delphi) Cleanup') {
steps {
sh "repository_cleanup . --remove-unversioned"
}
}
stage('(Delphi) Build Tools') {
steps {
sh 'rm -Rf installed/'
sh 'mkdir -p installed/'
/* TODO: do not use "make install" command, as somewhere the Windows path gets
messed up and in the end we have created files like this:
"tools/build-tool/data/E\357\200\272jworkspacecastle_game_engine_delphi_master/installed/share/castle-engine/android/integrated-services/google_play_games/app/src/main/java/net/sourceforge/castleengine/ServiceGooglePlayGames.java"
*/
// sh 'make clean tools install PREFIX=${CASTLE_ENGINE_PATH}/installed/'
sh 'make clean tools'
sh 'mkdir -p ${CASTLE_ENGINE_PATH}/installed/bin/'
sh 'cp tools/build-tool/castle-engine.exe ${CASTLE_ENGINE_PATH}/installed/bin/'
}
}
stage('(Delphi) Check AutoTests (Win64)') {
steps {
dir ('tests/delphi_tests/') {
sh 'castle-engine clean'
sh 'castle-engine compile --compiler=delphi --os=win64 --cpu=x86_64'
sh 'castle-engine run'
}
}
}
stage('(Delphi) Check AutoTests (Win32)') {
steps {
dir ('tests/delphi_tests/') {
sh 'castle-engine clean'
sh 'castle-engine compile --compiler=delphi --os=win32 --cpu=i386'
sh 'castle-engine run'
}
}
}
stage('(Delphi) Check AutoTests with NO_WINDOW_SYSTEM (Win64)') {
steps {
dir ('tests/') {
sh 'castle-engine clean'
sh 'castle-engine compile --compiler=delphi --os=win64 --cpu=x86_64 --compiler-option=-dNO_WINDOW_SYSTEM'
sh 'castle-engine run -- --console'
}
}
}
stage('(Delphi) Check AutoTests with NO_WINDOW_SYSTEM (Win32)') {
steps {
dir ('tests/') {
sh 'castle-engine clean'
sh 'castle-engine compile --compiler=delphi --os=win32 --cpu=i386 --compiler-option=-dNO_WINDOW_SYSTEM'
sh 'castle-engine run -- --console'
}
}
}
stage('(Delphi) Build Templates (Win64)') {
steps {
sh 'make test-editor-templates CASTLE_ENGINE_TOOL_OPTIONS="--compiler=delphi --os=win64 --cpu=x86_64"'
}
}
stage('(Delphi) Build Templates (Win32)') {
steps {
sh 'make test-editor-templates CASTLE_ENGINE_TOOL_OPTIONS="--compiler=delphi --os=win32 --cpu=i386"'
}
}
stage('(Delphi) Build Examples (Win64)') {
when { not { expression { return params.jenkins_fast } } }
steps {
sh 'make examples-delphi CASTLE_ENGINE_TOOL_OPTIONS="--os=win64 --cpu=x86_64"'
}
}
stage('(Delphi) Build Examples (Win32)') {
when { not { expression { return params.jenkins_fast } } }
steps {
sh 'make examples-delphi CASTLE_ENGINE_TOOL_OPTIONS="--os=win32 --cpu=i386"'
}
}
stage('(Delphi) Build Delphi-specific Examples (Win64)') {
steps {
dir ('examples/delphi/vcl') {
sh 'castle-engine clean'
sh 'castle-engine compile --compiler=delphi --os=win64 --cpu=x86_64'
}
dir ('examples/delphi/fmx') {
sh 'castle-engine clean'
sh 'castle-engine compile --compiler=delphi --os=win64 --cpu=x86_64'
}
}
}
stage('(Delphi) Build Delphi-specific Examples (Win32)') {
steps {
dir ('examples/delphi/vcl') {
sh 'castle-engine clean'
sh 'castle-engine compile --compiler=delphi --os=win32 --cpu=i386'
}
dir ('examples/delphi/fmx') {
sh 'castle-engine clean'
sh 'castle-engine compile --compiler=delphi --os=win32 --cpu=i386'
}
}
}
}
}
stage('Check Dependencies') {
when { not { expression { return params.jenkins_fast } } }
agent {
docker {
image 'kambi/castle-engine-cloud-builds-tools:cge-none'
}
}
environment {
/* Used by CGE build tool ("castle-engine").
Define env based on another env variable.
According to https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/110
this should be supported. */
CASTLE_ENGINE_PATH = "${WORKSPACE}"
}
stages {
stage('(Check Dependencies) Cleanup') {
steps {
sh "repository_cleanup . --remove-unversioned"
}
}
stage('(Check Dependencies) Build Tools') {
steps {
sh 'rm -Rf installed/'
sh 'mkdir -p installed/'
sh 'make clean tools install PREFIX=${CASTLE_ENGINE_PATH}/installed/'
}
}
stage('(Check Dependencies) Check Dependencies') {
steps {
dir ('tools/internal/check_units_dependencies/') {
sh 'export PATH="${PATH}:${CASTLE_ENGINE_PATH}/installed/bin/" && make'
}
archiveArtifacts artifacts: 'test-cge-units-dependencies_all_units.txt,cge_check_units_dependencies.log'
}
}
}
}
}
}
}
post {
regression {
mail to: 'michalis@castle-engine.io',
subject: "[jenkins] Build started failing: ${currentBuild.fullDisplayName}",
body: "See the build details on ${env.BUILD_URL}"
}
failure {
mail to: 'michalis@castle-engine.io',
subject: "[jenkins] Build failed: ${currentBuild.fullDisplayName}",
body: "See the build details on ${env.BUILD_URL}"
}
fixed {
mail to: 'michalis@castle-engine.io',
subject: "[jenkins] Build is again successful: ${currentBuild.fullDisplayName}",
body: "See the build details on ${env.BUILD_URL}"
}
}
}