source: Jenkinsfile@ ef3ac46

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 ef3ac46 was a33dcd5, checked in by Thierry Delisle <tdelisle@…>, 5 years ago

Forgot to stage som stuff

  • Property mode set to 100644
File size: 14.9 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 {
[1baf6ed]150 // Print potential limits before testing
151 // in case jenkins messes with them
[a33dcd5]152 sh 'free -h'
[1baf6ed]153 sh 'ulimit -a'
154
[91aa5ab]155 Tools.BuildStage('Test: short', !Settings.RunAllTests) {
[4c1b9ea8]156 dir (BuildDir) {
[3e93c00]157 //Run the tests from the tests directory
[4c51aca]158 sh "make --no-print-directory -C tests archiveerrors=${BuildDir}/tests/crashes/short"
[3e93c00]159 }
[4c1b9ea8]160 }
161
[91aa5ab]162 Tools.BuildStage('Test: full', Settings.RunAllTests) {
[4c1b9ea8]163 dir (BuildDir) {
164 //Run the tests from the tests directory
[4c51aca]165 sh """make --no-print-directory -C tests timeouts="--timeout=600 --global-timeout=14400" all-tests debug=yes archiveerrors=${BuildDir}/tests/crashes/full-debug"""
166 sh """make --no-print-directory -C tests timeouts="--timeout=600 --global-timeout=14400" all-tests debug=no archiveerrors=${BuildDir}/tests/crashes/full-nodebug"""
[143e6f3]167 }
[9beae23]168 }
[620dd2b]169 }
[4c1b9ea8]170 catch (Exception err) {
171 echo "Archiving core dumps"
[c95fdc9]172 dir (BuildDir) {
[62f96ae]173 archiveArtifacts artifacts: "tests/crashes/**/*,lib/**/lib*.so*", fingerprint: true
[c95fdc9]174 }
[4c1b9ea8]175 throw err
176 }
[95fdb0a]177}
178
179def benchmark() {
[91aa5ab]180 Tools.BuildStage('Benchmark', Settings.RunBenchmark) {
[5b8413b4]181 dir (BuildDir) {
[0dc3ac3]182 //Append bench results
[c6f1f3e]183 sh "make --no-print-directory -C benchmark jenkins arch=${Settings.Architecture.name}"
[0dc3ac3]184 }
[620dd2b]185 }
[9beae23]186}
[efd60d67]187
[95fdb0a]188def build_doc() {
[91aa5ab]189 Tools.BuildStage('Documentation', Settings.BuildDocumentation) {
[9beae23]190 dir ('doc/user') {
191 make_doc()
192 }
193
194 dir ('doc/refrat') {
195 make_doc()
196 }
[620dd2b]197 }
[9beae23]198}
199
[95fdb0a]200def publish() {
[91aa5ab]201 Tools.BuildStage('Publish', true) {
[95fdb0a]202
[1b3eef8]203 if( Settings.Publish && !Settings.RunBenchmark ) { echo 'No results to publish!!!' }
[95fdb0a]204
[3221a2b]205 def groupCompile = new PlotGroup('Compilation', 'duration (s) - lower is better', true)
206 def groupConcurrency = new PlotGroup('Concurrency', 'duration (n) - lower is better', false)
[a2a0065]207
[3898392]208 //Then publish the results
[13d2dac]209 do_plot(Settings.RunBenchmark && Settings.Publish, 'compile' , groupCompile , false, 'Compilation')
210 do_plot(Settings.RunBenchmark && Settings.Publish, 'compile.diff' , groupCompile , true , 'Compilation (relative)')
211 do_plot(Settings.RunBenchmark && Settings.Publish, 'ctxswitch' , groupConcurrency, false, 'Context Switching')
212 do_plot(Settings.RunBenchmark && Settings.Publish, 'ctxswitch.diff' , groupConcurrency, true , 'Context Switching (relative)')
213 do_plot(Settings.RunBenchmark && Settings.Publish, 'mutex' , groupConcurrency, false, 'Mutual Exclusion')
214 do_plot(Settings.RunBenchmark && Settings.Publish, 'mutex.diff' , groupConcurrency, true , 'Mutual Exclusion (relative)')
215 do_plot(Settings.RunBenchmark && Settings.Publish, 'scheduling' , groupConcurrency, false, 'Internal and External Scheduling')
216 do_plot(Settings.RunBenchmark && Settings.Publish, 'scheduling.diff', groupConcurrency, true , 'Internal and External Scheduling (relative)')
[620dd2b]217 }
[95fdb0a]218}
219
[29f4fe62]220//===========================================================================================================
221//Routine responsible of sending the email notification once the build is completed
222//===========================================================================================================
[a336d46]223//Standard build email notification
[13c98a4]224def email(boolean log) {
[a336d46]225 //Since tokenizer doesn't work, figure stuff out from the environnement variables and command line
226 //Configurations for email format
227 echo 'Notifying users of result'
228
229 def project_name = (env.JOB_NAME =~ /(.+)\/.+/)[0][1].toLowerCase()
230 def email_subject = "[${project_name} git][BUILD# ${env.BUILD_NUMBER} - ${currentBuild.result}] - branch ${env.BRANCH_NAME}"
[13c98a4]231 def email_body = """<p>This is an automated email from the Jenkins build machine. It was
[a336d46]232generated because of a git hooks/post-receive script following
[986e260]233a ref change which was pushed to the C\u2200 repository.</p>
[6a531ab]234""" + Tools.GitLogMessage()
[e8a22a7]235
[13c98a4]236 def email_to = !Settings.IsSandbox ? "cforall@lists.uwaterloo.ca" : "tdelisle@uwaterloo.ca"
[e8a22a7]237
[13c98a4]238 if( Settings && !Settings.Silent ) {
[094a42c]239 //send email notification
240 emailext body: email_body, subject: email_subject, to: email_to, attachLog: log
241 } else {
242 echo "Would send email to: ${email_to}"
243 echo "With title: ${email_subject}"
244 echo "Content: \n${email_body}"
245 }
[e8a22a7]246}
[5b8413b4]247
248//===========================================================================================================
249// Helper classes/variables/routines
250//===========================================================================================================
251//Description of a compiler (Must be serializable since pipelines are persistent)
252class CC_Desc implements Serializable {
[93fe3154]253 public String name
254 public String CXX
[6ebc13f]255 public String CC
[bf22bc6]256 public String lto
[93fe3154]257
[bf22bc6]258 CC_Desc(String name, String CXX, String CC, String lto) {
[93fe3154]259 this.name = name
260 this.CXX = CXX
[bf22bc6]261 this.CC = CC
262 this.lto = lto
[5b8413b4]263 }
264}
265
266//Description of an architecture (Must be serializable since pipelines are persistent)
267class Arch_Desc implements Serializable {
268 public String name
269 public String flags
[5307c33]270 public String node
[5b8413b4]271
[5307c33]272 Arch_Desc(String name, String flags, String node) {
[5b8413b4]273 this.name = name
274 this.flags = flags
[5307c33]275 this.node = node
[5b8413b4]276 }
277}
278
279class BuildSettings implements Serializable {
280 public final CC_Desc Compiler
281 public final Arch_Desc Architecture
[d21dd3cb]282 public final Boolean NewAST
[5b8413b4]283 public final Boolean RunAllTests
284 public final Boolean RunBenchmark
285 public final Boolean BuildDocumentation
286 public final Boolean Publish
287 public final Boolean Silent
288 public final Boolean IsSandbox
289 public final String DescLong
290 public final String DescShort
291
[a336d46]292 public String GitNewRef
293 public String GitOldRef
294
[490cb3c]295 BuildSettings(java.util.Collections$UnmodifiableMap param, String branch) {
[5b8413b4]296 switch( param.Compiler ) {
[099f5bd]297 case 'gcc-9':
[bf22bc6]298 this.Compiler = new CC_Desc('gcc-9', 'g++-9', 'gcc-9', '-flto=auto')
[099f5bd]299 break
300 case 'gcc-8':
[bf22bc6]301 this.Compiler = new CC_Desc('gcc-8', 'g++-8', 'gcc-8', '-flto=auto')
[099f5bd]302 break
303 case 'gcc-7':
[bf22bc6]304 this.Compiler = new CC_Desc('gcc-7', 'g++-7', 'gcc-7', '-flto=auto')
[099f5bd]305 break
[5b8413b4]306 case 'gcc-6':
[bf22bc6]307 this.Compiler = new CC_Desc('gcc-6', 'g++-6', 'gcc-6', '-flto=auto')
[5b8413b4]308 break
309 case 'gcc-5':
[bf22bc6]310 this.Compiler = new CC_Desc('gcc-5', 'g++-5', 'gcc-5', '-flto=auto')
[5b8413b4]311 break
312 case 'gcc-4.9':
[bf22bc6]313 this.Compiler = new CC_Desc('gcc-4.9', 'g++-4.9', 'gcc-4.9', '-flto=auto')
[5b8413b4]314 break
315 case 'clang':
[391c065]316 this.Compiler = new CC_Desc('clang', 'clang++-10', 'gcc-9', '-flto=thin -flto-jobs=0')
[5b8413b4]317 break
318 default :
319 error "Unhandled compiler : ${cc}"
320 }
321
322 switch( param.Architecture ) {
323 case 'x64':
[a3e8281]324 this.Architecture = new Arch_Desc('x64', '--host=x86_64', 'x64')
[5b8413b4]325 break
326 case 'x86':
[a3e8281]327 this.Architecture = new Arch_Desc('x86', '--host=i386', 'x86')
[5b8413b4]328 break
329 default :
330 error "Unhandled architecture : ${arch}"
331 }
332
[f95e8f0]333 this.IsSandbox = (branch == "jenkins-sandbox")
[d21dd3cb]334 this.NewAST = param.NewAST
[5b8413b4]335 this.RunAllTests = param.RunAllTests
[7a230fd]336 this.RunBenchmark = param.RunBenchmark
[5b8413b4]337 this.BuildDocumentation = param.BuildDocumentation
[7a230fd]338 this.Publish = param.Publish
[5b8413b4]339 this.Silent = param.Silent
340
341 def full = param.RunAllTests ? " (Full)" : ""
[490cb3c]342 this.DescShort = "${ this.Compiler.name }:${ this.Architecture.name }${full}"
[5b8413b4]343
[fe3d9ab]344 final ast = this.NewAST ? "New AST" : "Old AST"
[93fe3154]345 this.DescLong = """Compiler : ${ this.Compiler.name } (${ this.Compiler.CXX }/${ this.Compiler.CC })
[85799aa]346AST Version : ${ ast.toString() }
[5b8413b4]347Architecture : ${ this.Architecture.name }
348Arc Flags : ${ this.Architecture.flags }
349Run All Tests : ${ this.RunAllTests.toString() }
350Run Benchmark : ${ this.RunBenchmark.toString() }
351Build Documentation : ${ this.BuildDocumentation.toString() }
352Publish : ${ this.Publish.toString() }
353Silent : ${ this.Silent.toString() }
354"""
[a336d46]355
356 this.GitNewRef = ''
357 this.GitOldRef = ''
[5b8413b4]358 }
359}
360
[490cb3c]361class PlotGroup implements Serializable {
362 public String name
363 public String unit
364 public boolean log
365
366 PlotGroup(String name, String unit, boolean log) {
367 this.name = name
368 this.unit = unit
369 this.log = log
370 }
371}
372
[5b8413b4]373def prepare_build() {
374 // prepare the properties
375 properties ([ \
[62f96ae]376 buildDiscarder(logRotator( \
377 artifactDaysToKeepStr: '', \
378 artifactNumToKeepStr: '', \
379 daysToKeepStr: '730', \
380 numToKeepStr: '1000' \
381 )), \
[5b8413b4]382 [$class: 'ParametersDefinitionProperty', \
383 parameterDefinitions: [ \
384 [$class: 'ChoiceParameterDefinition', \
385 description: 'Which compiler to use', \
386 name: 'Compiler', \
[c09ae73]387 choices: 'gcc-9\ngcc-8\ngcc-7\ngcc-6\ngcc-5\ngcc-4.9\nclang', \
[fe27d99]388 defaultValue: 'gcc-8', \
[5b8413b4]389 ], \
390 [$class: 'ChoiceParameterDefinition', \
391 description: 'The target architecture', \
392 name: 'Architecture', \
393 choices: 'x64\nx86', \
394 defaultValue: 'x64', \
395 ], \
[d21dd3cb]396 [$class: 'BooleanParameterDefinition', \
397 description: 'If true, build compiler using new AST', \
398 name: 'NewAST', \
[6a531ab]399 defaultValue: true, \
[d21dd3cb]400 ], \
[5b8413b4]401 [$class: 'BooleanParameterDefinition', \
402 description: 'If false, only the quick test suite is ran', \
403 name: 'RunAllTests', \
404 defaultValue: false, \
[fe3d9ab]405 ], \
[5b8413b4]406 [$class: 'BooleanParameterDefinition', \
407 description: 'If true, jenkins also runs benchmarks', \
408 name: 'RunBenchmark', \
409 defaultValue: false, \
410 ], \
411 [$class: 'BooleanParameterDefinition', \
412 description: 'If true, jenkins also builds documentation', \
413 name: 'BuildDocumentation', \
414 defaultValue: true, \
415 ], \
416 [$class: 'BooleanParameterDefinition', \
417 description: 'If true, jenkins also publishes results', \
418 name: 'Publish', \
419 defaultValue: false, \
420 ], \
421 [$class: 'BooleanParameterDefinition', \
422 description: 'If true, jenkins will not send emails', \
423 name: 'Silent', \
424 defaultValue: false, \
425 ], \
426 ],
427 ]])
428
[bd8dca2]429 // It's unfortunate but it looks like we need to checkout the entire repo just to get
430 // - the pretty git printer
431 // - Jenkins.tools
[4c55047]432 checkout scm
[2407853]433
[1483a16]434 Tools = load "Jenkins/tools.groovy"
[bd8dca2]435
[490cb3c]436 final settings = new BuildSettings(params, env.BRANCH_NAME)
[5b8413b4]437
438 currentBuild.description = settings.DescShort
439 echo settings.DescLong
440
441 return settings
442}
443
444def make_doc() {
445 def err = null
446 try {
447 sh 'make clean > /dev/null'
448 sh 'make > /dev/null 2>&1'
449 }
450 catch (Exception caughtError) {
451 err = caughtError //rethrow error later
[65f4a51]452 sh 'cat build/*.log'
[5b8413b4]453 }
454 finally {
455 if (err) throw err // Must re-throw exception to propagate error
456 }
[a2a0065]457}
458
[3221a2b]459def do_plot(boolean new_data, String file, PlotGroup group, boolean relative, String title) {
[8d63649]460
[1b3eef8]461 if(new_data) {
462 echo "Publishing new data"
463 }
464
[cdcd53dc]465 def series = new_data ? [[
[df57a84]466 file: "${file}.csv",
[3c40dc2a]467 exclusionValues: '',
468 displayTableFlag: false,
469 inclusionFlag: 'OFF',
470 url: ''
[cdcd53dc]471 ]] : [];
[8d63649]472
473 echo "file is ${BuildDir}/benchmark/${file}.csv, group ${group}, title ${title}"
474 dir("${BuildDir}/benchmark/") {
475 plot csvFileName: "cforall-${env.BRANCH_NAME}-${file}.csv",
476 csvSeries: series,
[490cb3c]477 group: "${group.name}",
[3c40dc2a]478 title: "${title}",
479 style: 'lineSimple',
480 exclZero: false,
481 keepRecords: false,
[3221a2b]482 logarithmic: !relative && group.log,
[3c40dc2a]483 numBuilds: '120',
484 useDescr: true,
[490cb3c]485 yaxis: group.unit,
[3c40dc2a]486 yaxisMaximum: '',
487 yaxisMinimum: ''
[df57a84]488 }
489}
Note: See TracBrowser for help on using the repository browser.