From 910bea1a1d08a45d5accf69f99ffcc5c421d09e5 Mon Sep 17 00:00:00 2001 From: Fu Hanxi Date: Wed, 16 Oct 2024 09:37:50 +0200 Subject: [PATCH 1/3] ci: bypass import failure while checking test scripts we mock the missing packages in pytest_collectstart in plugin.py. but here the common_test_methods are imported by other scripts, which got executed earlier. --- tools/ci/python_packages/common_test_methods.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tools/ci/python_packages/common_test_methods.py b/tools/ci/python_packages/common_test_methods.py index 80392fbc27..fe5db2a9e7 100644 --- a/tools/ci/python_packages/common_test_methods.py +++ b/tools/ci/python_packages/common_test_methods.py @@ -1,12 +1,19 @@ -# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD +# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: Apache-2.0 - import logging import os import socket -from typing import Any, List +from typing import Any +from typing import List + +try: + import netifaces +except ImportError: + from unittest.mock import MagicMock + + netifaces = MagicMock() + logging.warning('netifaces is not installed. Please install it to get network interface information.') -import netifaces import yaml ENV_CONFIG_FILE_SEARCH = [ From bd26feef9b51ae4a22ee69619649b24b9bc44d43 Mon Sep 17 00:00:00 2001 From: Fu Hanxi Date: Wed, 16 Oct 2024 09:56:54 +0200 Subject: [PATCH 2/3] ci: ignore collect import error --- .gitlab/ci/build.yml | 4 ++++ .gitlab/ci/pre_check.yml | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitlab/ci/build.yml b/.gitlab/ci/build.yml index ce6ccfd276..6147e13503 100644 --- a/.gitlab/ci/build.yml +++ b/.gitlab/ci/build.yml @@ -309,7 +309,11 @@ generate_build_child_pipeline: - non_test_related_apps.txt expire_in: 1 week when: always + variables: + PYTEST_IGNORE_COLLECT_IMPORT_ERROR: "1" script: + # requires basic pytest dependencies + - run_cmd bash install.sh --enable-pytest - run_cmd python tools/ci/dynamic_pipelines/scripts/generate_build_child_pipeline.py build_child_pipeline: diff --git a/.gitlab/ci/pre_check.yml b/.gitlab/ci/pre_check.yml index 31dfb07266..2acc5ef0bf 100644 --- a/.gitlab/ci/pre_check.yml +++ b/.gitlab/ci/pre_check.yml @@ -117,8 +117,10 @@ check_test_scripts_build_test_rules: extends: - .pre_check_template - .before_script:build + variables: + PYTEST_IGNORE_COLLECT_IMPORT_ERROR: "1" script: - # required pytest related packages + # requires basic pytest dependencies - run_cmd bash install.sh --enable-pytest - python tools/ci/check_build_test_rules.py check-test-scripts examples/ tools/test_apps components From 1e614efa5f818aef3ccc7e7b308aa2489eba9bca Mon Sep 17 00:00:00 2001 From: Fu Hanxi Date: Wed, 16 Oct 2024 11:01:16 +0200 Subject: [PATCH 3/3] ci: add missing dependency --- tools/requirements/requirements.ci.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/requirements/requirements.ci.txt b/tools/requirements/requirements.ci.txt index fa1ac259d4..dfec5b20fc 100644 --- a/tools/requirements/requirements.ci.txt +++ b/tools/requirements/requirements.ci.txt @@ -15,3 +15,4 @@ pyyaml SimpleWebSocketServer pylint-gitlab minio +prettytable