forked from espressif/esptool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
464 lines (424 loc) · 14.9 KB
/
.gitlab-ci.yml
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
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
# Gitlab CI config
#
# Note: When updating, please also update test_esptool.yml GH Actions workflow file
stages:
- test
- report
- build_docs
- deploy_docs
- deploy_development_package
# cache the pip download directory in all jobs
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
PIP_EXTRA_INDEX_URL: "https://dl.espressif.com/pypi"
cache:
paths:
- "$CI_PROJECT_DIR/.cache/pip"
.test_template: &test_template
stage: test
image: python:3.7-bullseye
tags:
- host_test
dependencies: []
before_script:
- pip install -e .[dev] --prefer-binary
version_check:
<<: *test_template
only:
- tags
script:
- VERSION=$(esptool.py version | head -n 1)
- |
if [[ "$VERSION" != *"$CI_COMMIT_TAG" ]]
then
echo "Version number and git tag do not match!"
exit 1
fi
.host_tests_template: &host_tests_template
<<: *test_template
artifacts:
when: always
paths:
- "**/.coverage*"
- ".coverage*"
expire_in: 1 week
reports:
junit: test/report.xml
host_tests:
<<: *host_tests_template
variables:
PYTHONPATH: "$PYTHONPATH:${CI_PROJECT_DIR}/test"
COVERAGE_PROCESS_START: "${CI_PROJECT_DIR}/test/.covconf"
PYTEST_ADDOPTS: "-sv --junitxml=test/report.xml --color=yes"
script:
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_imagegen.py
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_espsecure.py
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_merge_bin.py
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_image_info.py
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_modules.py
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_espefuse.py --chip esp32
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_espefuse.py --chip esp32c2
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_espefuse.py --chip esp32c3
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_espefuse.py --chip esp32s2
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_espefuse.py --chip esp32s3
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_espefuse.py --chip esp32s3beta2
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_espefuse.py --chip esp32h2beta1
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_espefuse.py --chip esp32c6
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_espefuse.py --chip esp32h2
# some .coverage files in sub-directories are not collected on some runners, move them first
- find . -mindepth 2 -type f -name ".coverage*" -print -exec mv --backup=numbered {} . \;
# A new job "host_test_hsm" is created for the test "test_espsecure_hsm.py" which runs an ubuntu image,
# because python-pkcs11 (v0.7.0) package is compiled using GLIBC_2.34 but docker image python:3.7-bullseye
# support versions only upto GLIBC_2.31.
host_tests_hsm:
<<: *host_tests_template
image: ubuntu:latest
variables:
COVERAGE_PROCESS_START: "${CI_PROJECT_DIR}/test/.covconf"
PYTEST_ADDOPTS: "-sv --junitxml=test/report.xml --color=yes"
before_script:
- apt-get update
- apt-get install -y python3 python3-pip softhsm2
- ./ci/setup_softhsm2.sh || exit 1
- pip3 install -e .[dev,hsm] --prefer-binary
script:
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_espsecure_hsm.py
check_python_style:
stage: test
image: python:3.7-bullseye
tags:
- host_test
artifacts:
reports:
codequality: code_quality_report.json
when: on_failure
script:
# This step installs any 'dev' dependencies (ie flake8, Black)
# The runner should cache the downloads, so still quite fast.
- pip install -e .[dev] --prefer-binary
- python -m flake8 --exit-zero --format gl-codeclimate --output-file code_quality_report.json
- python -m flake8
- python -m black --check --diff .
.run_esptool: &run_esptool |
esptool.py --help
espefuse.py --help
espsecure.py --help
python esptool.py --help
python espefuse.py --help
python espsecure.py --help
python -m esptool --help
python -m espefuse --help
python -m espsecure --help
# Check all the scripts can run when installed, collect coverage
check_install_coverage:
<<: *test_template
artifacts:
when: always
paths:
- "**/.coverage*"
- ".coverage*"
expire_in: 1 week
script:
- coverage run --parallel-mode setup.py install
- coverage run --parallel-mode esptool.py --help
- coverage run --parallel-mode espefuse.py --help
- coverage run --parallel-mode espsecure.py --help
- *run_esptool
# Check all the scripts can run when installed
check_install:
<<: *test_template
before_script:
- pip install .
script:
- *run_esptool
# Check all the scripts can run when installed in editable mode
check_install_editable:
<<: *test_template
before_script:
- pip install -e .
script:
- *run_esptool
# Check all the scripts can run when installed in Python user install directory
check_install_system:
<<: *test_template
before_script:
- pip install --user .
script:
- python esptool.py --help
- python espefuse.py --help
- python espsecure.py --help
- python -m esptool --help
- python -m espefuse --help
- python -m espsecure --help
# Check all the scripts can run when installed in virtual environment
check_install_venv:
<<: *test_template
before_script:
- python -m venv test_env
- source test_env/bin/activate
- python -m pip install .
script:
- *run_esptool
# Check the stub can build and that a stub built in CI has the same contents
# as the one embedded in esptool
check_stub_build:
<<: *test_template
artifacts:
when: always
paths:
- flasher_stub/build/
- "**/.coverage*"
- ".coverage*"
expire_in: 1 week
variables:
TOOLCHAIN_DIR: "/root/.espressif/dist"
ESP8266_BINDIR: "${TOOLCHAIN_DIR}/xtensa-lx106-elf/bin"
ESP32_BINDIR: "${TOOLCHAIN_DIR}/xtensa-esp32-elf/bin"
ESP32S2_BINDIR: "${TOOLCHAIN_DIR}/xtensa-esp32s2-elf/bin"
ESP32S3_BINDIR: "${TOOLCHAIN_DIR}/xtensa-esp32s3-elf/bin"
ESP32C3_BINDIR: "${TOOLCHAIN_DIR}/riscv32-esp-elf/bin"
TOOLCHAIN_PATHS: "${ESP8266_BINDIR}:${ESP32_BINDIR}:${ESP32S2_BINDIR}:${ESP32S3_BINDIR}:${ESP32C3_BINDIR}"
script:
- ./ci/setup_ci_build_env.sh
- make -C flasher_stub V=1 PATH="${TOOLCHAIN_PATHS}:${PATH}"
- cd flasher_stub && coverage run --parallel-mode ./compare_stubs.py
.target_esptool_test:
stage: test
image: python:3.7-bullseye
variables:
PYTHONPATH: "$PYTHONPATH:${CI_PROJECT_DIR}/test"
COVERAGE_PROCESS_START: "${CI_PROJECT_DIR}/test/.covconf"
PYTEST_ADDOPTS: "-sv --junitxml=test/report.xml --color=yes"
before_script:
- pip install -e .[dev] --prefer-binary
artifacts:
reports:
junit: test/report.xml
when: always
paths:
- test/*.out
- "**/.coverage*"
- ".coverage*"
expire_in: 1 week
# ESP8266
target_esp8266:
extends: .target_esptool_test
tags:
- esptool_esp8266_target
script:
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_esptool.py --port /dev/serial_ports/ESP8266 --chip esp8266 --baud 115200
# ESP32
target_esp32:
extends: .target_esptool_test
tags:
- esptool_esp32_target
script:
# libffi (needed for espsecure) version keeps changing in python docker images, add a symlink to the installed version
- ln -sfn /usr/lib/arm-linux-gnueabihf/libffi.so.7.1.0 /usr/lib/arm-linux-gnueabihf/libffi.so.6
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_esptool.py --port /dev/serial_ports/ESP32 --chip esp32 --baud 115200
# ESP32S2
target_esp32s2:
extends: .target_esptool_test
tags:
- esptool_esp32s2_target
script:
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_esptool.py --port /dev/serial_ports/ESP32S2 --chip esp32s2 --baud 115200
target_esp32s2_usbcdc:
extends: .target_esptool_test
tags:
- esptool_esp32s2_cdc_target
script:
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_esptool.py --port /dev/serial_ports/ESP32S2_USBCDC --chip esp32s2 --baud 115200
# ESP32C3
target_esp32c3:
extends: .target_esptool_test
tags:
- esptool_esp32c3_target
script:
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_esptool.py --port /dev/serial_ports/ESP32C3 --chip esp32c3 --baud 115200
target_esp32c3_jtag_serial:
extends: .target_esptool_test
tags:
- esptool_esp32c3_jtag_serial_target
script:
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_esptool.py --port /dev/serial_ports/ESP32C3_JTAG_SERIAL --preload-port /dev/serial_ports/ESP32C3_PRELOAD --chip esp32c3 --baud 115200
# ESP32S3
target_esp32s3:
extends: .target_esptool_test
tags:
- esptool_esp32s3_target
script:
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_esptool.py --port /dev/serial_ports/ESP32S3 --chip esp32s3 --baud 115200
target_esp32s3_32MB:
extends: .target_esptool_test
tags:
- esptool_esp32s3_32MB_target
variables:
ESPTOOL_TEST_FLASH_SIZE: "32"
script:
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_esptool.py --port /dev/serial_ports/ESP32S3_32MB --chip esp32s3 --baud 115200
target_esp32s3_usbcdc:
extends: .target_esptool_test
tags:
- esptool_esp32s3_cdc_target
script:
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_esptool.py --port /dev/serial_ports/ESP32S3_USBCDC --chip esp32s3 --baud 115200
target_esp32s3_jtag_serial:
extends: .target_esptool_test
tags:
- esptool_esp32s3_jtag_serial_target
script:
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_esptool.py --port /dev/serial_ports/ESP32S3_JTAG_SERIAL --preload-port /dev/serial_ports/ESP32S3_PRELOAD --chip esp32s3 --baud 115200
# ESP32C2
target_esp32c2_40mhz:
extends: .target_esptool_test
tags:
- esptool_esp32c2_40mhz_target
script:
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_esptool.py --port /dev/serial_ports/ESP32C2_40MHZ --chip esp32c2 --baud 115200
target_esp32c2_26mhz:
extends: .target_esptool_test
tags:
- esptool_esp32c2_26mhz_target
script:
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_esptool.py --port /dev/serial_ports/ESP32C2_26MHZ --chip esp32c2 --baud 115200
# ESP32C6
target_esp32c6:
extends: .target_esptool_test
tags:
- esptool_esp32c6_target
script:
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_esptool.py --port /dev/serial_ports/ESP32C6 --chip esp32c6 --baud 115200
target_esp32c6_jtag_serial:
extends: .target_esptool_test
tags:
- esptool_esp32c6_jtag_serial_target
script:
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_esptool.py --port /dev/serial_ports/ESP32C6_JTAG_SERIAL --preload-port /dev/serial_ports/ESP32C6_PRELOAD --chip esp32c6 --baud 115200
# ESP32H2
target_esp32h2:
extends: .target_esptool_test
tags:
- esptool_esp32h2_target
script:
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_esptool.py --port /dev/serial_ports/ESP32H2 --chip esp32h2 --baud 115200
target_esp32h2_jtag_serial:
extends: .target_esptool_test
tags:
- esptool_esp32h2_jtag_serial_target
script:
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_esptool.py --port /dev/serial_ports/ESP32H2_JTAG_SERIAL --preload-port /dev/serial_ports/ESP32H2_PRELOAD --chip esp32h2 --baud 115200
combine_reports:
stage: report
image: python:3.7-bullseye
tags:
- host_test
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: cobertura_report.xml
when: always
paths:
- ".coverage*"
- cobertura_report.xml
- ./html_report/
expire_in: 1 week
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
variables:
LC_ALL: C.UTF-8
before_script:
- pip install -e .[dev] --prefer-binary
script:
# all .coverage files in sub-directories are moved to the parent dir first
- find . -mindepth 2 -type f -name ".coverage*" -print -exec mv --backup=numbered {} . \;
- coverage combine
- coverage report --precision=2
- coverage html -d html_report --precision=2
- coverage xml -o cobertura_report.xml
build_docs:
stage: build_docs
image: python:3.7-bullseye
tags:
- build_docs
only:
changes:
- "docs/**/*"
- "CONTRIBUTING.rst"
needs: []
artifacts:
when: always
paths:
- docs/_build/*/*/*.txt
- docs/_build/*/*/html/*
expire_in: 4 days
script:
- cd docs
- pip install -r requirements.txt --prefer-binary
- build-docs -l en -t {esp8266,esp32,esp32s2,esp32c3,esp32s3}
.deploy_docs_template:
stage: deploy_docs
image: python:3.7-bullseye
tags:
- deploy
needs:
- build_docs
only:
changes:
- "docs/**/*"
- "CONTRIBUTING.rst"
script:
- source ${CI_PROJECT_DIR}/docs/utils.sh
- add_doc_server_ssh_keys $DOCS_DEPLOY_PRIVATEKEY $DOCS_DEPLOY_SERVER $DOCS_DEPLOY_SERVER_USER
- export GIT_VER=$(git describe --always)
- pip install -r ${CI_PROJECT_DIR}/docs/requirements.txt --prefer-binary
- deploy-docs
deploy_docs_preview:
extends:
- .deploy_docs_template
except:
refs:
- master
variables:
TYPE: "preview"
DOCS_BUILD_DIR: "${CI_PROJECT_DIR}/docs/_build/"
DOCS_DEPLOY_PRIVATEKEY: "$DOCS_DEPLOY_KEY"
DOCS_DEPLOY_SERVER: "$DOCS_SERVER"
DOCS_DEPLOY_SERVER_USER: "$DOCS_SERVER_USER"
DOCS_DEPLOY_PATH: "$DOCS_PATH"
DOCS_DEPLOY_URL_BASE: "https://$DOCS_PREVIEW_SERVER_URL/docs/esptool"
deploy_docs_production:
extends:
- .deploy_docs_template
only:
refs:
- master
variables:
TYPE: "production"
DOCS_BUILD_DIR: "${CI_PROJECT_DIR}/docs/_build/"
DOCS_DEPLOY_PRIVATEKEY: "$DOCS_PROD_DEPLOY_KEY"
DOCS_DEPLOY_SERVER: "$DOCS_PROD_SERVER"
DOCS_DEPLOY_SERVER_USER: "$DOCS_PROD_SERVER_USER"
DOCS_DEPLOY_PATH: "$DOCS_PROD_PATH"
DOCS_DEPLOY_URL_BASE: "https://docs.espressif.com/projects/esptool"
deploy_dev_package:
<<: *test_template
rules:
- if: $CI_DEV_PUBLISH != null && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
variables:
TWINE_NON_INTERACTIVE: "true"
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${PYPI_ESPTOOL_TOKEN}
stage: deploy_development_package
dependencies: []
script:
- python -m pip install --upgrade pip
- python -m pip install twine setuptools
- python ci/patch_dev_release.py --dev-no ${CI_DEV_PUBLISH} esptool/__init__.py
# check what has been changed with git
- git diff
- python setup.py sdist
# skip release if it has already been released (with failure)
- python -m pip download esptool==$(python setup.py -V) && exit 1
- tar -ztvf dist/*
- python -m twine upload dist/*