-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathJenkinsfile-test-binaries
245 lines (235 loc) · 11.3 KB
/
Jenkinsfile-test-binaries
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
def qemuArchFlag(String arch) {
switch (arch) {
case 'armel': return '--platform=linux/arm/v6'
case 'armhf': return '--platform=linux/arm/v7'
case 'arm64': return '--platform=linux/arm64'
case 'ppc64el': return '--platform=linux/ppc64le'
case 's390x': return '--platform=linux/s390x'
default: return ''
}
}
def binaryName(String arch) {
if (arch == 'x86_64') {
return 'linux-stanc'
}
return "linux-${arch}-stanc"
}
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 {
string(defaultValue: 'master', name: 'git_branch',
description: "Please specify a git branch ( develop ), git hash ( aace72b6ccecbb750431c46f418879b325416c7d ), pull request ( PR-123 ), pull request from fork ( PR-123 )")
}
options {
parallelsAlwaysFailFast()
buildDiscarder(logRotator(numToKeepStr: '20', daysToKeepStr: '30'))
}
environment {
MACOS_SWITCH = 'stanc3-4.14'
}
stages {
stage('Build (Linux)') {
when {
beforeAgent true
allOf {
expression { !skipRebuildingBinaries }
anyOf { buildingTag(); branch 'master'; expression { params.build_multiarch } }
}
}
matrix {
axes {
axis {
name 'ARCHITECTURE'
values 'arm64', 'ppc64el', 's390x', 'armhf', 'armel', 'x86_64'
}
}
stages {
stage("Build static binary") {
agent {
dockerfile {
filename 'scripts/docker/static-builder/Dockerfile'
dir '.'
label 'linux && emulation'
args "${qemuArchFlag(ARCHITECTURE)} --group-add=987 --group-add=980 --group-add=988 --entrypoint='' -v /var/run/docker.sock:/var/run/docker.sock"
additionalBuildArgs "${qemuArchFlag(ARCHITECTURE)} --build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)"
}
}
steps {
dir("${env.WORKSPACE}/linux-${ARCHITECTURE}"){
cleanCheckout()
sh '''
eval $(opam env)
dune subst
dune build --profile static --root=.
'''
sh "mkdir -p bin && mv `find _build -name stanc.exe` bin/${binaryName(ARCHITECTURE)}"
archiveArtifacts 'bin/*'
}
}
post {always { sh "rm -rf ${env.WORKSPACE}/linux-${ARCHITECTURE}/*"}}
}
}
}
}
stage('Build (Other platforms)') {
parallel {
stage("Build static Linux x86_64 binary") {
agent {
dockerfile {
filename 'scripts/docker/static-builder/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()
sh '''
eval $(opam env)
dune subst
dune build --profile static --root=.
'''
sh "mkdir -p bin && mv `find _build -name stanc.exe` bin/linux-stanc"
archiveArtifacts 'bin/*'
}
}
post {always { sh "rm -rf ${env.WORKSPACE}/linux/*"}}
}
stage("Build MacOS binaries") {
agent none
stages {
stage("Build MacOS x86 binary") {
agent { label 'osx && intel' }
steps {
dir("${env.WORKSPACE}/osx-x86"){
cleanCheckout()
withEnv(['SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX10.11.sdk', 'MACOSX_DEPLOYMENT_TARGET=10.11']) {
sh '''
export PATH=/Users/jenkins/brew/bin:$PATH
bash -x scripts/install_ocaml.sh "$MACOS_SWITCH"
eval $(opam env --switch="$MACOS_SWITCH" --set-switch)
opam switch list
opam update -y || true
opam pin -y dune 3.6.0 --no-action
bash -x scripts/install_build_deps.sh
dune subst
dune build --root=. --profile release
'''
}
sh "mkdir -p bin && mv `find _build -name stanc.exe` bin/mac-x86-stanc"
archiveArtifacts 'bin/*'
}
}
post { always { sh "rm -rf ${env.WORKSPACE}/osx-x86/*" }}
}
stage("Build MacOS arm64 binary") {
agent { label 'osx && m1' }
steps {
dir("${env.WORKSPACE}/osx-arm64"){
cleanCheckout()
withEnv(['SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk', 'MACOSX_DEPLOYMENT_TARGET=11.0']) {
sh '''
export PATH=/Users/jenkins/brew/bin:$PATH
bash -x scripts/install_ocaml.sh "$MACOS_SWITCH"
eval $(opam env --switch="$MACOS_SWITCH" --set-switch)
opam switch list
opam update -y || true
bash -x scripts/install_build_deps.sh
dune subst
dune build --root=. --profile release
'''
}
sh "mkdir -p bin && mv `find _build -name stanc.exe` bin/mac-arm64-stanc"
archiveArtifacts 'bin/*'
}
}
post { always { sh "rm -rf ${env.WORKSPACE}/osx-arm64/*" }}
}
stage('Build MacOS fat binary') {
agent { label 'osx && m1' }
steps {
dir("${env.WORKSPACE}/osx-universal"){
unarchiveArtifacts 'bin/*'
unarchiveArtifacts 'bin/*'
withEnv(['SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk', 'MACOSX_DEPLOYMENT_TARGET=11.0']) {
sh "lipo -create bin/mac-x86-stanc bin/mac-arm64-stanc -output bin/mac-stanc"
}
sh "lipo -archs bin/mac-stanc"
archiveArtifacts 'bin/*'
}
}
post { always { sh "rm -rf ${env.WORKSPACE}/osx-universal/*" }}
}
}
}
stage("Build stanc.js") {
agent {
dockerfile {
filename 'scripts/docker/ci/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()
sh '''
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 '''
eval $(opam env)
dune build --force --profile=dev --root=. src/stancjs
'''
sh "mv `find _build -name stancjs.bc.js` bin/stanc-pretty.js"
archiveArtifacts 'bin/*'
}
}
post {always { sh "rm -rf ${env.WORKSPACE}/stancjs/*"}}
}
// Cross compiling for windows on debian
stage("Build Windows binary") {
agent {
dockerfile {
filename 'scripts/docker/ci/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 {
dir("${env.WORKSPACE}/windows"){
cleanCheckout()
sh '''
eval $(opam env)
dune subst
dune build -x windows --root=. --profile release
'''
sh "mkdir -p bin && mv _build/default.windows/src/stanc/stanc.exe bin/windows-stanc"
archiveArtifacts 'bin/*'
}
}
post {always { sh "rm -rf ${env.WORKSPACE}/windows/*"}}
}
}
}
}
}