-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
Jenkinsfile
1117 lines (1037 loc) · 47.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
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
@Library('StanUtils')
import org.stan.Utils
utils = new org.stan.Utils()
def skipExpressionTests = false
def skipRemainingStages = false
def skipCompileTests = false
def skipRebuildingBinaries = false
def skipCompileTestsAtO1 = false
/* Functions that runs a sh command and returns the stdout */
def runShell(String command){
def output = sh (returnStdout: true, script: "${command}").trim()
return "${output}"
}
def tagName() {
if (env.TAG_NAME) {
env.TAG_NAME
} else if (env.BRANCH_NAME == 'master') {
'nightly'
} else {
'unknown-tag'
}
}
def runPerformanceTests(String testsPath, String stancFlags = ""){
unstash 'ubuntu-exe'
sh """
git clone --recursive --depth 50 https://github.com/stan-dev/performance-tests-cmdstan
"""
writeFile(file:"performance-tests-cmdstan/cmdstan/make/local", text:"CXX=${CXX}")
utils.checkout_pr("cmdstan", "performance-tests-cmdstan/cmdstan", params.cmdstan_pr)
utils.checkout_pr("stan", "performance-tests-cmdstan/cmdstan/stan", params.stan_pr)
utils.checkout_pr("math", "performance-tests-cmdstan/cmdstan/stan/lib/stan_math", params.math_pr)
sh """
cd performance-tests-cmdstan
mkdir cmdstan/bin
cp ../bin/stanc cmdstan/bin/linux-stanc
cd cmdstan; make clean-all;
"""
if (stancFlags?.trim()) {
sh "cd performance-tests-cmdstan/cmdstan && echo 'STANCFLAGS= $stancFlags' >> make/local"
}
sh """
cd performance-tests-cmdstan/cmdstan
echo 'O=0' >> make/local
echo 'CXXFLAGS+=-Wall' >> make/local
make -j${env.PARALLEL} build
"""
if (params.run_slow_perf_tests) {
sh """
cd performance-tests-cmdstan
./runPerformanceTests.py -j${env.PARALLEL} --runs=0 --no-ignore-models ${testsPath}
"""
} else {
sh """
cd performance-tests-cmdstan
./runPerformanceTests.py -j${env.PARALLEL} --runs=0 ${testsPath}
"""
}
}
def cleanCheckout() {
retry(3) {
checkout([
$class: 'GitSCM',
branches: scm.branches,
extensions: [[$class: 'CloneOption', noTags: false]],
userRemoteConfigs: scm.userRemoteConfigs,
])
}
sh 'git clean -xffd'
}
pipeline {
agent none
parameters {
booleanParam(name:"skip_end_to_end", defaultValue: false, description:"Skip end-to-end tests ")
booleanParam(name:"skip_compile_O1", defaultValue: false, description:"Skip compile tests that run with STANCFLAGS = --O1")
booleanParam(name:"skip_compile", defaultValue: false, description:"Skip compile tests")
booleanParam(name:"skip_math_func_expr", defaultValue: false, description:"Skip math functions expressions test")
booleanParam(name:"skip_ocaml_tests", defaultValue: false, description:"Skip ocaml tests")
string(defaultValue: 'develop', name: 'cmdstan_pr',
description: "CmdStan PR to test against. Will check out this PR in the downstream Stan repo.")
string(defaultValue: 'develop', name: 'stan_pr',
description: "Stan PR to test against. Will check out this PR in the downstream Stan repo.")
string(defaultValue: 'develop', name: 'math_pr',
description: "Math PR to test against. Will check out this PR in the downstream Math repo.")
string(defaultValue: '', name: 'stanc_flags',
description: "Pass STANCFLAGS to make/local, default none")
booleanParam(name:"run_slow_perf_tests", defaultValue: false, description:"Run additional 'slow' performance tests")
string(defaultValue: '', name: 'build_multiarch_docker_tag', description: "Docker tag for the multiarch image")
}
options {
parallelsAlwaysFailFast()
buildDiscarder(logRotator(numToKeepStr: '20', daysToKeepStr: '30'))
disableConcurrentBuilds(abortPrevious: true)
}
environment {
CXX = 'clang++-6.0'
PARALLEL = 4
GIT_AUTHOR_NAME = 'Stan Jenkins'
GIT_AUTHOR_EMAIL = '[email protected]'
GIT_COMMITTER_NAME = 'Stan Jenkins'
GIT_COMMITTER_EMAIL = '[email protected]'
MULTIARCH_DOCKER_TAG = 'multiarch-ocaml-4.14-v2'
}
stages {
stage('Verify changes') {
agent {
dockerfile {
filename 'scripts/docker/debian/Dockerfile'
dir '.'
label 'linux'
args '--entrypoint=\'\''
additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)'
}
}
steps {
script {
cleanCheckout()
stash 'Stanc3Setup'
def stanMathSigs = ['test/integration/signatures/stan_math_signatures.t'].join(" ")
skipExpressionTests = utils.verifyChanges(stanMathSigs, "master")
def runTestPaths = ['src', 'test/integration/good', 'test/stancjs'].join(" ")
skipRemainingStages = utils.verifyChanges(runTestPaths, "master")
def compileTests = ['test/integration/good'].join(" ")
skipCompileTests = utils.verifyChanges(compileTests, "master")
def compileTestsAtO1 = ['test/integration/good/compiler-optimizations'].join(" ")
skipCompileTestsAtO1 = utils.verifyChanges(compileTestsAtO1, "master")
def sourceCodePaths = ['src', 'Jenkinsfile'].join(" ")
skipRebuildingBinaries = utils.verifyChanges(sourceCodePaths, "master")
}
}
post { always { runShell("rm -rf ./*") }}
}
stage("Build") {
agent {
dockerfile {
filename 'scripts/docker/debian/Dockerfile'
dir '.'
label 'linux'
args '--entrypoint=\'\''
additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)'
}
}
steps {
unstash "Stanc3Setup"
runShell("""
eval \$(opam env)
dune build @install
""")
sh "mkdir -p bin && mv _build/default/src/stanc/stanc.exe bin/stanc"
stash name:'ubuntu-exe', includes:'bin/stanc'
}
post { always { runShell("rm -rf ./*") }}
}
stage("Code formatting") {
when {
beforeAgent true
expression {
!skipRemainingStages
}
}
agent {
dockerfile {
filename 'scripts/docker/debian/Dockerfile'
dir '.'
label 'linux'
args '--entrypoint=\'\''
additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)'
}
}
steps {
unstash "Stanc3Setup"
sh """
eval \$(opam env)
make format ||
(
set +x &&
echo "The source code was not formatted. Please run 'make format; dune promote' and push the changes." &&
echo "Please consider installing the pre-commit git hook for formatting with the above command." &&
echo "Our hook can be installed with bash ./scripts/hooks/install_hooks.sh" &&
exit 1;
)
"""
}
post { always { runShell("rm -rf ./*") }}
}
stage("OCaml tests") {
when {
beforeAgent true
allOf {
expression {
!skipRemainingStages
}
expression {
!params.skip_ocaml_tests
}
}
}
parallel {
stage("Dune tests") {
agent {
dockerfile {
filename 'scripts/docker/debian/Dockerfile'
dir '.'
label 'linux'
args '--entrypoint=\'\''
additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)'
}
}
steps {
dir("${env.WORKSPACE}/dune-tests"){
unstash "Stanc3Setup"
runShell("""
eval \$(opam env)
BISECT_FILE=\$(pwd)/bisect dune runtest --instrument-with bisect_ppx --force --root=.
""")
sh """
eval \$(opam env)
bisect-ppx-report summary --expect src/ --do-not-expect src/stancjs/
bisect-ppx-report coveralls coverage.json --service-name jenkins --service-job-id $BUILD_ID --expect src/ --do-not-expect src/stancjs/
"""
withCredentials([usernamePassword(credentialsId: 'stan-stanc3-codecov-token', usernameVariable: 'DUMMY_USERNAME', passwordVariable: 'CODECOV_TOKEN')]) {
sh """
curl -Os https://uploader.codecov.io/v0.3.2/linux/codecov
chmod +x codecov
./codecov -v -C \$(git rev-parse HEAD)
"""
}
}
}
post { always { runShell("rm -rf ${env.WORKSPACE}/dune-tests/*") }}
}
stage("stancjs tests") {
agent {
dockerfile {
filename 'scripts/docker/debian/Dockerfile'
dir '.'
label 'linux'
args '--entrypoint=\'\''
additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)'
}
}
steps {
dir("${env.WORKSPACE}/stancjs-tests"){
unstash "Stanc3Setup"
runShell("""
eval \$(opam env)
dune build @runjstest --root=.
""")
}
}
post { always { runShell("rm -rf ${env.WORKSPACE}/stancjs-tests/*") }}
}
}
}
stage("CmdStan & Math tests") {
parallel {
stage("Compile tests - good") {
when {
beforeAgent true
allOf {
expression {
!skipCompileTests
}
expression {
!params.skip_compile
}
}
}
agent {
docker {
image 'stanorg/ci:gpu'
label 'linux'
}
}
steps {
dir("${env.WORKSPACE}/compile-tests-good"){
unstash "Stanc3Setup"
script {
runPerformanceTests("../test/integration/good", params.stanc_flags)
}
xunit([GoogleTest(
deleteOutputFiles: false,
failIfNotNew: true,
pattern: 'performance-tests-cmdstan/performance.xml',
skipNoTestFiles: false,
stopProcessingIfError: false)
])
}
}
post { always { runShell("rm -rf ${env.WORKSPACE}/compile-tests-good/*") }}
}
stage("Compile tests - example-models") {
when {
beforeAgent true
allOf {
expression {
!skipCompileTests
}
expression {
!params.skip_compile
}
}
}
agent {
docker {
image 'stanorg/ci:gpu'
label 'linux'
}
}
steps {
dir("${env.WORKSPACE}/compile-tests-example"){
script {
unstash "Stanc3Setup"
runPerformanceTests("example-models", params.stanc_flags)
}
xunit([GoogleTest(
deleteOutputFiles: false,
failIfNotNew: true,
pattern: 'performance-tests-cmdstan/performance.xml',
skipNoTestFiles: false,
stopProcessingIfError: false)
])
}
}
post { always { runShell("rm -rf ${env.WORKSPACE}/compile-tests-example/*") }}
}
stage("Compile tests - good at O=1") {
when {
beforeAgent true
allOf {
expression {
!skipCompileTestsAtO1
}
expression {
!params.skip_compile_O1
}
}
}
agent {
docker {
image 'stanorg/ci:gpu'
label 'linux'
}
}
steps {
dir("${env.WORKSPACE}/compile-good-O1"){
unstash "Stanc3Setup"
script {
runPerformanceTests("../test/integration/good", "--O1")
}
xunit([GoogleTest(
deleteOutputFiles: false,
failIfNotNew: true,
pattern: 'performance-tests-cmdstan/performance.xml',
skipNoTestFiles: false,
stopProcessingIfError: false)
])
}
}
post { always { runShell("rm -rf ${env.WORKSPACE}/compile-good-O1/*") }}
}
stage("Compile tests - example-models at O=1") {
when {
beforeAgent true
allOf {
expression {
!skipCompileTestsAtO1
}
expression {
!params.skip_compile_O1
}
}
}
agent {
docker {
image 'stanorg/ci:gpu'
label 'linux'
}
}
steps {
dir("${env.WORKSPACE}/compile-example-O1"){
script {
unstash "Stanc3Setup"
runPerformanceTests("example-models", "--O1")
}
xunit([GoogleTest(
deleteOutputFiles: false,
failIfNotNew: true,
pattern: 'performance-tests-cmdstan/performance.xml',
skipNoTestFiles: false,
stopProcessingIfError: false)
])
}
}
post { always { runShell("rm -rf ${env.WORKSPACE}/compile-example-O1/*") }}
}
stage("Model end-to-end tests") {
when {
beforeAgent true
allOf {
expression {
!skipCompileTests
}
expression {
!params.skip_end_to_end
}
}
}
agent {
docker {
image 'stanorg/ci:gpu'
label 'linux'
}
}
steps {
dir("${env.WORKSPACE}/compile-end-to-end"){
script {
unstash "Stanc3Setup"
unstash 'ubuntu-exe'
sh """
git clone --recursive --depth 50 https://github.com/stan-dev/performance-tests-cmdstan
"""
utils.checkout_pr("cmdstan", "performance-tests-cmdstan/cmdstan", params.cmdstan_pr)
utils.checkout_pr("stan", "performance-tests-cmdstan/cmdstan/stan", params.stan_pr)
utils.checkout_pr("math", "performance-tests-cmdstan/cmdstan/stan/lib/stan_math", params.math_pr)
sh """
cd performance-tests-cmdstan
git show HEAD --stat
echo "example-models/regression_tests/mother.stan" > all.tests
cat known_good_perf_all.tests >> all.tests
echo "" >> all.tests
cat shotgun_perf_all.tests >> all.tests
cat all.tests
echo "CXXFLAGS+=-march=core2" > cmdstan/make/local
echo "PRECOMPILED_HEADERS=false" >> cmdstan/make/local
cd cmdstan; make clean-all; git show HEAD --stat; cd ..
CXX="${CXX}" ./compare-compilers.sh "--tests-file all.tests --num-samples=10 -j${env.PARALLEL}" "\$(readlink -f ../bin/stanc)"
"""
}
xunit([GoogleTest(
deleteOutputFiles: false,
failIfNotNew: true,
pattern: 'performance-tests-cmdstan/performance.xml',
skipNoTestFiles: false,
stopProcessingIfError: false)
])
archiveArtifacts 'performance-tests-cmdstan/performance.xml'
}
}
post { always { runShell("rm -rf ${env.WORKSPACE}/compile-end-to-end/*") }}
}
stage("Model end-to-end tests at O=1") {
when {
beforeAgent true
allOf {
expression {
!params.skip_end_to_end
}
expression {
!skipCompileTestsAtO1
}
}
}
agent {
docker {
image 'stanorg/ci:gpu'
label 'linux'
}
}
steps {
dir("${env.WORKSPACE}/compile-end-to-end-O=1"){
script {
unstash "Stanc3Setup"
unstash 'ubuntu-exe'
sh """
git clone --recursive --depth 50 https://github.com/stan-dev/performance-tests-cmdstan
"""
utils.checkout_pr("cmdstan", "performance-tests-cmdstan/cmdstan", params.cmdstan_pr)
utils.checkout_pr("stan", "performance-tests-cmdstan/cmdstan/stan", params.stan_pr)
utils.checkout_pr("math", "performance-tests-cmdstan/cmdstan/stan/lib/stan_math", params.math_pr)
sh """
cd performance-tests-cmdstan
git show HEAD --stat
echo "example-models/regression_tests/mother.stan" > all.tests
cat optimizer.tests >> all.tests
echo "" >> all.tests
cat known_good_perf_all.tests >> all.tests
echo "" >> all.tests
cat shotgun_perf_all.tests >> all.tests
cat all.tests
echo "CXXFLAGS+=-march=core2" > cmdstan/make/local
echo "PRECOMPILED_HEADERS=false" >> cmdstan/make/local
cd cmdstan; make clean-all; git show HEAD --stat; cd ..
CXX="${CXX}" ./compare-optimizer.sh "--tests-file all.tests --num-samples=10 -j${env.PARALLEL}" "--O1" "\$(readlink -f ../bin/stanc)"
"""
}
xunit([GoogleTest(
deleteOutputFiles: false,
failIfNotNew: true,
pattern: 'performance-tests-cmdstan/performance.xml',
skipNoTestFiles: false,
stopProcessingIfError: false)
])
archiveArtifacts 'performance-tests-cmdstan/performance.xml'
}
}
post { always { runShell("rm -rf ${env.WORKSPACE}/compile-end-to-end-O=1/*") }}
}
stage('Math functions expressions test') {
when {
beforeAgent true
allOf {
expression {
!skipRemainingStages
}
expression {
!skipExpressionTests
}
expression {
!params.skip_math_func_expr
}
}
}
agent {
docker {
image 'stanorg/ci:gpu'
label 'linux'
}
}
steps {
dir("${env.WORKSPACE}/compile-expressions"){
unstash "Stanc3Setup"
unstash 'ubuntu-exe'
script {
sh """
git clone --recursive https://github.com/stan-dev/math.git
"""
utils.checkout_pr("math", "math", params.math_pr)
sh """
cp bin/stanc math/test/expressions/stanc
"""
dir("math") {
sh """
echo O=0 >> make/local
echo "CXX=${env.CXX} -Werror " >> make/local
"""
withEnv(['PATH+TBB=./lib/tbb']) {
try { sh "./runTests.py -j${env.PARALLEL} test/expressions" }
finally { junit 'test/**/*.xml' }
}
}
}
}
}
post { always { runShell("rm -rf ${env.WORKSPACE}/compile-expressions/*") }}
}
}
}
stage('Build and push multiarch docker image') {
when {
beforeAgent true
expression {
params.build_multiarch_docker_tag != ""
}
}
agent {
dockerfile {
filename 'scripts/docker/builder/Dockerfile'
dir '.'
label 'linux && triqs'
args '--group-add=987 --group-add=980 --group-add=988 --entrypoint=\'\' -v /var/run/docker.sock:/var/run/docker.sock'
additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)'
}
}
environment { DOCKER_TOKEN = credentials('aada4f7b-baa9-49cf-ac97-5490620fce8a') }
steps {
script {
retry(3) { checkout scm }
sh '''
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker buildx create --name stanc3_builder
docker buildx use stanc3_builder
docker login --username stanorg --password "${DOCKER_TOKEN}"
cd scripts/docker/multiarch
docker buildx build -t stanorg/stanc3:$build_multiarch_docker_tag \
--platform linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/mips64le,linux/s390x \
--build-arg PUID=$(id -u) \
--build-arg PGID=$(id -g) \
--progress=plain --push .
'''
}
}
post {
always {
deleteDir()
}
}
}
stage('Build binaries') {
parallel {
stage("Build & test Mac OS X binary") {
when {
beforeAgent true
expression { !skipRebuildingBinaries }
}
agent { label 'osx && !m1' }
steps {
dir("${env.WORKSPACE}/osx"){
cleanCheckout()
withEnv(['SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX10.11.sdk', 'MACOSX_DEPLOYMENT_TARGET=10.11']) {
runShell("""
export PATH=/Users/jenkins/brew/bin:\$PATH
eval \$(opam env --switch=stanc-4.14.1 --set-switch)
dune subst
opam update || true
bash -x scripts/install_build_deps.sh
dune build @install --root=.
""")
}
sh "mkdir -p bin && mv `find _build -name stanc.exe` bin/mac-stanc"
stash name:'mac-exe', includes:'bin/*'
}
}
post { always { runShell("rm -rf ${env.WORKSPACE}/osx/*") }}
}
stage("Build stanc.js") {
when {
beforeAgent true
expression {
!skipRebuildingBinaries
}
}
agent {
dockerfile {
filename 'scripts/docker/debian/Dockerfile'
dir '.'
label 'linux && triqs'
args '--group-add=987 --group-add=980 --group-add=988 --entrypoint=\'\''
additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)'
}
}
steps {
dir("${env.WORKSPACE}/stancjs"){
cleanCheckout()
runShell("""
eval \$(opam env)
dune subst
dune build --root=. --profile release src/stancjs
""")
sh "mkdir -p bin && mv `find _build -name stancjs.bc.js` bin/stanc.js"
sh "mv `find _build -name index.html` bin/load_stanc.html"
runShell("""
eval \$(opam env)
dune build --force --profile=dev --root=. src/stancjs
""")
sh "mv `find _build -name stancjs.bc.js` bin/stanc-pretty.js"
stash name:'js-exe', includes:'bin/*'
}
}
post {always { runShell("rm -rf ${env.WORKSPACE}/stancjs/*")}}
}
stage("Build & test a static Linux binary") {
when {
beforeAgent true
expression {
!skipRebuildingBinaries
}
}
agent {
dockerfile {
filename 'scripts/docker/static/Dockerfile'
dir '.'
label 'linux && triqs'
args '--group-add=987 --group-add=980 --group-add=988 --entrypoint=\'\''
additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)'
}
}
steps {
dir("${env.WORKSPACE}/linux"){
cleanCheckout()
runShell("""
eval \$(opam env)
dune subst
dune build @install --profile static --root=.
""")
sh "mkdir -p bin && mv `find _build -name stanc.exe` bin/linux-stanc"
stash name:'linux-exe', includes:'bin/*'
}
}
post {always { runShell("rm -rf ${env.WORKSPACE}/linux/*")}}
}
stage("Build & test a static Linux mips64el binary") {
when {
beforeAgent true
allOf {
expression { !skipRebuildingBinaries }
anyOf { buildingTag(); branch 'master' }
}
}
agent {
dockerfile {
filename 'scripts/docker/static/Dockerfile'
dir '.'
label 'linux && triqs'
args '--group-add=987 --group-add=980 --group-add=988 --entrypoint=\'\' -v /var/run/docker.sock:/var/run/docker.sock'
additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)'
}
}
steps {
dir("${env.WORKSPACE}/linux-mips64el"){
cleanCheckout()
sh """
eval \$(opam env)
bash -x scripts/build_multiarch_stanc3.sh mips64el ${MULTIARCH_DOCKER_TAG}
"""
sh "mkdir -p bin && mv `find _build -name stanc.exe` bin/linux-mips64el-stanc"
stash name:'linux-mips64el-exe', includes:'bin/*'
}
}
post {always { runShell("rm -rf ${env.WORKSPACE}/linux-mips64el/*")}}
}
stage("Build & test a static Linux ppc64el binary") {
when {
beforeAgent true
allOf {
expression { !skipRebuildingBinaries }
anyOf { buildingTag(); branch 'master' }
}
}
agent {
dockerfile {
filename 'scripts/docker/static/Dockerfile'
dir '.'
label 'linux && triqs'
args '--group-add=987 --group-add=980 --group-add=988 --entrypoint=\'\' -v /var/run/docker.sock:/var/run/docker.sock'
additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)'
}
}
steps {
dir("${env.WORKSPACE}/linux-ppc64el"){
cleanCheckout()
sh """
eval \$(opam env)
bash -x scripts/build_multiarch_stanc3.sh ppc64el ${MULTIARCH_DOCKER_TAG}
"""
sh "mkdir -p bin && mv `find _build -name stanc.exe` bin/linux-ppc64el-stanc"
stash name:'linux-ppc64el-exe', includes:'bin/*'
}
}
post {always { runShell("rm -rf ${env.WORKSPACE}/linux-ppc64el/*")}}
}
stage("Build & test a static Linux s390x binary") {
when {
beforeAgent true
allOf {
expression { !skipRebuildingBinaries }
anyOf { buildingTag(); branch 'master' }
}
}
agent {
dockerfile {
filename 'scripts/docker/static/Dockerfile'
dir '.'
label 'linux && triqs'
args '--group-add=987 --group-add=980 --group-add=988 --entrypoint=\'\' -v /var/run/docker.sock:/var/run/docker.sock'
additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)'
}
}
steps {
dir("${env.WORKSPACE}/linux-s390x"){
cleanCheckout()
sh """
eval \$(opam env)
bash -x scripts/build_multiarch_stanc3.sh s390x ${MULTIARCH_DOCKER_TAG}
"""
sh "mkdir -p bin && mv `find _build -name stanc.exe` bin/linux-s390x-stanc"
stash name:'linux-s390x-exe', includes:'bin/*'
}
}
post {always { runShell("rm -rf ${env.WORKSPACE}/linux-s390x/*")}}
}
stage("Build & test a static Linux arm64 binary") {
when {
beforeAgent true
allOf {
expression { !skipRebuildingBinaries }
anyOf { buildingTag(); branch 'master' }
}
}
agent {
dockerfile {
filename 'scripts/docker/static/Dockerfile'
dir '.'
label 'linux && triqs'
args '--group-add=987 --group-add=980 --group-add=988 --entrypoint=\'\' -v /var/run/docker.sock:/var/run/docker.sock'
additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)'
}
}
steps {
dir("${env.WORKSPACE}/linux-arm64"){
cleanCheckout()
sh """
eval \$(opam env)
bash -x scripts/build_multiarch_stanc3.sh arm64 ${MULTIARCH_DOCKER_TAG}
"""
sh "mkdir -p bin && mv `find _build -name stanc.exe` bin/linux-arm64-stanc"
stash name:'linux-arm64-exe', includes:'bin/*'
}
}
post {always { runShell("rm -rf ${env.WORKSPACE}/linux-arm64/*")}}
}
stage("Build & test a static Linux armhf binary") {
when {
beforeAgent true
allOf {
expression { !skipRebuildingBinaries }
anyOf { buildingTag(); branch 'master' }
}
}
agent {
dockerfile {
filename 'scripts/docker/static/Dockerfile'
dir '.'
label 'linux && triqs'
args '--group-add=987 --group-add=980 --group-add=988 --entrypoint=\'\' -v /var/run/docker.sock:/var/run/docker.sock'
additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)'
}
}
steps {
dir("${env.WORKSPACE}/linux-armhf"){
cleanCheckout()
sh """
eval \$(opam env)
bash -x scripts/build_multiarch_stanc3.sh armhf ${MULTIARCH_DOCKER_TAG}
"""
sh "mkdir -p bin && mv `find _build -name stanc.exe` bin/linux-armhf-stanc"
stash name:'linux-armhf-exe', includes:'bin/*'
}
}
post {always { runShell("rm -rf ${env.WORKSPACE}/linux-armhf/*")}}
}
stage("Build & test a static Linux armel binary") {
when {
beforeAgent true
allOf {
expression { !skipRebuildingBinaries }
anyOf { buildingTag(); branch 'master' }
}
}
agent {
dockerfile {
filename 'scripts/docker/static/Dockerfile'
dir '.'
label 'linux && triqs'
args '--group-add=987 --group-add=980 --group-add=988 --entrypoint=\'\' -v /var/run/docker.sock:/var/run/docker.sock'
additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)'
}
}
steps {
dir("${env.WORKSPACE}/linux-armel"){
cleanCheckout()
sh """
eval \$(opam env)
bash -x scripts/build_multiarch_stanc3.sh armel ${MULTIARCH_DOCKER_TAG}
"""
sh "mkdir -p bin && mv `find _build -name stanc.exe` bin/linux-armel-stanc"
stash name:'linux-armel-exe', includes:'bin/*'
}
}
post {always { runShell("rm -rf ${env.WORKSPACE}/linux-armel/*")}}
}
// Cross compiling for windows on debian
stage("Build & test static Windows binary") {
when {
beforeAgent true
expression {
!skipRebuildingBinaries
}
}
agent {
dockerfile {
filename 'scripts/docker/debian-windows/Dockerfile'
dir '.'
label 'linux && triqs'
args '--group-add=987 --group-add=980 --group-add=988 --entrypoint=\'\''
additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)'
}
}
steps {
dir("${env.WORKSPACE}/windows"){
cleanCheckout()
runShell("""
eval \$(opam env)
dune subst
dune build -x windows --root=.
""")
sh "mkdir -p bin && mv _build/default.windows/src/stanc/stanc.exe bin/windows-stanc"
stash name:'windows-exe', includes:'bin/*'
}
}
post {always { runShell("rm -rf ${env.WORKSPACE}/windows/*")}}
}
}
}
stage('Check binary version'){
when {
beforeAgent true
expression { !skipRebuildingBinaries }
}
agent {
dockerfile {
filename 'scripts/docker/publish/Dockerfile'
dir '.'
label 'linux'
args '--group-add=987 --group-add=980 --group-add=988 --entrypoint=\'\''
additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)'
}
}
steps {
sh "rm -r bin/ || true"
dir("bin"){
unstash 'linux-exe'
sh "bin/linux-stanc --version"
}
}
}
stage("Release tag and publish binaries") {
when {
beforeAgent true
allOf {
expression { !skipRemainingStages }
expression { !skipRebuildingBinaries }