forked from TaniaMirzin/mbed-bootloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
307 lines (279 loc) · 11.9 KB
/
Jenkinsfile
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
//----------------------------------------------------------------------------
// The confidential and proprietary information contained in this file may
// only be used by a person authorised under and to the extent permitted
// by a subsisting licensing agreement from ARM Limited or its affiliates.
//
// (C) COPYRIGHT 2019 ARM Limited or its affiliates.
// ALL RIGHTS RESERVED
//
// This entire notice must be reproduced on all copies of this file
// and copies of this file may only be made by a person if such person is
// permitted to do so under the terms of a subsisting license agreement
// from ARM Limited or its affiliates.
//----------------------------------------------------------------------------
repoName = "mbed-bootloader"
// This build archives artifacts at build stage and later on copies artifacts
// on the later state. Permission is needed for copying, even for the job itself.
// Instructions from here: https://stackoverflow.com/questions/47771722/grant-copy-artifact-permission-in-multi-branch-pipeline?rq=1
// Also, we trigger master branch rebuild every night
if (env.BRANCH_NAME == "master") {
properties([[$class: 'CopyArtifactPermissionProperty', projectNames: '*'], pipelineTriggers([cron('H H(0-4) * * *')])])
} else {
properties([[$class: 'CopyArtifactPermissionProperty', projectNames: '*'], pipelineTriggers([])])
}
toolchains = [
ARM: "armcc",
GCC_ARM: "arm-none-eabi-gcc",
IAR: "iar_arm"
]
// RaaS allocation timeout
raas_timeout = 1200
// Initial maps for parallel build steps
def buildStepsForParallel = [:]
def runStepsForParallel = [:]
def smokeTests = [:]
def deployBootloaderRepoStep() {
return {
stage ("deploy_bootloader_repo") {
node ("all-in-one-build-slave") {
dir(repoName) {
deleteDir()
checkout scm
sh ('''
mbed deploy --protocol ssh
mbed ls
mkdir release
python ./scripts/make_release.py --patch -o release
cd mbed-os
git archive -o ../mbed.tar HEAD
cd ..
tar cjf mbed-bootloader.tar.bz2 --exclude mbed-os --exclude mbed-bootloader.tar.bz2 * .[a-z]*
''')
stash name: "deployed_bootloader_repo", includes: "mbed-bootloader.tar.bz2", useDefaultExcludes: false
}
}
}
}
}
def bootloaderBuildStep(stepName,
target,
toolchain,
repoName,
mbed_app_json) {
return {
stage (stepName) {
node ("all-in-one-build-slave") {
dir(repoName) {
// get the deployed source code from previous step
deleteDir()
unstash "deployed_bootloader_repo"
sh ('''
tar xjf mbed-bootloader.tar.bz2
mkdir mbed-os
tar xf mbed.tar -C mbed-os
mbed config root .
''')
def build_dir = mbed_app_json[0..-6]
if (build_dir.indexOf('/') != -1) {
build_dir = build_dir.tokenize('/')[1]
}
build_dir = "BUILD/" + build_dir + "/${target}/${toolchain}"
// build with default setup
sh ("""
mbed --version
mbed compile -m ${target} -t ${toolchain} --app-config ${mbed_app_json} --build ${build_dir} --profile release
""")
// Archive the binary
def file_extension = ("${target}" == "NRF52840_DK" || "${target}" == "LPC55S69_NS") ? "hex" : "bin"
def binary_path = build_dir + "/${repoName}.${file_extension}"
archiveArtifacts artifacts: binary_path
archiveArtifacts artifacts: build_dir + "/${repoName}_application.map"
}
}
}
}
}
def build_test_config = [
// Bootloaders for Smoke test using internal flash
["DISCO_L475VG_IOT01A", "mbed_app.json", "GCC_ARM"],
["K64F", "mbed_app.json", "GCC_ARM"],
["NRF52840_DK", "mbed_app.json", "GCC_ARM"],
["NUCLEO_F303RE", "mbed_app.json", "GCC_ARM"],
["NUCLEO_F411RE", "mbed_app.json", "GCC_ARM"],
["NUCLEO_F429ZI", "mbed_app.json", "GCC_ARM"],
["DISCO_F769NI", "mbed_app.json", "GCC_ARM"],
// Bootloaders for just testing the build
["NRF52840_DK", "configs/kvstore_and_fw_candidate_on_sd.json", "GCC_ARM"],
["NUCLEO_L073RZ", "configs/kvstore_and_fw_candidate_on_sd.json", "GCC_ARM"],
["DISCO_L475VG_IOT01A", "configs/external_kvstore_with_qspif.json", "GCC_ARM"],
["NUCLEO_H743ZI2", "configs/internal_flash_no_rot.json", "GCC_ARM"],
// Bootloaders for release.
// NOTE: Must match make_release.py
["K64F", "configs/kvstore_and_fw_candidate_on_sd.json", "GCC_ARM"],
["K64F", "configs/internal_flash_no_rot.json", "GCC_ARM"],
["K64F", "configs/internal_kvstore_with_sd.json", "GCC_ARM"],
["K66F", "configs/internal_flash_no_rot.json", "GCC_ARM"],
["NRF52840_DK", "configs/internal_kvstore_with_qspif.json", "GCC_ARM"],
["NUCLEO_L4R5ZI", "configs/internal_flash_no_rot.json", "GCC_ARM"],
["NUCLEO_F429ZI", "configs/internal_flash_no_rot.json", "GCC_ARM"],
["UBLOX_EVK_ODIN_W2", "configs/internal_kvstore_with_sd.json", "GCC_ARM"],
["NUCLEO_F411RE", "configs/kvstore_and_fw_candidate_on_sd.json", "GCC_ARM"],
["DISCO_L475VG_IOT01A", "configs/internal_kvstore_with_qspif.json", "GCC_ARM"],
["LPC55S69_NS", "configs/psa.json", "GCC_ARM"],
["NUCLEO_F303RE", "configs/internal_kvstore_with_spif.json", "GCC_ARM"],
["DISCO_F769NI", "configs/internal_flash_no_rot.json", "GCC_ARM"],
]
for (int i = 0; i < build_test_config.size(); i++) {
def target = build_test_config[i][0]
def mbed_app_json = build_test_config[i][1]
def toolchain = build_test_config[i][2]
def stepName = "build_test_${target}_${toolchain}_${mbed_app_json}"
buildStepsForParallel[stepName] = bootloaderBuildStep(stepName,
target,
toolchain,
repoName,
mbed_app_json)
}
def greenteaTestStep(step_name,
target,
toolchain,
raas,
repo_name) {
return {
stage(step_name) {
node("all-in-one-build-slave") {
dir(repo_name) {
deleteDir()
unstash "deployed_bootloader_repo"
sh ("""
tar xjf mbed-bootloader.tar.bz2
mkdir mbed-os
tar xf mbed.tar -C mbed-os
mbed config root .
ls -al
# remove bootloader application main file
rm source/main.cpp
# build greentea tests
mbed test --compile -m ${target} -t ${toolchain} -n '*bootloader-hmac*' --app-config configs/test_configs/greentea.json
""")
env.RAAS_USERNAME = "ci"
env.RAAS_PASSWORD = "ci"
env.RAAS_PYCLIENT_FORCE_REMOTE_ALLOCATION = 1
env.RAAS_PYCLIENT_ALLOCATION_QUEUE_TIMEOUT = raas_timeout
// Only run if the test_spec.json is not empty
def test_spec_json_empty = sh (
script: """grep -c "\\"tests\\": {}" BUILD/tests/${target}/${toolchain}/test_spec.json || exit 0""",
returnStdout: true
)
echo "Printing test_spec_json_empty: [${test_spec_json_empty}]"
if (test_spec_json_empty.trim() == "1") {
echo "test_spec.json is empty, no tests to run"
} else {
sh ("mbedgt -g ${target}:raas_client:${raas}:443 -vV")
}
}
}
}
}
}
// Only HMAC tests remains in Greentea. This test is equivalent of unittest for
// ARM_UC_cryptoHMACSHA256(), and relies entirely on Mbed TLS and its SHA256 functions.
// Those are already tested in Mbed OS, and therefore we use minimal number of targets here
// for testing the ARM_UC_cryptoHMACSHA256().
def greentea_test_config = [
"K64F": ["toolchains": ["GCC_ARM"], "raas": "https://eeva.mbedcloudtesting.com"],
"NUCLEO_F429ZI": ["toolchains": ["GCC_ARM"], "raas": "https://ruka.mbedcloudtesting.com"],
]
for (target in greentea_test_config.keySet()) {
for (toolchain in greentea_test_config[target]["toolchains"]) {
def raas = greentea_test_config[target]["raas"]
def step_name = "greentea_test_${target}_${toolchain}"
runStepsForParallel[step_name] = greenteaTestStep(step_name,
target,
toolchain,
raas,
repoName)
}
}
def SmokeTestStep(step_name,
target,
toolchain,
raas,
repo_name) {
return {
stage(step_name) {
node("all-in-one-build-slave") {
dir(repo_name) {
env.RAAS_USERNAME = "ci"
env.RAAS_PASSWORD = "ci"
env.RAAS_PYCLIENT_FORCE_REMOTE_ALLOCATION = 1
env.RAAS_PYCLIENT_ALLOCATION_QUEUE_TIMEOUT = raas_timeout
deleteDir()
unstash "deployed_bootloader_repo"
sh ('''
tar xjf mbed-bootloader.tar.bz2
mkdir mbed-os
tar xf mbed.tar -C mbed-os
''')
copyArtifacts filter: '**/mbed-bootloader.*', projectName: '${JOB_NAME}', selector: specific('${BUILD_NUMBER}')
dir('TESTS/smoke') {
sh "./build.sh ${target}"
archiveArtifacts artifacts: "**/${target}_smoke.*"
sh "./test.sh ${target} ${raas}"
}
}
}
}
}
}
def smoke_test_config = [
"DISCO_L475VG_IOT01A": ["toolchains": [ "GCC_ARM"], "raas": "https://auli.mbedcloudtesting.com:443"],
"K64F": ["toolchains": [ "GCC_ARM"], "raas": "https://ruka.mbedcloudtesting.com:443"],
"NRF52840_DK": ["toolchains": [ "GCC_ARM"], "raas": "https://auli.mbedcloudtesting.com:443"],
"NUCLEO_F303RE": ["toolchains": [ "GCC_ARM"], "raas": "https://auli.mbedcloudtesting.com:443"],
"NUCLEO_F411RE": ["toolchains": [ "GCC_ARM"], "raas": "https://ruka.mbedcloudtesting.com:443"],
"NUCLEO_F429ZI": ["toolchains": [ "GCC_ARM"], "raas": "https://ruka.mbedcloudtesting.com:443"],
"DISCO_F769NI": ["toolchains": [ "GCC_ARM"], "raas": "https://rauni.mbedcloudtesting.com:443"],
]
for (target in smoke_test_config.keySet()) {
for (toolchain in smoke_test_config[target]["toolchains"]) {
def raas = smoke_test_config[target]["raas"]
def step_name = "smoke_${target}_${toolchain}"
smokeTests[step_name] = SmokeTestStep(step_name,
target,
toolchain,
raas,
repoName)
}
}
def ReleaseStep() {
return {
stage ("release_bootloader") {
node ("all-in-one-build-slave") {
dir(repoName) {
deleteDir()
unstash "deployed_bootloader_repo"
copyArtifacts filter: '**/mbed-bootloader*', projectName: '${JOB_NAME}', selector: specific('${BUILD_NUMBER}')
sh ('''
tar xjf mbed-bootloader.tar.bz2
mkdir mbed-os
tar xf mbed.tar -C mbed-os
mkdir -p release
python ./scripts/make_release.py -o release --prebuilt
''')
archiveArtifacts artifacts: 'release/*'
}
}
}
}
}
/* Jenkins does not allow stages inside parallel execution,
* https://issues.jenkins-ci.org/browse/JENKINS-26107 will solve this by adding labeled blocks
*/
// Actually run the steps in parallel - parallel takes a map as an argument, hence the above.
timestamps {
parallel "deploy_bootloader": deployBootloaderRepoStep()
parallel buildStepsForParallel
parallel smokeTests + runStepsForParallel
parallel "release_bootloader": ReleaseStep()
}