From 50ab5d530f92adde67aea4437ca218734dc06a1f Mon Sep 17 00:00:00 2001 From: jaimergp Date: Fri, 22 Mar 2024 09:32:27 +0100 Subject: [PATCH 1/3] do not raise on validation errors --- conda_smithy/configure_feedstock.py | 15 +++++++++------ conda_smithy/validate_schema.py | 6 ++++-- tests/test_configure_feedstock.py | 15 ++++++++------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/conda_smithy/configure_feedstock.py b/conda_smithy/configure_feedstock.py index 087204b89..2eb9b037b 100644 --- a/conda_smithy/configure_feedstock.py +++ b/conda_smithy/configure_feedstock.py @@ -9,7 +9,6 @@ import pprint import textwrap import time -import jsonschema import yaml import warnings from collections import Counter, OrderedDict, namedtuple @@ -1999,11 +1998,15 @@ def _read_forge_config(forge_dir, forge_yml=None): # Validate loaded configuration against a JSON schema. validate_lints, validate_hints = validate_json_schema(file_config) - for err in validate_lints: - raise ExceptionGroup("lints", [*map(ValueError, validate_lints)]) - - for hint in validate_hints: - logger.info(hint.message) + for err in chain(validate_lints, validate_hints): + logger.warn( + "%s: %s = %s -> %s", + os.path.relpath(forge_yml, forge_dir), + err.json_path, + err.instance, + err.message, + ) + logger.debug("Relevant schema:\n%s", json.dumps(err.schema, indent=2)) # The config is just the union of the defaults, and the overridden # values. diff --git a/conda_smithy/validate_schema.py b/conda_smithy/validate_schema.py index 5b9e38edd..a7c8fbcb8 100644 --- a/conda_smithy/validate_schema.py +++ b/conda_smithy/validate_schema.py @@ -1,6 +1,6 @@ import json from pathlib import Path - +from typing import Tuple, List from jsonschema import Draft202012Validator, validators from jsonschema.exceptions import ValidationError @@ -36,7 +36,9 @@ def get_validator_class(): _VALIDATOR_CLASS = get_validator_class() -def validate_json_schema(config, schema_file: str = None): +def validate_json_schema( + config, schema_file: str = None +) -> Tuple[List[ValidationError], List[ValidationError]]: # Validate the merged configuration against a JSON schema if not schema_file: schema_file = CONDA_FORGE_YAML_SCHEMA_FILE diff --git a/tests/test_configure_feedstock.py b/tests/test_configure_feedstock.py index 669a221ce..053b78eeb 100644 --- a/tests/test_configure_feedstock.py +++ b/tests/test_configure_feedstock.py @@ -1,11 +1,12 @@ +import copy +import logging import os - -from conda_smithy import configure_feedstock +import textwrap import pytest -import copy import yaml -import textwrap + +from conda_smithy import configure_feedstock def test_noarch_skips_appveyor(noarch_recipe, jinja_env): @@ -762,7 +763,7 @@ def test_conda_forge_yaml_empty(config_yaml): assert load_forge_config()["recipe_dir"] == "recipe" -def test_noarch_platforms_bad_yaml(config_yaml): +def test_noarch_platforms_bad_yaml(config_yaml, caplog): load_forge_config = lambda: configure_feedstock._load_forge_config( # noqa config_yaml, exclusive_config_file=os.path.join( @@ -773,10 +774,10 @@ def test_noarch_platforms_bad_yaml(config_yaml): with open(os.path.join(config_yaml, "conda-forge.yml"), "a+") as fp: fp.write("noarch_platforms: [eniac, zx80]") - with pytest.raises(configure_feedstock.ExceptionGroup) as excinfo: + with caplog.at_level(logging.WARNING): load_forge_config() - assert "eniac" in repr(excinfo.value) + assert "eniac" in caplog.text def test_forge_yml_alt_path(config_yaml): From b4dc179e010c8731e1f44cfcd43850fe1f6c96a0 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Fri, 22 Mar 2024 09:38:21 +0100 Subject: [PATCH 2/3] add news --- ...1885-do-not-raise-on-validation-errors.rst | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 news/1885-do-not-raise-on-validation-errors.rst diff --git a/news/1885-do-not-raise-on-validation-errors.rst b/news/1885-do-not-raise-on-validation-errors.rst new file mode 100644 index 000000000..786cc83cf --- /dev/null +++ b/news/1885-do-not-raise-on-validation-errors.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* Do not raise on ``conda-forge.yml`` validation errors during rerender. A warning will be printed instead. (#1879 via #1885) + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* From 0e7a106b44389ca755947a1eccedfef95e727b82 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Fri, 22 Mar 2024 09:44:05 +0100 Subject: [PATCH 3/3] fix test --- tests/test_configure_feedstock.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_configure_feedstock.py b/tests/test_configure_feedstock.py index 053b78eeb..68618a6eb 100644 --- a/tests/test_configure_feedstock.py +++ b/tests/test_configure_feedstock.py @@ -868,7 +868,7 @@ def test_cuda_enabled_render(cuda_enabled_recipe, jinja_env): del os.environ["CF_CUDA_ENABLED"] -def test_conda_build_tools(config_yaml): +def test_conda_build_tools(config_yaml, caplog): load_forge_config = lambda: configure_feedstock._load_forge_config( # noqa config_yaml, exclusive_config_file=os.path.join( @@ -901,8 +901,9 @@ def test_conda_build_tools(config_yaml): fp.write(unmodified) fp.write("conda_build_tool: does-not-exist") - with pytest.raises(configure_feedstock.ExceptionGroup): + with caplog.at_level(logging.WARNING): assert load_forge_config() + assert "does-not-exist" in caplog.text def test_remote_ci_setup(config_yaml):