-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathJenkinsfile-test-binaries
186 lines (174 loc) · 5.9 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
@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} && git pull origin ${params.git_branch}"
}
else if(os_type == "bat"){
bat "git checkout master && git pull && git checkout ${params.git_branch} && git pull origin ${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("Dune tests") {
agent {
docker {
image 'stanorg/stanc3:debian-ocaml-4.14'
//Forces image to ignore entrypoint
args "--entrypoint=\'\'"
}
}
steps {
runShell("""
eval \$(opam env)
dune runtest --verbose
""")
}
post { always { runShell("rm -rf ./*") }}
}
stage("Build") {
agent {
docker {
image 'stanorg/stanc3:debian-ocaml-4.14'
args "--entrypoint=\'\'"
}
}
steps {
script {
checkoutRepository("sh")
}
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 & test Mac OS X binary") {
agent { label 'osx' }
steps {
script {
checkoutRepository("sh")
}
runShell("""
export PATH=/Users/jenkins/brew/bin:\$PATH
eval \$(opam env)
opam update || true
bash -x scripts/install_build_deps.sh
dune subst
dune build @install
""")
sh "mkdir -p bin && mv `find _build -name stanc.exe` bin/mac-stanc"
archiveArtifacts 'bin/*'
}
post { always { runShell("rm -rf ./*") }}
}
stage("Build stanc.js") {
agent {
docker {
image 'stanorg/stanc3:debian-ocaml-4.14'
//Forces image to ignore entrypoint
args "--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 {
docker {
image 'stanorg/stanc3:static-ocaml-4.14'
//Forces image to ignore entrypoint
args "--entrypoint=\'\'"
}
}
steps {
script {
checkoutRepository("sh")
}
runShell("""
eval \$(opam env)
dune subst
dune build @install --profile static
""")
sh "mkdir -p bin && mv `find _build -name stanc.exe` bin/linux-stanc"
archiveArtifacts 'bin/*'
}
post {always { runShell("rm -rf ./*")}}
}
stage("Build & test static Windows binary") {
agent {
docker {
image 'stanorg/stanc3:debian-windows-ocaml-4.14'
//Forces image to ignore entrypoint
args "--entrypoint=\'\'"
}
}
steps {
script {
checkoutRepository("sh")
}
runShell("""
eval \$(opam env)
dune subst
dune build -x windows
""")
sh "mkdir -p bin && mv _build/default.windows/src/stanc/stanc.exe bin/windows-stanc"
stash name:'windows-exe', includes:'bin/*'
archiveArtifacts 'bin/*'
}
post {always { runShell("rm -rf ./*")}}
}
}
}