source: Jenkinsfile@ c4072d8e

ADT ast-experimental pthread-emulation qualifiedEnum
Last change on this file since c4072d8e was 4f3807d, checked in by Thierry Delisle <tdelisle@…>, 3 years ago

Removed jenkins performance plots since they were not very useful

  • Property mode set to 100644
File size: 13.5 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
[d3b95f1]9// Globals
[e018546]10BuildDir = null
11SrcDir = null
[d3b95f1]12Settings = null
13Tools = null
[4f9e706]14
[d3b95f1]15// Local variables
16def err = null
17def log_needed = false
[5b8413b4]18
[d3b95f1]19currentBuild.result = "SUCCESS"
[4f9e706]20
[d3b95f1]21try {
[47138ee]22 node {
23 //Wrap build to add timestamp to command line
24 wrap([$class: 'TimestamperBuildWrapper']) {
[85142648]25 Settings = prepare_build()
[d3b95f1]26 }
[47138ee]27 }
[952ee7a]28
[47138ee]29 node(Settings.Architecture.node) {
30 //Wrap build to add timestamp to command line
31 wrap([$class: 'TimestamperBuildWrapper']) {
[d3b95f1]32 BuildDir = pwd tmp: true
33 SrcDir = pwd tmp: false
34 currentBuild.description = "${currentBuild.description} on ${env.NODE_NAME}"
[7aebc62]35
[d3b95f1]36 Tools.Clean()
[fde808df]37
[d3b95f1]38 Tools.Checkout()
[95fdb0a]39
[d3b95f1]40 build()
[95fdb0a]41
[d3b95f1]42 test()
[95fdb0a]43
[d3b95f1]44 benchmark()
[7359098]45
[d3b95f1]46 build_doc()
[9beae23]47
[d3b95f1]48 publish()
[9beae23]49 }
[738cf8f]50 }
[d3b95f1]51}
[738cf8f]52
[d3b95f1]53//If an exception is caught we need to change the status and remember to
54//attach the build log to the email
55catch (Exception caughtError) {
56 // Store the result of the build log
57 currentBuild.result = "FAILURE"
[9dd31e7]58
[d3b95f1]59 // An error has occured, the build log is relevent
60 log_needed = true
[9beae23]61
[d3b95f1]62 // rethrow error later
63 err = caughtError
[852ae0ea]64
[d3b95f1]65 // print the error so it shows in the log
66 echo err.toString()
67}
[738cf8f]68
[d3b95f1]69finally {
70 //Send email with final results if this is not a full build
71 email(log_needed)
[9beae23]72
[d3b95f1]73 echo 'Build Completed'
[734891d]74
[d3b95f1]75 /* Must re-throw exception to propagate error */
76 if (err) {
77 throw err
[738cf8f]78 }
79}
[29f4fe62]80//===========================================================================================================
[9beae23]81// Main compilation routines
[29f4fe62]82//===========================================================================================================
[95fdb0a]83def build() {
[e507c11]84 debug = true
85 release = Settings.RunAllTests || Settings.RunBenchmark
[91aa5ab]86 Tools.BuildStage('Build : configure', true) {
[dcf1979]87 // Configure must be run inside the tree
88 dir (SrcDir) {
89 // Generate the necessary build files
90 sh './autogen.sh'
91 }
92
[50f2cfc]93 // Build outside of the src tree to ease cleaning
[5b8413b4]94 dir (BuildDir) {
[8e58264]95 //Configure the compilation (Output is not relevant)
[50f2cfc]96 //Use the current directory as the installation target so nothing escapes the sandbox
97 //Also specify the compiler by hand
[3fc5f010]98 targets=""
[d4510ea]99 if( Settings.RunAllTests || Settings.RunBenchmark ) {
[6bde81d]100 targets="--with-target-hosts='host:debug,host:nodebug'"
[3fc5f010]101 } else {
[6bde81d]102 targets="--with-target-hosts='host:debug'"
[3fc5f010]103 }
104
[d21dd3cb]105 ast = Settings.NewAST ? "--enable-new-ast" : "--disable-new-ast"
106
107 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]108
109 // Configure libcfa
[0b4ddb71]110 sh 'make -j $(nproc) --no-print-directory configure-libcfa'
[e507c11]111 }
112 }
113
[91aa5ab]114 Tools.BuildStage('Build : cfa-cpp', true) {
[e507c11]115 // Build outside of the src tree to ease cleaning
116 dir (BuildDir) {
117 // Build driver
[0b4ddb71]118 sh 'make -j $(nproc) --no-print-directory -C driver'
[e507c11]119
120 // Build translator
[0b4ddb71]121 sh 'make -j $(nproc) --no-print-directory -C src'
[e507c11]122 }
123 }
[1752d0e]124
[91aa5ab]125 Tools.BuildStage('Build : libcfa(debug)', debug) {
[e507c11]126 // Build outside of the src tree to ease cleaning
127 dir (BuildDir) {
[14d5461]128 sh "make -j \$(nproc) --no-print-directory -C libcfa/${Settings.Architecture.name}-debug"
[e507c11]129 }
130 }
131
[91aa5ab]132 Tools.BuildStage('Build : libcfa(nodebug)', release) {
[e507c11]133 // Build outside of the src tree to ease cleaning
134 dir (BuildDir) {
[14d5461]135 sh "make -j \$(nproc) --no-print-directory -C libcfa/${Settings.Architecture.name}-nodebug"
[50f2cfc]136 }
[620dd2b]137 }
[aa96fba]138
[91aa5ab]139 Tools.BuildStage('Build : install', true) {
[aa96fba]140 // Build outside of the src tree to ease cleaning
141 dir (BuildDir) {
[14d5461]142 sh 'make -j $(nproc) --no-print-directory install'
[aa96fba]143 }
144 }
[95fdb0a]145}
[24eecab]146
[95fdb0a]147def test() {
[4c1b9ea8]148 try {
[1baf6ed]149 // Print potential limits before testing
150 // in case jenkins messes with them
[a33dcd5]151 sh 'free -h'
[1baf6ed]152 sh 'ulimit -a'
153
[91aa5ab]154 Tools.BuildStage('Test: short', !Settings.RunAllTests) {
[4c1b9ea8]155 dir (BuildDir) {
[3e93c00]156 //Run the tests from the tests directory
[4c51aca]157 sh "make --no-print-directory -C tests archiveerrors=${BuildDir}/tests/crashes/short"
[3e93c00]158 }
[4c1b9ea8]159 }
160
[91aa5ab]161 Tools.BuildStage('Test: full', Settings.RunAllTests) {
[4c1b9ea8]162 dir (BuildDir) {
[14d5461]163 jopt = '-j $(nproc)'
[7d84369]164 if( Settings.Architecture.node == 'x86' ) {
[14d5461]165 jopt = '-j2'
[7d84369]166 }
[4c1b9ea8]167 //Run the tests from the tests directory
[7d84369]168 sh """make ${jopt} --no-print-directory -C tests timeouts="--timeout=600 --global-timeout=14400" all-tests debug=yes archiveerrors=${BuildDir}/tests/crashes/full-debug"""
169 sh """make ${jopt} --no-print-directory -C tests timeouts="--timeout=600 --global-timeout=14400" all-tests debug=no archiveerrors=${BuildDir}/tests/crashes/full-nodebug"""
[143e6f3]170 }
[9beae23]171 }
[620dd2b]172 }
[4c1b9ea8]173 catch (Exception err) {
174 echo "Archiving core dumps"
[c95fdc9]175 dir (BuildDir) {
[cc9ec56]176 def exists = fileExists 'tests/crashes'
177 if( exists ) {
[cece53c]178 sh """${SrcDir}/tools/jenkins/archive-gen.sh"""
179 archiveArtifacts artifacts: "tests/crashes/**/*,lib/**/lib*.so*,setup.sh", fingerprint: true
180 }
[c95fdc9]181 }
[4c1b9ea8]182 throw err
183 }
[95fdb0a]184}
185
186def benchmark() {
[91aa5ab]187 Tools.BuildStage('Benchmark', Settings.RunBenchmark) {
[5b8413b4]188 dir (BuildDir) {
[0dc3ac3]189 //Append bench results
[c6f1f3e]190 sh "make --no-print-directory -C benchmark jenkins arch=${Settings.Architecture.name}"
[0dc3ac3]191 }
[620dd2b]192 }
[9beae23]193}
[efd60d67]194
[95fdb0a]195def build_doc() {
[91aa5ab]196 Tools.BuildStage('Documentation', Settings.BuildDocumentation) {
[9beae23]197 dir ('doc/user') {
198 make_doc()
199 }
200
201 dir ('doc/refrat') {
202 make_doc()
203 }
[620dd2b]204 }
[9beae23]205}
206
[95fdb0a]207def publish() {
[91aa5ab]208 Tools.BuildStage('Publish', true) {
[95fdb0a]209
[1b3eef8]210 if( Settings.Publish && !Settings.RunBenchmark ) { echo 'No results to publish!!!' }
[620dd2b]211 }
[95fdb0a]212}
213
[29f4fe62]214//===========================================================================================================
215//Routine responsible of sending the email notification once the build is completed
216//===========================================================================================================
[a336d46]217//Standard build email notification
[13c98a4]218def email(boolean log) {
[bd50205]219 node {
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}"
226 def email_body = """<p>This is an automated email from the Jenkins build machine. It was
[1781e97]227generated because of a git hooks/post-receive script following
228a ref change which was pushed to the C\u2200 repository.</p>
[9824500]229
[1781e97]230<p>- Status --------------------------------------------------------------</p>
[9824500]231
[1781e97]232<p>BUILD# ${env.BUILD_NUMBER} - ${currentBuild.result}</p>
233<p>Check console output at ${env.BUILD_URL} to view the results.</p>
234""" + Tools.GitLogMessage()
[bd50205]235
236 def email_to = !Settings.IsSandbox ? "cforall@lists.uwaterloo.ca" : "tdelisle@uwaterloo.ca"
237
238 if( Settings && !Settings.Silent ) {
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 }
[094a42c]246 }
[e8a22a7]247}
[5b8413b4]248
249//===========================================================================================================
250// Helper classes/variables/routines
251//===========================================================================================================
252//Description of a compiler (Must be serializable since pipelines are persistent)
253class CC_Desc implements Serializable {
[93fe3154]254 public String name
255 public String CXX
[6ebc13f]256 public String CC
[bf22bc6]257 public String lto
[93fe3154]258
[bf22bc6]259 CC_Desc(String name, String CXX, String CC, String lto) {
[93fe3154]260 this.name = name
261 this.CXX = CXX
[bf22bc6]262 this.CC = CC
263 this.lto = lto
[5b8413b4]264 }
265}
266
267//Description of an architecture (Must be serializable since pipelines are persistent)
268class Arch_Desc implements Serializable {
269 public String name
270 public String flags
[5307c33]271 public String node
[5b8413b4]272
[5307c33]273 Arch_Desc(String name, String flags, String node) {
[5b8413b4]274 this.name = name
275 this.flags = flags
[5307c33]276 this.node = node
[5b8413b4]277 }
278}
279
280class BuildSettings implements Serializable {
281 public final CC_Desc Compiler
282 public final Arch_Desc Architecture
[d21dd3cb]283 public final Boolean NewAST
[5b8413b4]284 public final Boolean RunAllTests
285 public final Boolean RunBenchmark
286 public final Boolean BuildDocumentation
287 public final Boolean Publish
288 public final Boolean Silent
289 public final Boolean IsSandbox
290 public final String DescLong
291 public final String DescShort
292
[a336d46]293 public String GitNewRef
294 public String GitOldRef
295
[490cb3c]296 BuildSettings(java.util.Collections$UnmodifiableMap param, String branch) {
[5b8413b4]297 switch( param.Compiler ) {
[8110bc3]298 case 'gcc-11':
299 this.Compiler = new CC_Desc('gcc-11', 'g++-11', 'gcc-11', '-flto=auto')
300 break
301 case 'gcc-10':
302 this.Compiler = new CC_Desc('gcc-10', 'g++-10', 'gcc-10', '-flto=auto')
303 break
[099f5bd]304 case 'gcc-9':
[bf22bc6]305 this.Compiler = new CC_Desc('gcc-9', 'g++-9', 'gcc-9', '-flto=auto')
[099f5bd]306 break
307 case 'gcc-8':
[bf22bc6]308 this.Compiler = new CC_Desc('gcc-8', 'g++-8', 'gcc-8', '-flto=auto')
[099f5bd]309 break
310 case 'gcc-7':
[bf22bc6]311 this.Compiler = new CC_Desc('gcc-7', 'g++-7', 'gcc-7', '-flto=auto')
[099f5bd]312 break
[5b8413b4]313 case 'gcc-6':
[bf22bc6]314 this.Compiler = new CC_Desc('gcc-6', 'g++-6', 'gcc-6', '-flto=auto')
[5b8413b4]315 break
316 case 'gcc-5':
[bf22bc6]317 this.Compiler = new CC_Desc('gcc-5', 'g++-5', 'gcc-5', '-flto=auto')
[5b8413b4]318 break
319 case 'gcc-4.9':
[bf22bc6]320 this.Compiler = new CC_Desc('gcc-4.9', 'g++-4.9', 'gcc-4.9', '-flto=auto')
[5b8413b4]321 break
322 case 'clang':
[8110bc3]323 this.Compiler = new CC_Desc('clang', 'clang++-10', 'gcc-10', '-flto=thin -flto-jobs=0')
[5b8413b4]324 break
325 default :
326 error "Unhandled compiler : ${cc}"
327 }
328
329 switch( param.Architecture ) {
330 case 'x64':
[a3e8281]331 this.Architecture = new Arch_Desc('x64', '--host=x86_64', 'x64')
[5b8413b4]332 break
333 case 'x86':
[a3e8281]334 this.Architecture = new Arch_Desc('x86', '--host=i386', 'x86')
[5b8413b4]335 break
336 default :
337 error "Unhandled architecture : ${arch}"
338 }
339
[f95e8f0]340 this.IsSandbox = (branch == "jenkins-sandbox")
[d21dd3cb]341 this.NewAST = param.NewAST
[5b8413b4]342 this.RunAllTests = param.RunAllTests
[7a230fd]343 this.RunBenchmark = param.RunBenchmark
[5b8413b4]344 this.BuildDocumentation = param.BuildDocumentation
[7a230fd]345 this.Publish = param.Publish
[5b8413b4]346 this.Silent = param.Silent
347
348 def full = param.RunAllTests ? " (Full)" : ""
[490cb3c]349 this.DescShort = "${ this.Compiler.name }:${ this.Architecture.name }${full}"
[5b8413b4]350
[fe3d9ab]351 final ast = this.NewAST ? "New AST" : "Old AST"
[93fe3154]352 this.DescLong = """Compiler : ${ this.Compiler.name } (${ this.Compiler.CXX }/${ this.Compiler.CC })
[85799aa]353AST Version : ${ ast.toString() }
[5b8413b4]354Architecture : ${ this.Architecture.name }
355Arc Flags : ${ this.Architecture.flags }
356Run All Tests : ${ this.RunAllTests.toString() }
357Run Benchmark : ${ this.RunBenchmark.toString() }
358Build Documentation : ${ this.BuildDocumentation.toString() }
359Publish : ${ this.Publish.toString() }
360Silent : ${ this.Silent.toString() }
361"""
[a336d46]362
363 this.GitNewRef = ''
364 this.GitOldRef = ''
[5b8413b4]365 }
366}
367
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', \
[b6f39aa]382 choices: 'gcc-11\ngcc-10\ngcc-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}
Note: See TracBrowser for help on using the repository browser.