source: Jenkinsfile_disabled @ 1fcc2f3

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 1fcc2f3 was 1fcc2f3, checked in by Thierry Delisle <tdelisle@…>, 4 years ago

Merge branch 'master' into new-ast

  • Property mode set to 100644
File size: 16.0 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
[85142648]12node('master') {
13        // Globals
14        BuildDir  = pwd tmp: true
15        SrcDir    = pwd tmp: false
16        Settings  = null
17        StageName = ''
[4f9e706]18
[85142648]19        // Local variables
20        def err = null
21        def log_needed = false
[5b8413b4]22
[85142648]23        currentBuild.result = "SUCCESS"
[4f9e706]24
[85142648]25        try {
26                //Wrap build to add timestamp to command line
27                wrap([$class: 'TimestamperBuildWrapper']) {
[0ef06b6]28
[85142648]29                        Settings = prepare_build()
[952ee7a]30
[85142648]31                        node(Settings.Architecture.node) {
32                                BuildDir  = pwd tmp: true
33                                SrcDir    = pwd tmp: false
[23a14d86]34
[85142648]35                                clean()
[7aebc62]36
[85142648]37                                checkout()
[fde808df]38
[85142648]39                                build()
[95fdb0a]40
[85142648]41                                test()
[95fdb0a]42
[85142648]43                                benchmark()
[95fdb0a]44
[85142648]45                                build_doc()
[7359098]46
[85142648]47                                publish()
48                        }
[9beae23]49
[85142648]50                        // Update the build directories when exiting the node
51                        BuildDir  = pwd tmp: true
52                        SrcDir    = pwd tmp: false
[9beae23]53                }
[738cf8f]54        }
55
[85142648]56        //If an exception is caught we need to change the status and remember to
57        //attach the build log to the email
58        catch (Exception caughtError) {
59                //rethrow error later
60                err = caughtError
[738cf8f]61
[85142648]62                echo err.toString()
[e966ec0]63
[85142648]64                //An error has occured, the build log is relevent
65                log_needed = true
[9beae23]66
[85142648]67                //Store the result of the build log
68                currentBuild.result = "${StageName} FAILURE".trim()
69        }
[738cf8f]70
[85142648]71        finally {
72                //Send email with final results if this is not a full build
73                email(log_needed)
[9beae23]74
[85142648]75                echo 'Build Completed'
[734891d]76
[85142648]77                /* Must re-throw exception to propagate error */
78                if (err) {
79                        throw err
80                }
[738cf8f]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
[d3a4564]102
[a336d46]103                echo GitLogMessage()
[0dc3ac3]104        }
105}
106
[95fdb0a]107def build() {
[e507c11]108        debug = true
109        release = Settings.RunAllTests || Settings.RunBenchmark
110        build_stage('Build : configure', true) {
[50f2cfc]111                // Build outside of the src tree to ease cleaning
[5b8413b4]112                dir (BuildDir) {
[50f2cfc]113                        //Configure the conpilation (Output is not relevant)
114                        //Use the current directory as the installation target so nothing escapes the sandbox
115                        //Also specify the compiler by hand
[3fc5f010]116                        targets=""
[d4510ea]117                        if( Settings.RunAllTests || Settings.RunBenchmark ) {
[6bde81d]118                                targets="--with-target-hosts='host:debug,host:nodebug'"
[3fc5f010]119                        } else {
[6bde81d]120                                targets="--with-target-hosts='host:debug'"
[3fc5f010]121                        }
122
[93fe3154]123                        sh "${SrcDir}/configure CXX=${Settings.Compiler.CXX} CC=${Settings.Compiler.CC} ${Settings.Architecture.flags} ${targets} --quiet"
[f253e4a]124
125                        // Configure libcfa
[e70e54e]126                        sh 'make -j 8 --no-print-directory configure-libcfa'
[e507c11]127                }
128        }
129
130        build_stage('Build : cfa-cpp', true) {
131                // Build outside of the src tree to ease cleaning
132                dir (BuildDir) {
133                        // Build driver
134                        sh 'make -j 8 --no-print-directory -C driver'
135
136                        // Build translator
137                        sh 'make -j 8 --no-print-directory -C src'
138                }
139        }
[1752d0e]140
[e507c11]141        build_stage('Build : libcfa(debug)', debug) {
142                // Build outside of the src tree to ease cleaning
143                dir (BuildDir) {
144                        sh "make -j 8 --no-print-directory -C libcfa/${Settings.Architecture.name}-debug"
145                }
146        }
147
148        build_stage('Build : libcfa(nodebug)', release) {
149                // Build outside of the src tree to ease cleaning
150                dir (BuildDir) {
151                        sh "make -j 8 --no-print-directory -C libcfa/${Settings.Architecture.name}-nodebug"
[50f2cfc]152                }
[620dd2b]153        }
[95fdb0a]154}
[24eecab]155
[95fdb0a]156def test() {
[4c1b9ea8]157        try {
158                build_stage('Test: short', !Settings.RunAllTests) {
159                        dir (BuildDir) {
[3e93c00]160                                //Run the tests from the tests directory
[4c51aca]161                                sh "make --no-print-directory -C tests archiveerrors=${BuildDir}/tests/crashes/short"
[3e93c00]162                        }
[4c1b9ea8]163                }
164
165                build_stage('Test: full', Settings.RunAllTests) {
166                        dir (BuildDir) {
167                                        //Run the tests from the tests directory
[4c51aca]168                                        sh """make --no-print-directory -C tests timeouts="--timeout=600 --global-timeout=14400" all-tests debug=yes archiveerrors=${BuildDir}/tests/crashes/full-debug"""
169                                        sh """make --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) {
176                        archiveArtifacts artifacts: "tests/crashes/**/*", fingerprint: true
177                }
[4c1b9ea8]178                throw err
179        }
[95fdb0a]180}
181
182def benchmark() {
[6c55a3d]183        build_stage('Benchmark', Settings.RunBenchmark) {
[5b8413b4]184                dir (BuildDir) {
[0dc3ac3]185                        //Append bench results
[c6f1f3e]186                        sh "make --no-print-directory -C benchmark jenkins arch=${Settings.Architecture.name}"
[0dc3ac3]187                }
[620dd2b]188        }
[9beae23]189}
[efd60d67]190
[95fdb0a]191def build_doc() {
[6c55a3d]192        build_stage('Documentation', Settings.BuildDocumentation) {
[9beae23]193                dir ('doc/user') {
194                        make_doc()
195                }
196
197                dir ('doc/refrat') {
198                        make_doc()
199                }
[620dd2b]200        }
[9beae23]201}
202
[95fdb0a]203def publish() {
[6c55a3d]204        build_stage('Publish', true) {
[95fdb0a]205
[1b3eef8]206                if( Settings.Publish && !Settings.RunBenchmark ) { echo 'No results to publish!!!' }
[95fdb0a]207
[3221a2b]208                def groupCompile = new PlotGroup('Compilation', 'duration (s) - lower is better', true)
209                def groupConcurrency = new PlotGroup('Concurrency', 'duration (n) - lower is better', false)
[a2a0065]210
[3898392]211                //Then publish the results
[3221a2b]212                do_plot(Settings.RunBenchmark && Settings.Publish, 'compile'       , groupCompile    , false, 'Compilation')
213                do_plot(Settings.RunBenchmark && Settings.Publish, 'compile.diff'  , groupCompile    , true , 'Compilation (relative)')
214                do_plot(Settings.RunBenchmark && Settings.Publish, 'ctxswitch'     , groupConcurrency, false, 'Context Switching')
215                do_plot(Settings.RunBenchmark && Settings.Publish, 'ctxswitch.diff', groupConcurrency, true , 'Context Switching (relative)')
216                do_plot(Settings.RunBenchmark && Settings.Publish, 'mutex'         , groupConcurrency, false, 'Mutual Exclusion')
217                do_plot(Settings.RunBenchmark && Settings.Publish, 'mutex.diff'    , groupConcurrency, true , 'Mutual Exclusion (relative)')
218                do_plot(Settings.RunBenchmark && Settings.Publish, 'signal'        , groupConcurrency, false, 'Internal and External Scheduling')
219                do_plot(Settings.RunBenchmark && Settings.Publish, 'signal.diff'   , groupConcurrency, true , 'Internal and External Scheduling (relative)')
[620dd2b]220        }
[95fdb0a]221}
222
[29f4fe62]223//===========================================================================================================
224//Routine responsible of sending the email notification once the build is completed
225//===========================================================================================================
[6b6c26e]226@NonCPS
227def SplitLines(String text) {
228        def list = []
229
230        text.eachLine {
231                list += it
232        }
233
234        return list
235}
236
[a336d46]237def GitLogMessage() {
238        if (!Settings || !Settings.GitOldRef || !Settings.GitNewRef) return "\nERROR retrieveing git information!\n"
[e8a22a7]239
[fce01e7]240        def oldRef = Settings.GitOldRef
241        def newRef = Settings.GitNewRef
[6badd87]242
[fdb6ac6]243        def revText = sh(returnStdout: true, script: "git rev-list ${oldRef}..${newRef}").trim()
[6b6c26e]244        def revList = SplitLines( revText )
[6e31c43]245
[fdb6ac6]246        def gitUpdate = ""
247        revList.each { rev ->
[249091f]248                def type = sh(returnStdout: true, script: "git cat-file -t ${rev}").trim()
[fce01e7]249                gitUpdate = gitUpdate + "       via  ${rev} (${type})"
250        }
251
252        def rev = oldRef
[249091f]253        def type = sh(returnStdout: true, script: "git cat-file -t ${rev}").trim()
254        gitUpdate = gitUpdate + "      from  ${rev} (${type})"
[fce01e7]255
[249091f]256        def gitLog    = sh(returnStdout: true, script: "git rev-list --format=short ${oldRef}...${newRef}").trim()
[fce01e7]257
[249091f]258        def gitDiff   = sh(returnStdout: true, script: "git diff --stat --color ${newRef} ${oldRef}").trim()
[fce01e7]259        gitDiff = gitDiff.replace('[32m', '<span style="color: #00AA00;">')
260        gitDiff = gitDiff.replace('[31m', '<span style="color: #AA0000;">')
261        gitDiff = gitDiff.replace('[m', '</span>')
[7a927ed0]262
[a336d46]263        return """
[13c98a4]264<pre>
[848fb00]265The branch ${env.BRANCH_NAME} has been updated.
[7a927ed0]266${gitUpdate}
[13c98a4]267</pre>
268
269<p>Check console output at ${env.BUILD_URL} to view the results.</p>
[7b1a604]270
[13c98a4]271<p>- Status --------------------------------------------------------------</p>
[7b1a604]272
[13c98a4]273<p>BUILD# ${env.BUILD_NUMBER} - ${currentBuild.result}</p>
[7b1a604]274
[13c98a4]275<p>- Log -----------------------------------------------------------------</p>
[e8a22a7]276
[13c98a4]277<pre>
[7a927ed0]278${gitLog}
[13c98a4]279</pre>
280
281<p>-----------------------------------------------------------------------</p>
282<pre>
[7b1a604]283Summary of changes:
[7a927ed0]284${gitDiff}
[13c98a4]285</pre>
[7b1a604]286"""
[a336d46]287}
288
289//Standard build email notification
[13c98a4]290def email(boolean log) {
[a336d46]291        //Since tokenizer doesn't work, figure stuff out from the environnement variables and command line
292        //Configurations for email format
293        echo 'Notifying users of result'
294
295        def project_name = (env.JOB_NAME =~ /(.+)\/.+/)[0][1].toLowerCase()
296        def email_subject = "[${project_name} git][BUILD# ${env.BUILD_NUMBER} - ${currentBuild.result}] - branch ${env.BRANCH_NAME}"
[13c98a4]297        def email_body = """<p>This is an automated email from the Jenkins build machine. It was
[a336d46]298generated because of a git hooks/post-receive script following
[986e260]299a ref change which was pushed to the C\u2200 repository.</p>
[a336d46]300""" + GitLogMessage()
[e8a22a7]301
[13c98a4]302        def email_to = !Settings.IsSandbox ? "cforall@lists.uwaterloo.ca" : "tdelisle@uwaterloo.ca"
[e8a22a7]303
[13c98a4]304        if( Settings && !Settings.Silent ) {
[094a42c]305                //send email notification
306                emailext body: email_body, subject: email_subject, to: email_to, attachLog: log
307        } else {
308                echo "Would send email to: ${email_to}"
309                echo "With title: ${email_subject}"
310                echo "Content: \n${email_body}"
311        }
[e8a22a7]312}
[5b8413b4]313
314//===========================================================================================================
315// Helper classes/variables/routines
316//===========================================================================================================
317//Description of a compiler (Must be serializable since pipelines are persistent)
318class CC_Desc implements Serializable {
[93fe3154]319        public String name
320        public String CXX
[6ebc13f]321        public String CC
[93fe3154]322
[6ebc13f]323        CC_Desc(String name, String CXX, String CC) {
[93fe3154]324                this.name = name
325                this.CXX = CXX
[6ebc13f]326                this.CC = CC
[5b8413b4]327        }
328}
329
330//Description of an architecture (Must be serializable since pipelines are persistent)
331class Arch_Desc implements Serializable {
332        public String name
333        public String flags
[5307c33]334        public String node
[5b8413b4]335
[5307c33]336        Arch_Desc(String name, String flags, String node) {
[5b8413b4]337                this.name  = name
338                this.flags = flags
[5307c33]339                this.node  = node
[5b8413b4]340        }
341}
342
343class BuildSettings implements Serializable {
344        public final CC_Desc Compiler
345        public final Arch_Desc Architecture
346        public final Boolean RunAllTests
347        public final Boolean RunBenchmark
348        public final Boolean BuildDocumentation
349        public final Boolean Publish
350        public final Boolean Silent
351        public final Boolean IsSandbox
352        public final String DescLong
353        public final String DescShort
354
[a336d46]355        public String GitNewRef
356        public String GitOldRef
357
[490cb3c]358        BuildSettings(java.util.Collections$UnmodifiableMap param, String branch) {
[5b8413b4]359                switch( param.Compiler ) {
[099f5bd]360                        case 'gcc-9':
361                                this.Compiler = new CC_Desc('gcc-9', 'g++-9', 'gcc-9')
362                        break
363                        case 'gcc-8':
364                                this.Compiler = new CC_Desc('gcc-8', 'g++-8', 'gcc-8')
365                        break
366                        case 'gcc-7':
367                                this.Compiler = new CC_Desc('gcc-7', 'g++-7', 'gcc-7')
368                        break
[5b8413b4]369                        case 'gcc-6':
370                                this.Compiler = new CC_Desc('gcc-6', 'g++-6', 'gcc-6')
371                        break
372                        case 'gcc-5':
373                                this.Compiler = new CC_Desc('gcc-5', 'g++-5', 'gcc-5')
374                        break
375                        case 'gcc-4.9':
376                                this.Compiler = new CC_Desc('gcc-4.9', 'g++-4.9', 'gcc-4.9')
377                        break
378                        case 'clang':
[099f5bd]379                                this.Compiler = new CC_Desc('clang', 'clang++-6.0', 'gcc-6')
[5b8413b4]380                        break
381                        default :
382                                error "Unhandled compiler : ${cc}"
383                }
384
385                switch( param.Architecture ) {
386                        case 'x64':
[a3e8281]387                                this.Architecture = new Arch_Desc('x64', '--host=x86_64', 'x64')
[5b8413b4]388                        break
389                        case 'x86':
[a3e8281]390                                this.Architecture = new Arch_Desc('x86', '--host=i386', 'x86')
[5b8413b4]391                        break
392                        default :
393                                error "Unhandled architecture : ${arch}"
394                }
395
[f95e8f0]396                this.IsSandbox          = (branch == "jenkins-sandbox")
[5b8413b4]397                this.RunAllTests        = param.RunAllTests
[7a230fd]398                this.RunBenchmark       = param.RunBenchmark
[5b8413b4]399                this.BuildDocumentation = param.BuildDocumentation
[7a230fd]400                this.Publish            = param.Publish
[5b8413b4]401                this.Silent             = param.Silent
402
403                def full = param.RunAllTests ? " (Full)" : ""
[490cb3c]404                this.DescShort = "${ this.Compiler.name }:${ this.Architecture.name }${full}"
[5b8413b4]405
[93fe3154]406                this.DescLong = """Compiler              : ${ this.Compiler.name } (${ this.Compiler.CXX }/${ this.Compiler.CC })
[5b8413b4]407Architecture            : ${ this.Architecture.name }
408Arc Flags               : ${ this.Architecture.flags }
409Run All Tests           : ${ this.RunAllTests.toString() }
410Run Benchmark           : ${ this.RunBenchmark.toString() }
411Build Documentation     : ${ this.BuildDocumentation.toString() }
412Publish                 : ${ this.Publish.toString() }
413Silent                  : ${ this.Silent.toString() }
414"""
[a336d46]415
416                this.GitNewRef = ''
417                this.GitOldRef = ''
[5b8413b4]418        }
419}
420
[490cb3c]421class PlotGroup implements Serializable {
422        public String name
423        public String unit
424        public boolean log
425
426        PlotGroup(String name, String unit, boolean log) {
427                this.name = name
428                this.unit = unit
429                this.log = log
430        }
431}
432
[5b8413b4]433def prepare_build() {
434        // prepare the properties
435        properties ([                                                                                                   \
436                [$class: 'ParametersDefinitionProperty',                                                                \
437                        parameterDefinitions: [                                                                         \
438                                [$class: 'ChoiceParameterDefinition',                                           \
439                                        description: 'Which compiler to use',                                   \
440                                        name: 'Compiler',                                                                       \
[fe27d99]441                                        choices: 'gcc-9\ngcc-8\ngcc-7\ngcc-6\ngcc-5\ngcc-4.9\nclang',                                   \
442                                        defaultValue: 'gcc-8',                                                          \
[5b8413b4]443                                ],                                                                                              \
444                                [$class: 'ChoiceParameterDefinition',                                           \
445                                        description: 'The target architecture',                                 \
446                                        name: 'Architecture',                                                           \
447                                        choices: 'x64\nx86',                                                            \
448                                        defaultValue: 'x64',                                                            \
449                                ],                                                                                              \
450                                [$class: 'BooleanParameterDefinition',                                                  \
451                                        description: 'If false, only the quick test suite is ran',              \
452                                        name: 'RunAllTests',                                                            \
453                                        defaultValue: false,                                                            \
454                                ],                                                                                              \
455                                [$class: 'BooleanParameterDefinition',                                                  \
456                                        description: 'If true, jenkins also runs benchmarks',           \
457                                        name: 'RunBenchmark',                                                           \
458                                        defaultValue: false,                                                            \
459                                ],                                                                                              \
460                                [$class: 'BooleanParameterDefinition',                                                  \
461                                        description: 'If true, jenkins also builds documentation',              \
462                                        name: 'BuildDocumentation',                                                     \
463                                        defaultValue: true,                                                             \
464                                ],                                                                                              \
465                                [$class: 'BooleanParameterDefinition',                                                  \
466                                        description: 'If true, jenkins also publishes results',                 \
467                                        name: 'Publish',                                                                        \
468                                        defaultValue: false,                                                            \
469                                ],                                                                                              \
470                                [$class: 'BooleanParameterDefinition',                                                  \
471                                        description: 'If true, jenkins will not send emails',           \
472                                        name: 'Silent',                                                                         \
473                                        defaultValue: false,                                                            \
474                                ],                                                                                              \
475                        ],
476                ]])
477
[4c55047]478        // It's unfortunate but it looks like we need to checkout the entire repo just to get the pretty git printer
479        checkout scm
[2407853]480
[490cb3c]481        final settings = new BuildSettings(params, env.BRANCH_NAME)
[5b8413b4]482
483        currentBuild.description = settings.DescShort
484        echo                       settings.DescLong
485
486        return settings
487}
488
[6c55a3d]489def build_stage(String name, boolean run, Closure block ) {
[5b8413b4]490        StageName = name
491        echo " -------- ${StageName} -------- "
[8ecb590]492        if(run) {
493                stage(name, block)
494        } else {
495                stage(name) { Utils.markStageSkippedForConditional(STAGE_NAME) }
496        }
[5b8413b4]497}
498
499def make_doc() {
500        def err = null
501        try {
502                sh 'make clean > /dev/null'
503                sh 'make > /dev/null 2>&1'
504        }
505        catch (Exception caughtError) {
506                err = caughtError //rethrow error later
[65f4a51]507                sh 'cat build/*.log'
[5b8413b4]508        }
509        finally {
510                if (err) throw err // Must re-throw exception to propagate error
511        }
[a2a0065]512}
513
[3221a2b]514def do_plot(boolean new_data, String file, PlotGroup group, boolean relative, String title) {
[8d63649]515
[1b3eef8]516        if(new_data) {
517                echo "Publishing new data"
518        }
519
[cdcd53dc]520        def series = new_data ? [[
[df57a84]521                                file: "${file}.csv",
[3c40dc2a]522                                exclusionValues: '',
523                                displayTableFlag: false,
524                                inclusionFlag: 'OFF',
525                                url: ''
[cdcd53dc]526                        ]] : [];
[8d63649]527
528        echo "file is ${BuildDir}/benchmark/${file}.csv, group ${group}, title ${title}"
529        dir("${BuildDir}/benchmark/") {
530                plot csvFileName: "cforall-${env.BRANCH_NAME}-${file}.csv",
531                        csvSeries: series,
[490cb3c]532                        group: "${group.name}",
[3c40dc2a]533                        title: "${title}",
534                        style: 'lineSimple',
535                        exclZero: false,
536                        keepRecords: false,
[3221a2b]537                        logarithmic: !relative && group.log,
[3c40dc2a]538                        numBuilds: '120',
539                        useDescr: true,
[490cb3c]540                        yaxis: group.unit,
[3c40dc2a]541                        yaxisMaximum: '',
542                        yaxisMinimum: ''
[df57a84]543        }
544}
Note: See TracBrowser for help on using the repository browser.