forked from xmos/sln_voice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
315 lines (309 loc) · 16.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
308
309
310
311
312
313
314
315
@Library('[email protected]') _
getApproval()
pipeline {
agent none
options {
disableConcurrentBuilds()
skipDefaultCheckout()
timestamps()
// on develop discard builds after a certain number else keep forever
buildDiscarder(xmosDiscardBuildSettings())
}
parameters {
string(
name: 'TOOLS_VERSION',
defaultValue: '15.2.1',
description: 'The XTC tools version'
)
booleanParam(name: 'NIGHTLY_TEST_ONLY',
defaultValue: false,
description: 'Tests that only run during nightly builds.')
}
environment {
REPO = 'sln_voice'
VIEW = getViewName(REPO)
PYTHON_VERSION = "3.8.11"
VENV_DIRNAME = ".venv"
BUILD_DIRNAME = "dist"
XMOSDOC_VERSION = 'v4.0'
VRD_TEST_RIG_TARGET = "XCORE-AI-EXPLORER"
PIPELINE_TEST_VECTORS = "pipeline_test_vectors"
ASR_TEST_VECTORS = "asr_test_vectors"
}
stages {
stage('Build and Docs') {
parallel {
stage('Build and Test') {
when {
expression { !env.GH_LABEL_DOC_ONLY.toBoolean() }
}
agent {
label 'xcore.ai && vrd'
}
stages {
stage('Checkout') {
steps {
checkout scm
sh 'git submodule update --init --recursive --depth 1 --jobs \$(nproc)'
}
}
stage('Build tests') {
steps {
script {
uid = sh(returnStdout: true, script: 'id -u').trim()
gid = sh(returnStdout: true, script: 'id -g').trim()
}
// pull docker images
sh "docker pull ghcr.io/xmos/xcore_builder:latest"
sh "docker pull ghcr.io/xmos/xcore_voice_tester:develop"
// host apps
sh "docker run --rm -u $uid:$gid -w /sln_voice -v $WORKSPACE:/sln_voice ghcr.io/xmos/xcore_builder:latest bash -l tools/ci/build_host_apps.sh"
// test firmware and filesystems
sh "docker run --rm -u $uid:$gid -w /sln_voice -v $WORKSPACE:/sln_voice ghcr.io/xmos/xcore_builder:latest bash -l tools/ci/build_tests.sh"
// List built files for log
sh "ls -la dist_host/"
sh "ls -la dist/"
}
}
stage('ASRC Unit tests') {
steps {
withTools(params.TOOLS_VERSION) {
// tools/ci/build_tests.sh does not build for x86
sh "mkdir -p build_x86"
sh "cmake -B build_x86 -DXCORE_VOICE_TESTS=ON"
sh "cmake --build build_x86 --target test_asrc_div -j8"
// x86 build
sh "./build_x86/test_asrc_div"
// xcore build
sh "xsim dist/test_asrc_div.xe"
}
}
}
stage('ASRC Simulator') {
steps {
withTools(params.TOOLS_VERSION) {
dir("test/asrc_sim") {
createVenv('requirements.txt')
withVenv {
sh "pip install -r ./requirements.txt"
sh './run.sh'
}
}
}
}
}
stage('Create virtual environment') {
when {
expression { params.NIGHTLY_TEST_ONLY == true }
}
steps {
// Create venv
sh "pyenv install -s $PYTHON_VERSION"
sh "~/.pyenv/versions/$PYTHON_VERSION/bin/python -m venv $VENV_DIRNAME"
// Install dependencies
withVenv() {
sh "pip install git+https://github0.xmos.com/xmos-int/xtagctl.git"
sh "pip install -r test/requirements.txt"
}
}
}
stage('Cleanup xtagctl') {
when {
expression { params.NIGHTLY_TEST_ONLY == true }
}
steps {
// Cleanup any xtagctl cruft from previous failed runs
withTools(params.TOOLS_VERSION) {
withVenv {
sh "xtagctl reset_all $VRD_TEST_RIG_TARGET"
}
}
sh "rm -f ~/.xtag/status.lock ~/.xtag/acquired"
}
}
stage('Run Sample Rate Conversion test') {
when {
expression { params.NIGHTLY_TEST_ONLY == true }
}
steps {
withTools(params.TOOLS_VERSION) {
withVenv {
script {
withXTAG(["$VRD_TEST_RIG_TARGET"]) { adapterIDs ->
sh "test/sample_rate_conversion/check_sample_rate_conversion.sh " + adapterIDs[0]
}
sh "pytest test/sample_rate_conversion/test_sample_rate_conversion.py --wav_file test/sample_rate_conversion/test_output/sample_rate_conversion_output.wav --wav_duration 10"
}
}
}
}
}
stage('Run GPIO test') {
when {
expression { params.NIGHTLY_TEST_ONLY == true }
}
steps {
withTools(params.TOOLS_VERSION) {
withVenv {
script {
sh "test/ffd_gpio/run_tests.sh"
sh 'python tools/ci/python/parse_test_output.py testing/test.rpt -outfile="testing/test_results" --print_test_results --verbose'
}
}
}
}
}
stage('Run FFD Low Power Audio Buffer test') {
when {
expression { params.NIGHTLY_TEST_ONLY == true }
}
steps {
withTools(params.TOOLS_VERSION) {
withVenv {
script {
sh "test/ffd_low_power_audio_buffer/run_tests.sh"
sh "pytest test/ffd_low_power_audio_buffer/test_verify_low_power_audio_buffer.py"
}
}
}
}
}
stage('Run Device Firmware Update test') {
when {
expression { params.NIGHTLY_TEST_ONLY == true }
}
steps {
withTools(params.TOOLS_VERSION) {
withVenv {
script {
uid = sh(returnStdout: true, script: 'id -u').trim()
gid = sh(returnStdout: true, script: 'id -g').trim()
withXTAG(["$VRD_TEST_RIG_TARGET"]) { adapterIDs ->
sh "docker run --rm -u $uid:$gid --privileged -v /dev/bus/usb:/dev/bus/usb -w /sln_voice -v $WORKSPACE:/sln_voice ghcr.io/xmos/xcore_voice_tester:develop bash -l test/device_firmware_update/check_dfu.sh " + adapterIDs[0]
}
sh "pytest test/device_firmware_update/test_dfu.py --readback_image test/device_firmware_update/test_output/readback_upgrade.bin --upgrade_image test/device_firmware_update/test_output/test_ffva_dfu_upgrade.bin"
}
}
}
}
}
stage('Checkout Amazon WWE') {
when {
expression { params.NIGHTLY_TEST_ONLY == true }
}
steps {
sh 'git clone [email protected]:xmos/amazon_wwe.git'
}
}
stage('Setup test vectors') {
when {
expression { params.NIGHTLY_TEST_ONLY == true }
}
steps {
sh "cp -r /projects/hydra_audio/xcore-voice_xvf3510_no_processing_xmos_test_suite_subset $PIPELINE_TEST_VECTORS"
sh "ls -la $PIPELINE_TEST_VECTORS"
sh "cp -r /projects/hydra_audio/xcore-voice_no_processing_ffd_test_suite $ASR_TEST_VECTORS"
sh "ls -la $ASR_TEST_VECTORS"
}
}
stage('Run FFVA Pipeline test') {
when {
expression { params.NIGHTLY_TEST_ONLY == true }
}
steps {
withTools(params.TOOLS_VERSION) {
withVenv {
script {
withXTAG(["$VRD_TEST_RIG_TARGET"]) { adapterIDs ->
sh "test/pipeline/check_pipeline.sh $BUILD_DIRNAME/test_pipeline_ffva_adec_altarch.xe $PIPELINE_TEST_VECTORS test/pipeline/ffva_quick.txt test/pipeline/ffva_test_output $WORKSPACE/amazon_wwe " + adapterIDs[0]
}
sh "pytest test/pipeline/test_pipeline.py --log test/pipeline/ffva_test_output/results.csv"
}
}
}
}
}
stage('Run FFD Pipeline test') {
when {
expression { params.NIGHTLY_TEST_ONLY == true }
}
steps {
withTools(params.TOOLS_VERSION) {
withVenv {
script {
withXTAG(["$VRD_TEST_RIG_TARGET"]) { adapterIDs ->
sh "test/pipeline/check_pipeline.sh $BUILD_DIRNAME/test_pipeline_ffd.xe $PIPELINE_TEST_VECTORS test/pipeline/ffd_quick.txt test/pipeline/ffd_test_output $WORKSPACE/amazon_wwe " + adapterIDs[0]
}
sh "pytest test/pipeline/test_pipeline.py --log test/pipeline/ffd_test_output/results.csv"
}
}
}
}
}
stage('Run ASR test') {
when {
expression { params.NIGHTLY_TEST_ONLY == true }
}
steps {
withTools(params.TOOLS_VERSION) {
withVenv {
script {
withXTAG(["$VRD_TEST_RIG_TARGET"]) { adapterIDs ->
sh "test/asr/check_asr.sh Sensory $ASR_TEST_VECTORS test/asr/ffd_quick_sensory.txt test/asr/sensory_output " + adapterIDs[0]
sh "test/asr/check_asr.sh Cyberon $ASR_TEST_VECTORS test/asr/ffd_quick_cyberon.txt test/asr/cyberon_output " + adapterIDs[0]
}
sh "pytest test/asr/test_asr.py --log test/asr/sensory_output/results.csv"
sh "pytest test/asr/test_asr.py --log test/asr/cyberon_output/results.csv"
}
}
}
}
}
}
post {
cleanup {
// xcoreCleanSandbox removes all output and artifacts of the Jenkins pipeline
// Comment out this post section to leave the workspace which can be useful for running items on the Jenkins agent.
// However, beware that this pipeline will not run if the workspace is not manually cleaned.
xcoreCleanSandbox()
}
}
}
stage('Build docs') {
agent { label 'docker' }
stages {
stage ('Build docs with docker') {
steps {
checkout scm
sh 'git submodule update --init --recursive --depth 1 --jobs \$(nproc)'
sh "docker pull ghcr.io/xmos/xmosdoc:$XMOSDOC_VERSION"
sh """docker run -u "\$(id -u):\$(id -g)" \
--rm \
-v ${WORKSPACE}:/build \
ghcr.io/xmos/xmosdoc:$XMOSDOC_VERSION -v"""
// Zip all the generated files
zip dir: "doc/_build/", zipFile: "xcore_voice_docs_original.zip"
// Rename latex folder as pdf
sh "mv doc/_build/latex doc/_build/pdf"
// Update links to latex folder in html files
sh "find doc/_build/html -type f -exec sed -i -e 's/latex\\/sln_voice_programming_guide_/pdf\\/sln_voice_programming_guide_/g' {} \\;"
sh "find doc/_build/html -type f -exec sed -i -e 's/latex\\/sln_voice_quick_start_guide_/pdf\\/sln_voice_quick_start_guide_/g' {} \\;"
// Remove linkcheck folder
sh "rm -rf doc/_build/linkcheck"
// Zip all the generated files
zip dir: "doc/_build/", zipFile: "xcore_voice_docs_release.zip"
// Archive doc files
archiveArtifacts artifacts: "xcore_voice_docs*.zip"
}
}
}
post {
cleanup {
xcoreCleanSandbox()
}
}
}
}
}
}
}