From da1f78a280bfa3df8dc944c8426d39bc79cbc350 Mon Sep 17 00:00:00 2001 From: Shubham Patil Date: Fri, 7 Mar 2025 14:41:47 +0530 Subject: [PATCH] CI: enforce zap common files validations when updating submodule When updating submodule we need to run generate_zap_common_files.py to update the zap common files and most of the time it is missed, so make sure we enforce that check in CI --- .gitlab-ci.yml | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 992887eff..85dd53887 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -166,25 +166,40 @@ build_image: - chip_head_in_readme=$(awk -F'[][]' '/commit \[.* of connectedhomeip/{print $2}' README.md) # Check both conditions and collect errors - - commit_validation_error=0 + - validation_error=0 - | if echo "$chip_head_commit" | grep -q "^${chip_head_in_readme}"; then - echo "README.md is not in sync with the connectedhomeip submodule" + echo "README.md is in sync with the connectedhomeip submodule" else - echo "Please update the README.md file with the latest commit hash of the connectedhomeip submodule" - commit_validation_error=1 + echo "ERROR:Please update the README.md file with the latest commit hash of the connectedhomeip submodule" + validation_error=1 fi - | if echo "${chip_head_commit}" | grep -q "^${CHIP_SHORT_HASH}"; then echo "The CHIP_SHORT_HASH variable is set to correct value. Matches with current head commit" else - echo "The CHIP_SHORT_HASH seems to be incorrect or you have updated the submodule but not the CHIP_SHORT_HASH variable above" - commit_validation_error=1 + echo "ERROR: The CHIP_SHORT_HASH seems to be incorrect or you have updated the submodule but not the CHIP_SHORT_HASH variable above" + validation_error=1 + fi + + # Validate if we have the latest ZAP common files + # python3 is not installed in dind image, so we need to install it + - apk add --no-cache python3 + # update the submodule to so that script runs based on that submodule + - git submodule update --init --depth 1 connectedhomeip/connectedhomeip + - python3 components/esp_matter/zap_common/generate_zap_common_files.py + - | + if git diff --quiet components/esp_matter/zap_common; then + echo "ZAP common files are up to date." + else + echo "ERROR: ZAP common files are not up to date." + echo " Please run ./components/esp_matter/zap_common/generate_zap_common_files.py and commit the changes." + validation_error=1 fi # Exit with collected error status - - if [ $commit_validation_error -ne 0 ]; then exit 1; fi + - if [ $validation_error -ne 0 ]; then exit 1; fi - TAG="chip_${CHIP_SHORT_HASH}_idf_${IDF_VERSION}" - echo $TAG