forked from stan-dev/stanc3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile-test-binaries
197 lines (177 loc) · 6.94 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
@Library('StanUtils')
import org.stan.Utils
def utils = new org.stan.Utils()
/* 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 checkoutRepository(os_type) {
if(params.git_branch.contains("PR-")){
pr_number = params.git_branch.split("-")[1]
if(os_type == "sh"){
sh "git fetch origin pull/${pr_number}/head:pr/${pr_number}"
sh "git checkout pr/${pr_number}"
}
else if(os_type == "bat"){
bat "git fetch origin pull/${pr_number}/head:pr/${pr_number}"
bat "git checkout pr/${pr_number}"
}
}
else{
if(os_type == "sh"){
sh "git checkout master && git pull && git checkout ${params.git_branch}"
}
else if(os_type == "bat"){
bat "git checkout master && git pull && git checkout ${params.git_branch}"
}
}
}
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 )")
}
environment {
GITHUB_TOKEN = credentials('6e7c1e8f-ca2c-4b11-a70e-d934d3f6b681')
}
options {parallelsAlwaysFailFast()}
stages {
stage("Build") {
agent {
dockerfile {
filename 'docker/debian/Dockerfile'
args "-u root --entrypoint=\'\'"
}
}
steps {
script {
checkoutRepository("sh")
}
sh 'echo Hellow'
sh 'printenv'
runShell("""
eval \$(opam env)
dune build @install
""")
sh "mkdir -p bin && mv _build/default/src/stanc/stanc.exe bin/stanc"
archiveArtifacts 'bin/*'
}
post { always { runShell("rm -rf ./*") }}
}
stage("Build and test static release binaries") {
failFast true
parallel {
stage("Build & test Mac OS X binary") {
agent { label "osx && ocaml" }
steps {
script {
checkoutRepository("sh")
}
runShell("""
eval \$(opam env)
opam update || true
bash -x scripts/install_build_deps.sh
dune subst
dune build @install
""")
echo runShell("""
eval \$(opam env)
time dune runtest --verbose
""")
sh "mkdir -p bin && mv `find _build -name stanc.exe` bin/mac-stanc"
sh "mv _build/default/src/stan2tfp/stan2tfp.exe bin/mac-stan2tfp"
archiveArtifacts 'bin/*'
}
post { always { runShell("rm -rf ./*") }}
}
stage("Build stanc.js") {
agent {
dockerfile {
filename 'docker/debian/Dockerfile'
//Forces image to ignore entrypoint
args "-u root --entrypoint=\'\'"
}
}
steps {
script {
checkoutRepository("sh")
}
runShell("""
eval \$(opam env)
dune subst
dune build --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"
archiveArtifacts 'bin/*'
}
post {always { runShell("rm -rf ./*")}}
}
stage("Build & test a static Linux binary") {
agent {
dockerfile {
filename 'docker/static/Dockerfile'
//Forces image to ignore entrypoint
args "-u 1000 --entrypoint=\'\'"
}
}
steps {
script {
checkoutRepository("sh")
}
runShell("""
eval \$(opam env)
dune subst
dune build @install --profile static
""")
echo runShell("""
eval \$(opam env)
time dune runtest --profile static --verbose
""")
sh "mkdir -p bin && mv `find _build -name stanc.exe` bin/linux-stanc"
sh "mv `find _build -name stan2tfp.exe` bin/linux-stan2tfp"
archiveArtifacts 'bin/*'
}
post {always { runShell("rm -rf ./*")}}
}
// Cross compiling for windows on debian
stage("Build & test static Windows binary") {
agent {
dockerfile {
filename 'docker/debian-windows/Dockerfile'
label 'linux-ec2'
//Forces image to ignore entrypoint
args "-u 1000 --entrypoint=\'\'"
}
}
steps {
runShell("""
eval \$(opam env)
dune subst
dune build -x windows
""")
echo runShell("""
eval \$(opam env)
time dune runtest --verbose
""")
sh "mkdir -p bin && mv _build/default.windows/src/stanc/stanc.exe bin/windows-stanc"
sh "mv _build/default.windows/src/stan2tfp/stan2tfp.exe bin/windows-stan2tfp"
stash name:'windows-exe', includes:'bin/*'
}
post {always { runShell("rm -rf ./*")}}
}
}
}
}
}