Skip to content

Commit b84a2cc

Browse files
committed
Merge branch 'ci_enhnacement/esp_matter_symlink' into 'main'
esp-matter-ci : Changes to fix the arbitary failures in esp-matter CI test cases by using symlink approach. See merge request app-frameworks/esp-matter!714
2 parents 7bb5b53 + 0123d1e commit b84a2cc

File tree

4 files changed

+251
-58
lines changed

4 files changed

+251
-58
lines changed

.gitlab-ci.yml

+132-55
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,32 @@
11
stages:
2+
- docker_build
23
- build
34
- target_test
45
- docs
56

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+
614
variables:
715
ESP_MATTER_PATH: "$CI_PROJECT_DIR"
8-
IDF_PATH: "$CI_PROJECT_DIR/esp-idf"
916
BR_PATH: "$CI_PROJECT_DIR/esp-thread-br"
1017
IDF_GITHUB_ASSETS: "dl.espressif.com/github_assets"
1118
GIT_STRATEGY: fetch
1219
GIT_SUBMODULE_STRATEGY: none
1320
IDF_SKIP_CHECK_SUBMODULES: 1
1421
# This folder was on the runner host
1522
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"
1730

1831
.add_gitlab_ssh_key: &add_gitlab_ssh_key |
1932
mkdir -p ~/.ssh
@@ -47,28 +60,6 @@ variables:
4760
time rsync -a ~/.espressif/dist/ ${MATTER_CACHE_DIR}/espressif_dist/ || true
4861
fi
4962
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-
7263
.setup_ot_br: &setup_ot_br
7364
- cd ${CI_PROJECT_DIR}
7465
- git clone ${ESP_THREAD_BR_REPO_URL}
@@ -89,11 +80,21 @@ variables:
8980
- idf.py set-target esp32h2
9081
- idf.py build
9182

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+
9291
.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
9798

9899
.build_matter_examples: &build_matter_examples
99100
- export MATTER_EXAMPLES_PATH=$ESP_MATTER_PATH/connectedhomeip/connectedhomeip/examples
@@ -109,11 +110,14 @@ variables:
109110
- idf.py build
110111

111112
.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
117121
- cp sdkconfig.defaults sdkconfig.defaults.backup
118122
- cp sdkconfig.defaults.ext_plat_ci sdkconfig.defaults
119123
- idf.py set-target esp32
@@ -132,9 +136,51 @@ variables:
132136
- cd $ESP_MATTER_PATH/examples/controller
133137
- idf.py -D SDKCONFIG_DEFAULTS="sdkconfig.defaults.otbr" set-target esp32s3 build
134138

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+
135179
.build_examples_template:
136180
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"
138184
tags:
139185
- build
140186
# runner: `sudo mkdir -p /cache/matter_build/`
@@ -143,21 +189,22 @@ variables:
143189
before_script:
144190
- *add_gitlab_ssh_key
145191
- *get_build_caches
146-
- *chip_submodule_update
147192
- *setup_idf
148-
- *setup_matter
149193
- cd ${ESP_MATTER_PATH}
150194
- mkdir -p ${REPOS_PATH}
195+
- *setup_matter
151196
# update caches only when setup succeed
152197
- *update_build_caches
153198
variables:
154-
IDF_VERSION: "v5.0.1"
155199
REPOS_PATH: "$CI_PROJECT_DIR/repos"
156200
IDF_CCACHE_ENABLE: 1
157201

202+
158203
.build_managed_component_light_example:
159204
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"
161208
tags:
162209
- build
163210
- matter_cache
@@ -169,13 +216,15 @@ variables:
169216
- mkdir -p ${REPOS_PATH}
170217
- *update_build_caches
171218
variables:
172-
IDF_VERSION: "v5.2.1"
173219
REPOS_PATH: "$CI_PROJECT_DIR/repos"
174220
IDF_CCACHE_ENABLE: 1
175221

176222
build_esp_matter_examples_pytest_C6_idf_v5_1:
177223
extends:
178224
- .build_examples_template
225+
needs:
226+
- job: build_image
227+
optional: true
179228
artifacts:
180229
paths:
181230
- "examples/**/build*/size.json"
@@ -188,8 +237,6 @@ build_esp_matter_examples_pytest_C6_idf_v5_1:
188237
- "connectedhomeip/connectedhomeip/out/host/chip-tool"
189238
when: always
190239
expire_in: 4 days
191-
variables:
192-
IDF_VERSION: "v5.2.1"
193240
script:
194241
- cd ${ESP_MATTER_PATH}
195242
- pip install -r tools/ci/requirements-build.txt
@@ -198,6 +245,9 @@ build_esp_matter_examples_pytest_C6_idf_v5_1:
198245
build_esp_matter_examples_pytest_H2_idf_v5_1:
199246
extends:
200247
- .build_examples_template
248+
needs:
249+
- job: build_image
250+
optional: true
201251
artifacts:
202252
paths:
203253
- "examples/**/build*/size.json"
@@ -220,8 +270,6 @@ build_esp_matter_examples_pytest_H2_idf_v5_1:
220270
- "connectedhomeip/connectedhomeip/out/host/chip-tool"
221271
when: always
222272
expire_in: 4 days
223-
variables:
224-
IDF_VERSION: "v5.2.1"
225273
script:
226274
- *setup_ot_rcp
227275
- *setup_ot_br
@@ -232,6 +280,9 @@ build_esp_matter_examples_pytest_H2_idf_v5_1:
232280
build_esp_matter_examples_pytest_C2_idf_v5_1:
233281
extends:
234282
- .build_examples_template
283+
needs:
284+
- job: build_image
285+
optional: true
235286
artifacts:
236287
paths:
237288
- "examples/**/build*/size.json"
@@ -244,8 +295,6 @@ build_esp_matter_examples_pytest_C2_idf_v5_1:
244295
- "connectedhomeip/connectedhomeip/out/host/chip-tool"
245296
when: always
246297
expire_in: 4 days
247-
variables:
248-
IDF_VERSION: "v5.2.1"
249298
script:
250299
- cd ${ESP_MATTER_PATH}
251300
- pip install -r tools/ci/requirements-build.txt
@@ -254,6 +303,9 @@ build_esp_matter_examples_pytest_C2_idf_v5_1:
254303
build_esp_matter_examples_non_pytest_idf_v5_1:
255304
extends:
256305
- .build_examples_template
306+
needs:
307+
- job: build_image
308+
optional: true
257309
artifacts:
258310
paths:
259311
- "examples/**/build*/size.json"
@@ -265,8 +317,6 @@ build_esp_matter_examples_non_pytest_idf_v5_1:
265317
- "examples/**/build*/partition_table/*.bin"
266318
when: always
267319
expire_in: 4 days
268-
variables:
269-
IDF_VERSION: "v5.2.1"
270320
script:
271321
- *build_external_platform_example
272322
- *build_esp32c6_thread_example
@@ -287,6 +337,10 @@ build_esp_matter_examples_non_pytest_idf_v5_1:
287337
build_esp_matter_examples_pytest_C3_idf_v4_4:
288338
extends:
289339
- .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
290344
artifacts:
291345
paths:
292346
- "examples/**/build*/size.json"
@@ -299,53 +353,71 @@ build_esp_matter_examples_pytest_C3_idf_v4_4:
299353
- "connectedhomeip/connectedhomeip/out/host/chip-tool"
300354
when: always
301355
expire_in: 4 days
302-
variables:
303-
IDF_VERSION: "v4.4.3"
304356
script:
305357
- cd ${ESP_MATTER_PATH}
306358
- pip install -r tools/ci/requirements-build.txt
307359
- python tools/ci/build_apps.py ./examples --pytest_c3
360+
variables:
361+
IDF_CHECKOUT_REF: "v4.4.3"
308362

309363
pytest_esp32c3_esp_matter_dut:
310364
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"
312368
needs:
313369
- build_esp_matter_examples_pytest_C3_idf_v4_4
314370
script:
315371
- cd ${ESP_MATTER_PATH}
372+
- rm -rf connectedhomeip/connectedhomeip
373+
- ln -s ${CHIP_SUBMODULE_PATH} connectedhomeip/connectedhomeip
316374
- pip install -r tools/ci/requirements-pytest.txt
317375
- pytest examples/ --target esp32c3 -m esp_matter_dut --junitxml=XUNIT_RESULT.xml
318376
tags: ["esp32c3", "esp_matter_dut"]
377+
variables:
378+
IDF_CHECKOUT_REF: "v4.4.3"
319379

320380
pytest_esp32c6_esp_matter_dut:
321381
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"
323385
needs:
324386
- build_esp_matter_examples_pytest_C6_idf_v5_1
325387
script:
326388
- cd ${ESP_MATTER_PATH}
389+
- rm -rf connectedhomeip/connectedhomeip
390+
- ln -s ${CHIP_SUBMODULE_PATH} connectedhomeip/connectedhomeip
327391
- pip install -r tools/ci/requirements-pytest.txt
328392
- pytest examples/ --target esp32c6 -m esp_matter_dut --junitxml=XUNIT_RESULT.xml
329393
tags: ["esp32c6", "esp_matter_dut"]
330394

331395
pytest_esp32c2_esp_matter_dut:
332396
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"
334400
needs:
335401
- build_esp_matter_examples_pytest_C2_idf_v5_1
336402
script:
337403
- cd ${ESP_MATTER_PATH}
404+
- rm -rf connectedhomeip/connectedhomeip
405+
- ln -s ${CHIP_SUBMODULE_PATH} connectedhomeip/connectedhomeip
338406
- pip install -r tools/ci/requirements-pytest.txt
339407
- pytest examples/ --target esp32c2 -m esp_matter_dut --junitxml=XUNIT_RESULT.xml
340408
tags: ["esp32c2", "esp_matter_dut"]
341409

342410
pytest_esp32h2_esp_matter_dut:
343411
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"
345415
needs:
346416
- build_esp_matter_examples_pytest_H2_idf_v5_1
347417
script:
348418
- cd ${ESP_MATTER_PATH}
419+
- rm -rf connectedhomeip/connectedhomeip
420+
- ln -s ${CHIP_SUBMODULE_PATH} connectedhomeip/connectedhomeip
349421
- pip install -r tools/ci/requirements-pytest.txt
350422
- pytest examples/ --target esp32h2 -m esp_matter_dut --junitxml=XUNIT_RESULT.xml
351423
tags: ["esp32h2", "esp_matter_dut"]
@@ -360,7 +432,9 @@ build_upstream_examples:
360432
build_managed_component_light:
361433
extends:
362434
- .build_managed_component_light_example
363-
when: always
435+
needs:
436+
- job: build_image
437+
optional: true
364438
script:
365439
- cd ${ESP_MATTER_PATH}/examples/managed_component_light
366440
- idf.py set-target esp32c3
@@ -369,6 +443,8 @@ build_managed_component_light:
369443
build_docs:
370444
stage: build
371445
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"
372448
tags:
373449
- build
374450
variables:
@@ -403,7 +479,8 @@ build_docs:
403479
deploy_docs_preview:
404480
extends:
405481
- .deploy_docs_template
406-
when: always
482+
rules:
483+
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_BRANCH == "main" || $CI_PIPELINE_SOURCE == "push"
407484
variables:
408485
TYPE: "preview"
409486
DOCS_BUILD_DIR: "${CI_PROJECT_DIR}/docs/_build/"

0 commit comments

Comments
 (0)