forked from espressif/esptool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
575 lines (525 loc) · 17.8 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
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
# Gitlab CI config
#
# Note: When updating, please also update test_esptool.yml GH Actions workflow file
stages:
- pre-check
- test
- report
- build_docs
- deploy_docs
- deploy_development_package
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == "push"'
when: never
- if: '$CI_COMMIT_BRANCH'
include:
- project: espressif/shared-ci-dangerjs
ref: master
file: danger.yaml
run-danger-mr-linter:
stage: pre-check
tags:
- dangerjs
variables:
ENABLE_CHECK_UPDATED_CHANGELOG: 'false'
# 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 --upgrade pip
- pip install -e .[dev] --prefer-binary
version_check:
<<: *test_template
rules:
- if: '$CI_COMMIT_TAG != null'
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
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"
artifacts:
when: always
paths:
- "**/.coverage*"
- ".coverage*"
expire_in: 1 week
reports:
junit: test/report.xml
check_uf2_ids:
<<: *host_tests_template
allow_failure: true
variables:
COVERAGE_PROCESS_START: "${CI_PROJECT_DIR}/test/.covconf"
PYTEST_ADDOPTS: "-sv --junitxml=test/report.xml --color=yes"
script:
- coverage run -m pytest ${CI_PROJECT_DIR}/test/test_uf2_ids.py
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
# some .coverage files in sub-directories are not collected on some runners, move them firs
- find . -mindepth 2 -type f -name ".coverage*" -print -exec mv --backup=numbered {} . \;
host_tests_espefuse:
<<: *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"
parallel:
matrix:
- TARGET:
- esp32
- esp32c2
- esp32c3
- esp32c5
- esp32c5beta3
- esp32c6
- esp32c61
- esp32h2
- esp32h2beta1
- esp32p4
- esp32s2
- esp32s3
- esp32s3beta2
script:
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_espefuse.py --chip ${TARGET}
# 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 {} . \;
host_tests_latest_python:
<<: *host_tests_template
image: python:3.13-bullseye
variables:
PYTEST_ADDOPTS: "-sv --junitxml=test/report.xml --color=yes"
script:
- pytest ${CI_PROJECT_DIR}/test/test_imagegen.py
- pytest ${CI_PROJECT_DIR}/test/test_espsecure.py
- pytest ${CI_PROJECT_DIR}/test/test_merge_bin.py
- pytest ${CI_PROJECT_DIR}/test/test_image_info.py
- pytest ${CI_PROJECT_DIR}/test/test_modules.py
- pytest ${CI_PROJECT_DIR}/test/test_espefuse.py --chip esp32
# 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 python3-venv softhsm2
- ./ci/setup_softhsm2.sh || exit 1
- python3 -m venv esptoolenv
- source esptoolenv/bin/activate
- pip3 install -e .[dev,hsm] --prefer-binary
script:
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_espsecure_hsm.py
run_pre_commit_hooks:
stage: test
image: python:3.7-bullseye
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"
tags:
- host_test
script:
- pip install -e .[dev] --prefer-binary
- pre-commit run --all-files
.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
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"
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
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"
before_script:
- pip install .
script:
- *run_esptool
# Check all the scripts can run when installed in editable mode
check_install_editable:
<<: *test_template
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"
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
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"
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
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"
before_script:
- python -m venv test_env
- source test_env/bin/activate
- python -m pip install .
script:
- *run_esptool
check_stub_build:
<<: *test_template
script:
- ./ci/download_flasher_stubs.py
- git diff --exit-code
.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
# libffi (needed for espsecure) version keeps changing in python docker images. Add a symlink to the installed version on Raspberry Pi
- if [ $(uname -m) = "armv7l" ]; then ln -sfn /usr/lib/arm-linux-gnueabihf/libffi.so.7.1.0 /usr/lib/arm-linux-gnueabihf/libffi.so.6; fi
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:
- 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
variables:
ESPTOOL_TEST_SPI_CONN: "6,2,7,4,10"
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_octal:
extends: .target_esptool_test
tags:
- esptool_esp32s3_32MB_octal_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_32MB_quad:
extends: .target_esptool_test
tags:
- esptool_esp32s3_32MB_quad_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
variables:
ESPTOOL_TEST_SPI_CONN: "12,13,11,9,10"
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
target_esp32s3_sdm:
extends: .target_esptool_test
tags:
- esptool_esp32s3_sdm_target
script:
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_esptool_sdm.py --port /dev/serial_ports/ESP32S3_SDM --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
# ESP32P4
target_esp32p4:
extends: .target_esptool_test
tags:
- esptool_esp32p4_target
script:
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_esptool.py --port /dev/serial_ports/ESP32P4 --chip esp32p4 --baud 115200
# ESP32C5
target_esp32c5:
extends: .target_esptool_test
tags:
- esptool_esp32c5_target
script:
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_esptool.py --port /dev/serial_ports/ESP32C5 --chip esp32c5 --baud 115200
# ESP32C61
target_esp32c61:
extends: .target_esptool_test
tags:
- esptool_esp32c61_target
script:
- coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_esptool.py --port /dev/serial_ports/ESP32C61 --chip esp32c61 --baud 115200
.windows_test:
stage: test
variables:
PYTEST_ADDOPTS: "-sv --junitxml=test/report.xml --color=yes"
PYTHONPATH: "$PYTHONPATH:${CI_PROJECT_DIR}/test"
COVERAGE_PROCESS_START: "${CI_PROJECT_DIR}/test/.covconf"
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"
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
tags:
- windows-target
host_tests_windows:
extends: .windows_test
script:
- python -m coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_espefuse.py
- python -m coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_espsecure.py
- python -m coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_imagegen.py
- python -m coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_image_info.py
- python -m coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_modules.py
- python -m coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_merge_bin.py
target_tests_windows:
extends: .windows_test
script:
- python -m coverage run --parallel-mode -m pytest ${CI_PROJECT_DIR}/test/test_esptool.py --port COM4 --chip esp32 --baud 115200 -m quick_test
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
COVERAGE_RCFILE: "${CI_PROJECT_DIR}/test/.covconf"
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
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
- 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,esp32c2,esp32c6,esp32h2,esp32p4,esp32c5,esp32c61}
.deploy_docs_template:
stage: deploy_docs
image: python:3.7-bullseye
tags:
- deploy
needs:
- build_docs
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
rules:
- if: $CI_COMMIT_REF_NAME == "master" || $CI_PIPELINE_SOURCE == "schedule"
when: never
- changes:
- "docs/**/*"
- "CONTRIBUTING.rst"
variables:
TYPE: "preview"
DOCS_BUILD_DIR: "${CI_PROJECT_DIR}/docs/_build/"
DOCS_DEPLOY_PRIVATEKEY: "$DOCS_PREVIEW_DEPLOY_KEY"
DOCS_DEPLOY_SERVER: "$DOCS_PREVIEW_SERVER"
DOCS_DEPLOY_SERVER_USER: "$DOCS_PREVIEW_SERVER_USER"
DOCS_DEPLOY_PATH: "$DOCS_PREVIEW_PATH"
DOCS_DEPLOY_URL_BASE: "$DOCS_PREVIEW_URL_BASE"
deploy_docs_production:
extends:
- .deploy_docs_template
rules:
- if: $CI_COMMIT_REF_NAME == "master" && $CI_PIPELINE_SOURCE != "schedule"
changes:
- "docs/**/*"
- "CONTRIBUTING.rst"
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"