forked from espressif/esptool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
365 lines (335 loc) · 11.2 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
# Gitlab CI config
#
# Note: When updating, please also update test_esptool.yml GH Actions workflow file
stages:
- test
- report
- build_docs
- deploy_docs
# 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:
<<: *test_template
artifacts:
when: always
paths:
- "**/.coverage*"
- ".coverage*"
expire_in: 1 week
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
# 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 {} . \;
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:
reports:
junit: test/report.xml
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:
- ./test/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_esptool_test_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_esptool_test_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_esptool_test_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_esptool_test_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_esptool_test_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
# ESP32S3
target_esptool_test_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_esptool_test_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
# ESP32C2
target_esptool_test_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_esptool_test_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
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
- coverage html -d html_report
- coverage xml -o cobertura_report.xml
build_docs:
stage: build_docs
image: python:3.7-bullseye
tags:
- build_docs
only:
changes:
- "docs/**/*"
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/**/*"
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"