aboutsummaryrefslogtreecommitdiff
path: root/tcwg-bkk16-buildfarm-benchmark.yaml
blob: 694e38b9c1c2463d9a25a08ae5253418bf447657 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
- job:
    name: tcwg-bkk16-buildfarm-benchmark
    project-type: matrix
    defaults: global
    properties:
        - authorization:
            anonymous:
                - job-read
                - job-extended-read
            linaro:
                - job-build
                - job-cancel
        - build-discarder:
            days-to-keep: 30
            num-to-keep: 30
            artifact-days-to-keep: 2
            artifact-num-to-keep: 40
    parameters:
        - string:
            name: override
            default: ''
            description: 'Versions of components to build; e.g. binutils=binutils-gdb.git/linaro_binutils-2_25-branch gcc=gcc.git~linaro/gcc-5-branch glibc=glibc.git~release/2.21/master'
        - string:
            name: host_x86_64_languages
            default: 'default'
            description: 'Languages to build for x86_64-hosted toolchains, e.g., "c,c++" or "all" or "default"'
        - string:
            name: host_aarchXX_languages
            default: 'c,c++'
            description: 'Languages to build for AArchXX-hosted toolchains, e.g., "c,c++" or "all" or "default"'
        - string:
            name: runtests
            default: 'yes'
            description: 'Run toolchain testsuites: "yes", "no", "x86_64-host"'
        - bool:
            name: try_bootstrap
            default: 'true'
            description: 'Attempt to bootstrap GCC for compatible host and target combinations'
        - string:
            name: host_x86_64_excludecheck
            default: 'gdb'
            description: 'Do not run "make check" on these components on x86_64'
        - string:
            name: host_aarchXX_excludecheck
            default: 'gcc'
            description: 'Do not run "make check" on these components on AArchXX'
        - bool:
            name: rebuild
            default: true
            description: 'Rebuild the toolchain even if results are already on logserver'
        - string:
            name: log_name
            default: ''
            description: 'Logname directory on logserver; leave empty for default'
        - bool:
            name: dont_fail
            default: false
            description: 'Do not fail the build'
        - string:
            name: log_server
            default: dev-01.tcwglab:/home/maxim.kuvyrkov/logs
            description: 'Log_Server'
        - string:
            name: targets
            default: 'cross_main cross_aux native_x86 native_aarch64 native_aarch32'
            description: 'Which target toolchains to build: cross_main cross_aux native_x86 native_aarch64 native_aarch32'
        - string:
            name: abe_branch
            default: refs/remotes/origin/stable
            description: 'ABE revision to test'
        - string:
            name: scripts_branch
            default: master
            description: 'Scripts branch to use'
        - bool:
            name: run_benchmark
            default: false
            description: 'Whether to run a benchmark for benchmarkable targets.'
    disabled: false
    #Change to node would break the use of copy-to-master at end of file.
    #What we are really doing there is copy-to-matrix-parent, and that only
    #works if matrix parent == jenkins master node.
    node: master
    #Change to child workspace may need to be reflected in the build triggers
    #under publishers, at end of file.
    child-workspace: $target
    concurrent: true
    display-name: 'TCWG BKK16 BuildFarm Benchmark'
    scm:
        - git:
            url: https://git-us.linaro.org/toolchain/abe.git
            refspec: +refs/heads/*:refs/remotes/origin/* +refs/changes/*:refs/remotes/changes/*
            branches:
                - $abe_branch
            skip-tag: true
            shallow-clone: true
            wipe-workspace: false
            clean:
                before: true
    #Any changes in these axes may need to be reflected in the build triggers
    #under publishers, at end of file.
    axes:
        - axis:
            type: slave
            name: label
            values:
                - tcwg-x86_64-build
                - tcwg-aarch64-build
        - axis:
            type: user-defined
            name: target
            values:
                - aarch64-linux-gnu
                - armv8l-linux-gnueabihf
                - arm-linux-gnueabi
                - arm-linux-gnueabihf
                - armeb-linux-gnueabihf
                - aarch64-none-elf
                - aarch64_be-none-elf
                - native
                - schroot-i386-native
                - schroot-armhf-native
    execution-strategy:
        combination-filter: |
            (label=="tcwg-x86_64-build" && target!="schroot-armhf-native") || (label=="tcwg-aarch64-build" && (target=="native" || target=="schroot-armhf-native"))
        sequential: false
    wrappers:
        - timeout:
            timeout: 600
        - timestamps
        - ssh-agent-credentials:
            # tcwg-buildslave user id
            users:
                - 'e0958a95-204f-4c14-a66c-5e2be6c5d50a'
        - build-name:
            name: '#${BUILD_NUMBER}'
    builders:
        - shell: |
            #!/bin/bash

            set -e
            set -x

            #Ensure that artifact_parameters is empty - must exist to be used
            #by inject step, but if it is empty we will not publish any
            #artifacts. Must exist before first exit.
            rm -f artifact_parameters
            touch artifact_parameters

            #Ensure that the properties file isn't lying around from some old
            #build - stops us from kicking off the wrong benchmark.
            rm -f bench_parameters
            touch bench_parameters

            case "$target--$(uname -m)" in
              native--aarch64) target_kind=native_aarch64 ;;
              schroot-armhf-native--*) target_kind=native_aarch32 ;;
              native--x86_64|schroot-i386-native--*) target_kind=native_x86 ;;
              armeb-linux-gnueabihf--*|*-none-elf--*) target_kind=cross_aux ;;
              *-linux-gnu*--*) target_kind=cross_main ;;
              *) echo "ERROR: Cannot handle target: $target"; exit 1 ;;
            esac

            if ! echo "$targets" | grep -q "$target_kind"; then
              echo "NOTE: Skipping target $target because $target_kind is not in list: $targets"
              exit 0
            fi

            case ${target} in
              schroot-*)
                schroot_arch=$(echo ${target} | sed -e "s/^schroot-\([^-]*\)-\(.*\)/\1/")
                target=$(echo ${target} | sed -e "s/^schroot-\([^-]*\)-\(.*\)/\2/")
                ;;
              *)
                case $(uname -m) in
                  x86_64) schroot_arch="amd64" ;;
                  aarch64) schroot_arch="arm64" ;;
                  *) echo "Unexpected architecture $(uname -m)"; exit 1 ;;
                esac
                ;;
            esac
            schroot_image="tcwg-build-${schroot_arch}-trusty"

            case $(uname -m) in
              x86_64) languages="$host_x86_64_languages" ;;
              *) languages="$host_aarchXX_languages" ;;
            esac

            case "$runtests-$(uname -m)" in
              "yes"-*) runtests_opt="--runtests" ;;
              "x86_64-host"-x86_64) runtests_opt="--runtests" ;;
              *) runtests_opt="" ;;
            esac

            if $try_bootstrap; then
              bootstrap="--bootstrap"
            else
              bootstrap=""
            fi

            if [ x"$log_name" != x"" ]; then
              eval "logname_opt=\"--logname $log_name\""
            fi

            if $rebuild; then
              norebuild=""
            else
              norebuild="--norebuild"
            fi

            case $(uname -m) in
              x86_64) excludecheck="$host_x86_64_excludecheck" ;;
              *) excludecheck="$host_aarchXX_excludecheck" ;;
            esac

            excludecheck_opt=""
            for testsuite in $excludecheck; do
              excludecheck_opt="$excludecheck_opt --excludecheck $testsuite"
            done

            ulimit -u 5000

            session_id=$(schroot -b -c chroot:$schroot_image --preserve-environment)
            BUILD_SHELL="schroot -r -c session:$session_id --preserve-environment -- bash"
            $BUILD_SHELL -c "echo \"Build session is up; ulimit config:\"; ulimit -a"

            # Remove schroot session on exit
            trap "schroot -f -e -c session:$session_id" 0

            git clone -b $scripts_branch --depth 1 https://git-us.linaro.org/toolchain/jenkins-scripts

            result="0"
            ${BUILD_SHELL} -x ${WORKSPACE}/jenkins-scripts/jenkins.sh --abedir ${WORKSPACE} --target ${target} --override "$override" --languages ${languages} $bootstrap $runtests_opt $excludecheck_opt --logserver $log_server $logname_opt $norebuild -o '--tarbin' || result=$?

            echo "Result of jenkins.sh: $result"

            if test ${result} -eq 0; then
              #Cases for which we want to trigger a benchmark
              #Any changes in this list may need mirroring in the parameterized
              #builds triggers at end of file.
              if test "x${target}" = xarm-linux-gnueabihf ||
                 test "x${target}" = xaarch64-linux-gnu ||
                 test "x${target}" = xarmv8l-linux-gnueabihf; then
                #Only trigger if jenkins.sh exits without error _and_ the
                #artifacts exist. (If --norebuild is set and logs already
                #exist, there will be no error but also no artifacts.)
                toolchain="`ls snapshots/gcc-linaro-*.tar.xz`"
                sysroot="`ls snapshots/sysroot-*-linaro-*.tar.xz`"

                #Repeat ls, because this way is robust to filenames with spaces
                if test `ls snapshots/gcc-linaro-*.tar.xz | wc -l` -eq 1 &&
                   test `ls snapshots/sysroot-*-linaro-*.tar.xz | wc -l` -eq 1; then
                  cat > bench_parameters <<EOF
            BENCHMARK=Coremark-Pro
            TOOLCHAIN=${JENKINS_URL}job/${JOB_NAME//,/%2C}/${BUILD_NUMBER}/artifact/${toolchain}
            SYSROOT=${JENKINS_URL}job/${JOB_NAME//,/%2C}/${BUILD_NUMBER}/artifact/${sysroot}
            TARGET_CONFIG=Juno-A57
            RUN_FLAGS=quickrun
            TRIPLE=${target}
            Overrides=BUNDLE_STREAM=/anonymous/backbench/ \
                      METADATA=jenkins_initiator \
                      jenkins_initiator=${JENKINS_URL}job/${JOB_NAME//,/%2C}/${BUILD_NUMBER}
            LAVA_JOB_NAME=Buildbench: ${JOB_NAME} build ${BUILD_NUMBER}
            EOF

                  #Archives end up on public internet, so deliver source/scripts
                  #alongside prebuilt binaries
                  git archive HEAD -o source.tar
                  tar rf source.tar --exclude-vcs --exclude=${toolchain} --exclude=${sysroot} snapshots
                  xz source.tar

                  cat > artifact_parameters << EOF
            TOOLCHAIN=${toolchain}
            SYSROOT=${sysroot}
            EOF
                elif test `ls snapshots/gcc-linaro-*.tar.xz | wc -l` -ne 0 ||
                     test `ls snapshots/sysroot-*-linaro-*.tar.xz | wc -l` -ne 0; then
                  echo "Multiple matches for toolchain and/or sysroot tarball, cannot dispatch benchmark" >&2
                  result=2
                fi
              fi
            fi

            if $dont_fail; then
              result="0"
            fi
            exit $result
        - inject: #Create env vars used by achive step, below.
            properties-file: 'artifact_parameters'
    publishers:
        - archive:
            artifacts: '${TOOLCHAIN},${SYSROOT},source.tar.xz'
            only-if-success: true
            fingerprint: true
            allow-empty: true
        #Because JJB does not expose 'Use files in matrix child builds', we have
        #to copy the files to master and trigger from the copies. (We make sure
        #to initialize the files to empty so that we don't retrigger an old
        #benchmark by mistake.)
        #TODO: When we upgrade to a JJB that includes a fix for https://storyboard.openstack.org/#!/story/2000444
        #we can simplify all this, and also stop hard-coding paths that Jenkins
        #should be deriving from the matrix. And we should then delete the comments
        #that this commit has inserted next to axes and the list of benchmarkable
        #targets in the shell, as they will be misleading. And we can switch
        #the 'node' parameter back from 'master' to 'tcwg-x86_64-build' and delete
        #the comment above 'node', too.
        - copy-to-master:
            includes:
              - bench_parameters
        - trigger-parameterized-builds:
          - project: tcwg-benchmark
            property-file: aarch64-linux-gnu/bench_parameters
            condition: 'SUCCESS'
          - project: tcwg-benchmark
            property-file: armv8l-linux-gnueabihf/bench_parameters
            condition: 'SUCCESS'
          - project: tcwg-benchmark
            property-file: arm-linux-gnueabihf/bench_parameters
            condition: 'SUCCESS'
        - workspace-cleanup:
            include:
              - "**/.git"
            dirmatch: true