From d6ddc8531d4fb0c30281d7a6d4b10ededf8df430 Mon Sep 17 00:00:00 2001 From: Shubham Patil Date: Fri, 22 Nov 2024 16:18:45 +0530 Subject: [PATCH] ci: validate the chip submodule in readme --- .gitlab-ci.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 099c3c3ef..ddd6f8816 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -154,13 +154,29 @@ build_image: script: - cd ${ESP_MATTER_PATH} - chip_head_commit=$(git rev-parse HEAD:connectedhomeip/connectedhomeip) + - chip_head_in_readme=$(awk -F'[][]' '/commit \[.* of connectedhomeip/{print $2}' README.md) + + # Check both conditions and collect errors + - commit_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" + else + echo "Please update the README.md file with the latest commit hash of the connectedhomeip submodule" + commit_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" - exit 1 + commit_validation_error=1 fi + + # Exit with collected error status + - if [ $commit_validation_error -ne 0 ]; then exit 1; fi + - TAG="chip_${CHIP_SHORT_HASH}_idf_${IDF_VERSION}" - echo $TAG - |