source: Jenkinsfile@ 7583c02

ADT arm-eh ast-experimental enum forall-pointer-decay jacob/cs343-translation new-ast-unique-expr pthread-emulation qualifiedEnum
Last change on this file since 7583c02 was abc2a643, checked in by Thierry Delisle <tdelisle@…>, 5 years ago

Can't even use Java

  • Property mode set to 100644
File size: 14.8 KB
RevLine 
[a63ad80]1#!groovy
2
[7a230fd]3import groovy.transform.Field
4
[29f4fe62]5//===========================================================================================================
[9beae23]6// Main loop of the compilation
[29f4fe62]7//===========================================================================================================
[56a9ce6]8
[85142648]9node('master') {
10 // Globals
11 BuildDir = pwd tmp: true
12 SrcDir = pwd tmp: false
13 Settings = null
[1483a16]14 Tools = null
[4f9e706]15
[85142648]16 // Local variables
17 def err = null
18 def log_needed = false
[5b8413b4]19
[85142648]20 currentBuild.result = "SUCCESS"
[4f9e706]21
[85142648]22 try {
23 //Wrap build to add timestamp to command line
24 wrap([$class: 'TimestamperBuildWrapper']) {
[0ef06b6]25
[85142648]26 Settings = prepare_build()
[952ee7a]27
[85142648]28 node(Settings.Architecture.node) {
[9dd31e7]29 BuildDir = pwd tmp: true
30 SrcDir = pwd tmp: false
[23a14d86]31
[9dd31e7]32 Tools.Clean()
[7aebc62]33
[9dd31e7]34 Tools.Checkout()
[fde808df]35
[9dd31e7]36 build()
[95fdb0a]37
[9dd31e7]38 test()
[95fdb0a]39
[9dd31e7]40 benchmark()
[95fdb0a]41
[9dd31e7]42 build_doc()
[7359098]43
[9dd31e7]44 publish()
[85142648]45 }
[9beae23]46
[85142648]47 // Update the build directories when exiting the node
48 BuildDir = pwd tmp: true
49 SrcDir = pwd tmp: false
[9beae23]50 }
[738cf8f]51 }
52
[85142648]53 //If an exception is caught we need to change the status and remember to
54 //attach the build log to the email
55 catch (Exception caughtError) {
[9dd31e7]56 // Store the result of the build log
57 currentBuild.result = "FAILURE"
58
59 // An error has occured, the build log is relevent
[85142648]60 log_needed = true
[9beae23]61
[9dd31e7]62 // rethrow error later
[852ae0ea]63 err = caughtError
64
[9dd31e7]65 // print the error so it shows in the log
[852ae0ea]66 echo err.toString()
[85142648]67 }
[738cf8f]68
[85142648]69 finally {
70 //Send email with final results if this is not a full build
71 email(log_needed)
[9beae23]72
[85142648]73 echo 'Build Completed'
[734891d]74
[85142648]75 /* Must re-throw exception to propagate error */
76 if (err) {
77 throw err
78 }
[738cf8f]79 }
80}
[29f4fe62]81//===========================================================================================================
[9beae23]82// Main compilation routines
[29f4fe62]83//===========================================================================================================
[95fdb0a]84def build() {
[e507c11]85 debug = true
86 release = Settings.RunAllTests || Settings.RunBenchmark
[91aa5ab]87 Tools.BuildStage('Build : configure', true) {
[dcf1979]88 // Configure must be run inside the tree
89 dir (SrcDir) {
90 // Generate the necessary build files
91 sh './autogen.sh'
92 }
93
[50f2cfc]94 // Build outside of the src tree to ease cleaning
[5b8413b4]95 dir (BuildDir) {
[8e58264]96 //Configure the compilation (Output is not relevant)
[50f2cfc]97 //Use the current directory as the installation target so nothing escapes the sandbox
98 //Also specify the compiler by hand
[3fc5f010]99 targets=""
[d4510ea]100 if( Settings.RunAllTests || Settings.RunBenchmark ) {
[6bde81d]101 targets="--with-target-hosts='host:debug,host:nodebug'"
[3fc5f010]102 } else {
[6bde81d]103 targets="--with-target-hosts='host:debug'"
[3fc5f010]104 }
105
[d21dd3cb]106 ast = Settings.NewAST ? "--enable-new-ast" : "--disable-new-ast"
107
108 sh "${SrcDir}/configure CXX=${Settings.Compiler.CXX} CC=${Settings.Compiler.CC} ${Settings.Architecture.flags} AR=gcc-ar RANLIB=gcc-ranlib ${targets} ${ast} --quiet --prefix=${BuildDir}"
[f253e4a]109
110 // Configure libcfa
[e70e54e]111 sh 'make -j 8 --no-print-directory configure-libcfa'
[e507c11]112 }
113 }
114
[91aa5ab]115 Tools.BuildStage('Build : cfa-cpp', true) {
[e507c11]116 // Build outside of the src tree to ease cleaning
117 dir (BuildDir) {
118 // Build driver
119 sh 'make -j 8 --no-print-directory -C driver'
120
121 // Build translator
122 sh 'make -j 8 --no-print-directory -C src'
123 }
124 }
[1752d0e]125
[91aa5ab]126 Tools.BuildStage('Build : libcfa(debug)', debug) {
[e507c11]127 // Build outside of the src tree to ease cleaning
128 dir (BuildDir) {
129 sh "make -j 8 --no-print-directory -C libcfa/${Settings.Architecture.name}-debug"
130 }
131 }
132
[91aa5ab]133 Tools.BuildStage('Build : libcfa(nodebug)', release) {
[e507c11]134 // Build outside of the src tree to ease cleaning
135 dir (BuildDir) {
136 sh "make -j 8 --no-print-directory -C libcfa/${Settings.Architecture.name}-nodebug"
[50f2cfc]137 }
[620dd2b]138 }
[aa96fba]139
[91aa5ab]140 Tools.BuildStage('Build : install', true) {
[aa96fba]141 // Build outside of the src tree to ease cleaning
142 dir (BuildDir) {
143 sh "make -j 8 --no-print-directory install"
144 }
145 }
[95fdb0a]146}
[24eecab]147
[95fdb0a]148def test() {
[4c1b9ea8]149 try {
[91aa5ab]150 Tools.BuildStage('Test: short', !Settings.RunAllTests) {
[4c1b9ea8]151 dir (BuildDir) {
[3e93c00]152 //Run the tests from the tests directory
[4c51aca]153 sh "make --no-print-directory -C tests archiveerrors=${BuildDir}/tests/crashes/short"
[3e93c00]154 }
[4c1b9ea8]155 }
156
[91aa5ab]157 Tools.BuildStage('Test: full', Settings.RunAllTests) {
[4c1b9ea8]158 dir (BuildDir) {
159 //Run the tests from the tests directory
[4c51aca]160 sh """make --no-print-directory -C tests timeouts="--timeout=600 --global-timeout=14400" all-tests debug=yes archiveerrors=${BuildDir}/tests/crashes/full-debug"""
161 sh """make --no-print-directory -C tests timeouts="--timeout=600 --global-timeout=14400" all-tests debug=no archiveerrors=${BuildDir}/tests/crashes/full-nodebug"""
[143e6f3]162 }
[9beae23]163 }
[620dd2b]164 }
[4c1b9ea8]165 catch (Exception err) {
166 echo "Archiving core dumps"
[c95fdc9]167 dir (BuildDir) {
[62f96ae]168 archiveArtifacts artifacts: "tests/crashes/**/*,lib/**/lib*.so*", fingerprint: true
[c95fdc9]169 }
[4c1b9ea8]170 throw err
171 }
[95fdb0a]172}
173
174def benchmark() {
[91aa5ab]175 Tools.BuildStage('Benchmark', Settings.RunBenchmark) {
[5b8413b4]176 dir (BuildDir) {
[0dc3ac3]177 //Append bench results
[c6f1f3e]178 sh "make --no-print-directory -C benchmark jenkins arch=${Settings.Architecture.name}"
[0dc3ac3]179 }
[620dd2b]180 }
[9beae23]181}
[efd60d67]182
[95fdb0a]183def build_doc() {
[91aa5ab]184 Tools.BuildStage('Documentation', Settings.BuildDocumentation) {
[9beae23]185 dir ('doc/user') {
186 make_doc()
187 }
188
189 dir ('doc/refrat') {
190 make_doc()
191 }
[620dd2b]192 }
[9beae23]193}
194
[95fdb0a]195def publish() {
[91aa5ab]196 Tools.BuildStage('Publish', true) {
[95fdb0a]197
[1b3eef8]198 if( Settings.Publish && !Settings.RunBenchmark ) { echo 'No results to publish!!!' }
[95fdb0a]199
[3221a2b]200 def groupCompile = new PlotGroup('Compilation', 'duration (s) - lower is better', true)
201 def groupConcurrency = new PlotGroup('Concurrency', 'duration (n) - lower is better', false)
[a2a0065]202
[3898392]203 //Then publish the results
[13d2dac]204 do_plot(Settings.RunBenchmark && Settings.Publish, 'compile' , groupCompile , false, 'Compilation')
205 do_plot(Settings.RunBenchmark && Settings.Publish, 'compile.diff' , groupCompile , true , 'Compilation (relative)')
206 do_plot(Settings.RunBenchmark && Settings.Publish, 'ctxswitch' , groupConcurrency, false, 'Context Switching')
207 do_plot(Settings.RunBenchmark && Settings.Publish, 'ctxswitch.diff' , groupConcurrency, true , 'Context Switching (relative)')
208 do_plot(Settings.RunBenchmark && Settings.Publish, 'mutex' , groupConcurrency, false, 'Mutual Exclusion')
209 do_plot(Settings.RunBenchmark && Settings.Publish, 'mutex.diff' , groupConcurrency, true , 'Mutual Exclusion (relative)')
210 do_plot(Settings.RunBenchmark && Settings.Publish, 'scheduling' , groupConcurrency, false, 'Internal and External Scheduling')
211 do_plot(Settings.RunBenchmark && Settings.Publish, 'scheduling.diff', groupConcurrency, true , 'Internal and External Scheduling (relative)')
[620dd2b]212 }
[95fdb0a]213}
214
[29f4fe62]215//===========================================================================================================
216//Routine responsible of sending the email notification once the build is completed
217//===========================================================================================================
[a336d46]218//Standard build email notification
[13c98a4]219def email(boolean log) {
[a336d46]220 //Since tokenizer doesn't work, figure stuff out from the environnement variables and command line
221 //Configurations for email format
222 echo 'Notifying users of result'
223
224 def project_name = (env.JOB_NAME =~ /(.+)\/.+/)[0][1].toLowerCase()
225 def email_subject = "[${project_name} git][BUILD# ${env.BUILD_NUMBER} - ${currentBuild.result}] - branch ${env.BRANCH_NAME}"
[13c98a4]226 def email_body = """<p>This is an automated email from the Jenkins build machine. It was
[a336d46]227generated because of a git hooks/post-receive script following
[986e260]228a ref change which was pushed to the C\u2200 repository.</p>
[6a531ab]229""" + Tools.GitLogMessage()
[e8a22a7]230
[13c98a4]231 def email_to = !Settings.IsSandbox ? "cforall@lists.uwaterloo.ca" : "tdelisle@uwaterloo.ca"
[e8a22a7]232
[13c98a4]233 if( Settings && !Settings.Silent ) {
[094a42c]234 //send email notification
235 emailext body: email_body, subject: email_subject, to: email_to, attachLog: log
236 } else {
237 echo "Would send email to: ${email_to}"
238 echo "With title: ${email_subject}"
239 echo "Content: \n${email_body}"
240 }
[e8a22a7]241}
[5b8413b4]242
243//===========================================================================================================
244// Helper classes/variables/routines
245//===========================================================================================================
246//Description of a compiler (Must be serializable since pipelines are persistent)
247class CC_Desc implements Serializable {
[93fe3154]248 public String name
249 public String CXX
[6ebc13f]250 public String CC
[bf22bc6]251 public String lto
[93fe3154]252
[bf22bc6]253 CC_Desc(String name, String CXX, String CC, String lto) {
[93fe3154]254 this.name = name
255 this.CXX = CXX
[bf22bc6]256 this.CC = CC
257 this.lto = lto
[5b8413b4]258 }
259}
260
261//Description of an architecture (Must be serializable since pipelines are persistent)
262class Arch_Desc implements Serializable {
263 public String name
264 public String flags
[5307c33]265 public String node
[5b8413b4]266
[5307c33]267 Arch_Desc(String name, String flags, String node) {
[5b8413b4]268 this.name = name
269 this.flags = flags
[5307c33]270 this.node = node
[5b8413b4]271 }
272}
273
274class BuildSettings implements Serializable {
275 public final CC_Desc Compiler
276 public final Arch_Desc Architecture
[d21dd3cb]277 public final Boolean NewAST
[5b8413b4]278 public final Boolean RunAllTests
279 public final Boolean RunBenchmark
280 public final Boolean BuildDocumentation
281 public final Boolean Publish
282 public final Boolean Silent
283 public final Boolean IsSandbox
284 public final String DescLong
285 public final String DescShort
286
[a336d46]287 public String GitNewRef
288 public String GitOldRef
289
[490cb3c]290 BuildSettings(java.util.Collections$UnmodifiableMap param, String branch) {
[5b8413b4]291 switch( param.Compiler ) {
[099f5bd]292 case 'gcc-9':
[bf22bc6]293 this.Compiler = new CC_Desc('gcc-9', 'g++-9', 'gcc-9', '-flto=auto')
[099f5bd]294 break
295 case 'gcc-8':
[bf22bc6]296 this.Compiler = new CC_Desc('gcc-8', 'g++-8', 'gcc-8', '-flto=auto')
[099f5bd]297 break
298 case 'gcc-7':
[bf22bc6]299 this.Compiler = new CC_Desc('gcc-7', 'g++-7', 'gcc-7', '-flto=auto')
[099f5bd]300 break
[5b8413b4]301 case 'gcc-6':
[bf22bc6]302 this.Compiler = new CC_Desc('gcc-6', 'g++-6', 'gcc-6', '-flto=auto')
[5b8413b4]303 break
304 case 'gcc-5':
[bf22bc6]305 this.Compiler = new CC_Desc('gcc-5', 'g++-5', 'gcc-5', '-flto=auto')
[5b8413b4]306 break
307 case 'gcc-4.9':
[bf22bc6]308 this.Compiler = new CC_Desc('gcc-4.9', 'g++-4.9', 'gcc-4.9', '-flto=auto')
[5b8413b4]309 break
310 case 'clang':
[391c065]311 this.Compiler = new CC_Desc('clang', 'clang++-10', 'gcc-9', '-flto=thin -flto-jobs=0')
[5b8413b4]312 break
313 default :
314 error "Unhandled compiler : ${cc}"
315 }
316
317 switch( param.Architecture ) {
318 case 'x64':
[a3e8281]319 this.Architecture = new Arch_Desc('x64', '--host=x86_64', 'x64')
[5b8413b4]320 break
321 case 'x86':
[a3e8281]322 this.Architecture = new Arch_Desc('x86', '--host=i386', 'x86')
[5b8413b4]323 break
324 default :
325 error "Unhandled architecture : ${arch}"
326 }
327
[f95e8f0]328 this.IsSandbox = (branch == "jenkins-sandbox")
[d21dd3cb]329 this.NewAST = param.NewAST
[5b8413b4]330 this.RunAllTests = param.RunAllTests
[7a230fd]331 this.RunBenchmark = param.RunBenchmark
[5b8413b4]332 this.BuildDocumentation = param.BuildDocumentation
[7a230fd]333 this.Publish = param.Publish
[5b8413b4]334 this.Silent = param.Silent
335
336 def full = param.RunAllTests ? " (Full)" : ""
[490cb3c]337 this.DescShort = "${ this.Compiler.name }:${ this.Architecture.name }${full}"
[5b8413b4]338
[fe3d9ab]339 final ast = this.NewAST ? "New AST" : "Old AST"
[93fe3154]340 this.DescLong = """Compiler : ${ this.Compiler.name } (${ this.Compiler.CXX }/${ this.Compiler.CC })
[85799aa]341AST Version : ${ ast.toString() }
[5b8413b4]342Architecture : ${ this.Architecture.name }
343Arc Flags : ${ this.Architecture.flags }
344Run All Tests : ${ this.RunAllTests.toString() }
345Run Benchmark : ${ this.RunBenchmark.toString() }
346Build Documentation : ${ this.BuildDocumentation.toString() }
347Publish : ${ this.Publish.toString() }
348Silent : ${ this.Silent.toString() }
349"""
[a336d46]350
351 this.GitNewRef = ''
352 this.GitOldRef = ''
[5b8413b4]353 }
354}
355
[490cb3c]356class PlotGroup implements Serializable {
357 public String name
358 public String unit
359 public boolean log
360
361 PlotGroup(String name, String unit, boolean log) {
362 this.name = name
363 this.unit = unit
364 this.log = log
365 }
366}
367
[5b8413b4]368def prepare_build() {
369 // prepare the properties
370 properties ([ \
[62f96ae]371 buildDiscarder(logRotator( \
372 artifactDaysToKeepStr: '', \
373 artifactNumToKeepStr: '', \
374 daysToKeepStr: '730', \
375 numToKeepStr: '1000' \
376 )), \
[5b8413b4]377 [$class: 'ParametersDefinitionProperty', \
378 parameterDefinitions: [ \
379 [$class: 'ChoiceParameterDefinition', \
380 description: 'Which compiler to use', \
381 name: 'Compiler', \
[c09ae73]382 choices: 'gcc-9\ngcc-8\ngcc-7\ngcc-6\ngcc-5\ngcc-4.9\nclang', \
[fe27d99]383 defaultValue: 'gcc-8', \
[5b8413b4]384 ], \
385 [$class: 'ChoiceParameterDefinition', \
386 description: 'The target architecture', \
387 name: 'Architecture', \
388 choices: 'x64\nx86', \
389 defaultValue: 'x64', \
390 ], \
[d21dd3cb]391 [$class: 'BooleanParameterDefinition', \
392 description: 'If true, build compiler using new AST', \
393 name: 'NewAST', \
[6a531ab]394 defaultValue: true, \
[d21dd3cb]395 ], \
[5b8413b4]396 [$class: 'BooleanParameterDefinition', \
397 description: 'If false, only the quick test suite is ran', \
398 name: 'RunAllTests', \
399 defaultValue: false, \
[fe3d9ab]400 ], \
[5b8413b4]401 [$class: 'BooleanParameterDefinition', \
402 description: 'If true, jenkins also runs benchmarks', \
403 name: 'RunBenchmark', \
404 defaultValue: false, \
405 ], \
406 [$class: 'BooleanParameterDefinition', \
407 description: 'If true, jenkins also builds documentation', \
408 name: 'BuildDocumentation', \
409 defaultValue: true, \
410 ], \
411 [$class: 'BooleanParameterDefinition', \
412 description: 'If true, jenkins also publishes results', \
413 name: 'Publish', \
414 defaultValue: false, \
415 ], \
416 [$class: 'BooleanParameterDefinition', \
417 description: 'If true, jenkins will not send emails', \
418 name: 'Silent', \
419 defaultValue: false, \
420 ], \
421 ],
422 ]])
423
[bd8dca2]424 // It's unfortunate but it looks like we need to checkout the entire repo just to get
425 // - the pretty git printer
426 // - Jenkins.tools
[4c55047]427 checkout scm
[2407853]428
[1483a16]429 Tools = load "Jenkins/tools.groovy"
[bd8dca2]430
[490cb3c]431 final settings = new BuildSettings(params, env.BRANCH_NAME)
[5b8413b4]432
433 currentBuild.description = settings.DescShort
434 echo settings.DescLong
435
436 return settings
437}
438
439def make_doc() {
440 def err = null
441 try {
442 sh 'make clean > /dev/null'
443 sh 'make > /dev/null 2>&1'
444 }
445 catch (Exception caughtError) {
446 err = caughtError //rethrow error later
[65f4a51]447 sh 'cat build/*.log'
[5b8413b4]448 }
449 finally {
450 if (err) throw err // Must re-throw exception to propagate error
451 }
[a2a0065]452}
453
[3221a2b]454def do_plot(boolean new_data, String file, PlotGroup group, boolean relative, String title) {
[8d63649]455
[1b3eef8]456 if(new_data) {
457 echo "Publishing new data"
458 }
459
[cdcd53dc]460 def series = new_data ? [[
[df57a84]461 file: "${file}.csv",
[3c40dc2a]462 exclusionValues: '',
463 displayTableFlag: false,
464 inclusionFlag: 'OFF',
465 url: ''
[cdcd53dc]466 ]] : [];
[8d63649]467
468 echo "file is ${BuildDir}/benchmark/${file}.csv, group ${group}, title ${title}"
469 dir("${BuildDir}/benchmark/") {
470 plot csvFileName: "cforall-${env.BRANCH_NAME}-${file}.csv",
471 csvSeries: series,
[490cb3c]472 group: "${group.name}",
[3c40dc2a]473 title: "${title}",
474 style: 'lineSimple',
475 exclZero: false,
476 keepRecords: false,
[3221a2b]477 logarithmic: !relative && group.log,
[3c40dc2a]478 numBuilds: '120',
479 useDescr: true,
[490cb3c]480 yaxis: group.unit,
[3c40dc2a]481 yaxisMaximum: '',
482 yaxisMinimum: ''
[df57a84]483 }
484}
Note: See TracBrowser for help on using the repository browser.