From fd269f4f35fe6971f49af25abd3dd4f183bac621 Mon Sep 17 00:00:00 2001 From: Wolf Vollprecht Date: Fri, 10 Jan 2025 13:57:09 +0100 Subject: [PATCH] add missing file --- pixi.lock | 4 +-- pyproject.toml | 2 +- tests/__snapshots__/test_jinja.ambr | 22 -------------- tests/__snapshots__/test_recipe_sources.ambr | 23 +++++++++++++++ tests/test_jinja.py | 25 ---------------- tests/test_recipe_sources.py | 30 ++++++++++++++------ 6 files changed, 47 insertions(+), 59 deletions(-) create mode 100644 tests/__snapshots__/test_recipe_sources.ambr diff --git a/pixi.lock b/pixi.lock index 1bdbd47..4b8ab28 100644 --- a/pixi.lock +++ b/pixi.lock @@ -11120,8 +11120,8 @@ packages: timestamp: 1735902555109 - pypi: . name: rattler-build-conda-compat - version: 1.3.1 - sha256: 07d45e11b8a66ae56b42e4923ec0fcc4734e5cdcbf8406d53e40af881c4f2844 + version: 1.3.2 + sha256: 30871826ab7a5620327e356bcb317e9a893cd6edc340331da4a386e6471e1145 requires_dist: - typing-extensions>=4.12,<5 - jinja2>=3.0.2,<4 diff --git a/pyproject.toml b/pyproject.toml index 1d34f36..cc39c1b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "hatchling.build" [project] name = "rattler-build-conda-compat" description = "A package for exposing rattler-build API for conda-smithy" -version = "1.3.1" +version = "1.3.2" readme = "README.md" authors = [{ name = "Nichita Morcotilo", email = "nichita@prefix.dev" }] license = { file = "LICENSE.txt" } diff --git a/tests/__snapshots__/test_jinja.ambr b/tests/__snapshots__/test_jinja.ambr index 62381a8..ee187c6 100644 --- a/tests/__snapshots__/test_jinja.ambr +++ b/tests/__snapshots__/test_jinja.ambr @@ -1,12 +1,4 @@ # serializer version: 1 -# name: test_conditional_source_render - set({ - Source(url='https://blpapi.bloomberg.com/download/releases/raw/files/blpapi_cpp_3.24.11.1-linux.tar.gz', template='https://blpapi.bloomberg.com/download/releases/raw/files/blpapi_cpp_${{ blpapicpp_linux_version }}-linux.tar.gz', context={'name': 'blpapi', 'version': '3.24.11', 'blpapicpp_linux_version': '3.24.11.1', 'blpapicpp_win_version': '3.24.11.1', 'blpapicpp_osx_version': '3.24.11.1'}, sha256='eb1a9aa834a969a8ccbbb04061274623659a1fb273abda4413b47fe59e7ee412', md5=None), - Source(url='https://blpapi.bloomberg.com/download/releases/raw/files/blpapi_cpp_3.24.11.1-macos-arm64.tar.gz', template='https://blpapi.bloomberg.com/download/releases/raw/files/blpapi_cpp_${{ blpapicpp_osx_version }}-macos-arm64.tar.gz', context={'name': 'blpapi', 'version': '3.24.11', 'blpapicpp_linux_version': '3.24.11.1', 'blpapicpp_win_version': '3.24.11.1', 'blpapicpp_osx_version': '3.24.11.1'}, sha256='fa96331edf06dd2342cb27771367516296067e94961ec6e600add1c2eed9c41d', md5=None), - Source(url='https://blpapi.bloomberg.com/download/releases/raw/files/blpapi_cpp_3.24.11.1-windows.zip', template='https://blpapi.bloomberg.com/download/releases/raw/files/blpapi_cpp_${{ blpapicpp_win_version }}-windows.zip', context={'name': 'blpapi', 'version': '3.24.11', 'blpapicpp_linux_version': '3.24.11.1', 'blpapicpp_win_version': '3.24.11.1', 'blpapicpp_osx_version': '3.24.11.1'}, sha256='e63c0b75d50097194c425489a08cec9c0374ab7b8eafe5b015c076bb2432fa19', md5=None), - Source(url='https://blpapi.bloomberg.com/repository/releases/python/blpapi-3.24.11.tar.gz', template='https://blpapi.bloomberg.com/repository/releases/python/${{ name }}-${{ version }}.tar.gz', context={'name': 'blpapi', 'version': '3.24.11', 'blpapicpp_linux_version': '3.24.11.1', 'blpapicpp_win_version': '3.24.11.1', 'blpapicpp_osx_version': '3.24.11.1'}, sha256='94dc699df262187b3afe4f163526aac67fb5982b008efe851836e9f1cd5358c1', md5=None), - }) -# --- # name: test_context_rendering ''' context: @@ -320,20 +312,6 @@ ''' # --- -# name: test_multi_source_render - set({ - Source(url='https://all.com', template='https://all.com', context={'name': 'foobar', 'version': '1.2.3'}, sha256='yyy', md5=None), - Source(url='https://all.com/foobar/1.2.3.zip', template='https://all.com/${{ name }}/${{ version }}.zip', context={'name': 'foobar', 'version': '1.2.3'}, sha256='yyy', md5=None), - Source(url='https://foo.com', template='https://foo.com', context={'name': 'foobar', 'version': '1.2.3'}, sha256='679d42a76b82a6dc20ffd9048ab45fb2e5557a526113aaedc7419e12f3cfab38', md5=None), - Source(url='https://osx.com/osx-64/foo.zip', template='https://osx.com/${{ target_platform }}/foo.zip', context={'name': 'foobar', 'version': '1.2.3'}, sha256='zzz', md5=None), - Source(url='https://osx.com/win-64/foo.zip', template='https://osx.com/${{ target_platform }}/foo.zip', context={'name': 'foobar', 'version': '1.2.3'}, sha256='zzz', md5=None), - Source(url='https://win.com', template='https://win.com', context={'name': 'foobar', 'version': '1.2.3'}, sha256='xxx', md5=None), - Source(url=['https://foo.com/linux-64/zip.zip', 'https://mirror.com/linux-64/zip.zip'], template=['https://foo.com/${{ target_platform }}/zip.zip', 'https://mirror.com/${{ target_platform }}/zip.zip'], context={'name': 'foobar', 'version': '1.2.3'}, sha256='yyy', md5=None), - Source(url=['https://foo.com/osx-64/zip.zip', 'https://mirror.com/osx-64/zip.zip'], template=['https://foo.com/${{ target_platform }}/zip.zip', 'https://mirror.com/${{ target_platform }}/zip.zip'], context={'name': 'foobar', 'version': '1.2.3'}, sha256='yyy', md5=None), - Source(url=['https://foo.com/osx-arm64/zip.zip', 'https://mirror.com/osx-arm64/zip.zip'], template=['https://foo.com/${{ target_platform }}/zip.zip', 'https://mirror.com/${{ target_platform }}/zip.zip'], context={'name': 'foobar', 'version': '1.2.3'}, sha256='yyy', md5=None), - Source(url=['https://foo.com/win-64/zip.zip', 'https://mirror.com/win-64/zip.zip'], template=['https://foo.com/${{ target_platform }}/zip.zip', 'https://mirror.com/${{ target_platform }}/zip.zip'], context={'name': 'foobar', 'version': '1.2.3'}, sha256='xxx', md5=None), - }) -# --- # name: test_render_recipe_with_context ''' # yaml-language-server: $schema=https://raw.githubusercontent.com/prefix-dev/recipe-format/main/schema.json diff --git a/tests/__snapshots__/test_recipe_sources.ambr b/tests/__snapshots__/test_recipe_sources.ambr new file mode 100644 index 0000000..52e5566 --- /dev/null +++ b/tests/__snapshots__/test_recipe_sources.ambr @@ -0,0 +1,23 @@ +# serializer version: 1 +# name: test_conditional_source_render + set({ + Source(url='https://blpapi.bloomberg.com/download/releases/raw/files/blpapi_cpp_3.24.11.1-linux.tar.gz', template='https://blpapi.bloomberg.com/download/releases/raw/files/blpapi_cpp_${{ blpapicpp_linux_version }}-linux.tar.gz', context={'name': 'blpapi', 'version': '3.24.11', 'blpapicpp_linux_version': '3.24.11.1', 'blpapicpp_win_version': '3.24.11.1', 'blpapicpp_osx_version': '3.24.11.1'}, sha256='eb1a9aa834a969a8ccbbb04061274623659a1fb273abda4413b47fe59e7ee412', md5=None), + Source(url='https://blpapi.bloomberg.com/download/releases/raw/files/blpapi_cpp_3.24.11.1-macos-arm64.tar.gz', template='https://blpapi.bloomberg.com/download/releases/raw/files/blpapi_cpp_${{ blpapicpp_osx_version }}-macos-arm64.tar.gz', context={'name': 'blpapi', 'version': '3.24.11', 'blpapicpp_linux_version': '3.24.11.1', 'blpapicpp_win_version': '3.24.11.1', 'blpapicpp_osx_version': '3.24.11.1'}, sha256='fa96331edf06dd2342cb27771367516296067e94961ec6e600add1c2eed9c41d', md5=None), + Source(url='https://blpapi.bloomberg.com/download/releases/raw/files/blpapi_cpp_3.24.11.1-windows.zip', template='https://blpapi.bloomberg.com/download/releases/raw/files/blpapi_cpp_${{ blpapicpp_win_version }}-windows.zip', context={'name': 'blpapi', 'version': '3.24.11', 'blpapicpp_linux_version': '3.24.11.1', 'blpapicpp_win_version': '3.24.11.1', 'blpapicpp_osx_version': '3.24.11.1'}, sha256='e63c0b75d50097194c425489a08cec9c0374ab7b8eafe5b015c076bb2432fa19', md5=None), + Source(url='https://blpapi.bloomberg.com/repository/releases/python/blpapi-3.24.11.tar.gz', template='https://blpapi.bloomberg.com/repository/releases/python/${{ name }}-${{ version }}.tar.gz', context={'name': 'blpapi', 'version': '3.24.11', 'blpapicpp_linux_version': '3.24.11.1', 'blpapicpp_win_version': '3.24.11.1', 'blpapicpp_osx_version': '3.24.11.1'}, sha256='94dc699df262187b3afe4f163526aac67fb5982b008efe851836e9f1cd5358c1', md5=None), + }) +# --- +# name: test_multi_source_render + set({ + Source(url='https://all.com', template='https://all.com', context={'name': 'foobar', 'version': '1.2.3'}, sha256='yyy', md5=None), + Source(url='https://all.com/foobar/1.2.3.zip', template='https://all.com/${{ name }}/${{ version }}.zip', context={'name': 'foobar', 'version': '1.2.3'}, sha256='yyy', md5=None), + Source(url='https://foo.com', template='https://foo.com', context={'name': 'foobar', 'version': '1.2.3'}, sha256='679d42a76b82a6dc20ffd9048ab45fb2e5557a526113aaedc7419e12f3cfab38', md5=None), + Source(url='https://osx.com/osx-64/foo.zip', template='https://osx.com/${{ target_platform }}/foo.zip', context={'name': 'foobar', 'version': '1.2.3'}, sha256='zzz', md5=None), + Source(url='https://osx.com/win-64/foo.zip', template='https://osx.com/${{ target_platform }}/foo.zip', context={'name': 'foobar', 'version': '1.2.3'}, sha256='zzz', md5=None), + Source(url='https://win.com', template='https://win.com', context={'name': 'foobar', 'version': '1.2.3'}, sha256='xxx', md5=None), + Source(url=['https://foo.com/linux-64/zip.zip', 'https://mirror.com/linux-64/zip.zip'], template=['https://foo.com/${{ target_platform }}/zip.zip', 'https://mirror.com/${{ target_platform }}/zip.zip'], context={'name': 'foobar', 'version': '1.2.3'}, sha256='yyy', md5=None), + Source(url=['https://foo.com/osx-64/zip.zip', 'https://mirror.com/osx-64/zip.zip'], template=['https://foo.com/${{ target_platform }}/zip.zip', 'https://mirror.com/${{ target_platform }}/zip.zip'], context={'name': 'foobar', 'version': '1.2.3'}, sha256='yyy', md5=None), + Source(url=['https://foo.com/osx-arm64/zip.zip', 'https://mirror.com/osx-arm64/zip.zip'], template=['https://foo.com/${{ target_platform }}/zip.zip', 'https://mirror.com/${{ target_platform }}/zip.zip'], context={'name': 'foobar', 'version': '1.2.3'}, sha256='yyy', md5=None), + Source(url=['https://foo.com/win-64/zip.zip', 'https://mirror.com/win-64/zip.zip'], template=['https://foo.com/${{ target_platform }}/zip.zip', 'https://mirror.com/${{ target_platform }}/zip.zip'], context={'name': 'foobar', 'version': '1.2.3'}, sha256='xxx', md5=None), + }) +# --- diff --git a/tests/test_jinja.py b/tests/test_jinja.py index b2228b8..2b77b26 100644 --- a/tests/test_jinja.py +++ b/tests/test_jinja.py @@ -6,7 +6,6 @@ from rattler_build_conda_compat.jinja.jinja import render_recipe_with_context from rattler_build_conda_compat.jinja.utils import _MissingUndefined from rattler_build_conda_compat.loader import load_yaml -from rattler_build_conda_compat.recipe_sources import render_all_sources from rattler_build_conda_compat.yaml import _dump_yaml_to_string test_data = Path(__file__).parent / "data" @@ -55,27 +54,3 @@ def test_context_rendering(snapshot) -> None: into_yaml = _dump_yaml_to_string(rendered) assert into_yaml == snapshot - - -def test_multi_source_render(snapshot) -> None: - jolt_physics = test_data / "jolt-physics" / "sources.yaml" - variants = (test_data / "jolt-physics" / "ci_support").glob("*.yaml") - - recipe_yaml = load_yaml(jolt_physics.read_text()) - variants = [load_yaml(variant.read_text()) for variant in variants] - - sources = render_all_sources(recipe_yaml, variants) - assert sources == snapshot - - -def test_conditional_source_render(snapshot) -> None: - jolt_physics = test_data / "conditional_sources.yaml" - # reuse the ci_support variants - variants = (test_data / "jolt-physics" / "ci_support").glob("*.yaml") - - recipe_yaml = load_yaml(jolt_physics.read_text()) - variants = [load_yaml(variant.read_text()) for variant in variants] - - sources = render_all_sources(recipe_yaml, variants) - assert len(sources) == 4 - assert sources == snapshot diff --git a/tests/test_recipe_sources.py b/tests/test_recipe_sources.py index db2e36f..bfb9fbe 100644 --- a/tests/test_recipe_sources.py +++ b/tests/test_recipe_sources.py @@ -6,6 +6,8 @@ from rattler_build_conda_compat.loader import load_yaml from rattler_build_conda_compat.recipe_sources import get_all_url_sources, render_all_sources +test_data = Path(__file__).parent / "data" + @pytest.mark.parametrize( ("partial_recipe", "expected_output"), @@ -26,15 +28,25 @@ def test_recipe_sources(partial_recipe: str, expected_output: list[str]) -> None assert list(get_all_url_sources(recipe)) == expected_output -def test_recipe_source_rendering() -> None: - """Test that the recipe sources are correctly rendered""" - folder = Path(f"{Path(__file__).parent}/data/jolt-physics") - path = folder / "recipe.yaml" - variants = (folder / "ci_support").glob("*.yaml") +def test_multi_source_render(snapshot) -> None: + jolt_physics = test_data / "jolt-physics" / "sources.yaml" + variants = (test_data / "jolt-physics" / "ci_support").glob("*.yaml") - recipe = load_yaml(path.read_text()) - # load all variants + recipe_yaml = load_yaml(jolt_physics.read_text()) + variants = [load_yaml(variant.read_text()) for variant in variants] + + sources = render_all_sources(recipe_yaml, variants) + assert sources == snapshot + + +def test_conditional_source_render(snapshot) -> None: + jolt_physics = test_data / "conditional_sources.yaml" + # reuse the ci_support variants + variants = (test_data / "jolt-physics" / "ci_support").glob("*.yaml") + + recipe_yaml = load_yaml(jolt_physics.read_text()) variants = [load_yaml(variant.read_text()) for variant in variants] - rendered_sources = render_all_sources(recipe, variants) - print(rendered_sources) + sources = render_all_sources(recipe_yaml, variants) + assert len(sources) == 4 + assert sources == snapshot