1def thread_count = 1
2
3def wt_configure(Map args) {
4    sh """cmake .. \
5            -DCMAKE_C_COMPILER_LAUNCHER=ccache \
6            -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
7            -DBUILD_EXAMPLES=ON \
8            -DBUILD_TESTS=ON \
9            -DCONNECTOR_FCGI=OFF \
10            -DCONNECTOR_HTTP=ON \
11            -DEXAMPLES_CONNECTOR=wthttp \
12            -DENABLE_HARU=OFF \
13            -DENABLE_PANGO=OFF \
14            -DENABLE_POSTGRES=OFF \
15            -DENABLE_QT4=OFF \
16            -DENABLE_QT5=OFF \
17            -DENABLE_SQLITE=ON \
18            -DENABLE_SSL=OFF \
19            -DHTTP_WITH_ZLIB=OFF \
20            -DSHARED_LIBS=OFF \
21            -DMULTI_THREADED=${args.mt}"""
22}
23
24pipeline {
25    environment {
26        EMAIL = credentials('wt-dev-mail')
27    }
28    options {
29        buildDiscarder logRotator(numToKeepStr: '20')
30        disableConcurrentBuilds()
31    }
32    agent {
33        label 'build-freebsd12-1'
34    }
35    triggers {
36        pollSCM('H/5 * * * *')
37    }
38    stages {
39        stage('Single-threaded') {
40            steps {
41                dir('build-st') {
42                    wt_configure(mt: 'OFF')
43                    sh "make -k -j${thread_count}"
44                    sh "make -C examples -k -j${thread_count}"
45                }
46                dir('test') {
47                    warnError('non-mt test.wt failed') {
48                        sh "../build-st/test/test.wt --log_format=JUNIT --log_level=all --log_sink=${env.WORKSPACE}/st_test_log.xml"
49                    }
50                }
51            }
52        }
53        stage('Multithreaded') {
54            steps {
55                dir('build-mt') {
56                    wt_configure(mt: 'ON')
57                    sh "make -k -j${thread_count}"
58                    sh "make -C examples -k -j${thread_count}"
59                }
60                dir('test') {
61                    warnError('mt test.wt failed') {
62                        sh "../build-mt/test/test.wt --log_format=JUNIT --log_level=all --log_sink=${env.WORKSPACE}/mt_test_log.xml"
63                    }
64                }
65            }
66        }
67    }
68    post {
69        always {
70            junit '*_test_log.xml'
71        }
72        cleanup {
73            cleanWs()
74        }
75        failure {
76            mail to: env.EMAIL,
77                 subject: "Failed Pipeline: ${currentBuild.fullDisplayName}",
78                 body: "Something is wrong with ${env.BUILD_URL}"
79        }
80        unstable {
81            mail to: env.EMAIL,
82                 subject: "Unstable Pipeline: ${currentBuild.fullDisplayName}",
83                 body: "Something is wrong with ${env.BUILD_URL}"
84        }
85    }
86}
87