##################### # Default Variables # ##################### stages: - manual_gate - upload_cache - pre_check - auto_translate - build - assign_test - build_doc - target_test - host_test - test_deploy - pre_deploy - deploy - post_deploy variables: # System environment # Common parameters for the 'make' during CI tests MAKEFLAGS: "-j5 --no-keep-going" # By default, CI build jobs request and limit 4 CPU cores and 4 GB of memory # https://github.com/ninja-build/ninja/blob/def9560a0b6d755936e615ce443a0aec45c39bdb/src/ninja.cc#L262 # cpu_cores + 2 IDF_PY_BUILD_JOBS: "6" # GitLab-CI environment # Thanks to pack-objects cache, clone strategy should behave faster than fetch # so we pick "clone" as default git strategy # Shiny runners by default remove the CI_PROJECT_DIR every time at the beginning of one job # and clone with a --depth=1 # Brew runners will fetch from locally mirror first, and cache the local CI_PROJECT_DIR # In conclusion # - set GIT_STRATEGY: "clone" to shiny runners # - set GIT_STRATEGY: "fetch" to brew runners GIT_STRATEGY: clone GIT_DEPTH: 1 GIT_SUBMODULE_STRATEGY: none # here we use cache for submodules, so we don't need to fetch them every time # since we're using merged-result pipelines, the last commit should work for most cases # --prune --prune-tags: in case remote branch or tag is force pushed GIT_FETCH_EXTRA_FLAGS: "--no-recurse-submodules --prune --prune-tags" LATEST_GIT_TAG: v6.2-dev SUBMODULE_FETCH_TOOL: "tools/ci/ci_fetch_submodule.py" # by default we will fetch all submodules # jobs can overwrite this variable to only fetch submodules they required # set to "none" if don't need to fetch submodules SUBMODULES_TO_FETCH: "all" # tell build system do not check submodule update as we download archive instead of clone IDF_SKIP_CHECK_SUBMODULES: 1 IDF_PATH: "$CI_PROJECT_DIR" V: "0" CHECKOUT_REF_SCRIPT: "$CI_PROJECT_DIR/tools/ci/checkout_project_ref.py" # Docker images ESP_ENV_IMAGE: "${CI_REGISTRY}/ci/images/idf-v6.2:1" ESP_IDF_DOC_ENV_IMAGE: "${CI_REGISTRY}/ci/images/idf-v6.2-docs:1" TARGET_TEST_ENV_IMAGE: "${CI_REGISTRY}/ci/images/idf-v6.2-target-test:1" SONARQUBE_SCANNER_IMAGE: "${CI_DOCKER_REGISTRY}/sonarqube-scanner:5" # Set this variable to the branch of idf-constraints repo in order to test a custom Python constraint file. The # branch name must be without the remote part ("origin/"). Keep the variable empty in order to use the constraint # file from https://dl.espressif.com/dl/esp-idf. CI_PYTHON_CONSTRAINT_BRANCH: "" # Update the filename for a specific ESP-IDF release. It is used only with CI_PYTHON_CONSTRAINT_BRANCH. CI_PYTHON_CONSTRAINT_FILE: "espidf.constraints.v6.2.txt" # Set this variable to repository name of a Python tool you wish to install and test in the context of ESP-IDF CI. # Keep the variable empty when not used. CI_PYTHON_TOOL_REPO: "" # Set this variable to the branch of a Python tool repo specified in CI_PYTHON_TOOL_REPO. The # branch name must be without the remote part ("origin/"). Keep the variable empty when not used. # This is used only if CI_PYTHON_TOOL_REPO is not empty. CI_PYTHON_TOOL_BRANCH: "" # Set this variable to Clang toolchain distro URL to be used. # NOTE: We have separate toolchains for Xtensa and RISCV, therefore jobs for one arch will fail. # This is OK as far as we use CI_CLANG_DISTRO_URL for pre-release tests purposes only. # Keep the variable empty when not used. CI_CLANG_DISTRO_URL: "" # Set this variable to specify the file name for the known failure cases. KNOWN_FAILURE_CASES_FILE_NAME: "master.txt" IDF_CI_BUILD: 1 PYTHONWARNINGS: "ignore" # ccache settings # some settings need to set in .gitlab-ci.yml as it takes effect while start-up the job # https://ccache.dev/manual/latest.html#_configuring_ccache # host mapping volume to share ccache between runner concurrent jobs CCACHE_DIR: "/cache/idf_ccache" CCACHE_MAXSIZE: "50G" FF_USE_NEW_BASH_EVAL_STRATEGY: "true" FORCE_COLOR: "1" # rich print with color ################################################ # `before_script` and `after_script` Templates # ################################################ .common_before_scripts: &common-before_scripts | source tools/ci/utils.sh is_based_on_commits $REQUIRED_ANCESTOR_COMMITS if [[ -n "$IDF_DONT_USE_MIRRORS" ]]; then export IDF_MIRROR_PREFIX_MAP= fi if echo "$CI_MERGE_REQUEST_LABELS" | egrep "(^|,)include_nightly_run(,|$)"; then export INCLUDE_NIGHTLY_RUN="1" export NIGHTLY_RUN="1" fi # configure cmake related flags source tools/ci/configure_ci_environment.sh if [[ "$CI_CCACHE_STATS" == 1 ]] && command -v ccache >/dev/null 2>&1 && [[ -n "$CCACHE_STATSLOG" ]]; then mkdir -p "$(dirname "$CCACHE_STATSLOG")" rm -f "$CCACHE_STATSLOG" fi # add extra python packages export PYTHONPATH="$IDF_PATH/tools:$IDF_PATH/tools/ci:$IDF_PATH/tools/esp_app_trace:$IDF_PATH/components/partition_table:$IDF_PATH/tools/ci/python_packages:$PYTHONPATH" .setup_tools_and_idf_python_venv: &setup_tools_and_idf_python_venv | # must use after setup_tools_except_target_test # otherwise the export.sh won't work properly # download constraint file for dev if [[ -n "$CI_PYTHON_CONSTRAINT_BRANCH" ]]; then wget -O /tmp/constraint.txt --header="Authorization:Bearer ${ESPCI_TOKEN}" "${GITLAB_HTTP_SERVER}/api/v4/projects/2581/repository/files/${CI_PYTHON_CONSTRAINT_FILE}/raw?ref=${CI_PYTHON_CONSTRAINT_BRANCH}" mkdir -p ~/.espressif mv /tmp/constraint.txt ~/.espressif/${CI_PYTHON_CONSTRAINT_FILE} fi # Mirror if [[ -n "$IDF_DONT_USE_MIRRORS" ]]; then export IDF_MIRROR_PREFIX_MAP= fi # Optimize pip install if echo "${CI_RUNNER_TAGS}" | grep "shiny"; then export PIP_INDEX_URL="${PIP_INDEX_URL_SHINY}" fi if [[ "$(uname -m)" == "x86_64" ]] || [[ "$(uname -m)" == "aarch64" ]]; then export IDF_PIP_WHEELS_URL="" fi # install.sh if [[ "${CI_JOB_STAGE}" != "target_test" ]]; then section_start "running_install_sh" "Running install.sh" if [[ "${CI_JOB_STAGE}" == "build_doc" || "${CI_JOB_GROUP_NAME}" == *docs* ]]; then run_cmd bash install.sh --enable-ci --enable-docs else run_cmd bash install.sh --enable-ci fi section_end "running_install_sh" else section_start "install_python_env" "Install Python environment, skip required tools check" run_cmd python tools/idf_tools.py install-python-env --features ci,test-specific export IDF_SKIP_TOOLS_CHECK=1 section_end "install_python_env" fi section_start "source_export" "Source export.sh" source ./export.sh section_end "source_export" # Eager upgrade of CI dependencies # Done after sourcing export.sh so that we could easily invoke the right pip section_start "upgrade_ci_dependencies" "Upgrading CI dependencies" pip install --upgrade --upgrade-strategy=eager -r $IDF_PATH/tools/requirements/requirements.ci.txt -c ~/.espressif/${CI_PYTHON_CONSTRAINT_FILE} # we need the latest DEV release for esptool to be installed in every job without bumping the minimal requirement in # the constraint file. CI_ESPTOOL_EXTRA_INDEX_URL (set in GitLab project variables) optionally points to an internal # package registry so that internal dev builds are preferred when the variable is set; it is a no-op when unset. # Use an explicit if/else: the `${VAR:+--flag "$VAR"}` form collapses to a single token under zsh (macOS runners). if [[ -n "$CI_ESPTOOL_EXTRA_INDEX_URL" ]]; then pip install --upgrade --pre --extra-index-url "$CI_ESPTOOL_EXTRA_INDEX_URL" esptool -c ~/.espressif/${CI_PYTHON_CONSTRAINT_FILE} else pip install --upgrade --pre esptool -c ~/.espressif/${CI_PYTHON_CONSTRAINT_FILE} fi section_end "upgrade_ci_dependencies" REEXPORT_NEEDED=0 if [[ ! -z "$INSTALL_EXTRA_TOOLS" ]]; then section_start "installing_optional_tools" "Install optional tools ${INSTALL_EXTRA_TOOLS}" run_cmd $IDF_PATH/tools/idf_tools.py --non-interactive install $INSTALL_EXTRA_TOOLS section_end "installing_optional_tools" REEXPORT_NEEDED=1 fi # Install esp-clang if necessary (esp-clang is separately installed) if [[ "$IDF_TOOLCHAIN" == "clang" && -z "$CI_CLANG_DISTRO_URL" ]]; then $IDF_PATH/tools/idf_tools.py --non-interactive install esp-clang REEXPORT_NEEDED=1 fi if [[ $REEXPORT_NEEDED -eq 1 ]]; then section_start "re_source_export" "Re-source export.sh" source ./export.sh section_end "re_source_export" fi # Custom clang toolchain if [[ "$IDF_TOOLCHAIN" == "clang" && ! -z "$CI_CLANG_DISTRO_URL" ]]; then echo "Using custom clang from ${CI_CLANG_DISTRO_URL}" wget $CI_CLANG_DISTRO_URL ARCH_NAME=$(basename $CI_CLANG_DISTRO_URL) tar -x -f $ARCH_NAME export PATH=$PWD/esp-clang/bin:$PATH fi # Custom OpenOCD if [[ "$CI_JOB_STAGE" == "target_test" ]]; then machine="$(uname -m)" if [[ "$machine" == "armv7l" ]] ; then OOCD_DISTRO_URL="$OOCD_DISTRO_URL_ARMHF" elif [[ "$machine" == "aarch64" ]] ; then OOCD_DISTRO_URL="$OOCD_DISTRO_URL_ARM64" fi if [[ ! -z "$OOCD_DISTRO_URL" ]]; then echo "Using custom OpenOCD from ${OOCD_DISTRO_URL}" wget $OOCD_DISTRO_URL ARCH_NAME=$(basename $OOCD_DISTRO_URL) tar -x -f $ARCH_NAME export OPENOCD_SCRIPTS=$PWD/openocd-esp32/share/openocd/scripts export PATH=$PWD/openocd-esp32/bin:$PATH fi fi if [[ -n "$CI_PYTHON_TOOL_REPO" ]]; then git clone --quiet --depth=1 -b ${CI_PYTHON_TOOL_BRANCH} https://gitlab-ci-token:${ESPCI_TOKEN}@${GITLAB_HTTPS_HOST}/espressif/${CI_PYTHON_TOOL_REPO}.git pip install ./${CI_PYTHON_TOOL_REPO} rm -rf ${CI_PYTHON_TOOL_REPO} fi info "setup tools and python venv done" .show_ccache_statistics: &show_ccache_statistics | # Show ccache statistics if enabled globally section_start "ccache_show_stats" "Show ccache statistics" if [[ "$CI_CCACHE_STATS" == 1 ]] && command -v ccache >/dev/null 2>&1; then if ccache --help 2>/dev/null | grep -q -- '--show-log-stats'; then if [[ -n "$CCACHE_STATSLOG" && -f "$CCACHE_STATSLOG" ]]; then ccache --show-log-stats -vv else echo "INFO: No per-job ccache statistics were recorded" fi else ccache --show-stats -vv fi fi || true section_end "ccache_show_stats" .upload_failed_job_log_artifacts: &upload_failed_job_log_artifacts | if [ $CI_JOB_STATUS = "failed" ]; then run_cmd idf-ci gitlab upload-artifacts --type log fi .before_script:minimal: before_script: - *common-before_scripts .after_script:build: after_script: - source tools/ci/utils.sh - source tools/ci/configure_ci_environment.sh - *show_ccache_statistics - run_cmd idf-ci gitlab upload-artifacts --type junit - | if [ $CI_JOB_STATUS = "failed" ]; then run_cmd idf-ci gitlab upload-artifacts --type log fi .brew-macos-settings: variables: GIT_STRATEGY: fetch IDF_CCACHE_ENABLE: "0" CCACHE_DIR: "/var/tmp/cache/idf_ccache" tags: - macos-tart image: macos-sequoia-idf-v6.2 after_script: [] # ccache now is disabled for macos brew runners timeout: 30m .brew-windows-settings: image: windows_11_idf_v6_2 tags: [windows-vm, brew] variables: GIT_STRATEGY: fetch LC_ALL: C.UTF-8 # git clean at the final cleanup stage stuck on Windows VM # a new VM for each job anyway, so we can skip cleaning the workspace GIT_CLEAN_FLAGS: none # IDF_CCACHE_ENABLE: "1" # CCACHE_DIR: "C:/cache/idf_ccache" before_script: - if ($env:IDF_DONT_USE_MIRRORS) { $env:IDF_MIRROR_PREFIX_MAP = '' } - ./install.ps1 --enable-ci - ./export.ps1 # Keep the esptool upgrade in line with how it is done in setup_tools_and_idf_python_venv - $extraIndex = if ($env:CI_ESPTOOL_EXTRA_INDEX_URL) { @('--extra-index-url', $env:CI_ESPTOOL_EXTRA_INDEX_URL) } else { @() } - pip install --upgrade --pre @extraIndex esptool -c "$env:USERPROFILE\.espressif\$env:CI_PYTHON_CONSTRAINT_FILE" - $env:PYTHONPATH = "$env:PYTHONPATH;$env:IDF_PATH\tools;$env:IDF_PATH\tools\esp_app_trace;$env:IDF_PATH\components\partition_table;$env:IDF_PATH\tools\ci\python_packages" - python "${SUBMODULE_FETCH_TOOL}" -s "${SUBMODULES_TO_FETCH}" # Sync VM clock. net start/stop exit 2 when the service is already in that state; do not fail CI. - | function Invoke-NetService($Action, $Name) { $output = net $Action $Name 2>&1 if ($LASTEXITCODE -eq 2) { Write-Host "net $Action $Name already in requested state: $output" $global:LASTEXITCODE = 0 return } if ($LASTEXITCODE -ne 0) { Write-Host $output exit $LASTEXITCODE } } Invoke-NetService start w32time w32tm /config /manualpeerlist:"time.google.com,0x9 pool.ntp.org,0x9" /syncfromflags:manual /reliable:yes /update if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } Invoke-NetService stop w32time Invoke-NetService start w32time w32tm /resync if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } after_script: [] ############# # `default` # ############# default: cache: # pull only for most of the use cases since it's cache dir. # Only set "push" policy for "upload_cache" stage jobs - key: submodule-cache-${LATEST_GIT_TAG} fallback_keys: - submodule-cache paths: - .cache/submodule_archives policy: pull before_script: - *common-before_scripts - *setup_tools_and_idf_python_venv - add_gitlab_ssh_keys - fetch_submodules - export EXTRA_CFLAGS=${PEDANTIC_CFLAGS} - export EXTRA_CXXFLAGS=${PEDANTIC_CXXFLAGS}