aboutsummaryrefslogtreecommitdiff
path: root/tcwg-llvm-staged-build.yaml
blob: 31637c81daaa0fcba34cb4ccc1bf9e357e83dd6d (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
- job:
    name: tcwg-llvm-staged-build
    project-type: matrix
    defaults: global
    properties:
        - authorization:
            anonymous:
                - job-read
                - job-extended-read
            linaro:
                - job-build
                - job-cancel
        - build-discarder:
            days-to-keep: 10
            num-to-keep: 10
    parameters:
        - string:
            name: revision
            default: ''
            description: 'SVN revision in the format rNNNNN. Empty string will bring trunk on all repos.'
        - string:
            name: toolchain
            default: ''
            description: 'URL of the toolchain to use. This needs to be a tarball with a /bin directory inside with either GCC or LLVM from make install'
        - string:
            name: build_container_tag
            default: 'xenial'
            description: 'Type of image to use in the container: trusty, xenial.'
        - bool:
            name: twostage
            default: false
            description: 'Whether or not to trigger a second stage with this build.'
        - bool:
            name: testsuite
            default: false
            description: 'Whether or not to trigger a test-suite with this build.'
        - string:
            name: target_list
            default: 'tcwg-x86_64-build'
            description: 'List of targets -- tcwg-x86_64-build tcwg-tk1_32-build tcwg-apm_64-build -- should be a subset of slave axis'
    disabled: false
    node: tcwg-x86_64-cam
    retry-count: 3
    concurrent: true
    display-name: 'TCWG LLVM Staged Build'
    scm:
        - git:
            url: http://git.linaro.org/toolchain/jenkins-scripts.git
            refspec: +refs/heads/master:refs/remotes/origin/master
            name: origin
            branches:
                - refs/heads/master
            skip-tag: true
            shallow-clone: true
            wipe-workspace: true
    axes:
        - axis:
            type: slave
            name: label
            values:
                - tcwg-x86_64-build
                - tcwg-tk1_32-build
                - tcwg-apm_64-build
        - axis:
            type: dynamic
            name: target
            values:
                - target_list
    execution-strategy:
        combination-filter: |
            label==target
        sequential: false
    execution-strategy:
        sequential: false
    wrappers:
        - timeout:
            timeout: 300
        - timestamps
        - ssh-agent-credentials:
            # tcwg-buildslave user id
            users:
                - 'e0958a95-204f-4c14-a66c-5e2be6c5d50a'
        - build-name:
            name: '#${BUILD_NUMBER}-${GIT_REVISION,length=8}'
    builders:
        - shell: |
            #!/bin/bash
            set -ex

            # Select builder arch/type/container
            buildjobs=7
            triple=""
            case ${label} in
                tcwg-x86_64-build)
                    builder_arch=amd64
                    triple="x86_64-linux-gnu"
                    ;;
                tcwg-tk1_32-build)
                    builder_arch=armhf
                    triple="armv7-linux-gnueabihf"
                    buildjobs=4 # TK1s only have 4 cores
                    ;;
                tcwg-apm_64-build)
                    builder_arch=arm64
                    triple="aarch64-linux-gnu"
                    ;;
                *) echo "ERROR: Unsupported label: $label"; exit 1 ;;
            esac

            # Start build container
            builder=$(${WORKSPACE}/nodename2hostname.sh $NODE_NAME)
            bash ${WORKSPACE}/start-container-docker.sh --arch ${builder_arch} --distro ${build_container_tag} --session-host ${builder} --weight 1 > build-container.sh

            # Define CONTAINER, CONTAINER_CLEANUP, session_host and session_port
            . ./build-container.sh
            BUILD_CONTAINER="${CONTAINER}"
            BUILD_CONTAINER_CLEANUP="${CONTAINER_CLEANUP}"

            # Make sure to cleanup build container if something goes
            # wrong when preparing the test environment
            if [ "${BUILD_CONTAINER_CLEANUP}" != "" ]; then
                CONTAINERS_CLEANUP="${BUILD_CONTAINER_CLEANUP}"
                trap "${CONTAINERS_CLEANUP}" EXIT
            fi

            # Setup job parameters and run
            linkjobs=7
            buildid="ci${BUILD_ID}"
            if [ ! -z ${revision} ]; then
              buildid=${revision}
            fi
            ${BUILD_CONTAINER} "cd ${WORKSPACE} && bash -x ${WORKSPACE}/tcwg-llvm-build.sh \
                --workspace=${WORKSPACE} \
                --buildid=${buildid} \
                --linkjobs=${linkjobs} \
                --revision=${revision} \
                --toolchain=${toolchain}"

            # Chained jobs (FIXME: handle targets)
            fileserver=dev-01.tcwglab
            url_prefix='~tcwg-buildslave/builds/binaries/llvm'
            target=clang+llvm-${buildid}-${triple}
            tarball=${target}.tar.xz
            toolchain_url="http://${fileserver}/${url_prefix}/${tarball}"

            # We don't want an infinite chain, so make sure the 3rd stage is off
            if ${twostage}; then
              cat << EOF > llvm.params.twostage
              toolchain=${toolchain_url}
              twostage=false
            EOF

            # If we requested 2 stages and test-suite, only test the 2nd stage
            elif ${testsuite}; then
              cat << EOF > llvm.params.testsuite
              toolchain=${toolchain_url}
            EOF

            fi

        - conditional-step:
            condition-kind: file-exists
            condition-filename: llvm.params.twostage
            steps:
                - trigger-builds:
                    - project: 'tcwg-llvm-staged-build'
                      property-file: llvm.params.twostage
                      current-parameters: true
                      block: false

        - conditional-step:
            condition-kind: file-exists
            condition-filename: llvm.params.testsuite
            steps:
                - trigger-builds:
                    - project: 'tcwg-llvm-testsuite'
                      property-file: llvm.params.testsuite
                      current-parameters: true
                      block: false