Jürgen Gmach has proposed merging ~jugmac00/lpcraft:lpcraft-conda-build-plugin-is-overly-aggressive into lpcraft:main.
Commit message: test Requested reviews: Launchpad code reviewers (launchpad-reviewers) Related bugs: Bug #1978715 in lpcraft: "lpcraft conda build plugin is overly aggressive in detecting variant config files" https://bugs.launchpad.net/lpcraft/+bug/1978715 For more details, see: https://code.launchpad.net/~jugmac00/lpcraft/+git/lpcraft/+merge/440046 -- Your team Launchpad code reviewers is requested to review the proposed merge of ~jugmac00/lpcraft:lpcraft-conda-build-plugin-is-overly-aggressive into lpcraft:main.
diff --git a/lpcraft/plugin/tests/test_plugins.py b/lpcraft/plugin/tests/test_plugins.py index 1def73b..3fc6f53 100644 --- a/lpcraft/plugin/tests/test_plugins.py +++ b/lpcraft/plugin/tests/test_plugins.py @@ -484,6 +484,42 @@ class TestPlugins(CommandBaseTestCase): ) self.assertEqual(["PYTHON=3.8", "pip"], plugin_match[0].conda_packages) + def test_conda_build_plugin_settings(self): + config = dedent( + """ + pipeline: + - build + + jobs: + build: + build-target: info/recipe/parent + series: focal + architectures: amd64 + plugin: conda-build + run: | + pip install --upgrade pytest + """ + ) + config_path = Path(".launchpad.yaml") + config_path.write_text(config) + config_obj = lpcraft.config.Config.load(config_path) + self.assertEqual(config_obj.jobs["build"][0].plugin, "conda-build") + pm = get_plugin_manager(config_obj.jobs["build"][0]) + plugins = pm.get_plugins() + plugin_match = [ + _ for _ in plugins if _.__class__.__name__ == "CondaBuildPlugin" + ] + self.assertEqual( + [ + "defaults", + ], + plugin_match[0].conda_channels, + ) + self.assertEqual( + ["PYTHON=3.8", "conda-build"], plugin_match[0].conda_packages + ) + self.assertEqual("./info", plugin_match[0].recipe_folder) + @patch("lpcraft.commands.run.get_provider") @patch("lpcraft.commands.run.get_host_architecture", return_value="amd64") def test_conda_build_plugin( @@ -517,6 +553,8 @@ class TestPlugins(CommandBaseTestCase): ) Path(".launchpad.yaml").write_text(config) Path("info/recipe/parent").mkdir(parents=True) + Path("info/a.txt").touch() + Path("info/b.txt").touch() Path("info/recipe/meta.yaml").touch() Path("info/recipe/parent/meta.yaml").touch() pre_run_command = dedent( @@ -679,6 +717,43 @@ class TestPlugins(CommandBaseTestCase): ] self.assertEqual("info/recipe", plugin_match[0].build_target) + def test_conda_build_plugin_finds_recipe_custom_folder(self): + config = dedent( + """ + pipeline: + - build + + jobs: + build: + series: focal + architectures: amd64 + plugin: conda-build + conda-channels: + - conda-forge + conda-packages: + - mamba + - pip + conda-python: 3.8 + recipe-folder: custominfo + run: | + pip install --upgrade pytest + """ + ) + config_path = Path(".launchpad.yaml") + config_path.write_text(config) + Path("include/fake_subdir").mkdir(parents=True) + meta_yaml = Path("custominfo/recipe/meta.yaml") + meta_yaml.parent.mkdir(parents=True) + meta_yaml.touch() + config_obj = lpcraft.config.Config.load(config_path) + self.assertEqual(config_obj.jobs["build"][0].plugin, "conda-build") + pm = get_plugin_manager(config_obj.jobs["build"][0]) + plugins = pm.get_plugins() + plugin_match = [ + _ for _ in plugins if _.__class__.__name__ == "CondaBuildPlugin" + ] + self.assertEqual("custominfo/recipe", plugin_match[0].build_target) + def test_conda_build_plugin_finds_recipe_with_fake_parent(self): config = dedent( """ diff --git a/lpcraft/plugins/plugins.py b/lpcraft/plugins/plugins.py index 4dbad96..c32f6f5 100644 --- a/lpcraft/plugins/plugins.py +++ b/lpcraft/plugins/plugins.py @@ -264,12 +264,22 @@ class CondaBuildPlugin(MiniCondaPlugin): conda_channels: Optional[List[StrictStr]] conda_packages: Optional[List[StrictStr]] conda_python: Optional[StrictStr] + recipe_folder: Optional[StrictStr] DEFAULT_CONDA_PACKAGES = ("conda-build",) + DEFAULT_RECIPE_FOLDER = "./info" def get_plugin_config(self) -> "CondaBuildPlugin.Config": return cast(CondaBuildPlugin.Config, self.config.plugin_config) + @property + def recipe_folder(self) -> str: + recipe_folder = self.DEFAULT_RECIPE_FOLDER + plugin_config = self.get_plugin_config() + if plugin_config.recipe_folder: + recipe_folder = plugin_config.recipe_folder + return recipe_folder + @staticmethod def _has_recipe(dir_: Path) -> bool: return dir_.joinpath("meta.yaml").is_file() @@ -300,7 +310,7 @@ class CondaBuildPlugin(MiniCondaPlugin): continue raise FileNotFoundError - return _find_recipe_dir(Path(".")) + return _find_recipe_dir(Path(self.recipe_folder)) def find_build_target(self) -> str: def find_parents(pth: Path) -> Path:
_______________________________________________ Mailing list: https://launchpad.net/~launchpad-reviewers Post to : launchpad-reviewers@lists.launchpad.net Unsubscribe : https://launchpad.net/~launchpad-reviewers More help : https://help.launchpad.net/ListHelp