forked from espressif/esp-adf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
361 lines (336 loc) · 11.5 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
stages:
- build
- assign_test
# - example_test
- deploy
variables:
# System environment
# Common parameters for the 'make' during CI tests
MAKEFLAGS: "-j5 --no-keep-going"
# GitLab-CI environment
# more attempts for more robust
GET_SOURCES_ATTEMPTS: "10"
ARTIFACT_DOWNLOAD_ATTEMPTS: "10"
# We use get_sources.sh script to fetch the submodules and/or re-fetch the repo
# if it was corrupted (if submodule update fails this can happen)
GIT_STRATEGY: clone
GIT_SUBMODULE_STRATEGY: none
ADF_PATH: "$CI_PROJECT_DIR"
IDF_PATH: "$CI_PROJECT_DIR/esp-idf"
.setup_tools_unless_target_test: &setup_tools_unless_target_test |
if [[ "$SETUP_TOOLS" == "1" || "$CI_JOB_STAGE" != "target_test" ]]; then
$IDF_PATH/tools/idf_tools.py --non-interactive install && eval "$($IDF_PATH/tools/idf_tools.py --non-interactive export)" || exit 1
fi
before_script:
# add gitlab ssh key
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo -n $GITLAB_KEY > ~/.ssh/id_rsa_base64
- base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
# replace submodule esp-idf to internal repository to speedup cloning
- sed -i "s%https://github.com/espressif/esp-idf%${GITLAB_SSH_SERVER}/idf/esp-idf.git%" .gitmodules
# replace submodule esp-adf-libs to internal repository to speedup cloning
- sed -i "s%https://github.com/espressif/esp-adf-libs%${GITLAB_SSH_SERVER}/adf/esp-adf-libs.git%" .gitmodules
# - sed -i "s%https://github.com/espressif/esp-sr.git%${GITLAB_SSH_SERVER}/speech-recognition-internal/esp_sr_public.git%" .gitmodules
- git submodule update --init
# (the same regular expressions are used to set these are used in 'only:' sections below
- source esp-idf/tools/ci/configure_ci_environment.sh
# fetch the submodules (& if necessary re-fetch repo) from gitlab
- time ./esp-idf/tools/ci/get-full-sources.sh
.add_gitlab_key_before:
before_script: &add_gitlab_key_before
- echo "Not fetching submodules"
- source $IDF_PATH/tools/ci/configure_ci_environment.sh
# add gitlab ssh key
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo -n $AUTO_KEY > ~/.ssh/id_rsa_base64
- base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
.build_template: &build_template
stage: build
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
tags:
- build
variables:
BATCH_BUILD: "1"
V: "0"
.build_examples_template: &build_examples_template
<<: *build_template
artifacts:
when: always
paths:
- build_examples/*/*/*/build/*.bin
- build_examples/*/*/*/build/*.elf
- build_examples/*/*/*/build/*.map
- build_examples/*/*/*/build/download.config
- build_examples/*/*/*/build/bootloader/*.bin
- $LOG_PATH
expire_in: 1 week
variables:
IDF_CI_BUILD: "1"
LOG_PATH: "$CI_PROJECT_DIR/log_examples"
script:
# it's not possible to build 100% out-of-tree and have the "artifacts"
# mechanism work, but this is the next best thing
- rm -rf build_examples
- mkdir build_examples
- cd build_examples
# build some of examples
- mkdir -p ${LOG_PATH}
- ${ADF_PATH}/tools/ci/build_examples.sh "${CI_JOB_NAME}"
.build_examples_make: &build_examples_make
<<: *build_template
parallel: 8
# This is a workaround for a rarely encountered issue with building examples in CI.
# Probably related to building of Kconfig in 'make clean' stage
retry: 1
artifacts:
when: always
paths:
- build_examples/*/*/*/build/*.bin
- build_examples/*/*/*/sdkconfig
- build_examples/*/*/*/build/*.elf
- build_examples/*/*/*/build/*.map
- build_examples/*/*/*/build/download.config
- build_examples/*/*/*/build/bootloader/*.bin
- build_examples/*/*/*/*/build/partition_table/*.bin
- $LOG_PATH
expire_in: 4 days
variables:
IDF_CI_BUILD: "1"
LOG_PATH: "$CI_PROJECT_DIR/log_examples_make"
# This is IDF CI limits
# only:
# # Here both 'variables' and 'refs' conditions are given. They are combined with "AND" logic.
# variables:
# - $BOT_TRIGGER_WITH_LABEL == null
# - $BOT_LABEL_BUILD
# - $BOT_LABEL_EXAMPLE_TEST
# - $BOT_LABEL_REGULAR_TEST
# - $BOT_LABEL_WEEKEND_TEST
# refs:
# - master
# - /^release\/v/
# - /^v\d+\.\d+(\.\d+)?($|-)/
# - triggers
# - schedules
# - pipelines
# - web
script:
# it's not possible to build 100% out-of-tree and have the "artifacts"
# mechanism work, but this is the next best thing
- rm -rf build_examples
- mkdir build_examples
- cd build_examples
# build some of examples
- mkdir -p ${LOG_PATH}
# enable pedantic flags for compilation
- export PEDANTIC_CFLAGS="-Werror -Werror=deprecated-declarations -Werror=unused-variable -Werror=unused-but-set-variable -Werror=unused-function"
- export EXTRA_CFLAGS=${PEDANTIC_CFLAGS} && export EXTRA_CXXFLAGS=${EXTRA_CFLAGS}
- ${ADF_PATH}/tools/ci/build_examples.sh
# Check if the tests demand Make built binaries. If not, delete them
- if [ "$EXAMPLE_TEST_BUILD_SYSTEM" == "make" ]; then exit 0; fi
- cd ..
- rm -rf build_examples
# same as above, but for CMake
.build_examples_cmake: &build_examples_cmake
extends: .build_template
parallel: 8
artifacts:
when: always
paths:
- build_examples/list.json
- build_examples/list_job_*.json
- build_examples/*/*/*/sdkconfig
- build_examples/*/*/*/build/*.bin
- build_examples/*/*/*/build/*.elf
- build_examples/*/*/*/build/*.map
- build_examples/*/*/*/build/flasher_args.json
- build_examples/*/*/*/build/bootloader/*.bin
- build_examples/*/*/*/build/partition_table/*.bin
- $LOG_PATH
expire_in: 4 days
variables:
LOG_PATH: "$CI_PROJECT_DIR/log_examples"
BUILD_PATH: "$CI_PROJECT_DIR/build_examples"
only:
variables:
- $BOT_TRIGGER_WITH_LABEL == null
- $BOT_LABEL_BUILD
- $BOT_LABEL_EXAMPLE_TEST
- $BOT_LABEL_REGULAR_TEST
- $BOT_LABEL_WEEKEND_TEST
script:
# it's not possible to build 100% out-of-tree and have the "artifacts"
# mechanism work, but this is the next best thing
- mkdir -p ${BUILD_PATH}
- mkdir -p ${LOG_PATH}
- echo "The IDF branch is "${IDF_VERSION}
- $ADF_PATH/tools/ci/set_idf.sh ${IDF_VERSION}
- *setup_tools_unless_target_test
- export PEDANTIC_CFLAGS="-Werror -Wno-implicit-fallthrough"
- export EXTRA_CFLAGS=${PEDANTIC_CFLAGS} && export EXTRA_CXXFLAGS=${EXTRA_CFLAGS}
- ${ADF_PATH}/tools/ci/build_examples_cmake.sh
# Check if the tests demand CMake built binaries. If not, delete them
- if [ "$EXAMPLE_TEST_BUILD_SYSTEM" == "cmake" ]; then exit 0; fi
- cd ..
- rm -rf build_examples
build_examples_v40_cmake:
extends: .build_examples_cmake
variables:
IDF_TARGET: esp32
IDF_VERSION: release/v4.0
build_examples_v41_cmake:
extends: .build_examples_cmake
variables:
IDF_TARGET: esp32
IDF_VERSION: release/v4.1
build_examples_v42_cmake:
extends: .build_examples_cmake
variables:
IDF_TARGET: esp32
IDF_VERSION: release/v4.2
.build_examples_cmake_s2:
extends: .build_examples_cmake
variables:
IDF_TARGET: esp32s2beta
IDF_VERSION: release/v4.1
build_examples_v33_make:
<<: *build_examples_make
build_adf_test:
<<: *build_template
artifacts:
when: always
paths:
- adf-cli/build/*.bin
- adf-cli/build/*.elf
- adf-cli/build/*.map
- adf-cli/build/download.config
- adf-cli/build/bootloader/*.bin
- $IDF_PATH/tools/ci
- $IDF_PATH/components/esptool_py
- $IDF_PATH/components/partition_table
expire_in: 1 month
script:
- git clone ${ADF_TEST_CLI_REPO}
- cd adf-cli
- git checkout ${CI_COMMIT_REF_NAME} || echo "Using adf-cli default branch..."
- make defconfig
- make
- make print_flash_cmd > build/download.config
build_docs:
stage: build
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
tags:
- build_docs
artifacts:
when: always
paths:
# English version of documentation
- docs/en/doxygen-warning-log.txt
- docs/en/sphinx-warning-log.txt
- docs/en/sphinx-warning-log-sanitized.txt
- docs/en/_build/html
- docs/sphinx-err-*
# Chinese version of documentation
- docs/zh_CN/doxygen-warning-log.txt
- docs/zh_CN/sphinx-warning-log.txt
- docs/zh_CN/sphinx-warning-log-sanitized.txt
- docs/zh_CN/_build/html
expire_in: 1 mos
script:
- cd docs
- ./check_lang_folder_sync.sh
- cd en
- make gh-linkcheck
- make html
- ../check_doc_warnings.sh
- cd ../zh_CN
- make gh-linkcheck
- make html
- ../check_doc_warnings.sh
assign_test:
tags:
- assign_test
image: $CI_DOCKER_REGISTRY/audio_test_env$BOT_DOCKER_IMAGE_TAG
stage: assign_test
# gitlab ci do not support match job with RegEx or wildcard now in dependencies.
# we have a lot build example jobs. now we don't use dependencies, just download all artificats of build stage.
dependencies:
- build_adf_test
- build_examples_v33_make
- build_examples_v40_cmake
variables:
TEST_FW_PATH: "$CI_PROJECT_DIR/general_test_framework"
EXAMPLE_CONFIG_OUTPUT_PATH: "$CI_PROJECT_DIR/examples/test_configs"
AUTO_TEST_PATH: "$CI_PROJECT_DIR/audio_auto_test"
artifacts:
paths:
- $TEST_FW_PATH
- $EXAMPLE_CONFIG_OUTPUT_PATH
- $AUTO_TEST_PATH
expire_in: 1 mos
before_script: *add_gitlab_key_before
script:
- source /opt/pyenv/activate
- pyenv global 3.5.5
- git clone ${AUDIO_AUTO_REPO}
- git clone ${TEST_FW_REPO}
# assign example tests
- python $TEST_FW_PATH/CIAssignExampleTest.py $CI_PROJECT_DIR/examples $CI_PROJECT_DIR/.gitlab-ci.yml $EXAMPLE_CONFIG_OUTPUT_PATH
.example_test_template: &example_test_template
stage: example_test
when: on_success
dependencies:
- assign_test
- build_examples_v33_make
- build_examples_v40_cmake
- build_adf_test
artifacts:
when: always
paths:
- $LOG_PATH
expire_in: 1 mos
variables:
TEST_FW_PATH: "$CI_PROJECT_DIR/general_test_framework"
TEST_CASE_PATH: "$CI_PROJECT_DIR/examples"
CONFIG_FILE: "$CI_PROJECT_DIR/examples/test_configs/$CI_JOB_NAME.yml"
LOG_PATH: "$CI_PROJECT_DIR/log_examples"
ENV_FILE: "$IDF_PATH/ci-test-runner-configs/$CI_RUNNER_DESCRIPTION/EnvConfig.yml"
AUTO_TEST_PATH: "$CI_PROJECT_DIR/audio_auto_test"
before_script: *add_gitlab_key_before
script:
# first test if config file exists, if not exist, exit 0
- test -e $CONFIG_FILE || exit 0
# run test
- python $TEST_FW_PATH/Runner.py $TEST_CASE_PATH -c $CONFIG_FILE -e $ENV_FILE
.example_test_play_mp3: &example_test_play_mp3
<<: *example_test_template
tags:
- ESP32
- Example_AUDIO_PLAY
push_to_github:
stage: deploy
only:
- master
- /^release\/v/
# when: on_success
image: $CI_DOCKER_REGISTRY/esp32-ci-env
variables:
GIT_STRATEGY: clone
before_script:
- echo "skip default before_script"
script:
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo -n $GH_PUSH_KEY >> ~/.ssh/id_rsa_base64
- base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
- git remote remove github &>/dev/null || true
- git remote add github [email protected]:espressif/esp-adf.git
- tools/ci/push_to_github.sh