forked from pharo-project/pharo-vm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
323 lines (266 loc) · 10.9 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
def isWindows(){
//If NODE_LABELS environment variable is null, we assume we are on master unix machine
if (env.NODE_LABELS == null) {
return false
}
return env.NODE_LABELS.toLowerCase().contains('windows')
}
def shell(params){
if(isWindows()) bat(params)
else sh(params)
}
def isMainBranch(){
return env.BRANCH_NAME == 'headless'
}
def runInCygwin(command){
def c = """#!c:\\tools\\cygwin\\bin\\bash --login
cd `cygpath \"$WORKSPACE\"`
set -ex
${command}
"""
echo("Executing: ${c}")
withEnv(["PHARO_CI_TESTING_ENVIRONMENT=true"]) {
return sh(c)
}
}
def buildGTKBundle(){
node("unix"){
cleanWs()
stage("build-GTK-bundle"){
def commitHash = checkout(scm).GIT_COMMIT
unstash name: "packages-Windows-x86_64-CoInterpreter"
def shortGitHash = commitHash.substring(0,8)
def gtkBundleName = "PharoVM-8.1.0-GTK-${shortGitHash}-win64-bin.zip"
dir("build"){
shell "wget http://files.pharo.org/vm/pharo-spur64/win/third-party/Gtk3.zip"
shell "unzip Gtk3.zip -d ./bundleGTK"
shell "unzip -n build/packages/PharoVM-*-Windows-x86_64-bin.zip -d ./bundleGTK"
dir("bundleGTK"){
shell "zip -r -9 ../${gtkBundleName} *"
}
stash includes: "${gtkBundleName}", name: "packages-Windows-x86_64-gtkBundle"
archiveArtifacts artifacts: "${gtkBundleName}"
if(!isPullRequest() && isMainBranch()){
sshagent (credentials: ['b5248b59-a193-4457-8459-e28e9eb29ed7']) {
sh "scp -o StrictHostKeyChecking=no \
${gtkBundleName} \
[email protected]:/home/pharoorgde/files/vm/pharo-spur64-headless/win/${gtkBundleName}"
sh "scp -o StrictHostKeyChecking=no \
${gtkBundleName} \
[email protected]:/home/pharoorgde/files/vm/pharo-spur64-headless/win/latest-win64-GTK.zip"
}
}
}
}
}
}
def recordCygwinVersions(buildDirectory){
runInCygwin "cd ${buildDirectory} && cygcheck -c -d > cygwinVersions.txt"
archiveArtifacts artifacts: "${buildDirectory}/cygwinVersions.txt"
}
def runBuild(platformName, configuration, headless = true){
cleanWs()
def platform = headless ? platformName : "${platformName}-stockReplacement"
def buildDirectory = headless ? "build" :"build-stockReplacement"
def additionalParameters = headless ? "" : "-DALWAYS_INTERACTIVE=1"
stage("Checkout-${platform}"){
dir('repository') {
checkout scm
}
}
stage("Build-${platform}-${configuration}"){
if(isWindows()){
runInCygwin "mkdir ${buildDirectory}"
recordCygwinVersions(buildDirectory)
runInCygwin "cd ${buildDirectory} && cmake -DFLAVOUR=${configuration} ${additionalParameters} -DPHARO_DEPENDENCIES_PREFER_DOWNLOAD_BINARIES=TRUE ../repository"
runInCygwin "cd ${buildDirectory} && VERBOSE=1 make install"
runInCygwin "cd ${buildDirectory} && VERBOSE=1 make package"
}else{
cmakeBuild generator: "Unix Makefiles", cmakeArgs: "-DFLAVOUR=${configuration} ${additionalParameters} -DPHARO_DEPENDENCIES_PREFER_DOWNLOAD_BINARIES=TRUE", sourceDir: "repository", buildDir: "${buildDirectory}", installation: "InSearchPath"
dir("${buildDirectory}"){
shell "VERBOSE=1 make install"
shell "VERBOSE=1 make package"
}
}
stash excludes: '_CPack_Packages', includes: "${buildDirectory}/build/packages/*", name: "packages-${platform}-${configuration}"
archiveArtifacts artifacts: "${buildDirectory}/build/packages/*", excludes: '_CPack_Packages'
}
}
def runUnitTests(platform){
cleanWs()
stage("VM Unit Tests"){
dir('repository') {
checkout scm
}
cmakeBuild generator: "Unix Makefiles", sourceDir: "repository", buildDir: "runTests", installation: "InSearchPath"
dir("runTests"){
shell "VERBOSE=1 make vmmaker"
dir("build/vmmaker"){
shell "wget https://files.pharo.org/vm/pharo-spur64/Darwin-x86_64/third-party/libllvm-full.zip"
shell "unzip libllvm-full.zip -d ./vm/Contents/MacOS/Plugins"
shell "wget https://files.pharo.org/vm/pharo-spur64/Darwin-x86_64/third-party/libunicorn.zip"
shell "unzip libunicorn.zip -d ./vm/Contents/MacOS/Plugins"
shell "PHARO_CI_TESTING_ENVIRONMENT=true ./vm/Contents/MacOS/Pharo --logLevel=4 ./image/VMMaker.image test --junit-xml-output 'VMMakerTests'"
// Stop if tests fail
// Archive xml reports either case
try {
junit allowEmptyResults: true, testResults: "*.xml"
} catch (ex) {
if (currentBuild.result == 'UNSTABLE'){
currentBuild.result = 'FAILURE'
}
archiveArtifacts artifacts: '*.xml'
}
}
}
}
}
def runTests(platform, configuration, packages, withWorker){
cleanWs()
def stageName = withWorker ? "Tests-${platform}-${configuration}-worker" : "Tests-${platform}-${configuration}"
def hasWorker = withWorker ? "--worker" : ""
stage(stageName){
unstash name: "packages-${platform}-${configuration}"
shell "mkdir runTests"
dir("runTests"){
try{
shell "wget -O - get.pharo.org/64/90 | bash "
shell "echo 90 > pharo.version"
if(isWindows()){
runInCygwin "cd runTests && unzip ../build/build/packages/PharoVM-*-${platform}-bin.zip -d ."
runInCygwin "PHARO_CI_TESTING_ENVIRONMENT=true cd runTests && ./PharoConsole.exe --logLevel=4 ${hasWorker} Pharo.image test --junit-xml-output --stage-name=${stageName} '${packages}'"
} else {
shell "unzip ../build/build/packages/PharoVM-*-${platform}-bin.zip -d ."
if(platform == 'Darwin-x86_64'){
shell "PHARO_CI_TESTING_ENVIRONMENT=true ./Pharo.app/Contents/MacOS/Pharo --logLevel=4 ${hasWorker} Pharo.image test --junit-xml-output --stage-name=${stageName} '${packages}'"
}
if(platform == 'Linux-x86_64'){
shell "PHARO_CI_TESTING_ENVIRONMENT=true ./pharo --logLevel=4 ${hasWorker} Pharo.image test --junit-xml-output --stage-name=${stageName} '${packages}'"
}
}
junit allowEmptyResults: true, testResults: "*.xml"
} finally{
if(fileExists('PharoDebug.log')){
shell "mv PharoDebug.log PharoDebug-${stageName}.log"
archiveArtifacts allowEmptyArchive: true, artifacts: "PharoDebug-${stageName}.log", fingerprint: true
}
if(fileExists('crash.dmp')){
shell "mv crash.dmp crash-${stageName}.dmp"
archiveArtifacts allowEmptyArchive: true, artifacts: "crash-${stageName}.dmp", fingerprint: true
}
if(fileExists('progress.log')){
shell "mv progress.log progress-${stageName}.log"
shell "cat progress-${stageName}.log"
archiveArtifacts allowEmptyArchive: true, artifacts: "progress-${stageName}.log", fingerprint: true
}
}
}
archiveArtifacts artifacts: 'runTests/*.xml', excludes: '_CPack_Packages'
}
}
def upload(platform, configuration, archiveName) {
cleanWs()
unstash name: "packages-${platform}-${configuration}"
def expandedBinaryFileName = sh(returnStdout: true, script: "ls build/build/packages/PharoVM-*-${archiveName}-bin.zip").trim()
def expandedCSourceFileName = sh(returnStdout: true, script: "ls build/build/packages/PharoVM-*-${archiveName}-c-src.zip").trim()
def expandedHeadersFileName = sh(returnStdout: true, script: "ls build/build/packages/PharoVM-*-${archiveName}-include.zip").trim()
sshagent (credentials: ['b5248b59-a193-4457-8459-e28e9eb29ed7']) {
sh "scp -o StrictHostKeyChecking=no \
${expandedBinaryFileName} \
[email protected]:/home/pharoorgde/files/vm/pharo-spur64-headless/${platform}"
sh "scp -o StrictHostKeyChecking=no \
${expandedBinaryFileName} \
[email protected]:/home/pharoorgde/files/vm/pharo-spur64-headless/${platform}/latest.zip"
sh "scp -o StrictHostKeyChecking=no \
${expandedHeadersFileName} \
[email protected]:/home/pharoorgde/files/vm/pharo-spur64-headless/${platform}/include"
sh "scp -o StrictHostKeyChecking=no \
${expandedHeadersFileName} \
[email protected]:/home/pharoorgde/files/vm/pharo-spur64-headless/${platform}/include/latest.zip"
sh "scp -o StrictHostKeyChecking=no \
${expandedCSourceFileName} \
[email protected]:/home/pharoorgde/files/vm/pharo-spur64-headless/${platform}/source"
sh "scp -o StrictHostKeyChecking=no \
${expandedCSourceFileName} \
[email protected]:/home/pharoorgde/files/vm/pharo-spur64-headless/${platform}/source/latest.zip"
}
}
def uploadStockReplacement(platform, configuration, archiveName) {
cleanWs()
unstash name: "packages-${archiveName}-${configuration}"
def expandedBinaryFileName = sh(returnStdout: true, script: "ls build-stockReplacement/build/packages/PharoVM-*-${archiveName}-bin.zip").trim()
sshagent (credentials: ['b5248b59-a193-4457-8459-e28e9eb29ed7']) {
sh "scp -o StrictHostKeyChecking=no \
${expandedBinaryFileName} \
[email protected]:/home/pharoorgde/files/vm/pharo-spur64/${platform}"
sh "scp -o StrictHostKeyChecking=no \
${expandedBinaryFileName} \
[email protected]:/home/pharoorgde/files/vm/pharo-spur64/${platform}/latestReplacement.zip"
}
}
def isPullRequest() {
return env.CHANGE_ID != null
}
def uploadPackages(){
node('unix'){
stage('Upload'){
if (isPullRequest()) {
//Only upload files if not in a PR (i.e., CHANGE_ID not empty)
echo "[DO NO UPLOAD] In PR " + (env.CHANGE_ID?.trim())
return;
}
if(!isMainBranch()){
echo "[DO NO UPLOAD] In branch different that 'headless': ${env.BRANCH_NAME}";
return;
}
upload('Darwin-x86_64', "CoInterpreter", 'Darwin-x86_64')
upload('Linux-x86_64', "CoInterpreter", 'Linux-x86_64')
upload('Windows-x86_64', "CoInterpreter", 'Windows-x86_64')
uploadStockReplacement('Darwin-x86_64', "CoInterpreter", 'Darwin-x86_64-stockReplacement')
uploadStockReplacement('Linux-x86_64', "CoInterpreter", 'Linux-x86_64-stockReplacement')
uploadStockReplacement('Windows-x86_64', "CoInterpreter", 'Windows-x86_64-stockReplacement')
}
}
}
try{
properties([disableConcurrentBuilds()])
def platforms = ['Linux-x86_64', 'Darwin-x86_64', 'Windows-x86_64']
def builders = [:]
def tests = [:]
node('Darwin-x86_64'){
runUnitTests('Darwin-x86_64')
}
for (platf in platforms) {
// Need to bind the label variable before the closure - can't do 'for (label in labels)'
def platform = platf
builders[platform] = {
node(platform){
timeout(30){
runBuild(platform, "CoInterpreter")
}
timeout(30){
// Only build the Stock replacement version in the main branch
if(isMainBranch()){
runBuild(platform, "CoInterpreter", false)
}
}
}
}
tests[platform] = {
node(platform){
timeout(45){
runTests(platform, "CoInterpreter", ".*", false)
}
timeout(45){
runTests(platform, "CoInterpreter", ".*", true)
}
}
}
}
parallel builders
uploadPackages()
buildGTKBundle()
parallel tests
} catch (e) {
throw e
}