aboutsummaryrefslogtreecommitdiff
path: root/tcwg-buildfarm-master-hetzner-bernie.yaml
blob: d9fd28b056444fe73e533b43f965a45e4a4b9034 (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
- job:
    name: 'tcwg-buildfarm-master-hetzner-bernie'
    project-type: matrix
    defaults: global
    logrotate:
        daysToKeep: 30
        numToKeep: 100
        artifactDaysToKeep: 2
        artifactNumToKeep: 40
    properties:
        - authorization:
            anonymous:
                - job-read
                - job-extended-read
            linaro:
                - job-build
                - job-cancel
        - copyartifact:
            projects: tcwg-benchmark
    parameters:
        - string:
            name: gcc_branch
            default: 'latest'
            description: 'GCC revision to build'
        - 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: 'x86_64-host'
            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: excludecheck
            default: 'gdb'
            description: 'Do not run "make check" on this component'
        - 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: ex40-01.tcwglab.linaro.org:logs-master
            description: 'Log_Server'
        - string:
            name: abe_branch
            default: refs/heads/master
            description: 'ABE revision to test'
    disabled: false
    node: tcwg-x86_64-ex40
    retry-count: 3
    concurrent: true
    display-name: 'TCWG ZZZ Buildfarm Master Hetzner Bernie'
    scm:
        - git:
            url: https://git-us.linaro.org/toolchain/abe.git
            refspec: +refs/changes/*:refs/remotes/changes/*
            branches:
                - ${abe_branch}
            skip-tag: true
            shallow-clone: true
            wipe-workspace: true
    axes:
        - axis:
            type: slave
            name: label
            values:
                - tcwg-aarch64-build
        - axis:
            type: user-defined
            name: target
            values:
                - native
    execution-strategy:
        combination-filter: |
            (label=="tcwg-x86_64-ex40" && 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}-${ENV,var="gcc_branch"}'
    builders:
        - shell: |
            #!/bin/bash

            set -e
            set -x

            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

            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"

            # Sometimes /dev/pts can't get unmounted on the first try.
            # Workaround by retrying.
            trap "{ schroot -f -e -c session:$session_id || { sleep 60 ; schroot -f -e -c session:$session_id; } }" 0

            result="0"
            ${BUILD_SHELL} -x ./jenkins.sh --target ${target} --gcc-branch ${gcc_branch} --languages ${languages} $bootstrap $runtests_opt --excludecheck ${excludecheck} --fileserver ex40-01.tcwglab.linaro.org/snapshots-ref --logserver $log_server $logname_opt $norebuild -o '--tarbin' || result=$?

            #Do not trigger a benchmark if jenkins.sh exits without error and
            #without having built a toolchain (probably because --norebuild was
            #set and the logs already existed).
            #trigger-builds will only trigger if the properties file exists, so
            #create the file conditionally
            if test -e snapshots/gcc-linaro-*.tar.xz; then
              #Cases for which we want to trigger a benchmark
              #if test "x${target}" = xarm-linux-gnueabihf || TODO Uncomment when uinstance is complete
              #   test "x${target}" = xaarch64-linux-gnu; then
                toolchain="`ls snapshots/gcc-linaro-*.tar.xz`"
                sysroot="`ls snapshots/sysroot-*-linaro-*.tar.xz`"
                cat > bench_parameters <<EOF
            BENCHMARK=CoremarkPro
            TOOLCHAIN=${JENKINS_URL}/job/${JOB_NAME}/${BUILD_NUMBER}/artifact/${toolchain}
            SYSROOT=${JENKINS_URL}/job/${JOB_NAME}/${BUILD_NUMBER}/artifact/${sysroot}
            TARGET_CONFIG=Juno-A57
            TIMEOUT=$((72 * 3600))
            PUBLIC_KEY=ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCzlCPpuwMRSXZNq4Mut/GuitOhEturcsl9X1iNjOMGZXbtfBC8TCSXqotkziuYXpej1FCdXn3FEQsVw6Mw3I9Wq1p9okkgzVdsNzHAIob8ras/e9kOeJZGY5gSGBYf3t1MubAyaa033MJ+e3NRC4sbUmeeN3d9PD+Wc9QC3en9qfSpm6hh9EFHOHOjFk5+W0YZ83AL1PgalqL/hCN2/p9a8S1fsfDkfTgEh1XFIOiLds0fNzzmyXepxuA1n696iuSFMCIwmNcCfwRwRgt012UPgZu3avegYbDyijk8EtgFBuEA5OvX91BTHmaSjicsD9nJN63ms88l9OZMeTlPVjkD bogden
            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
                #No need for a 'remove bench/artifact_params' case, as we wipe workspace
              #fi TODO: Uncomment when uinstance is complete
            fi
            touch artifact_parameters #This file must exist, as it is used in
                                      #an inject step, and inject won't fail
                                      #good if there is no file

            echo "Result of jenkins.sh: $result"
            if $dont_fail; then
              result="0"
            fi
            exit $result
        - inject:
            properties-file: 'artifact_parameters'
        #If bench_parameters is missing, we don't set any parameters and
        #therefore do not trigger. We _do_ trigger even when some configurations
        #of the build have failed (unless no parameters are set).
        #There is a race here - tcwg-benchmark may want to access the
        #artifacts before the archive step (below) completes. In practice, this
        #is very unlikely to ever cause a problem - the artifacts are accessed
        #by a lava job triggered by tcwg-benchmark, and the lava target has to
        #boot, so there is a lot of time for the archive step to run.
        #Ideally, we would trigger _after_ archive, but this happens in the
        #master of this matrix job, and the master does not have access to
        #benchmark_parameters. We can copy benchmark_parameters up to the
        #master, but then we have the problem of identifying all the benchmark_
        #parameters for each child of the matrix, and triggering a build for
        #each.
        #The 'Use files in matrix child builds' option of trigger-parameterized-builds
        #would likely solve this problem - but it is not exposed in jjb. Have
        #raised https://storyboard.openstack.org/#!/story/2000444.
        #TODO: When we have a jjb that lets us eliminate the race, eliminate
        #the race.
        - trigger-builds:
           - project: tcwg-benchmark
             property-file: bench_parameters
    publishers:
      - archive:
          artifacts: '${TOOLCHAIN},${SYSROOT},source.tar.xz'
          only-if-success: true
          fingerprint: true
          allow-empty: true