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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
def cancelPreviousBuilds() {
def jobName = env.JOB_NAME
def buildNumber = env.BUILD_NUMBER.toInteger()
def currentJob = Jenkins.instance.getItemByFullName(jobName)
for (def build : currentJob.builds) {
def exec = build.getExecutor()
/* Kill older jobs */
if (build.isBuilding() && build.number.toInteger() < buildNumber && exec != null) {
def cause = { "Job stoped by #${buildNumber}" as String} as CauseOfInterruption
exec.interrupt(Result.ABORTED, cause)
println("Aborting previous build:#${build.number}")
}
}
}
pipeline {
agent {
node {
label 'jenkins-slave-ccache-ram'
customWorkspace "/home/jenkins/workspace/${JOB_NAME}/${BUILD_NUMBER}"
}
}
options{
ansiColor('xterm')
parallelsAlwaysFailFast()
}
environment {
JOBS=15
PATH="/usr/local/cmake-3.21.3-linux-x86_64/bin:/usr/local/gcc-arm-none-eabi-10-2020-q4-major/bin:$PATH"
}
stages {
stage('Check for previous running builds') {
steps {
script {
cancelPreviousBuilds()
}
}
}
stage('Initial checks') {
when {
changeRequest()
}
environment {
GITHUB_BASE_REF="${pullRequest.base}"
GITHUB_HEAD_REF="${pullRequest.headRef}"
}
steps {
echo "install additional python dependencies"
sh '''#!/bin/bash -e
python3 -m pip install ghapi
'''
echo "Check if branch needs rebasing"
sh '''#!/bin/bash -e
pushd ${WORKSPACE}
if [ $(git rev-list --count origin/${CHANGE_TARGET}...`(git merge-base ${GIT_COMMIT} origin/${CHANGE_TARGET})`) = 0 ]; then
echo "Branch OK"
else
echo "Branch is not rebased. Exiting"
exit 1
fi
popd'''
echo "Commit Message check"
sh '''#!/bin/bash -e
pushd ${WORKSPACE}
./tools/check_commit_messages.py
popd'''
echo "Copyright notice check"
sh '''#!/bin/bash -e
pushd ${WORKSPACE}
./config/license_header_check.sh --ci --check-only
popd'''
echo "Style checking"
sh '''#!/bin/bash -e
pushd ${WORKSPACE}
./config/style_check_hook.sh --last
popd'''
}
}
stage('Build RT1051') {
environment {
CCACHE_DIR="/ccache/RT1051"
XDG_CACHE_HOME="/clang-cache"
}
steps {
echo "Check if branch needs rebasing"
sh '''#!/bin/bash -e
pushd ${WORKSPACE}
if [ $(git rev-list --count origin/${CHANGE_TARGET}...`(git merge-base ${GIT_COMMIT} origin/${CHANGE_TARGET})`) = 0 ]; then
echo "Branch OK"
else
echo "Branch is not rebased. Exiting"
exit 1
fi
popd'''
sh '''#!/bin/bash -e
export JOBS=${JOBS:-6}
export CCACHE_DIR=/ccache/RT1051
echo "JOBS=${JOBS}"
echo "cmake path=$(which cmake)"
echo "\'workspace dir:${WORKSPACE}\'"
pushd "${WORKSPACE}"
echo "./configure.sh pure rt1051 Release -G Ninja"
./configure.sh pure rt1051 Release -G Ninja
pushd build-PurePhone-rt1051-Release
ninja -j ${JOBS} PurePhone-boot.bin
popd
rm -r build-PurePhone-rt1051-Release
echo "./configure.sh bell rt1051 Release -G Ninja"
./configure.sh bell rt1051 Release -G Ninja
pushd build-BellHybrid-rt1051-Release
ninja -j ${JOBS} BellHybrid-boot.bin
popd
echo "disk usage before removal:"
du -h --max-depth=1 .
rm -r build-BellHybrid-rt1051-Release
echo "disk usage after removal:"
du -h --max-depth=1 .
popd'''
echo "CCache stats"
sh '''#!/bin/bash
export CCACHE_DIR=/ccache/RT1051
ccache --show-stats'''
}
}
stage('Build Linux - Pure') {
environment {
CCACHE_DIR="/ccache/Linux"
XDG_CACHE_HOME="/clang-cache"
}
when {
expression {
return !(env.CHANGE_TARGET ==~ /release\/[0-9]+\.[0-9]+\.[0-9]+-bell/)
}
}
steps {
echo "Check if branch needs rebasing"
sh '''#!/bin/bash -e
pushd ${WORKSPACE}
if [ $(git rev-list --count origin/${CHANGE_TARGET}...`(git merge-base ${GIT_COMMIT} origin/${CHANGE_TARGET})`) = 0 ]; then
echo "Branch OK"
else
echo "Branch is not rebased. Exiting"
exit 1
fi
popd'''
echo "Configure"
sh '''#!/bin/bash -e
echo "JOBS=${JOBS}"
pushd "${WORKSPACE}"
echo "./configure.sh pure linux Debug -G Ninja"
./configure.sh pure linux Debug -G Ninja
popd'''
echo "Clang Tidy check"
/* requires compilation database - must be run after configuration */
sh '''#!/bin/bash -e
pushd ${WORKSPACE}
./config/clang_check.sh PurePhone
popd'''
echo "Build"
sh '''#!/bin/bash -e
echo "JOBS=${JOBS}"
pushd "${WORKSPACE}"
pushd build-PurePhone-linux-Debug
ninja -j ${JOBS} PurePhone-boot.bin
popd
popd'''
echo "Build Unit Tests"
sh '''#!/bin/bash -e
pushd "${WORKSPACE}"
pushd build-PurePhone-linux-Debug
ninja -j ${JOBS} unittests
popd'''
echo "CCache stats"
sh '''#!/bin/bash
export CCACHE_DIR=/ccache/Linux
ccache --show-stats'''
echo "Check for Statics"
sh '''#!/bin/bash -e
pushd "${WORKSPACE}"
./tools/find_global_data.py build-PurePhone-linux-Debug/PurePhone.elf
popd'''
echo "Run Unit Tests"
sh '''#!/bin/bash -e
export JOBS=${JOBS:-6}
echo "JOBS=${JOBS}"
pushd "${WORKSPACE}"
pushd build-PurePhone-linux-Debug
ninja check -j ${JOBS}
popd
echo "disk usage before removal:"
du -h --max-depth=1 .
rm -r build-PurePhone-linux-Debug
echo "disk usage after removal:"
du -h --max-depth=1 .
popd'''
}
}
stage('Build Linux - Bell') {
environment {
CCACHE_DIR="/ccache/Linux"
XDG_CACHE_HOME="/clang-cache"
}
when {
expression {
return !(env.CHANGE_TARGET ==~ /release\/[0-9]+\.[0-9]+\.[0-9]+-pure/)
}
}
steps {
echo "Check if branch needs rebasing"
sh '''#!/bin/bash -e
pushd ${WORKSPACE}
if [ $(git rev-list --count origin/${CHANGE_TARGET}...`(git merge-base ${GIT_COMMIT} origin/${CHANGE_TARGET})`) = 0 ]; then
echo "Branch OK"
else
echo "Branch is not rebased. Exiting"
exit 1
fi
popd'''
echo "Configure"
sh '''#!/bin/bash -e
echo "JOBS=${JOBS}"
pushd "${WORKSPACE}"
echo "./configure.sh bell linux Debug -G Ninja"
./configure.sh bell linux Debug -G Ninja
popd'''
echo "Clang Tidy check"
/* requires compilation database - must be run after configuration */
sh '''#!/bin/bash -e
pushd ${WORKSPACE}
./config/clang_check.sh BellHybrid
popd'''
echo "Build"
sh '''#!/bin/bash -e
echo "JOBS=${JOBS}"
pushd "${WORKSPACE}"
pushd build-BellHybrid-linux-Debug
ninja -j ${JOBS} BellHybrid-boot.bin
popd
popd'''
echo "Build Unit Tests"
sh '''#!/bin/bash -e
pushd "${WORKSPACE}"
pushd "${WORKSPACE}"
pushd build-BellHybrid-linux-Debug
ninja -j ${JOBS} unittests
popd
popd'''
echo "CCache stats"
sh '''#!/bin/bash
export CCACHE_DIR=/ccache/Linux
ccache --show-stats'''
echo "Check for Statics"
sh '''#!/bin/bash -e
pushd "${WORKSPACE}"
./tools/find_global_data.py build-BellHybrid-linux-Debug/BellHybrid.elf
popd'''
echo "Run Unit Tests"
sh '''#!/bin/bash -e
export JOBS=${JOBS:-6}
echo "JOBS=${JOBS}"
pushd "${WORKSPACE}"
pushd build-BellHybrid-linux-Debug
ninja check -j ${JOBS}
popd
echo "disk usage before removal:"
du -h --max-depth=1 .
rm -r build-BellHybrid-linux-Debug
echo "disk usage after removal:"
du -h --max-depth=1 .
popd'''
}
}
stage('master-jobs') {
when {
branch 'master'
}
steps {
echo "run some tests"
sh '''#!/bin/bash
echo "HAL 9000 sleeps here."
'''
}
}
}
post {
cleanup {
deleteDir()
dir("${workspace}@tmp") {
deleteDir()
}
dir("${workspace}@script") {
deleteDir()
}
}
}
}