Skip to content

Commit

Permalink
Merge branch 'fix/fix_a_issue_for_submodule_update' into 'main'
Browse files Browse the repository at this point in the history
feat(ci): add check for components version

See merge request espressif/esp-thread-br!126
  • Loading branch information
chshu committed Jul 16, 2024
2 parents bdda569 + 4b6411b commit b872f68
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 2 deletions.
63 changes: 63 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
stages:
- build
- check_results
- docs

variables:
Expand Down Expand Up @@ -112,6 +113,13 @@ build_examples:
script:
- *submodule_update
- *build_basic_thread_border_router
- cd $ESP_THREAD_BR_PATH
- echo "build_examples_result=true" > build_examples_result.txt
artifacts:
when: always
paths:
- build_examples_result.txt
expire_in: 1 days
tags:
- build
# allow failure if esp_ot_cli_extension version updated but haven't publish to component registry yet
Expand All @@ -134,6 +142,13 @@ build_idf_otbr_examples:
script:
- *setup_idf
- *build_idf_example_ot_br
- cd $ESP_THREAD_BR_PATH
- echo "build_idf_otbr_example_result=true" > build_idf_otbr_example_result.txt
artifacts:
when: always
paths:
- build_idf_otbr_example_result.txt
expire_in: 1 days
tags:
- build

Expand All @@ -144,6 +159,13 @@ build_idf_otbr_autostart_examples:
script:
- *setup_idf
- *build_idf_example_ot_br_autostart
- cd $ESP_THREAD_BR_PATH
- echo "build_idf_otbr_autostart_example_result=true" > build_idf_otbr_autostart_example_result.txt
artifacts:
when: always
paths:
- build_idf_otbr_autostart_example_result.txt
expire_in: 1 days
tags:
- build

Expand All @@ -154,6 +176,13 @@ build_idf_otcli_examples:
script:
- *setup_idf
- *build_idf_example_ot_cli
- cd $ESP_THREAD_BR_PATH
- echo "build_idf_otcli_example_result=true" > build_idf_otcli_example_result.txt
artifacts:
when: always
paths:
- build_idf_otcli_example_result.txt
expire_in: 1 days
tags:
- build

Expand All @@ -175,6 +204,40 @@ build_docs:
tags:
- build_docs

check_build_result:
stage: check_results
image: $ESP_ENV_IMAGE
needs:
- build_examples
- build_idf_otbr_examples
- build_idf_otbr_autostart_examples
- build_idf_otcli_examples
script:
- *submodule_update
- chmod 700 ./check_components_version.sh
- ALLOW_FAILURE_OUTPUT=$(./check_components_version.sh)
- echo "$ALLOW_FAILURE_OUTPUT"
- ALLOW_FAILURE_VALUE=$(echo "$ALLOW_FAILURE_OUTPUT" | cut -d'=' -f2)
- echo "ALLOW_FAILURE_VALUE=$ALLOW_FAILURE_VALUE"
- |
if [ "$ALLOW_FAILURE_VALUE" == "true" ]; then
echo "allow failure"
exit 0;
else
if [ -f "build_examples_result.txt" ] &&
[ -f "build_idf_otbr_example_result.txt" ] &&
[ -f "build_idf_otbr_autostart_example_result.txt" ] &&
[ -f "build_idf_otcli_example_result.txt" ]; then
echo "Success!!!"
exit 0
else
echo "Fail!!!"
exit 1
fi
fi
tags:
- build

.deploy_docs_template:
stage: docs
image: $CI_DOCKER_REGISTRY/esp-idf-doc-env-v5.1:1-1
Expand Down
27 changes: 27 additions & 0 deletions check_components_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh

export ESP_EXTCMD_COMPONENTS_PATH="components/esp_ot_cli_extension"

if git diff --name-only HEAD~1 | grep -q "${ESP_EXTCMD_COMPONENTS_PATH}/idf_component.yml"; then
OLD_VERSION=$(git show HEAD~1:${ESP_EXTCMD_COMPONENTS_PATH}/idf_component.yml | grep -m 1 "^version: " | awk '{print $2}' | tr -d '"')
NEW_VERSION=$(head -n 1 ${ESP_EXTCMD_COMPONENTS_PATH}/idf_component.yml | grep "^version: " | awk '{print $2}' | tr -d '"')
if [ -z "$OLD_VERSION" ] || [ -z "$NEW_VERSION" ]; then
echo "Error: version not found or incorrect format in ${ESP_EXTCMD_COMPONENTS_PATH}/idf_component.yml"
exit 1
fi
if [ "$OLD_VERSION" != "$NEW_VERSION" ]; then
OLD_MAJOR=$(echo $OLD_VERSION | cut -d. -f1)
OLD_MINOR=$(echo $OLD_VERSION | cut -d. -f2)
NEW_MAJOR=$(echo $NEW_VERSION | cut -d. -f1)
NEW_MINOR=$(echo $NEW_VERSION | cut -d. -f2)
if [ "$OLD_MAJOR" != "$NEW_MAJOR" ] || [ "$OLD_MINOR" != "$NEW_MINOR" ]; then
echo "ALLOW_FAILURE=true"
else
echo "ALLOW_FAILURE=false"
fi
else
echo "ALLOW_FAILURE=false"
fi
else
echo "ALLOW_FAILURE=false"
fi
3 changes: 1 addition & 2 deletions components/esp_ot_br_server/src/esp_br_web_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,7 @@ void handle_ot_resource_node_set_dataset_request(const cJSON *request, cJSON *lo
if (ret == OT_ERROR_NOT_FOUND) {
ESP_GOTO_ON_FALSE(otDatasetCreateNewNetwork(ins, &dataset) == OT_ERROR_NONE, OT_ERROR_FAILED, exit, API_TAG,
"Cannot create a new dataset");
ESP_GOTO_ON_FALSE(otDatasetConvertToTlvs(&dataset, &datasetTlvs) == OT_ERROR_NONE, OT_ERROR_FAILED, exit,
API_TAG, "Cannot convert the dataset");
otDatasetConvertToTlvs(&dataset, &datasetTlvs);
errcode = 201;
ret = OT_ERROR_NONE;
}
Expand Down

0 comments on commit b872f68

Please sign in to comment.