source: Jenkinsfile@ 05c34c3

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

Reverted local timeout but increased global timeout

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