mirror of
https://github.com/espressif/esp-modbus.git
synced 2026-08-03 20:24:09 +02:00
268 lines
7.9 KiB
YAML
268 lines
7.9 KiB
YAML
stages:
|
|
- build
|
|
- target_test
|
|
- deploy
|
|
|
|
variables:
|
|
# System environment
|
|
ESP_DOCS_ENV_IMAGE: "$CI_DOCKER_REGISTRY/esp-idf-doc-env-v5.0:2-2"
|
|
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
|
|
|
|
.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 "ESP-IDF: $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:
|
|
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 ${SUBDIR}
|
|
--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_master:
|
|
extends: .build_pytest_template
|
|
image: espressif/idf:latest
|
|
parallel:
|
|
matrix:
|
|
- SUBDIR: ["serial", "tcp", "generic"]
|
|
variables:
|
|
TEST_TARGETS: "esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6 esp32h2 esp32p4"
|
|
|
|
build_idf_v5.0:
|
|
extends: .build_pytest_template
|
|
image: espressif/idf:release-v5.0
|
|
parallel:
|
|
matrix:
|
|
- SUBDIR: ["serial", "tcp", "generic"]
|
|
variables:
|
|
TEST_TARGETS: "esp32 esp32s2 esp32s3 esp32c2 esp32c3"
|
|
|
|
build_idf_v5.2:
|
|
extends: .build_pytest_template
|
|
image: espressif/idf:release-v5.2
|
|
parallel:
|
|
matrix:
|
|
- SUBDIR: ["serial", "tcp", "generic"]
|
|
variables:
|
|
TEST_TARGETS: "esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6 esp32h2"
|
|
|
|
.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
|
|
- pip install --only-binary cryptography pytest-embedded pytest-embedded-serial-esp pytest-embedded-idf
|
|
|
|
.test_template:
|
|
extends:
|
|
- .before_script_pytest_jobs
|
|
tags:
|
|
- multi_dut_modbus_${TEST_PORT}
|
|
artifacts:
|
|
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_BRANCH}.xml
|
|
when: always
|
|
expire_in: 1 week
|
|
script:
|
|
- cd ${TEST_DIR}/${TEST_PORT}
|
|
- echo "Start target test for [esp-idf_${IDF_BRANCH}_${IDF_TARGET}_${TEST_PORT}]"
|
|
- python -m pytest --junit-xml=${TEST_DIR}/${TEST_PORT}/results_${IDF_TARGET}_${IDF_BRANCH}.xml --target=${IDF_TARGET}
|
|
- ls -lh > ${TEST_DIR}/test_dir.txt
|
|
|
|
target_test:
|
|
stage: target_test
|
|
image: "$CI_DOCKER_REGISTRY/target-test-env-v5.2:2"
|
|
extends: .test_template
|
|
needs: [build_idf_master, build_idf_v5.2, build_idf_v5.0]
|
|
parallel:
|
|
matrix:
|
|
- IDF_BRANCH: ["master", "v5.2", "v5.0"]
|
|
IDF_TARGET: ["esp32"]
|
|
TEST_PORT: ["serial", "tcp", "generic"]
|
|
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_DEPLOY_KEY"
|
|
DOCS_DEPLOY_SERVER: "$DOCS_SERVER"
|
|
DOCS_DEPLOY_SERVER_USER: "$DOCS_SERVER_USER"
|
|
DOCS_DEPLOY_PATH: "$DOCS_PATH"
|
|
DOCS_DEPLOY_URL_BASE: "https://$DOCS_PREVIEW_SERVER_URL/docs/esp-modbus"
|
|
|
|
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}
|
|
- python -m idf_component_manager upload-component --allow-existing --name=esp-modbus --namespace=espressif
|