Skip to content

Commit

Permalink
Merge branch 'feature/uptimize_ci_stability' into 'main'
Browse files Browse the repository at this point in the history
ci: optimize ci stability

See merge request espressif/esp-zigbee-sdk!162
  • Loading branch information
chshu committed Jan 17, 2025
2 parents 4a10990 + 6cb23d9 commit 8114916
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 62 deletions.
8 changes: 6 additions & 2 deletions .gitlab/ci/build_idf_examples.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
build_idf_examples:
stage: build
image: ${CI_DOCKER_REGISTRY}/esp-env-${DEFAULT_BUILD_DOCKER_ENV}
extends:
- .update_zigbee_lib_script
before_script:
- source tools/ci/utils.sh
- setup_idf
- setup_zboss_lib
- bash ./tools/ci/update_cmake_files.sh
- pip install -r tools/ci/requirements-build.txt
artifacts:
paths:
- "**/build*/*.bin"
Expand Down
51 changes: 0 additions & 51 deletions .gitlab/ci/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,57 +5,6 @@ stages:
- docs

variables:
GIT_STRATEGY: fetch
GIT_SUBMODULE_STRATEGY: none
DEFAULT_IDF_VERSION: "v5.3.2"
DEFAULT_BUILD_DOCKER_ENV: "v5.3:1"
DEFAULT_DOC_DOCKER_ENV: "v5.3:1-1"
# tell build system do not check submodule update as we download archive instead of clone
IDF_SKIP_CHECK_SUBMODULES: 1

.init_ssh: &init_ssh
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo -n "${GITLAB_KEY}" >~/.ssh/id_rsa_base64
- base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 >~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >>~/.ssh/config

.setup_idf: &setup_idf
- cd $CI_PROJECT_DIR
- echo "Fetching ESP-IDF ${IDF_VERSION} from ${IDF_GIT_REPO_URL}"
- git clone --depth=1 -b $CI_COMMIT_REF_NAME ${IDF_GIT_REPO_URL} || git clone --depth=1 -b ${IDF_VERSION} ${IDF_GIT_REPO_URL}
- cd esp-idf
- git submodule update --init --depth=1
- ./install.sh
- . ./export.sh

.setup_esp_zboss_lib: &setup_esp_zboss_lib
- cd $CI_PROJECT_DIR
- echo "Fetching esp-zboss-lib from ${ESP_ZBOSS_LIB_REPO_URL}"
- git clone --depth=1 -b $CI_COMMIT_REF_NAME ${ESP_ZBOSS_LIB_REPO_URL} || git clone --depth=1 -b master ${ESP_ZBOSS_LIB_REPO_URL}
- cd esp-zboss-lib

.update_zigbee_lib_script:
before_script:
- *init_ssh
- *setup_idf
- *setup_esp_zboss_lib
- cd ${CI_PROJECT_DIR}
- bash ./tools/ci/update_cmake_files.sh
- pip install -r tools/ci/requirements-build.txt

.build_rcp_gateway_script:
script:
- python tools/ci/build_apps.py ./examples --rcp_gateway
- mv $CI_PROJECT_DIR/examples/esp_zigbee_gateway/sdkconfig.defaults $CI_PROJECT_DIR/examples/esp_zigbee_gateway/sdkconfig.defaults.ori
- cp $CI_PROJECT_DIR/tools/ci/sdkconfig_for_gateway_ci.defaults $CI_PROJECT_DIR/examples/esp_zigbee_gateway/sdkconfig.defaults
- cd esp-idf/examples/openthread/ot_rcp
- echo "CONFIG_OPENTHREAD_NCP_VENDOR_HOOK=y" >> sdkconfig.defaults
- idf.py set-target esp32h2
- idf.py build
- cd $CI_PROJECT_DIR/examples/esp_zigbee_gateway
- idf.py set-target esp32s3
- idf.py build
- mv $CI_PROJECT_DIR/examples/esp_zigbee_gateway/sdkconfig.defaults.ori $CI_PROJECT_DIR/examples/esp_zigbee_gateway/sdkconfig.defaults
- cd ${CI_PROJECT_DIR}
2 changes: 1 addition & 1 deletion .gitlab/ci/generate_build_test_jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ generate_child_pipeline:
paths:
- child_pipeline_default.yml
- child_pipeline_lts.yml
expire_in: 1 week
expire_in: 3 days
when: always
script:
- python3 tools/ci/dynamic_pipelines/generate_child_pipeline.py -p $CI_PROJECT_DIR -t .gitlab/ci/templates.yml -i ${DEFAULT_IDF_VERSION} -d ${DEFAULT_BUILD_DOCKER_ENV}
Expand Down
24 changes: 17 additions & 7 deletions .gitlab/ci/templates.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
include:
- '.gitlab/ci/common.yml'

.common_before_scripts: &common_before_scripts
- source tools/ci/utils.sh
- setup_idf
- setup_zboss_lib
- bash tools/ci/update_cmake_files.sh
- pip install -r tools/ci/requirements-build.txt

.build_pytest_example_template:
stage: build
extends:
- .update_zigbee_lib_script
before_script:
- *common_before_scripts
image: ${CI_DOCKER_REGISTRY}/esp-env-${DOCKER_ENV_VERSION}
artifacts:
paths:
Expand All @@ -26,9 +33,8 @@ include:

.build_pytest_gateway_template:
stage: build
extends:
- .update_zigbee_lib_script
- .build_rcp_gateway_script
before_script:
- *common_before_scripts
image: ${CI_DOCKER_REGISTRY}/esp-env-${DOCKER_ENV_VERSION}
artifacts:
paths:
Expand All @@ -42,13 +48,16 @@ include:
- "**/build*/partition_table/*.bin"
when: always
expire_in: 4 days
script:
- python tools/ci/build_apps.py ./examples --rcp_gateway
- build_rcp_gateway
tags:
- build

.build_non_pytest_example_template:
stage: build
extends:
- .update_zigbee_lib_script
before_script:
- *common_before_scripts
image: ${CI_DOCKER_REGISTRY}/esp-env-${DOCKER_ENV_VERSION}
artifacts:
paths:
Expand All @@ -59,6 +68,7 @@ include:
- "**/build*/partition_table/*.bin"
when: always
expire_in: 4 days
parallel: 2
script:
- python tools/ci/build_apps.py ./examples --no_pytest
--parallel-count ${CI_NODE_TOTAL:-1}
Expand Down
2 changes: 1 addition & 1 deletion examples/constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class ZigbeeCIConstants:
default_id = ['0x0000', '0xffff']
invalid_device_addr = ['0xFFF8', '0xFFF9', '0xFFFA', '0xFFFB', '0xFFFC', '0xFFFD', '0xFFFE', '0xFFFF']
invalid_device_addr = ['0xfff8', '0xfff9', '0xfffa', '0xfffb', '0xfffc', '0xfffd', '0xfffe', '0xffff']
invalid_panid = ['0x0000', '0xffff']
coordinator_addr = '0x0000'
channel_min = 11
Expand Down
41 changes: 41 additions & 0 deletions tools/ci/utils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
export ESP_IDF_HTTP="https://gitlab-ci-token:${CI_JOB_TOKEN}@${ESP_GITLAB}/espressif/esp-idf.git"
export ESP_ZBOSS_LIB_HTTP="https://gitlab-ci-token:${CI_JOB_TOKEN}@${ESP_GITLAB}/espressif/esp-zboss-lib.git"

function setup_idf() {
pushd $CI_PROJECT_DIR
idf_ref="${CI_COMMIT_REF_NAME}"
[ "$idf_ref" == "main" ] && idf_ref="${IDF_VERSION}"
echo "Try to fetch ${idf_ref}"
git clone --depth=1 -b ${idf_ref} ${ESP_IDF_HTTP} || git clone --depth=1 -b ${IDF_VERSION} ${ESP_IDF_HTTP}
popd

pushd esp-idf
git submodule update --init --depth=1
./install.sh
. ./export.sh
popd
}

function setup_zboss_lib() {
pushd $CI_PROJECT_DIR
git clone --depth=1 -b $CI_COMMIT_REF_NAME ${ESP_ZBOSS_LIB_HTTP} || git clone --depth=1 -b master ${ESP_ZBOSS_LIB_HTTP}
popd
}

function build_rcp_gateway() {
mv $CI_PROJECT_DIR/examples/esp_zigbee_gateway/sdkconfig.defaults $CI_PROJECT_DIR/examples/esp_zigbee_gateway/sdkconfig.defaults.ori
cp $CI_PROJECT_DIR/tools/ci/sdkconfig_for_gateway_ci.defaults $CI_PROJECT_DIR/examples/esp_zigbee_gateway/sdkconfig.defaults

pushd $CI_PROJECT_DIR/esp-idf/examples/openthread/ot_rcp
echo "CONFIG_OPENTHREAD_NCP_VENDOR_HOOK=y" >> sdkconfig.defaults
idf.py set-target esp32h2
idf.py build
popd

pushd $CI_PROJECT_DIR/examples/esp_zigbee_gateway
idf.py set-target esp32s3
idf.py build
popd

mv $CI_PROJECT_DIR/examples/esp_zigbee_gateway/sdkconfig.defaults.ori $CI_PROJECT_DIR/examples/esp_zigbee_gateway/sdkconfig.defaults
}

0 comments on commit 8114916

Please sign in to comment.