From f182c30f7c525ef516c61465c4ca36292848627a Mon Sep 17 00:00:00 2001 From: AhmedBasem Date: Fri, 15 Sep 2023 16:57:11 +0200 Subject: [PATCH] Add test-install errors to the registry checks. --- aiida-registry-app/src/Components/Details.jsx | 21 ++++++++++++++----- aiida_registry/fetch_metadata.py | 21 ++++++++++++------- aiida_registry/test_install.py | 8 ++++++- 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/aiida-registry-app/src/Components/Details.jsx b/aiida-registry-app/src/Components/Details.jsx index 51918ff7..a1db0420 100644 --- a/aiida-registry-app/src/Components/Details.jsx +++ b/aiida-registry-app/src/Components/Details.jsx @@ -76,13 +76,24 @@ function Details({pluginKey}) {

Registry checks

- {value.warnings ? ( + {value.warnings || value.errors ? ( <> - {value.warnings.map((warning) => ( - {warning} - ))} + {value.warnings && ( + <> + {value.warnings.map((warning) => ( + {warning} + ))} + + )} + {value.errors && ( + <> + {value.errors.map((error) => ( +
{error}
+ ))} + + )} - ):( + ) : ( All checks passed! )} diff --git a/aiida_registry/fetch_metadata.py b/aiida_registry/fetch_metadata.py index ff078cee..ab89aa2a 100644 --- a/aiida_registry/fetch_metadata.py +++ b/aiida_registry/fetch_metadata.py @@ -32,7 +32,10 @@ from .parse_pypi import PypiData, get_pypi_metadata from .utils import fetch_file -GITHUB_TOKEN = os.environ["GITHUB_TOKEN"] +try: + GITHUB_TOKEN = os.environ["GITHUB_TOKEN"] +except KeyError: + GITHUB_TOKEN = "" @lru_cache(maxsize=None) @@ -354,12 +357,16 @@ def is_pip_url_pypi(string: str) -> bool: return PYPI_NAME_RE.match(string) is not None -def add_warnings(metadata): - """Add fetch warnings to the data object.""" +def add_registry_checks(metadata, include_errors=False): + """Add fetch warnings/errors to the data object.""" plugins_warnings = REPORTER.plugins_warnings - for name, warnings in plugins_warnings.items(): - metadata[name]["warnings"] = warnings + if include_errors: + for name, error_list in plugins_warnings.items(): + metadata["plugins"][name]["errors"] = error_list + else: + for name, warning_list in plugins_warnings.items(): + metadata[name]["warnings"] = warning_list return metadata @@ -379,9 +386,7 @@ def fetch_metadata(filter_list=None, fetch_pypi=True, fetch_pypi_wheel=True): plugins_metadata[plugin_name] = complete_plugin_data( plugin_data, fetch_pypi=fetch_pypi, fetch_pypi_wheel=fetch_pypi_wheel ) - - plugins_metadata = add_warnings(plugins_metadata) - + plugins_metadata = add_registry_checks(plugins_metadata) REPORTER.info(f"{PLUGINS_METADATA} dumped") if os.environ.get("GITHUB_ACTIONS") == "true": diff --git a/aiida_registry/test_install.py b/aiida_registry/test_install.py index ceee37f7..fcb11d5b 100644 --- a/aiida_registry/test_install.py +++ b/aiida_registry/test_install.py @@ -10,7 +10,9 @@ import sys from dataclasses import asdict, dataclass -from . import PLUGINS_METADATA +from aiida_registry.fetch_metadata import add_registry_checks + +from . import PLUGINS_METADATA, REPORTER # Where to mount the workdir inside the Docker container _DOCKER_WORKDIR = "/tmp/scripts" @@ -72,6 +74,7 @@ def handle_error(process_result, message): if process_result.exit_code != 0: error_message = process_result.output.decode("utf8") + REPORTER.warn(f"{message}\n{error_message}") raise ValueError(f"{message}\n{error_message}") return error_message @@ -87,6 +90,7 @@ def test_install_one_docker(container_image, plugin): is_package_importable = False process_metadata = {} error_message = "" + REPORTER.set_plugin_name(plugin["name"]) print(" - Starting container for {}".format(plugin["name"])) container = client.containers.run( @@ -219,6 +223,8 @@ def test_install_all(container_image): except KeyError: continue + data = add_registry_checks(data, include_errors=True) + print("Dumping plugins.json") with open(PLUGINS_METADATA, "w", encoding="utf8") as handle: json.dump(data, handle, indent=2)