1
1
stages :
2
+ - docker_build
2
3
- build
3
4
- target_test
4
5
- docs
5
6
7
+ workflow :
8
+ rules :
9
+ - if : $CI_PIPELINE_SOURCE == "merge_request_event"
10
+ - if : $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
11
+ when : never
12
+ - if : $CI_COMMIT_BRANCH
13
+
6
14
variables :
7
15
ESP_MATTER_PATH : " $CI_PROJECT_DIR"
8
- IDF_PATH : " $CI_PROJECT_DIR/esp-idf"
9
16
BR_PATH : " $CI_PROJECT_DIR/esp-thread-br"
10
17
IDF_GITHUB_ASSETS : " dl.espressif.com/github_assets"
11
18
GIT_STRATEGY : fetch
12
19
GIT_SUBMODULE_STRATEGY : none
13
20
IDF_SKIP_CHECK_SUBMODULES : 1
14
21
# This folder was on the runner host
15
22
MATTER_CACHE_DIR : /cache/matter_build
16
- IDF_CHECKOUT_REF : " v5.1.2"
23
+ # This variable represents the latest idf version supported for the target branch.
24
+ # Note: Do change this variable in case of idf version change MR.
25
+ IDF_CHECKOUT_REF : " v5.2.1"
26
+ # This variable represents the short hash of the connectedhomeip submodule.
27
+ # Note: Do change this short hash on submodule update MRs.
28
+ CHIP_SHORT_HASH : " 5bb5c9e2"
29
+ DOCKER_IMAGE_NAME : " espressif/chip-idf"
17
30
18
31
.add_gitlab_ssh_key : &add_gitlab_ssh_key |
19
32
mkdir -p ~/.ssh
@@ -47,28 +60,6 @@ variables:
47
60
time rsync -a ~/.espressif/dist/ ${MATTER_CACHE_DIR}/espressif_dist/ || true
48
61
fi
49
62
50
- .chip_submodule_update : &chip_submodule_update
51
- - sed -i "s%https://github.com/espressif%${GITLAB_SSH_SERVER}/espressif%" .gitmodules
52
- - git submodule sync --recursive
53
- - git submodule update -f --init --recursive --depth 1
54
-
55
- .setup_idf : &setup_idf
56
- # TODO: IDF_VERSION maybe a commit id, use `git fetch` rather than `git clone -b`
57
- # - git clone -b ${IDF_VERSION} ${IDF_GIT_REPO_URL} --depth=1
58
- - mkdir -p esp-idf
59
- - cd esp-idf
60
- - git init
61
- - git remote add origin ${IDF_GIT_REPO_URL}
62
- - git fetch origin ${IDF_VERSION}:refs/head --depth=1 -f
63
- - git checkout ${IDF_VERSION}
64
- - ./install.sh
65
- - . ./export.sh
66
- # fetch submodules
67
- - export PYTHONPATH=${IDF_PATH}/tools/ci/python_packages/:${PYTHONPATH}
68
- - pip install python-gitlab
69
- - pip install --upgrade idf-component-manager
70
- - python tools/ci/ci_fetch_submodule.py
71
-
72
63
.setup_ot_br : &setup_ot_br
73
64
- cd ${CI_PROJECT_DIR}
74
65
- git clone ${ESP_THREAD_BR_REPO_URL}
@@ -89,11 +80,21 @@ variables:
89
80
- idf.py set-target esp32h2
90
81
- idf.py build
91
82
83
+ .setup_idf : &setup_idf
84
+ - source ${IDF_PATH}/export.sh
85
+ - export PYTHONPATH=${IDF_PATH}/tools/ci/python_packages/:${PYTHONPATH}
86
+ - pip install python-gitlab
87
+ - pip install --upgrade idf-component-manager
88
+ - cd ${IDF_PATH}
89
+ - python tools/ci/ci_fetch_submodule.py
90
+
92
91
.setup_matter : &setup_matter
93
- - cd ${CI_PROJECT_DIR}
94
- # Setting up Python environment still spend a pretty long time (15mins -> 5mins).
95
- - ./install.sh
96
- - . ./export.sh
92
+ - cd ${ESP_MATTER_PATH}
93
+ - rm -rf connectedhomeip/connectedhomeip # Remove submodule directory
94
+ - ln -s ${CHIP_SUBMODULE_PATH} connectedhomeip/connectedhomeip # Create symlink to specified CHIP_SUBMODULE_PATH
95
+ - cd ${ESP_MATTER_PATH}
96
+ - . ./export.sh
97
+ - python3 -m pip install -r requirements.txt
97
98
98
99
.build_matter_examples : &build_matter_examples
99
100
- export MATTER_EXAMPLES_PATH=$ESP_MATTER_PATH/connectedhomeip/connectedhomeip/examples
@@ -109,11 +110,14 @@ variables:
109
110
- idf.py build
110
111
111
112
.build_external_platform_example : &build_external_platform_example
112
- - rm -rf $ESP_MATTER_PATH/../platform
113
- - mkdir $ESP_MATTER_PATH/../platform
114
- - cp -r $ESP_MATTER_PATH/connectedhomeip/connectedhomeip/src/platform/ESP32 $ESP_MATTER_PATH/../platform/ESP32_custom
115
- - cp $ESP_MATTER_PATH/examples/common/external_platform/BUILD.gn $ESP_MATTER_PATH/../platform/ESP32_custom
116
- - cd $ESP_MATTER_PATH/examples/light
113
+ - rm -rf ${ESP_MATTER_PATH}/../platform
114
+ - mkdir -p ${ESP_MATTER_PATH}/../platform
115
+ - cp -r ${CHIP_SUBMODULE_PATH}/src/platform/ESP32 $ESP_MATTER_PATH/../platform/ESP32_custom
116
+ - cp ${ESP_MATTER_PATH}/examples/common/external_platform/BUILD.gn $ESP_MATTER_PATH/../platform/ESP32_custom
117
+ - cd ${ESP_MATTER_PATH}/examples/blemesh_bridge
118
+ - cp sdkconfig.defaults sdkconfig.defaults.backup
119
+ - cp sdkconfig.defaults.ext_plat_ci sdkconfig.defaults
120
+ - cd ${ESP_MATTER_PATH}/examples/light
117
121
- cp sdkconfig.defaults sdkconfig.defaults.backup
118
122
- cp sdkconfig.defaults.ext_plat_ci sdkconfig.defaults
119
123
- idf.py set-target esp32
@@ -132,9 +136,51 @@ variables:
132
136
- cd $ESP_MATTER_PATH/examples/controller
133
137
- idf.py -D SDKCONFIG_DEFAULTS="sdkconfig.defaults.otbr" set-target esp32s3 build
134
138
139
+ build_image :
140
+ stage : docker_build
141
+ image : espressif/dind:1
142
+ tags :
143
+ - amd64
144
+ - dind
145
+ - internet
146
+ rules :
147
+ - if : $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_BRANCH == "main"
148
+ before_script :
149
+ - mkdir -p $HOME/.docker
150
+ - echo $DOCKER_AUTH_CONFIG > $HOME/.docker/config.json
151
+ script :
152
+ - cd ${ESP_MATTER_PATH}
153
+ - chip_head_commit=$(git rev-parse HEAD:connectedhomeip/connectedhomeip)
154
+ - |
155
+ if echo "${chip_head_commit}" | grep -q "^${CHIP_SHORT_HASH}"; then
156
+ echo "The CHIP_SHORT_HASH variable is set to correct value. Matches with current head commit"
157
+ else
158
+ echo "The CHIP_SHORT_HASH seems to be incorrect or you have updated the submodule but not the CHIP_SHORT_HASH variable above"
159
+ exit 1
160
+ fi
161
+ - TAG="chip_${CHIP_SHORT_HASH}_idf_${IDF_VERSION}"
162
+ - echo $TAG
163
+ - |
164
+ if wget -qO- "https://hub.docker.com/v2/repositories/espressif/chip-idf/tags" | grep -q ${TAG}; then
165
+ echo "No Differences detected. The docker image with ${TAG} is present in docker hub. Skipping docker build "
166
+ else
167
+ echo "Differences detected. The docker image with ${TAG} is not present on docker hub. Triggering docker build due to submdoule update or idf version change in CI."
168
+ cd ${ESP_MATTER_PATH}/tools/docker/chip_idf
169
+ docker build --build-arg CHIP_CHECKOUT_REF=${chip_head_commit} --build-arg IDF_CHECKOUT_REF=${IDF_VERSION} --tag ${DOCKER_IMAGE_NAME}:${TAG} .
170
+ docker push ${DOCKER_IMAGE_NAME}:${TAG} .
171
+ fi
172
+ parallel :
173
+ matrix :
174
+ # Change the idf version here in case of idf version change MR.
175
+ - IDF_VERSION :
176
+ - " v4.4.3"
177
+ - " v5.2.1"
178
+
135
179
.build_examples_template :
136
180
stage : build
137
- image : gitlab.espressif.cn:5050/app-frameworks/esp-matter/build-env:latest
181
+ image : ${DOCKER_IMAGE_NAME}:chip_${CHIP_SHORT_HASH}_idf_${IDF_CHECKOUT_REF}
182
+ rules :
183
+ - if : $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_PIPELINE_SOURCE == "push" || $CI_COMMIT_BRANCH == "main"
138
184
tags :
139
185
- build
140
186
# runner: `sudo mkdir -p /cache/matter_build/`
@@ -143,21 +189,22 @@ variables:
143
189
before_script :
144
190
- *add_gitlab_ssh_key
145
191
- *get_build_caches
146
- - *chip_submodule_update
147
192
- *setup_idf
148
- - *setup_matter
149
193
- cd ${ESP_MATTER_PATH}
150
194
- mkdir -p ${REPOS_PATH}
195
+ - *setup_matter
151
196
# update caches only when setup succeed
152
197
- *update_build_caches
153
198
variables :
154
- IDF_VERSION : " v5.0.1"
155
199
REPOS_PATH : " $CI_PROJECT_DIR/repos"
156
200
IDF_CCACHE_ENABLE : 1
157
201
202
+
158
203
.build_managed_component_light_example :
159
204
stage : build
160
- image : gitlab.espressif.cn:5050/app-frameworks/esp-matter/build-env:latest
205
+ image : ${DOCKER_IMAGE_NAME}:chip_${CHIP_SHORT_HASH}_idf_${IDF_CHECKOUT_REF}
206
+ rules :
207
+ - if : $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_PIPELINE_SOURCE == "push" || $CI_COMMIT_BRANCH == "main"
161
208
tags :
162
209
- build
163
210
- matter_cache
@@ -169,13 +216,15 @@ variables:
169
216
- mkdir -p ${REPOS_PATH}
170
217
- *update_build_caches
171
218
variables :
172
- IDF_VERSION : " v5.2.1"
173
219
REPOS_PATH : " $CI_PROJECT_DIR/repos"
174
220
IDF_CCACHE_ENABLE : 1
175
221
176
222
build_esp_matter_examples_pytest_C6_idf_v5_1 :
177
223
extends :
178
224
- .build_examples_template
225
+ needs :
226
+ - job : build_image
227
+ optional : true
179
228
artifacts :
180
229
paths :
181
230
- " examples/**/build*/size.json"
@@ -188,8 +237,6 @@ build_esp_matter_examples_pytest_C6_idf_v5_1:
188
237
- " connectedhomeip/connectedhomeip/out/host/chip-tool"
189
238
when : always
190
239
expire_in : 4 days
191
- variables :
192
- IDF_VERSION : " v5.2.1"
193
240
script :
194
241
- cd ${ESP_MATTER_PATH}
195
242
- pip install -r tools/ci/requirements-build.txt
@@ -198,6 +245,9 @@ build_esp_matter_examples_pytest_C6_idf_v5_1:
198
245
build_esp_matter_examples_pytest_H2_idf_v5_1 :
199
246
extends :
200
247
- .build_examples_template
248
+ needs :
249
+ - job : build_image
250
+ optional : true
201
251
artifacts :
202
252
paths :
203
253
- " examples/**/build*/size.json"
@@ -220,8 +270,6 @@ build_esp_matter_examples_pytest_H2_idf_v5_1:
220
270
- " connectedhomeip/connectedhomeip/out/host/chip-tool"
221
271
when : always
222
272
expire_in : 4 days
223
- variables :
224
- IDF_VERSION : " v5.2.1"
225
273
script :
226
274
- *setup_ot_rcp
227
275
- *setup_ot_br
@@ -232,6 +280,9 @@ build_esp_matter_examples_pytest_H2_idf_v5_1:
232
280
build_esp_matter_examples_pytest_C2_idf_v5_1 :
233
281
extends :
234
282
- .build_examples_template
283
+ needs :
284
+ - job : build_image
285
+ optional : true
235
286
artifacts :
236
287
paths :
237
288
- " examples/**/build*/size.json"
@@ -244,8 +295,6 @@ build_esp_matter_examples_pytest_C2_idf_v5_1:
244
295
- " connectedhomeip/connectedhomeip/out/host/chip-tool"
245
296
when : always
246
297
expire_in : 4 days
247
- variables :
248
- IDF_VERSION : " v5.2.1"
249
298
script :
250
299
- cd ${ESP_MATTER_PATH}
251
300
- pip install -r tools/ci/requirements-build.txt
@@ -254,6 +303,9 @@ build_esp_matter_examples_pytest_C2_idf_v5_1:
254
303
build_esp_matter_examples_non_pytest_idf_v5_1 :
255
304
extends :
256
305
- .build_examples_template
306
+ needs :
307
+ - job : build_image
308
+ optional : true
257
309
artifacts :
258
310
paths :
259
311
- " examples/**/build*/size.json"
@@ -265,8 +317,6 @@ build_esp_matter_examples_non_pytest_idf_v5_1:
265
317
- " examples/**/build*/partition_table/*.bin"
266
318
when : always
267
319
expire_in : 4 days
268
- variables :
269
- IDF_VERSION : " v5.2.1"
270
320
script :
271
321
- *build_external_platform_example
272
322
- *build_esp32c6_thread_example
@@ -287,6 +337,10 @@ build_esp_matter_examples_non_pytest_idf_v5_1:
287
337
build_esp_matter_examples_pytest_C3_idf_v4_4 :
288
338
extends :
289
339
- .build_examples_template
340
+ image : ${DOCKER_IMAGE_NAME}:chip_${CHIP_SHORT_HASH}_idf_${IDF_CHECKOUT_REF}
341
+ needs :
342
+ - job : build_image
343
+ optional : true
290
344
artifacts :
291
345
paths :
292
346
- " examples/**/build*/size.json"
@@ -299,53 +353,71 @@ build_esp_matter_examples_pytest_C3_idf_v4_4:
299
353
- " connectedhomeip/connectedhomeip/out/host/chip-tool"
300
354
when : always
301
355
expire_in : 4 days
302
- variables :
303
- IDF_VERSION : " v4.4.3"
304
356
script :
305
357
- cd ${ESP_MATTER_PATH}
306
358
- pip install -r tools/ci/requirements-build.txt
307
359
- python tools/ci/build_apps.py ./examples --pytest_c3
360
+ variables :
361
+ IDF_CHECKOUT_REF : " v4.4.3"
308
362
309
363
pytest_esp32c3_esp_matter_dut :
310
364
stage : target_test
311
- image : ${TARGET_TEST_ENV}
365
+ image : ${DOCKER_IMAGE_NAME}:chip_${CHIP_SHORT_HASH}_idf_${IDF_CHECKOUT_REF}
366
+ rules :
367
+ - if : $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_BRANCH == "main" || $CI_PIPELINE_SOURCE == "push"
312
368
needs :
313
369
- build_esp_matter_examples_pytest_C3_idf_v4_4
314
370
script :
315
371
- cd ${ESP_MATTER_PATH}
372
+ - rm -rf connectedhomeip/connectedhomeip
373
+ - ln -s ${CHIP_SUBMODULE_PATH} connectedhomeip/connectedhomeip
316
374
- pip install -r tools/ci/requirements-pytest.txt
317
375
- pytest examples/ --target esp32c3 -m esp_matter_dut --junitxml=XUNIT_RESULT.xml
318
376
tags : ["esp32c3", "esp_matter_dut"]
377
+ variables :
378
+ IDF_CHECKOUT_REF : " v4.4.3"
319
379
320
380
pytest_esp32c6_esp_matter_dut :
321
381
stage : target_test
322
- image : ${TARGET_TEST_ENV}
382
+ image : ${DOCKER_IMAGE_NAME}:chip_${CHIP_SHORT_HASH}_idf_${IDF_CHECKOUT_REF}
383
+ rules :
384
+ - if : $CI_PIPELINE_SOURCE == 'merge_request_event' || $CI_COMMIT_BRANCH == "main" || $CI_PIPELINE_SOURCE == "push"
323
385
needs :
324
386
- build_esp_matter_examples_pytest_C6_idf_v5_1
325
387
script :
326
388
- cd ${ESP_MATTER_PATH}
389
+ - rm -rf connectedhomeip/connectedhomeip
390
+ - ln -s ${CHIP_SUBMODULE_PATH} connectedhomeip/connectedhomeip
327
391
- pip install -r tools/ci/requirements-pytest.txt
328
392
- pytest examples/ --target esp32c6 -m esp_matter_dut --junitxml=XUNIT_RESULT.xml
329
393
tags : ["esp32c6", "esp_matter_dut"]
330
394
331
395
pytest_esp32c2_esp_matter_dut :
332
396
stage : target_test
333
- image : ${TARGET_TEST_ENV}
397
+ image : ${DOCKER_IMAGE_NAME}:chip_${CHIP_SHORT_HASH}_idf_${IDF_CHECKOUT_REF}
398
+ rules :
399
+ - if : $CI_PIPELINE_SOURCE == 'merge_request_event' || $CI_COMMIT_BRANCH == "main" || $CI_PIPELINE_SOURCE == "push"
334
400
needs :
335
401
- build_esp_matter_examples_pytest_C2_idf_v5_1
336
402
script :
337
403
- cd ${ESP_MATTER_PATH}
404
+ - rm -rf connectedhomeip/connectedhomeip
405
+ - ln -s ${CHIP_SUBMODULE_PATH} connectedhomeip/connectedhomeip
338
406
- pip install -r tools/ci/requirements-pytest.txt
339
407
- pytest examples/ --target esp32c2 -m esp_matter_dut --junitxml=XUNIT_RESULT.xml
340
408
tags : ["esp32c2", "esp_matter_dut"]
341
409
342
410
pytest_esp32h2_esp_matter_dut :
343
411
stage : target_test
344
- image : ${TARGET_TEST_ENV}
412
+ image : ${DOCKER_IMAGE_NAME}:chip_${CHIP_SHORT_HASH}_idf_${IDF_CHECKOUT_REF}
413
+ rules :
414
+ - if : $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_BRANCH == "main" || $CI_PIPELINE_SOURCE == "push"
345
415
needs :
346
416
- build_esp_matter_examples_pytest_H2_idf_v5_1
347
417
script :
348
418
- cd ${ESP_MATTER_PATH}
419
+ - rm -rf connectedhomeip/connectedhomeip
420
+ - ln -s ${CHIP_SUBMODULE_PATH} connectedhomeip/connectedhomeip
349
421
- pip install -r tools/ci/requirements-pytest.txt
350
422
- pytest examples/ --target esp32h2 -m esp_matter_dut --junitxml=XUNIT_RESULT.xml
351
423
tags : ["esp32h2", "esp_matter_dut"]
@@ -360,7 +432,9 @@ build_upstream_examples:
360
432
build_managed_component_light :
361
433
extends :
362
434
- .build_managed_component_light_example
363
- when : always
435
+ needs :
436
+ - job : build_image
437
+ optional : true
364
438
script :
365
439
- cd ${ESP_MATTER_PATH}/examples/managed_component_light
366
440
- idf.py set-target esp32c3
@@ -369,6 +443,8 @@ build_managed_component_light:
369
443
build_docs :
370
444
stage : build
371
445
image : $CI_DOCKER_REGISTRY/esp-idf-doc-env-v5.1:1-1
446
+ rules :
447
+ - if : $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_BRANCH == "main" || $CI_PIPELINE_SOURCE == "push"
372
448
tags :
373
449
- build
374
450
variables :
@@ -403,7 +479,8 @@ build_docs:
403
479
deploy_docs_preview :
404
480
extends :
405
481
- .deploy_docs_template
406
- when : always
482
+ rules :
483
+ - if : $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_BRANCH == "main" || $CI_PIPELINE_SOURCE == "push"
407
484
variables :
408
485
TYPE : " preview"
409
486
DOCS_BUILD_DIR : " ${CI_PROJECT_DIR}/docs/_build/"
0 commit comments