This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 123
/
Jenkinsfile
1685 lines (1513 loc) · 48 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
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
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// vim: ts=2:sw=2:expandtab:syntax=groovy
/* https://build.libelektra.org/job/elektra-jenkinsfile/
* This file describes how the elektra-jenkinsfile buildjob should be
* executed.
*
* 1. libraries and global variables are set
* 2. define the main stages of the pipeline
* 3. describe sub stages. This is where you will want to add new builds
* 4. helper section to help write build scripts
*
* General Information about Jenkinsfiles can be found at
* https://jenkins.io/doc/book/pipeline/jenkinsfile/.
*
* A Snippet generator is available to the public at
* https://qa.nuxeo.org/jenkins/pipeline-syntax/.
* A list of available commands on the build server can be found after a login at
* https://build.libelektra.org/job/libelektra/pipeline-syntax/.
*/
// TODO have a per plugin/binding deps in Dockerfile for easier maintenance
// TODO add warnings plugins to scan for compiler warnings
// Does appear to be not working for multiple runs in one job
// Libraries
@Library('libelektra-shared') _
// Buildjob properties
properties([
buildDiscarder(
logRotator(
artifactDaysToKeepStr: '31', // Keep artifacts for max 31 days
artifactNumToKeepStr: '5', // Keep artifacts for last 5 builds
daysToKeepStr: '90', // Keep build info for 90 days
numToKeepStr: '60' // Keep a max of 60 builds
)
)
])
// If previous run is still running, cancel it unless we are building
// code from the `master` branch.
abortPreviousRunUnlessMaster()
pipelineConfig {
// uncomment if you you want to overwrite these values
// dockerNodeLabel = 'docker'
// registry = 'hub.libelektra.org'
now = new Date()
}
/* Define reusable cmake Flag globals
*
* They can be passed to many of the test helper functions and the cmake
* function and represent flags usually passed to cmake.
*/
CMAKE_FLAGS_BASE = [
'SITE': '${STAGE_NAME}',
'KDB_DB_SYSTEM': '${WORKSPACE}/config/kdb/system',
'KDB_DB_SPEC': '${WORKSPACE}/config/kdb/spec',
'KDB_DB_HOME': '${WORKSPACE}/config/kdb/home',
'CMAKE_INSTALL_PREFIX': '${WORKSPACE}/system',
'BUILD_DOCUMENTATION': 'OFF',
'CMAKE_RULE_MESSAGES': 'OFF',
'COMMON_FLAGS': '-Werror'
]
CMAKE_FLAGS_BUILD_ALL = [
'BINDINGS': 'ALL',
'PLUGINS': 'ALL',
'TOOLS': 'ALL'
]
CMAKE_FLAGS_COVERAGE = ['ENABLE_COVERAGE': 'ON']
CMAKE_FLAGS_CLANG = [
'CMAKE_C_COMPILER': 'clang',
'CMAKE_CXX_COMPILER': 'clang++'
]
CMAKE_FLAGS_MMAP = [
'KDB_DB_FILE': 'default.mmap',
'KDB_DB_INIT': 'elektra.mmap',
'KDB_DEFAULT_STORAGE': 'mmapstorage'
]
CMAKE_FLAGS_GDWARF4_VALGRIND_WORKAROUND = [
'CMAKE_C_FLAGS': '-gdwarf-4',
'CMAKE_CXX_FLAGS': '-gdwarf-4'
]
CMAKE_FLAGS_I386 = [
'CMAKE_C_FLAGS': '-m32',
'CMAKE_CXX_FLAGS': '-m32'
]
CMAKE_FLAGS_ASAN = ['ENABLE_ASAN': 'ON']
CMAKE_FLAGS_DEBUG = ['ENABLE_DEBUG': 'ON']
CMAKE_FLAGS_LOGGER = ['ENABLE_LOGGER': 'ON']
CMAKE_FLAGS_OPTIMIZATIONS_OFF = ['ENABLE_OPTIMIZATIONS': 'OFF']
CMAKE_FLAGS_BUILD_TESTING_OFF = ['BUILD_TESTING': 'OFF']
// CMAKE_FLAGS_BUILD_SHARED = ['BUILD_SHARED': 'ON'] is ON per default
CMAKE_FLAGS_BUILD_FULL = ['BUILD_FULL': 'ON']
CMAKE_FLAGS_BUILD_STATIC = ['BUILD_STATIC': 'ON']
// Define TEST enum used in buildAndTest helper
enum TEST {
MEM, // Test for memoryleaks via valgrind
NOKDB, // Only run tests that do not write to disk
ALL, // Run all tests
INSTALL, // Run all tests on an installed version of Elektra
CRYPTOS // Test crypto, fcrypt and gpgme for memory leaks (quite unstable)
public TEST() {} // WORKAROUND https://issues.jenkins-ci.org/browse/JENKINS-33023
}
DOCKER_IMAGES = [:] // Containers docker image descriptions, populated during
// dockerInit()
/*****************************************************************************
* Main Stages
*
* Serial stages that contain parallelized logic. Only proceeds to the next
* if previous stage did not fail.
*****************************************************************************/
/* main function wrapping around all stages
*
* Added to improve readability.
*/
def main() {
stage("Init docker images") {
dockerInit()
}
stage("Pull docker images") {
parallel dockerUtils.generateDockerPullStages(DOCKER_IMAGES)
}
maybeStage("Build docker images", DOCKER_IMAGES.any {img -> !img.value.exists}) {
lock('docker-images') {
parallel dockerUtils.generateDockerBuildStages(DOCKER_IMAGES)
}
}
stage("Basic checks") {
milestone label: "Basic checks"
parallel generateBasicCheckStages()
}
stage("Main builds") {
milestone label: "Main builds"
parallel generateMainBuildStages()
}
stage("Full builds") {
milestone label: "Full builds"
parallel generateFullBuildStages()
}
stage("Build artifacts") {
milestone label: "Build artifacts"
parallel generateArtifactStages()
}
maybeStage("Deploy Website", isMaster()) {
milestone label: "Deploy Website"
parallel deployWebsite()
}
// maybeStage("Deploy Web UI", isMaster()) {
// deployWebUI()
// }
}
try {
detectInterruption {
main()
}
} catch(UserInterruptedException uie) {
println "Caught ${uie}"
} catch(Exception e) {
if (isMaster()) {
// If master is failing we want to know ASAP so send a mail.
// collect changes since last build
def changes = currentBuild.changeSets.collect() {
it.collect() {
"* ${it.getCommitId().take(7)} - ${it.getAuthor()} - ${it.getMsg().take(40)}"
}.join('\n')
}.join('\n')
if (!changes) {
changes = "* No new changes since last build"
}
def message = """\
Build ${JOB_NAME}:${BUILD_NUMBER} failed.
Url: ${RUN_DISPLAY_URL}
Reason: ${e}
Changes: ${RUN_CHANGES_DISPLAY_URL}
${changes}
Logs: ${currentBuild.rawBuild.getLog(20).join('\n')}
"""
mail subject: "Build ${JOB_NAME} failed",
body: message,
replyTo: "noreply@libelektra.org",
to: "build@libelektra.org"
}
throw e
}
/*****************************************************************************
* Stage Generators
*****************************************************************************/
/* Populate DOCKER_IMAGES with data
*
* For this we need a checkout of the scm to generate the hash for the
* Dockerfiles which indicates if a rebuild of the images is needed
*/
def dockerInit() {
node("master") {
echo "Processing DOCKER_IMAGES"
checkout scm
/* We use the sid image for testing if we are compatible with Debian
* unstable.
* Additionally we use it for tests with Clang and for source
* formatting checks (as they depend on Clang).
*/
DOCKER_IMAGES.sid = dockerUtils.createDockerImageDesc(
"debian-sid", dockerUtils.&idTesting,
"./scripts/docker/debian/sid",
"./scripts/docker/debian/sid/Dockerfile"
)
/*
* Debian Bullseye. Used for testing and packaging.
*/
DOCKER_IMAGES.bullseye = dockerUtils.createDockerImageDesc(
"debian-bullseye", dockerUtils.&idTesting,
"./scripts/docker/debian/bullseye",
"./scripts/docker/debian/bullseye/Dockerfile"
)
/* A minimal Debian Bullseye image used to test Elektra without any
* additional requirements introduced by optional plugins, bindings,
* ...
*/
DOCKER_IMAGES.bullseye_minimal = dockerUtils.createDockerImageDesc(
"debian-bullseye-minimal", dockerUtils.&idTesting,
"./scripts/docker/debian/bullseye",
"./scripts/docker/debian/bullseye/minimal.Dockerfile"
)
/* A Docker image for cross-building i386
*/
DOCKER_IMAGES.bullseye_i386 = dockerUtils.createDockerImageDesc(
"debian-bullseye-i386", dockerUtils.&idTesting,
"./scripts/docker/debian/bullseye",
"./scripts/docker/debian/bullseye/i386.Dockerfile"
)
/* Build Elektra's documentation with this image.
* Also contains latex for pdf creation.
*/
DOCKER_IMAGES.bullseye_doc = dockerUtils.createDockerImageDesc(
"debian-bullseye-doc", dockerUtils.&idTesting,
"./scripts/docker/debian/bullseye",
"./scripts/docker/debian/bullseye/doc.Dockerfile"
)
/* Our main target for compatibility is Debian stable
* (currently buster).
* Hence we try to build all parts of Elektra via this image.
* Most of the tests defined below use this image.
* Especially noteworthy is that this image is also used for Debian
* package building
*/
DOCKER_IMAGES.buster = dockerUtils.createDockerImageDesc(
"debian-buster", dockerUtils.&idTesting,
"./scripts/docker/debian/buster",
"./scripts/docker/debian/buster/Dockerfile"
)
/* A minimal Debian buster image used to test Elektra without any
* additional requirements introduced by optional plugins, bindings,
* ...
*/
DOCKER_IMAGES.buster_minimal = dockerUtils.createDockerImageDesc(
"debian-buster-minimal", dockerUtils.&idTesting,
"./scripts/docker/debian/buster",
"./scripts/docker/debian/buster/minimal.Dockerfile"
)
/* A Docker image for cross-building i386
*/
DOCKER_IMAGES.buster_i386 = dockerUtils.createDockerImageDesc(
"debian-buster-i386", dockerUtils.&idTesting,
"./scripts/docker/debian/buster",
"./scripts/docker/debian/buster/i386.Dockerfile"
)
/* Alpine: used to compile against musl and uses ash as shell
*/
DOCKER_IMAGES.alpine = dockerUtils.createDockerImageDesc(
"alpine", dockerUtils.&idTesting,
"./scripts/docker/alpine/3.17",
"./scripts/docker/alpine/3.17/Dockerfile"
)
/* Ubuntu Focal Fossa image*/
DOCKER_IMAGES.focal = dockerUtils.createDockerImageDesc(
"focal", dockerUtils.&idTesting,
"./scripts/docker/ubuntu/focal",
"./scripts/docker/ubuntu/focal/Dockerfile"
)
/* Ubuntu Jammy Jellyfish image*/
DOCKER_IMAGES.jammy = dockerUtils.createDockerImageDesc(
"jammy", dockerUtils.&idTesting,
"./scripts/docker/ubuntu/jammy",
"./scripts/docker/ubuntu/jammy/Dockerfile"
)
/* Ubuntu Kinetic Kudu image*/
DOCKER_IMAGES.kinetic = dockerUtils.createDockerImageDesc(
"kinetic", dockerUtils.&idTesting,
"./scripts/docker/ubuntu/kinetic",
"./scripts/docker/ubuntu/kinetic/Dockerfile"
)
/* Fedora 36 image*/
DOCKER_IMAGES.fedora_36 = dockerUtils.createDockerImageDesc(
"fedora-36", dockerUtils.&idTesting,
"./scripts/docker/fedora/36",
"./scripts/docker/fedora/36/Dockerfile"
)
DOCKER_IMAGES.fedora_37 = dockerUtils.createDockerImageDesc(
"fedora-37", dockerUtils.&idTesting,
"./scripts/docker/fedora/37",
"./scripts/docker/fedora/37/Dockerfile"
)
DOCKER_IMAGES.opensuse_15_3 = dockerUtils.createDockerImageDesc(
"opensuse-15-3", dockerUtils.&idTesting,
"./scripts/docker/opensuse/15.3",
"./scripts/docker/opensuse/15.3/Dockerfile"
)
/* CentOS Stream 8 image*/
DOCKER_IMAGES.centos_stream8 = dockerUtils.createDockerImageDesc(
"centos-stream-8", dockerUtils.&idTesting,
"./scripts/docker/centos/stream8",
"./scripts/docker/centos/stream8/Dockerfile"
)
/* Image building the libelektra.org website */
DOCKER_IMAGES.website = dockerUtils.createDockerImageDesc(
"website", dockerUtils.&idArtifact,
".",
"./scripts/docker/website/Dockerfile",
false
)
/* Image building Elektra webui base image */
DOCKER_IMAGES.webui_base = dockerUtils.createDockerImageDesc(
"web-base", dockerUtils.&idArtifact,
".",
"./scripts/docker/webui/base/Dockerfile",
false
)
/* Image building elektrad */
DOCKER_IMAGES.webui_elektrad = dockerUtils.createDockerImageDesc(
"elektrad-demo", dockerUtils.&idArtifact,
"./scripts/docker/webui/elektrad-demo/",
"./scripts/docker/webui/elektrad-demo/Dockerfile",
false
)
/* Image building webd */
DOCKER_IMAGES.webui_webd = dockerUtils.createDockerImageDesc(
"webd-demo", dockerUtils.&idArtifact,
"./scripts/docker/webui/webd-demo/",
"./scripts/docker/webui/webd-demo/Dockerfile",
false
)
/* Debian buster image used to install previously built packages */
DOCKER_IMAGES.buster_installed = dockerUtils.createDockerImageDesc(
"debian-buster-installed", dockerUtils.&idArtifact,
"./build/package",
"./scripts/docker/debian/buster/release.Dockerfile",
false
)
/* Debian bullseye image used to install previously built packages */
DOCKER_IMAGES.bullseye_installed = dockerUtils.createDockerImageDesc(
"debian-bullseye-installed", dockerUtils.&idArtifact,
"./build/package",
"./scripts/docker/debian/bullseye/release.Dockerfile",
false
)
/* Ubuntu Focal Fossa image used to install previously built packages */
DOCKER_IMAGES.focal_installed = dockerUtils.createDockerImageDesc(
"ubuntu-focal-installed", dockerUtils.&idArtifact,
"./build/package",
"./scripts/docker/ubuntu/focal/release.Dockerfile",
false
)
/* Ubuntu Jammy Jellyfish image used to install previously built packages */
DOCKER_IMAGES.jammy_installed = dockerUtils.createDockerImageDesc(
"ubuntu-jammy-installed", dockerUtils.&idArtifact,
"./build/package",
"./scripts/docker/ubuntu/jammy/release.Dockerfile",
false
)
/* Ubuntu Kinetic Kudu image used to install previously built packages */
DOCKER_IMAGES.kinetic_installed = dockerUtils.createDockerImageDesc(
"ubuntu-kinetic-installed", dockerUtils.&idArtifact,
"./build/package",
"./scripts/docker/ubuntu/kinetic/release.Dockerfile",
false
)
/* Fedora 36 image used to install previously built packages */
DOCKER_IMAGES.fedora_36_installed = dockerUtils.createDockerImageDesc(
"fedora-36-installed", dockerUtils.&idArtifact,
"./build/package",
"./scripts/docker/fedora/36/release.Dockerfile",
false
)
/* Fedora 37 image used to install previously built packages */
DOCKER_IMAGES.fedora_37_installed = dockerUtils.createDockerImageDesc(
"fedora-37-installed", dockerUtils.&idArtifact,
"./build/package",
"./scripts/docker/fedora/37/release.Dockerfile",
false
)
/* openSuse Leap 15.3 image used to install previously built packages */
DOCKER_IMAGES.opensuse_15_3_installed = dockerUtils.createDockerImageDesc(
"opensuse-15-3-installed", dockerUtils.&idTesting,
"./build/package",
"./scripts/docker/opensuse/15.3/release.Dockerfile",
false
)
/* Image to build openwrt package */
/* TODO: Reenable when we have a new maintainer for openwrt
*
DOCKER_IMAGES.openwrt_sdk = dockerUtils.createDockerImageDesc(
'openwrt-sdk', dockerUtils.&idTesting,
'./scripts/docker/openwrt/sdk',
'./scripts/docker/openwrt/sdk/Dockerfile'
)*/
}
}
/* Generate basic check stages
*
* Runs basic checks that do not to build the code
*/
def generateBasicCheckStages() {
def tasks = [:]
// Do not abort parallel stages if any fail, so we can see the output of all stages
tasks.failFast = false
// Check the ABI and API compatibility of Elektra
tasks << buildIcheck()
// Check if release notes have been updated
tasks << buildCheckReleaseNotes()
// Check if all file names comply with the file name convention
tasks << buildCheckFileNames()
// Check for reuse compliancy
tasks << buildCheckReuseCompliant()
// Check formatting of c and CMake files
tasks << buildFormatChecks()
// Run the open tasks plugin and sloccount
tasks << buildTodo()
return tasks
}
/* Generate Main stages
*
* Should be used to give quick feedback to developer and check for obvious
* errors before the intensive tasks start
*/
def generateMainBuildStages() {
def tasks = [:]
// We want to fail fast (i.e. abort parallel stages if one fails
tasks.failFast = true
tasks << buildAndTest(
"fedora-37-full",
DOCKER_IMAGES.fedora_37,
CMAKE_FLAGS_BUILD_ALL +
CMAKE_FLAGS_DEBUG +
CMAKE_FLAGS_BUILD_FULL +
CMAKE_FLAGS_BUILD_STATIC,
[TEST.ALL, TEST.MEM, TEST.NOKDB, TEST.INSTALL]
)
// Build doc and upload
tasks << buildDoc()
// Add a task that should build the whole project to catch all test errors
// in a standard environment
tasks << buildAndTest(
"debian-bullseye-full",
DOCKER_IMAGES.bullseye,
CMAKE_FLAGS_BUILD_ALL +
CMAKE_FLAGS_DEBUG +
CMAKE_FLAGS_BUILD_FULL +
CMAKE_FLAGS_BUILD_STATIC +
CMAKE_FLAGS_COVERAGE
,
[TEST.ALL, TEST.MEM, TEST.NOKDB, TEST.INSTALL]
)
return tasks
}
/* Generate Test stages for full test coverage
*/
def generateFullBuildStages() {
def tasks = [:]
tasks << buildAndTest(
"fedora-36-full",
DOCKER_IMAGES.fedora_36,
CMAKE_FLAGS_BUILD_ALL +
CMAKE_FLAGS_DEBUG +
CMAKE_FLAGS_BUILD_FULL +
CMAKE_FLAGS_BUILD_STATIC,
[TEST.ALL, TEST.MEM, TEST.NOKDB, TEST.INSTALL]
)
// Build Elektra with clang and ASAN
// Detects memory leaks via ASAN
tasks << buildAndTestAsan(
"fedora-37-asan",
DOCKER_IMAGES.fedora_37,
CMAKE_FLAGS_BUILD_ALL
)
tasks << buildAndTest(
"opensuse-15-3",
DOCKER_IMAGES.opensuse_15_3,
CMAKE_FLAGS_BUILD_ALL+
CMAKE_FLAGS_DEBUG,
[TEST.ALL, TEST.MEM, TEST.INSTALL]
)
tasks << buildAndTest(
"centos-stream-8",
DOCKER_IMAGES.centos_stream8,
CMAKE_FLAGS_BUILD_ALL+
CMAKE_FLAGS_DEBUG,
[TEST.ALL, TEST.MEM, TEST.INSTALL]
)
// Add a task that should build the whole project to catch all test errors
// in a standard environment
tasks << buildAndTest(
"debian-buster-full",
DOCKER_IMAGES.buster,
CMAKE_FLAGS_BUILD_ALL +
CMAKE_FLAGS_DEBUG +
CMAKE_FLAGS_BUILD_FULL +
CMAKE_FLAGS_BUILD_STATIC +
CMAKE_FLAGS_COVERAGE
,
[TEST.ALL, TEST.MEM, TEST.NOKDB, TEST.INSTALL]
)
// Build Elektra with ASAN enabled
// Detects memory leaks via ASAN
tasks << buildAndTestAsan(
"debian-buster-asan",
DOCKER_IMAGES.buster,
CMAKE_FLAGS_BUILD_ALL
)
// Build Elektra with clang and ASAN
// Detects memory leaks via ASAN
tasks << buildAndTestAsan(
"debian-unstable-clang-asan",
DOCKER_IMAGES.sid,
CMAKE_FLAGS_BUILD_ALL +
CMAKE_FLAGS_CLANG
)
// Build Elektra on debian-unstable for compatibility tests
tasks << buildAndTest(
"debian-unstable-full",
DOCKER_IMAGES.sid,
CMAKE_FLAGS_BUILD_ALL+
CMAKE_FLAGS_DEBUG,
[TEST.ALL, TEST.MEM, TEST.INSTALL]
)
// Build Elektra on debian bullseye
tasks << buildAndTest(
"debian-bullseye-full",
DOCKER_IMAGES.bullseye,
CMAKE_FLAGS_BUILD_ALL+
CMAKE_FLAGS_DEBUG,
[TEST.ALL, TEST.MEM, TEST.INSTALL]
)
tasks << buildAndTest(
"debian-bullseye-full-i386",
DOCKER_IMAGES.bullseye_i386,
CMAKE_FLAGS_I386 + [
'PLUGINS': 'NODEP'
] + CMAKE_FLAGS_BUILD_ALL,
[TEST.ALL]
)
tasks << buildAndTest(
"debian-buster-full-i386",
DOCKER_IMAGES.buster_i386,
CMAKE_FLAGS_I386 + [
'PLUGINS': 'NODEP'
] + CMAKE_FLAGS_BUILD_ALL,
[TEST.ALL]
)
// Build Elektra with clang. We use unstable for easy access to clang-9.0
// Detects problems when using an alternative compiler (clang)
tasks << buildAndTest(
"debian-unstable-full-clang",
DOCKER_IMAGES.sid,
CMAKE_FLAGS_BUILD_ALL +
CMAKE_FLAGS_DEBUG +
CMAKE_FLAGS_CLANG +
CMAKE_FLAGS_GDWARF4_VALGRIND_WORKAROUND,
[TEST.ALL, TEST.MEM, TEST.INSTALL]
)
// Build Elektra via mingw for Windows
tasks << buildAndTestMingwW64_x86_64()
tasks << buildAndTestMingwW64_i686()
// Build Elektra on alpine
tasks << buildAndTest(
"alpine",
DOCKER_IMAGES.alpine,
CMAKE_FLAGS_BUILD_ALL +
CMAKE_FLAGS_BUILD_STATIC + [
'PLUGINS': 'ALL;-date',
],
[TEST.ALL]
)
// Build Elektra on Ubuntu Jammy Jellyfish
tasks << buildAndTest(
"ubuntu-jammy",
DOCKER_IMAGES.jammy,
CMAKE_FLAGS_BUILD_ALL,
[TEST.ALL]
)
// Build Elektra on Ubuntu Kinetic Kudu
tasks << buildAndTest(
"ubuntu-kinetic",
DOCKER_IMAGES.kinetic,
CMAKE_FLAGS_BUILD_ALL,
[TEST.ALL]
)
// Build Elektra on a minimal Debian buster Docker image
tasks << buildAndTest(
"debian-buster-minimal",
DOCKER_IMAGES.buster_minimal,
[:],
[TEST.ALL]
)
// Build Elektra on a minimal Debian Bullseye Docker image
tasks << buildAndTest(
"debian-bullseye-minimal",
DOCKER_IMAGES.bullseye_minimal,
[:],
[TEST.ALL]
)
// Build Elektra on a minimal Debian Bullseye Docker image
// specify NODEP and see if plugins are properly included/excluded
tasks << buildAndTest(
"debian-bullseye-minimal-nodep",
DOCKER_IMAGES.bullseye_minimal,
['PLUGINS': 'NODEP'],
[TEST.ALL]
)
// Build Elektra without the cache plugin
tasks << buildAndTest(
"debian-bullseye-full-nocache",
DOCKER_IMAGES.bullseye,
CMAKE_FLAGS_BUILD_ALL +
CMAKE_FLAGS_DEBUG +
CMAKE_FLAGS_COVERAGE + [
'PLUGINS': 'ALL;-DEPRECATED;-cache',
],
[TEST.ALL, TEST.MEM]
)
// tasks << buildAndTestAsan(
// "debian-bullseye-full-mmap-asan",
// DOCKER_IMAGES.bullseye,
// CMAKE_FLAGS_BUILD_ALL +
// CMAKE_FLAGS_DEBUG +
// CMAKE_FLAGS_MMAP
// )
// Build Elektra with xdg resolver to see if we are compliant
def xdgResolver = 'resolver_mf_xp_x'
tasks << buildAndTest(
"debian-bullseye-full-xdg",
DOCKER_IMAGES.bullseye,
[
'PLUGINS': "${xdgResolver};dump;sync;base64;spec;error;timeofday;profile;mathcheck;tracer;hosts;network;glob;backend;modules;version;missing",
'KDB_DEFAULT_RESOLVER': xdgResolver
],
[TEST.ALL, TEST.MEM]
)
// Build Elektra without tests
tasks << buildAndTest(
"debian-bullseye-full-build-testing-off",
DOCKER_IMAGES.bullseye,
CMAKE_FLAGS_BUILD_ALL +
CMAKE_FLAGS_BUILD_TESTING_OFF
,
[]
)
// Build Elektra without optimizations
tasks << buildAndTest(
"debian-bullseye-full-optimizations-off",
DOCKER_IMAGES.bullseye,
CMAKE_FLAGS_BUILD_ALL +
CMAKE_FLAGS_OPTIMIZATIONS_OFF +
CMAKE_FLAGS_DEBUG +
CMAKE_FLAGS_LOGGER
,
[TEST.ALL, TEST.MEM]
)
// Run memory analysis of the crypto plugins in separate environment as theses tests are quite unstable
tasks << buildAndTest(
"debian-buster-cryptoplugins",
DOCKER_IMAGES.buster,
CMAKE_FLAGS_BUILD_ALL+
CMAKE_FLAGS_DEBUG + [
'PLUGINS': 'dump;resolver_fm_hpu_b;list;spec;sync;crypto;fcrypt;gpgme;base64',
'TOOLS': 'kdb;gen-gpg-testkey',
'BINDINGS': '',
],
[TEST.CRYPTOS]
)
tasks << buildAndTest(
"debian-bullseye-cryptoplugins",
DOCKER_IMAGES.bullseye,
CMAKE_FLAGS_BUILD_ALL+
CMAKE_FLAGS_DEBUG + [
'PLUGINS': 'dump;resolver_fm_hpu_b;list;spec;sync;crypto;fcrypt;gpgme;base64',
'TOOLS': 'kdb;gen-gpg-testkey',
'BINDINGS': '',
],
[TEST.CRYPTOS]
)
// We need the webui_base image to build webui images later
tasks << dockerUtils.buildImageStage(DOCKER_IMAGES.webui_base)
return tasks
}
/* Stage for analysing open Tasks and running sloccount */
def buildTodo() {
def stageName = "todo"
def openTaskPatterns = '''\
**/*.c, **/*.h, **/*.hpp, **/*.cpp,\
**/CMakeLists.txt, **/Dockerfile*, Jenkinsfile*
'''
return [(stageName): {
stage(stageName) {
withDockerEnv(DOCKER_IMAGES.bullseye_doc) {
sh "sloccount --duplicates --wide --details ${WORKSPACE} > sloccount.sc"
step([$class: 'SloccountPublisher', ignoreBuildFailure: true])
recordIssues(tools: [taskScanner(ignoreCase: true, includePattern: openTaskPatterns, lowTags: 'TODO,FIXME')])
utils.archive(["sloccount.sc"])
deleteDir()
}
}
}]
}
/* Stage checking if release notes have been updated (only on PRs, as it doesn't make sense on master) */
def buildCheckReleaseNotes() {
def stageName = "check-release-notes"
return [(stageName): {
maybeStage(stageName, !isMaster()) {
withDockerEnv(DOCKER_IMAGES.bullseye, [DockerOpts.MOUNT_MIRROR]) {
sh "scripts/build/run_check_release_notes"
deleteDir()
}
}
}]
}
/* Stage checking for correct file names in the repository */
def buildCheckFileNames() {
def stageName = "check-file-names"
return [(stageName): {
stage(stageName) {
withDockerEnv(DOCKER_IMAGES.bullseye, [DockerOpts.MOUNT_MIRROR]) {
sh "scripts/dev/filename-checker"
deleteDir()
}
}
}]
}
/* Stage checking if for reuse compliancy */
def buildCheckReuseCompliant() {
def stageName = "check-reuse-compliant"
return [(stageName): {
stage(stageName) {
withDockerEnv(DOCKER_IMAGES.bullseye, [DockerOpts.MOUNT_MIRROR]) {
sh "reuse lint"
deleteDir()
}
}
}]
}
/* Stage running Icheck to see if the API has been modified */
def buildIcheck() {
def stageName = "icheck"
return [(stageName): {
stage(stageName) {
withDockerEnv(DOCKER_IMAGES.bullseye, [DockerOpts.MOUNT_MIRROR]) {
sh "scripts/build/run_icheck"
deleteDir()
}
}
}]
}
def buildFormatChecks() {
def stageName = "formatting-check"
return [(stageName): {
stage(stageName) {
withDockerEnv(DOCKER_IMAGES.sid, [DockerOpts.MOUNT_MIRROR]) {
dir('build') {
deleteDir()
utils.cmake(env.WORKSPACE, [:])
ctest("Test -R testscr_check_formatting")
}
}
}
}]
}
/* Stage building and uploading the documentation */
def buildDoc() {
def stageName = "doc"
cmakeFlags = [
'BUILD_PDF': 'ON',
'BUILD_FULL': 'OFF',
'BUILD_SHARED': 'OFF',
'BUILD_STATIC': 'OFF',
'BUILD_TESTING': 'OFF'
]
return [(stageName): {
stage(stageName) {
withDockerEnv(DOCKER_IMAGES.bullseye_doc) {
dir('build') {
deleteDir()
utils.cmake(env.WORKSPACE, cmakeFlags)
sh "make html latex man pdf"
}
def apib = "./doc/api_blueprints/snippet-sharing.apib"
def apiDocDir = "./build/API_DOC/restapi"
sh "mkdir -p ${apiDocDir}/${VERSION}"
sh "cp ${apib} ${apiDocDir}/${VERSION}/"
apiary(apib, "${apiDocDir}/${VERSION}/snippet-sharing.html")
dir(apiDocDir) {
sh "ln -s ${VERSION} current"
}
recordIssues(tools: [doxygen(pattern: 'build/doc/doxygen.log')])
def uploadDir = "api/${env.BRANCH_NAME}"
if (!isMaster()) {
uploadDir = "api/pr/${env.BRANCH_NAME}"
}
sshPublisher(
publishers: [
sshPublisherDesc(
verbose: true,
configName: 'doc.libelektra.org',
transfers: [
sshTransfer(
sourceFiles: 'build/doc/latex/*',
removePrefix: 'build/doc/',
remoteDirectory: "${uploadDir}"
),
sshTransfer(
sourceFiles: 'build/doc/html/*',
removePrefix: 'build/doc/',
remoteDirectory: "${uploadDir}"
),
sshTransfer(
sourceFiles: 'build/doc/man/man3elektra/*',
removePrefix: 'build/doc/man/man3elektra/',
remoteDirectory: "${uploadDir}/man"
)
]
)
]
)
deleteDir()
}
}
}]
}
/* Helper to generate an asan enabled test */
def buildAndTestAsan(testName, image, extraCmakeFlags = [:]) {
def cmakeFlags = CMAKE_FLAGS_BASE +
CMAKE_FLAGS_ASAN +
extraCmakeFlags
def dockerOpts = [DockerOpts.MOUNT_MIRROR, DockerOpts.PTRACE]
return [(testName): {
stage(testName) {
withDockerEnv(image, dockerOpts) {
dir('build') {
deleteDir()
utils.cmake(env.WORKSPACE, cmakeFlags)
sh "make"
def llvm_symbolizer = sh(returnStdout: true,
script: 'which llvm-symbolizer').trim()
withEnv(["ASAN_OPTIONS='symbolize=1'",
"ASAN_SYMBOLIZER_PATH=${llvm_symbolizer}"]){
ctest()
}
}
}
}
}]
}
/* Helper to generate mingw x86_64 test */
def buildAndTestMingwW64_x86_64() {
def testName = "debian-bullseye-mingw-w64-x86_64"
return [(testName): {
stage(testName) {
withDockerEnv(DOCKER_IMAGES.bullseye) {
dir('build') {
deleteDir()
sh '../scripts/dev/configure-mingw-w64-x86_64 ..'
sh 'make'
def destdir='elektra'
withEnv(["DESTDIR=${destdir}"]){
sh 'make install'
}
sh "zip -r elektra.zip ${destdir}"
utils.archive(['elektra.zip'])
}
}
}
}]
}
/* Helper to generate mingw i686 test */
def buildAndTestMingwW64_i686() {
def testName = "debian-bullseye-mingw-w64-i686"
return [(testName): {
stage(testName) {
withDockerEnv(DOCKER_IMAGES.bullseye) {