-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jenkinsfile-bleeding-edge-monthly
498 lines (472 loc) · 22.1 KB
/
Jenkinsfile-bleeding-edge-monthly
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
#!/usr/bin/env groovy
@Library('StanUtils')
import org.stan.Utils
utils = new org.stan.Utils()
def runTests(String testPath, boolean jumbo = false) {
try {
if (jumbo && !params.disableJumbo) {
sh "python3 runTests.py -j${env.PARALLEL} ${testPath} --jumbo --debug"
} else {
sh "python3 runTests.py -j${env.PARALLEL} ${testPath}"
}
}
finally { junit 'test/**/*.xml' }
}
def setupMakeLocal(String o = "3", String cc = "clang" , String cxx = "clang++" , String cFlags = "", String cppFlags = "", String cxxFlags = "", String ldFlags = "", String makeLocalPath = "make/local") {
sh """
echo O="${o}" >> ${makeLocalPath}
echo CC="${cc}" >> ${makeLocalPath}
echo CXX="${cxx}" >> ${makeLocalPath}
"""
if (cc == "clang") {
sh """
echo CFLAGS+="-stdlib=libc++ ${cFlags}" >> ${makeLocalPath}
echo CPPFLAGS+="-nostdinc++ -nodefaultlibs -I/usr/local/include/c++/v1 ${cppFlags}" >> ${makeLocalPath}
echo CXXFLAGS+="-nostdinc++ -nostdlib++ -I/usr/local/include/c++/v1 ${cxxFlags}" >> ${makeLocalPath}
echo LDFLAGS+="-L/usr/local/lib -Wl,-R/usr/local/lib -I/usr/local/include/c++/v1 -L/usr/local/lib -Wl,-rpath,/usr/local/lib -lc++ -lc++abi -lm -lc -lgcc_s -lgcc ${ldFlags}" >> ${makeLocalPath}
"""
}
sh "${cxx} --version"
}
pipeline {
agent none
options {
preserveStashes(buildCount: 7)
}
parameters {
booleanParam(defaultValue: false, name: 'buildDocker', description: 'Build docker image with latest gcc, clang')
string(defaultValue: 'develop', name: 'cmdstan_pr',
description: "CmdStan PR to test against. Will check out this PR in the downstream Stan repo. Example: PR-123")
string(defaultValue: 'develop', name: 'stan_pr',
description: "Stan PR to test against. Will check out this PR in the downstream Stan repo. Example: PR-123")
string(defaultValue: 'develop', name: 'math_pr',
description: "Math PR to test against. Will check out this PR in the downstream Math repo. Example: PR-123")
string(defaultValue: 'master', name: 'stanc3_pr',
description: "Stanc3 PR to test against. Will check out this PR in the downstream Math repo. Example: PR-123")
booleanParam(defaultValue: true, description: 'Run Full Unit Tests', name: 'run_full_unit_tests')
booleanParam(defaultValue: true, description: 'Run CmdStan & Math tests', name: 'run_cmdstan_math_tests')
string(name: 'custom_gcc_tag', description: "Example: 13.3.0 | See: https://api.github.com/repos/gcc-mirror/gcc/tags")
string(name: 'custom_llvm_tag', description: "Example: 19.1.0-rc4 | See: https://api.github.com/repos/llvm/llvm-project/tags")
booleanParam(defaultValue: true, name: 'build_gcc', description: "Build gcc part ?")
booleanParam(defaultValue: true, name: 'build_llvm', description: "build llvm part ?")
}
environment {
STAN_NUM_THREADS = 4
N_TESTS = 100
PARALLEL = 4
GCC = 'g++'
}
stages {
stage('Build and push docker image') {
when {
beforeAgent true
expression {
params.buildDocker
}
}
agent {
dockerfile {
filename '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 """
cd docker/bleeding-edge-compilers
docker build -t stanorg/ci:bleeding-edge-compilers --no-cache --build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g) --build-arg CUSTOM_GCC_TAG=\${custom_gcc_tag} --build-arg CUSTOM_LLVM_TAG=\${custom_llvm_tag} --build-arg BUILD_LLVM=\${build_gcc} --build-arg BUILD_LLVM=\${build_llvm} .
docker login --username stanorg --password "${DOCKER_TOKEN}"
docker push stanorg/ci:bleeding-edge-compilers
"""
}
}
post {
always {
deleteDir()
}
}
}
stage('Pull latest docker image') {
parallel {
stage('Pull on mesa') {
agent { label 'linux && v100 && mesa' }
steps {
sh "docker pull stanorg/ci:bleeding-edge-compilers"
}
}
stage('Pull on triqs') {
agent { label 'linux && v100 && triqs' }
steps {
sh "docker pull stanorg/ci:bleeding-edge-compilers"
}
}
}
}
stage('Prepare math') {
agent {
docker {
image 'alpine/git'
label 'linux'
args "--entrypoint=\'\'"
}
}
steps {
script {
sh """
rm -rf math
git clone https://github.com/stan-dev/math.git
cd math
if [[ "${params.math_pr}" == *"PR-"* ]]; then
PRID=\$(echo "${params.math_pr}" | tr "-" "\n" | tail -1)
git fetch origin pull/\$PRID/head:ci-branch
git checkout ci-branch
else
git checkout "${params.math_pr}"
fi
git clean -xffd
"""
stash 'MathSetup'
}
}
post {
always {
deleteDir()
}
}
}
stage('Prepare Performance-Tests-Cmdstan') {
agent {
docker {
image 'alpine/git'
label 'linux'
args "--entrypoint=\'\'"
}
}
steps {
deleteDir()
checkout([$class: 'GitSCM',
branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'SubmoduleOption',
disableSubmodules: false,
parentCredentials: false,
recursiveSubmodules: true,
reference: '',
trackingSubmodules: false]],
submoduleCfg: [],
userRemoteConfigs: [[url: "https://github.com/stan-dev/performance-tests-cmdstan.git",
credentialsId: 'a630aebc-6861-4e69-b497-fd7f496ec46b'
]]])
stash 'PerfSetup'
}
post {
always {
deleteDir()
}
}
}
stage('Prepare stanc3') {
agent {
docker {
image 'alpine/git'
label 'linux'
args "--entrypoint=\'\'"
}
}
steps {
script {
sh """
rm -rf stanc3
git clone https://github.com/stan-dev/stanc3.git
cd stanc3
git submodule update --init --recursive
if [[ "${params.stanc3_pr}" == *"PR-"* ]]; then
PRID=\$(echo "${params.stanc3_pr}" | tr "-" "\n" | tail -1)
git fetch origin pull/\$PRID/head:ci-branch
git checkout ci-branch
else
git checkout "${params.stanc3_pr}"
fi
git clean -xffd
"""
stash 'Stanc3Setup'
}
}
post {
always {
deleteDir()
}
}
}
stage("Get nightly Stanc3") {
agent {
docker {
image 'osexp2000/ubuntu-with-utils'
args "--entrypoint=\'\'"
label 'linux'
}
}
steps {
sh"""
wget -O stanc https://github.com/stan-dev/stanc3/releases/download/nightly/linux-stanc && mkdir bin && mv stanc bin/
chmod +x bin/stanc
"""
stash name:'ubuntu-exe', includes:'bin/stanc'
}
post { always { sh "rm -rf ./*" }}
}
stage('Full Unit Tests') {
when {
beforeAgent true
expression { params.run_full_unit_tests }
}
parallel {
stage('Rev/Fwd Unit Tests - CLANG') {
agent {
docker {
image 'stanorg/ci:bleeding-edge-compilers'
label 'linux && triqs'
args '--pull always --cap-add SYS_PTRACE'
}
}
steps {
unstash 'MathSetup'
dir('math') {
script {
setupMakeLocal("3", "clang", "clang++")
runTests("test/unit/math/rev")
runTests("test/unit/math/fwd")
}
}
}
post { always { retry(3) { deleteDir() } } }
}
stage('Mix Unit Tests - CLANG') {
agent {
docker {
image 'stanorg/ci:bleeding-edge-compilers'
label 'linux && triqs'
args '--pull always --cap-add SYS_PTRACE'
}
}
steps {
unstash 'MathSetup'
dir('math') {
script {
setupMakeLocal("3", "clang", "clang++")
runTests("test/unit/math/mix", true)
}
}
}
post { always { retry(3) { deleteDir() } } }
}
stage('Prim Unit Tests - CLANG') {
agent {
docker {
image 'stanorg/ci:bleeding-edge-compilers'
label 'linux && triqs'
args '--pull always --cap-add SYS_PTRACE'
}
}
steps {
unstash 'MathSetup'
dir('math') {
script {
setupMakeLocal("3", "clang", "clang++")
runTests("test/unit/*_test.cpp", false)
runTests("test/unit/math/*_test.cpp", false)
runTests("test/unit/math/prim", true)
runTests("test/unit/math/memory", false)
}
}
}
post { always { retry(3) { deleteDir() } } }
}
stage('Rev/Fwd Unit Tests - GCC') {
agent {
docker {
image 'stanorg/ci:bleeding-edge-compilers'
label 'linux && triqs'
args '--pull always --cap-add SYS_PTRACE'
}
}
steps {
unstash 'MathSetup'
dir('math') {
script {
setupMakeLocal("3", "gcc", "g++")
runTests("test/unit/math/rev")
runTests("test/unit/math/fwd")
}
}
}
post { always { retry(3) { deleteDir() } } }
}
stage('Mix Unit Tests - GCC') {
agent {
docker {
image 'stanorg/ci:bleeding-edge-compilers'
label 'linux && triqs'
args '--pull always --cap-add SYS_PTRACE'
}
}
steps {
unstash 'MathSetup'
dir('math') {
script {
setupMakeLocal("3", "gcc", "g++")
runTests("test/unit/math/mix", true)
}
}
}
post { always { retry(3) { deleteDir() } } }
}
stage('Prim Unit Tests - GCC') {
agent {
docker {
image 'stanorg/ci:bleeding-edge-compilers'
label 'linux && triqs'
args '--pull always --cap-add SYS_PTRACE'
}
}
steps {
unstash 'MathSetup'
dir('math') {
script {
setupMakeLocal("3", "gcc", "g++")
runTests("test/unit/*_test.cpp", false)
runTests("test/unit/math/*_test.cpp", false)
runTests("test/unit/math/prim", true)
runTests("test/unit/math/memory", false)
}
}
}
post { always { retry(3) { deleteDir() } } }
}
}
}
stage("CmdStan & Math tests") {
when {
beforeAgent true
expression { params.run_cmdstan_math_tests }
}
parallel {
stage("Model end-to-end - CLANG") {
agent {
docker {
image 'stanorg/ci:bleeding-edge-compilers'
label 'linux && triqs'
args '--pull always'
}
}
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)
setupMakeLocal("3","clang", "clang++","","","-march=core2", "", "performance-tests-cmdstan/cmdstan/make/local")
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
cd cmdstan; make clean-all; git show HEAD --stat; make -j4 build
rm bin/stanc
cp ../../bin/stanc bin/stanc
make print-compiler-flags
make -j4 examples/bernoulli/bernoulli; ./bin/stanc --version; cd ..
echo "STANCFLAGS += --O1" >> cmdstan/make/local
./runPerformanceTests.py -j${env.PARALLEL} --overwrite-golds --runs=0 --tests-file all.tests --num-samples=20
./runPerformanceTests.py -j${env.PARALLEL} --runs=0 ../stanc3/test/integration/good
"""
}
xunit([GoogleTest(
deleteOutputFiles: false,
failIfNotNew: true,
pattern: 'performance-tests-cmdstan/performance.xml',
skipNoTestFiles: false,
stopProcessingIfError: false)
])
archiveArtifacts 'performance-tests-cmdstan/performance.xml'
}
}
post { always { sh "rm -rf ${env.WORKSPACE}/compile-end-to-end-O=1/*" }}
}
stage("Model end-to-end - GCC") {
agent {
docker {
image 'stanorg/ci:bleeding-edge-compilers'
label 'linux && triqs'
args '--pull always'
}
}
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)
setupMakeLocal("3","gcc","g++","","","-march=core2", "", "performance-tests-cmdstan/cmdstan/make/local")
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
cd cmdstan; make clean-all; git show HEAD --stat; make -j4 build
rm bin/stanc
cp ../../bin/stanc bin/stanc
make print-compiler-flags
make -j4 examples/bernoulli/bernoulli; ./bin/stanc --version; cd ..
echo "STANCFLAGS += --O1" >> cmdstan/make/local
./runPerformanceTests.py -j${env.PARALLEL} --overwrite-golds --runs=0 --tests-file all.tests --num-samples=20
./runPerformanceTests.py -j${env.PARALLEL} --runs=0 ../stanc3/test/integration/good
"""
}
xunit([GoogleTest(
deleteOutputFiles: false,
failIfNotNew: true,
pattern: 'performance-tests-cmdstan/performance.xml',
skipNoTestFiles: false,
stopProcessingIfError: false)
])
archiveArtifacts 'performance-tests-cmdstan/performance.xml'
}
}
post { always { sh "rm -rf ${env.WORKSPACE}/compile-end-to-end-O=1/*" }}
}
}
}
}
//post {
// always {
// node("linux") {
// recordIssues enabledForFailure: false, tool: clang()
// }
// }
// success { script { utils.mailBuildResults("SUCCESSFUL") } }
// unstable { script { utils.mailBuildResults("UNSTABLE") } }
// failure { script { utils.mailBuildResults("FAILURE") } }
//}
}