From 23c339e231d36614cd86c7c64c04b55eca1b1dda Mon Sep 17 00:00:00 2001 From: Fu Hanxi Date: Tue, 16 Jan 2024 20:21:40 +0100 Subject: [PATCH] ci: raise RuntimeError instead of SystemExit to avoid kill the process otherwise the pytest process will be killed immediately --- conftest.py | 5 +++++ tools/ci/idf_ci/uploader.py | 12 +++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/conftest.py b/conftest.py index 4820cbf1df..850a49faa0 100644 --- a/conftest.py +++ b/conftest.py @@ -123,6 +123,11 @@ class BuildReportDownloader: def download_app( self, app_build_path: str, artifact_type: ArtifactType = ArtifactType.BUILD_DIR_WITHOUT_MAP_AND_ELF_FILES ) -> None: + if app_build_path not in self.app_presigned_urls_dict: + raise ValueError(f'No presigned url found for {app_build_path}. ' + f'Usually this should not happen, please re-trigger a pipeline.' + f'If this happens again, please report this bug to the CI channel.') + url = self.app_presigned_urls_dict[app_build_path][artifact_type.value] logging.debug('Downloading app from %s', url) diff --git a/tools/ci/idf_ci/uploader.py b/tools/ci/idf_ci/uploader.py index 95b6819d57..ad91fa619e 100644 --- a/tools/ci/idf_ci/uploader.py +++ b/tools/ci/idf_ci/uploader.py @@ -1,14 +1,16 @@ # SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: Apache-2.0 - import glob import os import typing as t from datetime import timedelta -from zipfile import ZIP_DEFLATED, ZipFile +from zipfile import ZIP_DEFLATED +from zipfile import ZipFile import minio -from artifacts_handler import ArtifactType, get_minio_client, getenv +from artifacts_handler import ArtifactType +from artifacts_handler import get_minio_client +from artifacts_handler import getenv from idf_build_apps import App from idf_build_apps.utils import rmdir from idf_ci_utils import IDF_PATH @@ -103,7 +105,7 @@ class AppUploader: try: self._client.stat_object(getenv('IDF_S3_BUCKET'), obj_name) except minio.error.S3Error as e: - raise SystemExit( + raise RuntimeError( f'No such file on minio server: {obj_name}. ' f'Probably the build failed or the artifacts got expired. ' f'Full error message: {str(e)}' @@ -112,7 +114,7 @@ class AppUploader: self._client.fget_object(getenv('IDF_S3_BUCKET'), obj_name, zip_filename) print(f'Downloaded to {zip_filename}') except minio.error.S3Error as e: - raise SystemExit('Shouldn\'t happen, please report this bug in the CI channel' + str(e)) + raise RuntimeError('Shouldn\'t happen, please report this bug in the CI channel' + str(e)) with ZipFile(zip_filename, 'r') as zr: zr.extractall()