mirror of
https://github.com/espressif/esp-modbus.git
synced 2026-08-03 20:24:09 +02:00
347 lines
9.9 KiB
YAML
347 lines
9.9 KiB
YAML
stages:
|
|
- build
|
|
- target_test
|
|
- deploy
|
|
|
|
variables:
|
|
# System environment
|
|
ESP_DOCS_ENV_IMAGE: "$CI_DOCKER_REGISTRY/esp-idf-doc-env-v5.3:1-1"
|
|
ESP_DOCS_PATH: "$CI_PROJECT_DIR"
|
|
TEST_DIR: "$CI_PROJECT_DIR/test"
|
|
|
|
# GitLab-CI environment
|
|
GET_SOURCES_ATTEMPTS: "10"
|
|
ARTIFACT_DOWNLOAD_ATTEMPTS: "10"
|
|
GIT_SUBMODULE_STRATEGY: none
|
|
|
|
# Define a matrix for IDF versions and their corresponding targets
|
|
.options_list:
|
|
markers:
|
|
TEST_PORT:
|
|
- "tcp"
|
|
- "serial"
|
|
- "generic"
|
|
# - "tcp_p4"
|
|
# - "serial_p4"
|
|
|
|
.setup_idf_tools: &setup_idf_tools |
|
|
tools/idf_tools.py --non-interactive install && eval "$(tools/idf_tools.py --non-interactive export)" || exit 1
|
|
|
|
.add_gh_key_remote: &add_gh_key_remote |
|
|
command -v ssh-agent >/dev/null || exit 1
|
|
eval $(ssh-agent -s)
|
|
printf '%s\n' "${GH_PUSH_KEY}" | tr -d '\r' | ssh-add - > /dev/null
|
|
mkdir -p ~/.ssh && chmod 700 ~/.ssh
|
|
[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config || ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
|
|
git remote remove github || true
|
|
git remote add github ${GH_PUSH_REPO}
|
|
|
|
after_script:
|
|
# Just for cleaning space, no other causes
|
|
- git clean -ffdx
|
|
|
|
.build_template:
|
|
stage: build
|
|
tags:
|
|
- build
|
|
variables:
|
|
SIZE_INFO_LOCATION: "${TEST_DIR}/size_info.txt"
|
|
IDF_CCACHE_ENABLE: "1"
|
|
after_script:
|
|
# Show ccache statistics if enabled globally
|
|
- test "$CI_CCACHE_STATS" == 1 && test -n "$(which ccache)" && ccache --show-stats || true
|
|
dependencies: []
|
|
|
|
.before_script_build_jobs:
|
|
before_script:
|
|
- pip install idf-component-manager --upgrade
|
|
- pip install "idf_build_apps~=1.0.1"
|
|
|
|
.check_idf_ver: &check_idf_ver |
|
|
export IDF_PATH=$(find /opt -type d -name "*idf*" \
|
|
\( -exec test -f '{}/tools/idf.py' \; -and -exec test -f '{}/tools/idf_tools.py' \; \
|
|
\) -print -quit)
|
|
if [ -z "${IDF_PATH}" ];then
|
|
echo "IDF version is not found."
|
|
else
|
|
cd ${IDF_PATH}
|
|
export IDF_DESCRIBE=$(git describe)
|
|
export IDF_VERSION=${IDF_DESCRIBE%-*}
|
|
echo "$IDF_VERSION" >> $TEST_DIR/idf_version_info.txt
|
|
echo "ESP-IDF: $IDF_VERSION"
|
|
fi
|
|
|
|
# This template gets expanded multiple times, once for every IDF version.
|
|
# IDF version is specified by setting the espressif/idf image tag.
|
|
#
|
|
# TEST_TARGETS sets the list of IDF_TARGET values to build the test for.
|
|
# It should contain only the targets with optimized assembly implementations.
|
|
#
|
|
.build_pytest_template:
|
|
stage: build
|
|
extends:
|
|
- .build_template
|
|
- .before_script_build_jobs
|
|
artifacts:
|
|
name: artifacts_${CI_JOB_NAME}
|
|
paths:
|
|
- "**/build*/size.json"
|
|
- "**/build*/build.log"
|
|
- "**/build*/build_log.txt"
|
|
- "**/build*/*.bin"
|
|
- "**/build*/*.elf"
|
|
- "**/build*/*.map"
|
|
- "**/build*/flasher_args.json"
|
|
- "**/build*/flash_project_args"
|
|
- "**/build*/config/sdkconfig.json"
|
|
- "**/build*/bootloader/*.bin"
|
|
- "**/build*/partition_table/*.bin"
|
|
- "**/idf_version_info.txt"
|
|
- $SIZE_INFO_LOCATION
|
|
when: always
|
|
expire_in: 3 weeks
|
|
script:
|
|
# CI specific options start from "--collect-size-info xxx". could ignore when running locally
|
|
# The script below will build all test applications defined in environment variable $TEST_TARGETS
|
|
- *check_idf_ver
|
|
- cd ${TEST_DIR}
|
|
- python -m idf_build_apps build -v -p ${TEST_PORT}
|
|
--recursive
|
|
--target all
|
|
--default-build-targets ${TEST_TARGETS}
|
|
--config "sdkconfig.ci.*=" --build-dir "build_@t_@w"
|
|
--build-log build_log.txt
|
|
--check-warnings
|
|
--ignore-warning-file ../tools/ignore_build_warnings.txt
|
|
--collect-size-info $SIZE_INFO_LOCATION
|
|
--manifest-rootpath .
|
|
--manifest-file .build-test-rules.yml
|
|
# delete all other build artifacts, except esp32
|
|
- echo "Delete build folders:" $(find . -type d -regex '^\./.*build_esp32[a-z]+[0-9]+[_a-z]*' -print -exec rm -rf {} +)
|
|
variables:
|
|
TEST_TARGETS: "esp32"
|
|
|
|
build_idf_latest:
|
|
extends: .build_pytest_template
|
|
image: espressif/idf:latest
|
|
parallel:
|
|
matrix:
|
|
- !reference [.options_list, markers]
|
|
variables:
|
|
TEST_TARGETS: "esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c5 esp32c6 esp32c61 esp32h2 esp32p4"
|
|
|
|
# Check the support policy for esp-idf v5.3
|
|
build_idf_v5.3:
|
|
extends: .build_pytest_template
|
|
image: espressif/idf:release-v5.3
|
|
parallel:
|
|
matrix:
|
|
- !reference [.options_list, markers]
|
|
variables:
|
|
TEST_TARGETS: "esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6 esp32h2 esp32p4"
|
|
|
|
build_idf_v5.2:
|
|
extends: .build_pytest_template
|
|
image: espressif/idf:release-v5.2
|
|
parallel:
|
|
matrix:
|
|
- !reference [.options_list, markers]
|
|
variables:
|
|
TEST_TARGETS: "esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6 esp32h2"
|
|
|
|
build_idf_v5.1:
|
|
extends: .build_pytest_template
|
|
image: espressif/idf:release-v5.1
|
|
parallel:
|
|
matrix:
|
|
- !reference [.options_list, markers]
|
|
variables:
|
|
TEST_TARGETS: "esp32 esp32s2 esp32s3 esp32c2 esp32c3"
|
|
|
|
build_idf_v5.0:
|
|
extends: .build_pytest_template
|
|
image: espressif/idf:release-v5.0
|
|
parallel:
|
|
matrix:
|
|
- !reference [.options_list, markers]
|
|
variables:
|
|
TEST_TARGETS: "esp32 esp32s2 esp32s3 esp32c2 esp32c3"
|
|
|
|
.target_test_template:
|
|
stage: target_test
|
|
timeout: 1 hour
|
|
variables:
|
|
GIT_DEPTH: 1
|
|
SUBMODULES_TO_FETCH: "none"
|
|
cache:
|
|
# Usually do not need submodule-cache in target_test
|
|
- key: pip-cache
|
|
paths:
|
|
- .cache/pip
|
|
policy: pull
|
|
|
|
.before_script_pytest_jobs:
|
|
before_script:
|
|
# Install pytest-embedded to perform test cases (workaround to upgrade the version )
|
|
- pip install --only-binary cryptography pytest-embedded pytest-embedded-serial-esp pytest-embedded-idf --upgrade
|
|
|
|
.test_template:
|
|
extends:
|
|
- .before_script_pytest_jobs
|
|
tags:
|
|
- multi_dut_modbus_${TEST_PORT}
|
|
variables:
|
|
IDF_TARGET: "esp32" # the only esp32 runners are available for now
|
|
artifacts:
|
|
name: artifacts_${CI_JOB_NAME}
|
|
paths:
|
|
- "${TEST_DIR}/*/*.log"
|
|
- "${TEST_DIR}/*.txt"
|
|
- "${TEST_DIR}/*/results_*.xml"
|
|
- "${TEST_DIR}/pytest_embedded_log/"
|
|
reports:
|
|
junit: ${TEST_DIR}/${TEST_PORT}/results_${IDF_TARGET}_${IDF_VER%-*}.xml
|
|
when: always
|
|
expire_in: 1 week
|
|
script: |
|
|
export IDF_VER=$(cat ${TEST_DIR}/idf_version_info.txt)
|
|
cd ${TEST_DIR}/${TEST_PORT}
|
|
echo "Start test job: ${CI_JOB_NAME}, version: ${IDF_VER%-*}, folder: ${PWD##*/}"
|
|
python -m pytest --embedded-services serial,esp,idf --junit-xml=${TEST_DIR}/${TEST_PORT}/results_${IDF_TARGET}_${IDF_VER%-*}.xml --target=${IDF_TARGET}
|
|
ls -lh > ${TEST_DIR}/test_dir.txt
|
|
|
|
target_test_latest:
|
|
stage: target_test
|
|
image: "$CI_DOCKER_REGISTRY/target-test-env-v5.3:1"
|
|
extends: .test_template
|
|
needs:
|
|
- build_idf_latest
|
|
parallel:
|
|
matrix:
|
|
- !reference [.options_list, markers]
|
|
after_script: []
|
|
|
|
# Test the support policy for esp-idf v5.3
|
|
target_test_v5.3:
|
|
stage: target_test
|
|
image: "$CI_DOCKER_REGISTRY/target-test-env-v5.3:1"
|
|
extends: .test_template
|
|
needs:
|
|
- build_idf_v5.3
|
|
parallel:
|
|
matrix:
|
|
- !reference [.options_list, markers]
|
|
after_script: []
|
|
|
|
target_test_v5.2:
|
|
stage: target_test
|
|
image: "$CI_DOCKER_REGISTRY/target-test-env-v5.2:2"
|
|
extends: .test_template
|
|
needs:
|
|
- build_idf_v5.2
|
|
parallel:
|
|
matrix:
|
|
- !reference [.options_list, markers]
|
|
after_script: []
|
|
|
|
target_test_v5.1:
|
|
stage: target_test
|
|
image: "$CI_DOCKER_REGISTRY/target-test-env-v5.1:1"
|
|
extends: .test_template
|
|
needs:
|
|
- build_idf_v5.1
|
|
parallel:
|
|
matrix:
|
|
- !reference [.options_list, markers]
|
|
after_script: []
|
|
|
|
target_test_v5.0:
|
|
stage: target_test
|
|
image: "$CI_DOCKER_REGISTRY/target-test-env-v5.0:3"
|
|
extends: .test_template
|
|
parallel:
|
|
matrix:
|
|
- !reference [.options_list, markers]
|
|
needs:
|
|
job: build_idf_v5.0
|
|
artifacts: true
|
|
after_script: []
|
|
|
|
build_docs:
|
|
stage: build
|
|
image: $ESP_DOCS_ENV_IMAGE
|
|
tags:
|
|
- build_docs
|
|
artifacts:
|
|
when: always
|
|
paths:
|
|
- docs/_build/*/*/*.txt
|
|
- docs/_build/*/*/html/*
|
|
expire_in: 4 days
|
|
# No cleaning when the artifacts
|
|
after_script: []
|
|
script:
|
|
- cd docs
|
|
- pip install -r requirements.txt
|
|
- ./generate_docs
|
|
|
|
.deploy_docs_template:
|
|
stage: deploy
|
|
image: $ESP_DOCS_ENV_IMAGE
|
|
tags:
|
|
- deploy_docs
|
|
needs:
|
|
- build_docs
|
|
only:
|
|
changes:
|
|
- "docs/**/*"
|
|
script:
|
|
- source ${CI_PROJECT_DIR}/docs/utils.sh
|
|
- add_doc_server_ssh_keys $DOCS_DEPLOY_PRIVATEKEY $DOCS_DEPLOY_SERVER $DOCS_DEPLOY_SERVER_USER
|
|
- export GIT_VER=$(git describe --always)
|
|
- pip install -r ${CI_PROJECT_DIR}/docs/requirements.txt
|
|
- deploy-docs
|
|
|
|
deploy_docs_preview:
|
|
extends:
|
|
- .deploy_docs_template
|
|
except:
|
|
refs:
|
|
- master
|
|
variables:
|
|
TYPE: "preview"
|
|
DOCS_BUILD_DIR: "${CI_PROJECT_DIR}/docs/_build/"
|
|
DOCS_DEPLOY_PRIVATEKEY: "$DOCS_PREVIEW_PRIVATEKEY"
|
|
DOCS_DEPLOY_SERVER: "$DOCS_PREVIEW_SERVER"
|
|
DOCS_DEPLOY_SERVER_USER: "$DOCS_PREVIEW_SERVER_USER"
|
|
DOCS_DEPLOY_PATH: "$DOCS_PREVIEW_PATH"
|
|
DOCS_DEPLOY_URL_BASE: "$DOCS_PREVIEW_URL_BASE"
|
|
|
|
deploy_docs_production:
|
|
extends:
|
|
- .deploy_docs_template
|
|
only:
|
|
refs:
|
|
- master
|
|
variables:
|
|
TYPE: "production"
|
|
DOCS_BUILD_DIR: "${CI_PROJECT_DIR}/docs/_build/"
|
|
DOCS_DEPLOY_PRIVATEKEY: "$DOCS_PROD_DEPLOY_KEY"
|
|
DOCS_DEPLOY_SERVER: "$DOCS_PROD_SERVER"
|
|
DOCS_DEPLOY_SERVER_USER: "$DOCS_PROD_SERVER_USER"
|
|
DOCS_DEPLOY_PATH: "$DOCS_PROD_PATH"
|
|
DOCS_DEPLOY_URL_BASE: "https://docs.espressif.com/projects/esp-modbus"
|
|
|
|
upload_to_component_manager:
|
|
stage: deploy
|
|
image: python:3.10-alpine
|
|
tags:
|
|
- deploy
|
|
rules:
|
|
- if: '$CI_COMMIT_BRANCH == "master"'
|
|
- if: '$FORCE_PUSH_COMPONENT == "1"'
|
|
script:
|
|
- pip install idf-component-manager
|
|
- export IDF_COMPONENT_API_TOKEN=${ESP_MODBUS_API_KEY}
|
|
- export COMP_VERSION=$(grep 'version:' idf_component.yml | head -n 1 | awk '{print $2}' | tr -d '"')
|
|
- compote component upload --namespace=espressif --name=esp-modbus --allow-existing --version=${COMP_VERSION} |