source: Jenkinsfile @ 74b0de43

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

Tentative to lint FullBuild? on fast compile

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