Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Jenkinsfile

    rabc2a643 re11957e  
    22
    33import groovy.transform.Field
     4
     5// For skipping stages
     6import org.jenkinsci.plugins.pipeline.modeldefinition.Utils
    47
    58//===========================================================================================================
     
    1215        SrcDir    = pwd tmp: false
    1316        Settings  = null
    14         Tools     = null
     17        StageName = ''
    1518
    1619        // Local variables
     
    3033                                SrcDir    = pwd tmp: false
    3134
    32                                 Tools.Clean()
    33 
    34                                 Tools.Checkout()
     35                                clean()
     36
     37                                checkout()
    3538
    3639                                build()
     
    5457        //attach the build log to the email
    5558        catch (Exception caughtError) {
    56                 // Store the result of the build log
    57                 currentBuild.result = "FAILURE"
    58 
    59                 // An error has occured, the build log is relevent
     59                //rethrow error later
     60                err = caughtError
     61
     62                echo err.toString()
     63
     64                //An error has occured, the build log is relevent
    6065                log_needed = true
    6166
    62                 // rethrow error later
    63                 err = caughtError
    64 
    65                 // print the error so it shows in the log
    66                 echo err.toString()
     67                //Store the result of the build log
     68                currentBuild.result = "${StageName} FAILURE".trim()
    6769        }
    6870
     
    8284// Main compilation routines
    8385//===========================================================================================================
     86def clean() {
     87        build_stage('Cleanup', true) {
     88                // clean the build by wipping the build directory
     89                dir(BuildDir) {
     90                        deleteDir()
     91                }
     92        }
     93}
     94
     95//Compilation script is done here but environnement set-up and error handling is done in main loop
     96def checkout() {
     97        build_stage('Checkout', true) {
     98                //checkout the source code and clean the repo
     99                final scmVars = checkout scm
     100                Settings.GitNewRef = scmVars.GIT_COMMIT
     101                Settings.GitOldRef = scmVars.GIT_PREVIOUS_COMMIT
     102
     103                echo GitLogMessage()
     104
     105                // This is a complete hack but it solves problems with automake thinking it needs to regenerate makefiles
     106                // We fudged automake/missing to handle that but automake stills bakes prints inside the makefiles
     107                // and these cause more problems.
     108                sh 'find . -name Makefile.in -exec touch {} +'
     109        }
     110}
     111
    84112def build() {
    85113        debug = true
    86114        release = Settings.RunAllTests || Settings.RunBenchmark
    87         Tools.BuildStage('Build : configure', true) {
    88                 // Configure must be run inside the tree
    89                 dir (SrcDir) {
    90                         // Generate the necessary build files
    91                         sh './autogen.sh'
    92                 }
    93 
     115        build_stage('Build : configure', true) {
    94116                // Build outside of the src tree to ease cleaning
    95117                dir (BuildDir) {
    96                         //Configure the compilation (Output is not relevant)
     118                        //Configure the conpilation (Output is not relevant)
    97119                        //Use the current directory as the installation target so nothing escapes the sandbox
    98120                        //Also specify the compiler by hand
     
    104126                        }
    105127
    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}"
     128                        sh "${SrcDir}/configure CXX=${Settings.Compiler.CXX} CC=${Settings.Compiler.CC} ${Settings.Architecture.flags} ${targets} --quiet"
    109129
    110130                        // Configure libcfa
     
    113133        }
    114134
    115         Tools.BuildStage('Build : cfa-cpp', true) {
     135        build_stage('Build : cfa-cpp', true) {
    116136                // Build outside of the src tree to ease cleaning
    117137                dir (BuildDir) {
     
    124144        }
    125145
    126         Tools.BuildStage('Build : libcfa(debug)', debug) {
     146        build_stage('Build : libcfa(debug)', debug) {
    127147                // Build outside of the src tree to ease cleaning
    128148                dir (BuildDir) {
     
    131151        }
    132152
    133         Tools.BuildStage('Build : libcfa(nodebug)', release) {
     153        build_stage('Build : libcfa(nodebug)', release) {
    134154                // Build outside of the src tree to ease cleaning
    135155                dir (BuildDir) {
     
    137157                }
    138158        }
    139 
    140         Tools.BuildStage('Build : install', true) {
    141                 // Build outside of the src tree to ease cleaning
    142                 dir (BuildDir) {
    143                         sh "make -j 8 --no-print-directory install"
    144                 }
    145         }
    146159}
    147160
    148161def test() {
    149162        try {
    150                 Tools.BuildStage('Test: short', !Settings.RunAllTests) {
     163                build_stage('Test: short', !Settings.RunAllTests) {
    151164                        dir (BuildDir) {
    152165                                //Run the tests from the tests directory
     
    155168                }
    156169
    157                 Tools.BuildStage('Test: full', Settings.RunAllTests) {
     170                build_stage('Test: full', Settings.RunAllTests) {
    158171                        dir (BuildDir) {
    159172                                        //Run the tests from the tests directory
     
    166179                echo "Archiving core dumps"
    167180                dir (BuildDir) {
    168                         archiveArtifacts artifacts: "tests/crashes/**/*,lib/**/lib*.so*", fingerprint: true
     181                        archiveArtifacts artifacts: "tests/crashes/**/*", fingerprint: true
    169182                }
    170183                throw err
     
    173186
    174187def benchmark() {
    175         Tools.BuildStage('Benchmark', Settings.RunBenchmark) {
     188        build_stage('Benchmark', Settings.RunBenchmark) {
    176189                dir (BuildDir) {
    177190                        //Append bench results
     
    182195
    183196def build_doc() {
    184         Tools.BuildStage('Documentation', Settings.BuildDocumentation) {
     197        build_stage('Documentation', Settings.BuildDocumentation) {
    185198                dir ('doc/user') {
    186199                        make_doc()
     
    194207
    195208def publish() {
    196         Tools.BuildStage('Publish', true) {
     209        build_stage('Publish', true) {
    197210
    198211                if( Settings.Publish && !Settings.RunBenchmark ) { echo 'No results to publish!!!' }
     
    202215
    203216                //Then publish the results
    204                 do_plot(Settings.RunBenchmark && Settings.Publish, 'compile'        , groupCompile    , false, 'Compilation')
    205                 do_plot(Settings.RunBenchmark && Settings.Publish, 'compile.diff'   , groupCompile    , true , 'Compilation (relative)')
    206                 do_plot(Settings.RunBenchmark && Settings.Publish, 'ctxswitch'      , groupConcurrency, false, 'Context Switching')
    207                 do_plot(Settings.RunBenchmark && Settings.Publish, 'ctxswitch.diff' , groupConcurrency, true , 'Context Switching (relative)')
    208                 do_plot(Settings.RunBenchmark && Settings.Publish, 'mutex'          , groupConcurrency, false, 'Mutual Exclusion')
    209                 do_plot(Settings.RunBenchmark && Settings.Publish, 'mutex.diff'     , groupConcurrency, true , 'Mutual Exclusion (relative)')
    210                 do_plot(Settings.RunBenchmark && Settings.Publish, 'scheduling'     , groupConcurrency, false, 'Internal and External Scheduling')
    211                 do_plot(Settings.RunBenchmark && Settings.Publish, 'scheduling.diff', groupConcurrency, true , 'Internal and External Scheduling (relative)')
     217                do_plot(Settings.RunBenchmark && Settings.Publish, 'compile'       , groupCompile    , false, 'Compilation')
     218                do_plot(Settings.RunBenchmark && Settings.Publish, 'compile.diff'  , groupCompile    , true , 'Compilation (relative)')
     219                do_plot(Settings.RunBenchmark && Settings.Publish, 'ctxswitch'     , groupConcurrency, false, 'Context Switching')
     220                do_plot(Settings.RunBenchmark && Settings.Publish, 'ctxswitch.diff', groupConcurrency, true , 'Context Switching (relative)')
     221                do_plot(Settings.RunBenchmark && Settings.Publish, 'mutex'         , groupConcurrency, false, 'Mutual Exclusion')
     222                do_plot(Settings.RunBenchmark && Settings.Publish, 'mutex.diff'    , groupConcurrency, true , 'Mutual Exclusion (relative)')
     223                do_plot(Settings.RunBenchmark && Settings.Publish, 'signal'        , groupConcurrency, false, 'Internal and External Scheduling')
     224                do_plot(Settings.RunBenchmark && Settings.Publish, 'signal.diff'   , groupConcurrency, true , 'Internal and External Scheduling (relative)')
    212225        }
    213226}
     
    216229//Routine responsible of sending the email notification once the build is completed
    217230//===========================================================================================================
     231@NonCPS
     232def SplitLines(String text) {
     233        def list = []
     234
     235        text.eachLine {
     236                list += it
     237        }
     238
     239        return list
     240}
     241
     242def GitLogMessage() {
     243        if (!Settings || !Settings.GitOldRef || !Settings.GitNewRef) return "\nERROR retrieveing git information!\n"
     244
     245        def oldRef = Settings.GitOldRef
     246        def newRef = Settings.GitNewRef
     247
     248        def revText = sh(returnStdout: true, script: "git rev-list ${oldRef}..${newRef}").trim()
     249        def revList = SplitLines( revText )
     250
     251        def gitUpdate = ""
     252        revList.each { rev ->
     253                def type = sh(returnStdout: true, script: "git cat-file -t ${rev}").trim()
     254                gitUpdate = gitUpdate + "       via  ${rev} (${type})"
     255        }
     256
     257        def rev = oldRef
     258        def type = sh(returnStdout: true, script: "git cat-file -t ${rev}").trim()
     259        gitUpdate = gitUpdate + "      from  ${rev} (${type})"
     260
     261        def gitLog    = sh(returnStdout: true, script: "git rev-list --format=short ${oldRef}...${newRef}").trim()
     262
     263        def gitDiff   = sh(returnStdout: true, script: "git diff --stat --color ${newRef} ${oldRef}").trim()
     264        gitDiff = gitDiff.replace('[32m', '<span style="color: #00AA00;">')
     265        gitDiff = gitDiff.replace('[31m', '<span style="color: #AA0000;">')
     266        gitDiff = gitDiff.replace('[m', '</span>')
     267
     268        return """
     269<pre>
     270The branch ${env.BRANCH_NAME} has been updated.
     271${gitUpdate}
     272</pre>
     273
     274<p>Check console output at ${env.BUILD_URL} to view the results.</p>
     275
     276<p>- Status --------------------------------------------------------------</p>
     277
     278<p>BUILD# ${env.BUILD_NUMBER} - ${currentBuild.result}</p>
     279
     280<p>- Log -----------------------------------------------------------------</p>
     281
     282<pre>
     283${gitLog}
     284</pre>
     285
     286<p>-----------------------------------------------------------------------</p>
     287<pre>
     288Summary of changes:
     289${gitDiff}
     290</pre>
     291"""
     292}
     293
    218294//Standard build email notification
    219295def email(boolean log) {
     
    227303generated because of a git hooks/post-receive script following
    228304a ref change which was pushed to the C\u2200 repository.</p>
    229 """ + Tools.GitLogMessage()
     305""" + GitLogMessage()
    230306
    231307        def email_to = !Settings.IsSandbox ? "cforall@lists.uwaterloo.ca" : "tdelisle@uwaterloo.ca"
     
    249325        public String CXX
    250326        public String CC
    251         public String lto
    252 
    253         CC_Desc(String name, String CXX, String CC, String lto) {
     327
     328        CC_Desc(String name, String CXX, String CC) {
    254329                this.name = name
    255330                this.CXX = CXX
    256                 this.CC  = CC
    257                 this.lto = lto
     331                this.CC = CC
    258332        }
    259333}
     
    275349        public final CC_Desc Compiler
    276350        public final Arch_Desc Architecture
    277         public final Boolean NewAST
    278351        public final Boolean RunAllTests
    279352        public final Boolean RunBenchmark
     
    291364                switch( param.Compiler ) {
    292365                        case 'gcc-9':
    293                                 this.Compiler = new CC_Desc('gcc-9', 'g++-9', 'gcc-9', '-flto=auto')
     366                                this.Compiler = new CC_Desc('gcc-9', 'g++-9', 'gcc-9')
    294367                        break
    295368                        case 'gcc-8':
    296                                 this.Compiler = new CC_Desc('gcc-8', 'g++-8', 'gcc-8', '-flto=auto')
     369                                this.Compiler = new CC_Desc('gcc-8', 'g++-8', 'gcc-8')
    297370                        break
    298371                        case 'gcc-7':
    299                                 this.Compiler = new CC_Desc('gcc-7', 'g++-7', 'gcc-7', '-flto=auto')
     372                                this.Compiler = new CC_Desc('gcc-7', 'g++-7', 'gcc-7')
    300373                        break
    301374                        case 'gcc-6':
    302                                 this.Compiler = new CC_Desc('gcc-6', 'g++-6', 'gcc-6', '-flto=auto')
     375                                this.Compiler = new CC_Desc('gcc-6', 'g++-6', 'gcc-6')
    303376                        break
    304377                        case 'gcc-5':
    305                                 this.Compiler = new CC_Desc('gcc-5', 'g++-5', 'gcc-5', '-flto=auto')
     378                                this.Compiler = new CC_Desc('gcc-5', 'g++-5', 'gcc-5')
    306379                        break
    307380                        case 'gcc-4.9':
    308                                 this.Compiler = new CC_Desc('gcc-4.9', 'g++-4.9', 'gcc-4.9', '-flto=auto')
     381                                this.Compiler = new CC_Desc('gcc-4.9', 'g++-4.9', 'gcc-4.9')
    309382                        break
    310383                        case 'clang':
    311                                 this.Compiler = new CC_Desc('clang', 'clang++-10', 'gcc-9', '-flto=thin -flto-jobs=0')
     384                                this.Compiler = new CC_Desc('clang', 'clang++-6.0', 'gcc-6')
    312385                        break
    313386                        default :
     
    327400
    328401                this.IsSandbox          = (branch == "jenkins-sandbox")
    329                 this.NewAST             = param.NewAST
    330402                this.RunAllTests        = param.RunAllTests
    331403                this.RunBenchmark       = param.RunBenchmark
     
    337409                this.DescShort = "${ this.Compiler.name }:${ this.Architecture.name }${full}"
    338410
    339                 final ast = this.NewAST ? "New AST" : "Old AST"
    340411                this.DescLong = """Compiler              : ${ this.Compiler.name } (${ this.Compiler.CXX }/${ this.Compiler.CC })
    341 AST Version             : ${ ast.toString() }
    342412Architecture            : ${ this.Architecture.name }
    343413Arc Flags               : ${ this.Architecture.flags }
     
    369439        // prepare the properties
    370440        properties ([                                                                                                   \
    371                 buildDiscarder(logRotator(                                                                              \
    372                         artifactDaysToKeepStr: '',                                                                      \
    373                         artifactNumToKeepStr: '',                                                                       \
    374                         daysToKeepStr: '730',                                                                           \
    375                         numToKeepStr: '1000'                                                                            \
    376                 )),                                                                                                             \
    377441                [$class: 'ParametersDefinitionProperty',                                                                \
    378442                        parameterDefinitions: [                                                                         \
     
    380444                                        description: 'Which compiler to use',                                   \
    381445                                        name: 'Compiler',                                                                       \
    382                                         choices: 'gcc-9\ngcc-8\ngcc-7\ngcc-6\ngcc-5\ngcc-4.9\nclang',   \
     446                                        choices: 'gcc-9\ngcc-8\ngcc-7\ngcc-6\ngcc-5\ngcc-4.9\nclang',                                   \
    383447                                        defaultValue: 'gcc-8',                                                          \
    384448                                ],                                                                                              \
     
    389453                                        defaultValue: 'x64',                                                            \
    390454                                ],                                                                                              \
    391                                 [$class: 'BooleanParameterDefinition',                                                  \
    392                                         description: 'If true, build compiler using new AST',           \
    393                                         name: 'NewAST',                                                                         \
    394                                         defaultValue: true,                                                             \
    395                                 ],                                                                                              \
    396455                                [$class: 'BooleanParameterDefinition',                                                  \
    397456                                        description: 'If false, only the quick test suite is ran',              \
     
    422481                ]])
    423482
    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
     483        // It's unfortunate but it looks like we need to checkout the entire repo just to get the pretty git printer
    427484        checkout scm
    428 
    429         Tools = load "Jenkins/tools.groovy"
    430485
    431486        final settings = new BuildSettings(params, env.BRANCH_NAME)
     
    435490
    436491        return settings
     492}
     493
     494def build_stage(String name, boolean run, Closure block ) {
     495        StageName = name
     496        echo " -------- ${StageName} -------- "
     497        if(run) {
     498                stage(name, block)
     499        } else {
     500                stage(name) { Utils.markStageSkippedForConditional(STAGE_NAME) }
     501        }
    437502}
    438503
Note: See TracChangeset for help on using the changeset viewer.