-
Notifications
You must be signed in to change notification settings - Fork 92
/
.gitlab-ci.yml
340 lines (308 loc) · 9.57 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
stages:
- check
- build
- target_test
- deploy
variables:
# System environment
# Common parameters for the 'make' during CI tests
MAKEFLAGS: "-j5 --no-keep-going"
# GitLab-CI environment
TARGET_TEST_ENV_IMAGE: "$CI_DOCKER_REGISTRY/target-test-env-v5.2:1"
ESP_DOCS_ENV_IMAGE: "$CI_DOCKER_REGISTRY/esp-idf-doc-env-v5.0:2-2"
GET_SOURCES_ATTEMPTS: "10"
ARTIFACT_DOWNLOAD_ATTEMPTS: "10"
GIT_SUBMODULE_STRATEGY: none
ESP_DOCS_PATH: "$CI_PROJECT_DIR"
TEST_DIR: "$CI_PROJECT_DIR/test_app"
SIZE_INFO_LOCATION: "${TEST_DIR}/size_info.txt"
ESP_IDF_GIT: "https://gitlab-ci-token:${CI_JOB_TOKEN}@${GITLAB_HTTPS_SERVER}/espressif/esp-idf.git"
.setup_idf_tools: &setup_idf_tools |
tools/idf_tools.py --non-interactive install && eval "$(tools/idf_tools.py --non-interactive export)" || exit 1
.add_gh_key_remote: &add_gh_key_remote |
command -v ssh-agent >/dev/null || exit 1
eval $(ssh-agent -s)
printf '%s\n' "${GH_PUSH_KEY}" | tr -d '\r' | ssh-add - > /dev/null
mkdir -p ~/.ssh && chmod 700 ~/.ssh
[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config || ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
git remote remove github || true
git remote add github ${GH_PUSH_REPO}
check_pre_commit_MR:
stage: check
image: "$CI_DOCKER_REGISTRY/esp-idf-pre-commit:1"
tags:
- build
- internet
dependencies: []
script:
- pre-commit run --all-files --show-diff-on-failure
.install_clang: &install_clang |
pip install --upgrade pyclang
$IDF_PATH/tools/idf_tools.py --non-interactive install esp-clang
source $IDF_PATH/export.sh
.before_script_build_jobs:
before_script:
- *install_clang
# This template gets expanded multiple times, once for every IDF version.
# IDF version is specified by setting the espressif/idf image tag.
#
# EXAMPLE_TARGETS sets the list of IDF_TARGET values to build examples for.
# It should be equal to the list of targets supported by the specific IDF version.
#
# TEST_TARGETS sets the list of IDF_TARGET values to build the test_app for.
# It should contain only the targets with optimized assembly implementations.
#
.build_template:
stage: build
tags:
- build
- internet
dependencies: []
script:
- ./build_all.sh
variables:
EXAMPLE_TARGETS: "esp32"
TEST_TARGETS: "esp32"
IDF_TOOLCHAIN: "gcc"
# GCC builds
build_idf_v4.2:
extends: .build_template
image: espressif/idf:release-v4.2
variables:
EXAMPLE_TARGETS: "esp32 esp32s2"
build_idf_v4.3:
extends: .build_template
image: espressif/idf:release-v4.3
variables:
EXAMPLE_TARGETS: "esp32 esp32s2 esp32c3"
build_idf_v4.4:
extends: .build_template
image: espressif/idf:release-v4.4
variables:
EXAMPLE_TARGETS: "esp32 esp32s2 esp32c3 esp32s3"
TEST_TARGETS: "esp32 esp32s3"
build_idf_v5.0:
extends: .build_template
image: espressif/idf:release-v5.0
variables:
EXAMPLE_TARGETS: "esp32 esp32s2 esp32s3 esp32c3 esp32c2"
TEST_TARGETS: "esp32 esp32s3"
# GNU Make based build system is not supported starting from IDF v5.0
SKIP_GNU_MAKE_BUILD: 1
build_idf_v5.3:
extends: .build_template
image: espressif/idf:release-v5.3
variables:
EXAMPLE_TARGETS: "esp32 esp32s2 esp32s3 esp32c3 esp32c2"
TEST_TARGETS: "esp32 esp32s3"
# GNU Make based build system is not supported starting from IDF v5.0
SKIP_GNU_MAKE_BUILD: 1
build_idf_latest:
extends: .build_template
image: espressif/idf:latest
variables:
EXAMPLE_TARGETS: "esp32 esp32s2 esp32s3 esp32c3 esp32p4"
TEST_TARGETS: "esp32 esp32s3 esp32p4"
# GNU Make based build system is not supported starting from IDF v5.0
SKIP_GNU_MAKE_BUILD: 1
# clang build
build_clang_idf_latest:
extends:
- .before_script_build_jobs
- .build_template
image: espressif/idf:latest
variables:
EXAMPLE_TARGETS: "esp32 esp32s2 esp32c3 esp32s3"
TEST_TARGETS: "esp32 esp32s3"
IDF_TOOLCHAIN: clang
# GNU Make based build system is not supported starting from IDF v5.0
SKIP_GNU_MAKE_BUILD: 1
# target tests related parts:
.build_pytest_template:
stage: build
image: $TARGET_TEST_ENV_IMAGE
extends:
- .build_template
artifacts:
paths:
- "**/build*/*.bin"
- "**/build*/*.elf"
- "**/build*/*.map"
- "**/build*/flasher_args.json"
- "**/build*/flash_project_args"
- "**/build*/config/sdkconfig.json"
- "**/build*/bootloader/*.bin"
- "**/build*/partition_table/*.bin"
- $SIZE_INFO_LOCATION
when: always
expire_in: 3 days
before_script:
# Get ESP-IDF and install the tools.
- pip install idf-component-manager --upgrade
- pip install "idf_build_apps~=0.3.0"
- cd /opt/
- git clone -b master --depth 1 https://github.com/espressif/esp-idf.git
- cd esp-idf
- export IDF_PATH=${PWD}
# - export IDF_DESCRIBE=`git describe`
# - export IDF_VERSION=${IDF_DESCRIBE%-*}
- tools/idf_tools.py --non-interactive install cmake
- tools/idf_tools.py install-python-env
- tools/idf_tools.py --non-interactive install && eval "$(tools/idf_tools.py --non-interactive export)" || exit 1
# - 'echo "ESP-IDF: ${IDF_VERSION}" >> ${TEST_DIR}/idf_version_info.txt'
script:
# CI specific options start from "--collect-size-info xxx". could ignore when running locally
# The script below will build all test applications defined in environment variable $TEST_TARGETS
- cd ${TEST_DIR}
- python -m idf_build_apps build -v -p .
--recursive
--target all
--default-build-targets ${TEST_TARGETS}
--config "sdkconfig.*=" --build-dir "build"
--collect-size-info $SIZE_INFO_LOCATION
--parallel-count ${CI_NODE_TOTAL:-1}
--parallel-index ${CI_NODE_INDEX:-1}
--ignore-warning-str "DeprecationWarning:"
variables:
TEST_TARGETS: "esp32"
build_latest_test_app:
extends: .build_pytest_template
image: espressif/idf:latest
variables:
TEST_TARGETS: "esp32"
.target_test_template:
image: $TARGET_TEST_ENV_IMAGE
stage: target_test
timeout: 1 hour
variables:
GIT_DEPTH: 1
SUBMODULES_TO_FETCH: "none"
cache:
# Usually do not need submodule-cache in target_test
- key: pip-cache
paths:
- .cache/pip
policy: pull
.before_script_pytest_jobs:
before_script:
# Get ESP-IDF and install the tools.
- dir
- cd /opt/
- git clone -b ${IDF_BRANCH} --depth 1 https://github.com/espressif/esp-idf.git
- cd esp-idf
- export IDF_PATH=${PWD}
# - export IDF_DESCRIBE=`git describe`
# - export IDF_VERSION=${IDF_DESCRIBE%-*}
# - tools/idf_tools.py --non-interactive install cmake
# - tools/idf_tools.py install-python-env
# - tools/idf_tools.py --non-interactive install && eval "$(tools/idf_tools.py --non-interactive export)" || exit 1
# - 'echo "ESP-IDF: ${IDF_VERSION}" >> ${TEST_DIR}/idf_version_info.txt'
# - pip install "pytest-embedded-serial-esp~=1.2.3" "pytest-embedded-idf~=1.2.3"
.test_template:
stage: target_test
image: $TARGET_TEST_ENV_IMAGE
extends:
- .before_script_pytest_jobs
tags: [esp32]
# artifacts:
# paths:
# - "${TEST_DIR}/*/*.log"
# - "${TEST_DIR}/*.txt"
# - "${TEST_DIR}/*/results_*.xml"
# - "${TEST_DIR}/pytest_embedded_log/"
# reports:
# junit: ${TEST_DIR}/results_${IDF_TARGET}.xml
# when: always
# expire_in: 1 week
script:
- dir
- cd ${TEST_DIR}
- dir
- python -m pytest --junit-xml=./results_${TEST_TARGETS}.xml --target=${TEST_TARGETS}
- ls -lh > test_dir.txt
variables:
TEST_TARGETS: "esp32"
test_examples:
extends: .test_template
parallel:
matrix:
- IDF_BRANCH: ["master"]
IDF_TARGET: ["esp32"]
after_script: []
#-------------------------------
build_docs:
stage: build
image: $ESP_DOCS_ENV_IMAGE
tags:
- build_docs
dependencies: []
artifacts:
when: always
paths:
- docs/_build/*/*/*.txt
- docs/_build/*/*/html/*
expire_in: 4 days
# No cleaning when the artifacts
after_script: []
script:
- cd docs
- pip install -r requirements.txt
- build-docs -l en -t esp32
.deploy_docs_template:
stage: deploy
image: $ESP_DOCS_ENV_IMAGE
tags:
- deploy_docs
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
- 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_PREVIEW_PRIVATEKEY
DOCS_DEPLOY_SERVER: $DOCS_DEPLOY_PREVIEW_SERVER
DOCS_DEPLOY_SERVER_USER: $DOCS_PREVIEW_SERVER_USER
DOCS_DEPLOY_PATH: $DOCS_DEPLOY_PREVIEW_PATH
DOCS_DEPLOY_URL_BASE: "${DOCS_PREVIEW_SERVER_URL}"
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_PRIVATEKEY"
DOCS_DEPLOY_SERVER: "$DOCS_PROD_SERVER"
DOCS_DEPLOY_SERVER_USER: "$DOCS_PROD_SERVER_USER"
DOCS_DEPLOY_PATH: "$DOCS_PROD_PATH"
DOCS_DEPLOY_URL_BASE: "${DOCS_PROD_URL_BASE}"
push_master_to_github:
stage: deploy
tags:
- deploy
only:
- master
- /^release\/v/
- /^v\d+\.\d+(\.\d+)?($|-)/
when: on_success
dependencies: []
script:
- git clone --depth 1 ${ESP_IDF_GIT} esp-idf
- *add_gh_key_remote
- esp-idf/tools/ci/push_to_github.sh