diff --git a/.env.ci b/.env.ci new file mode 100644 index 0000000..88cb36b --- /dev/null +++ b/.env.ci @@ -0,0 +1 @@ +PIXI_PR_NUMBER=4875 diff --git a/tests/data/pixi_build/out-of-tree-source/out_of_tree_source/external.txt b/tests/data/pixi_build/out-of-tree-source/out_of_tree_source/external.txt new file mode 100644 index 0000000..f2376e2 --- /dev/null +++ b/tests/data/pixi_build/out-of-tree-source/out_of_tree_source/external.txt @@ -0,0 +1 @@ +initial content diff --git a/tests/data/pixi_build/out-of-tree-source/package/pixi.toml b/tests/data/pixi_build/out-of-tree-source/package/pixi.toml new file mode 100644 index 0000000..b08034d --- /dev/null +++ b/tests/data/pixi_build/out-of-tree-source/package/pixi.toml @@ -0,0 +1,18 @@ +[package] +name = "out-of-tree-source" +version = "1.0.0" + +[package.build] +source = { path = "../out_of_tree_source" } + +[package.build.backend] +channels = [ + "https://prefix.dev/pixi-build-backends", + "https://prefix.dev/conda-forge", +] +name = "pixi-build-rattler-build" +version = "*" + +[package.build.configuration] +debug-dir = "{debug_dir}" +extra-input-globs = ["external.txt"] diff --git a/tests/data/pixi_build/out-of-tree-source/package/recipe.yaml b/tests/data/pixi_build/out-of-tree-source/package/recipe.yaml new file mode 100644 index 0000000..6ca686c --- /dev/null +++ b/tests/data/pixi_build/out-of-tree-source/package/recipe.yaml @@ -0,0 +1,6 @@ +package: + name: out-of-tree-source + version: 1.0.0 + +source: + path: ../out_of_tree_source diff --git a/tests/data/pixi_build/out-of-tree-source/pixi.toml b/tests/data/pixi_build/out-of-tree-source/pixi.toml new file mode 100644 index 0000000..02a5a7f --- /dev/null +++ b/tests/data/pixi_build/out-of-tree-source/pixi.toml @@ -0,0 +1,9 @@ +[workspace] +channels = ["https://prefix.dev/conda-forge"] +name = "out-of-tree-source" +platforms = ["linux-64", "osx-arm64", "win-64"] +preview = ["pixi-build"] +version = "1.0.0" + +[dependencies] +out-of-tree-source = { path = "package" } diff --git a/tests/integration_python/test_build.py b/tests/integration_python/test_build.py index 7531918..c663028 100644 --- a/tests/integration_python/test_build.py +++ b/tests/integration_python/test_build.py @@ -112,6 +112,80 @@ def test_source_change_trigger_rebuild(pixi: Path, simple_workspace: Workspace) assert conda_build_params.is_file() +def test_out_of_tree_source_respects_cache( + pixi: Path, build_data: Path, tmp_pixi_workspace: Path +) -> None: + """ + Test that if you have an out-of-tree build with a something like + + [package.build] + source = "some-dir" + That it rebuilds correctly when changed and does not rebuild when unchanged + """ + project = "out-of-tree-source" + test_data = build_data.joinpath(project) + target_dir = tmp_pixi_workspace.joinpath(project) + copytree_with_local_backend(test_data, target_dir) + + manifest_path = target_dir.joinpath("pixi.toml") + package_manifest_path = target_dir.joinpath("package", "pixi.toml") + + package_manifest = tomllib.loads(package_manifest_path.read_text(encoding="utf-8")) + configuration = package_manifest["package"]["build"].setdefault("configuration", {}) + + debug_dir = target_dir.joinpath("debug_dir") + debug_dir.mkdir(parents=True, exist_ok=True) + configuration["debug-dir"] = str(debug_dir) + + package_manifest_path.write_text(tomli_w.dumps(package_manifest), encoding="utf-8") + + verify_cli_command( + [ + pixi, + "install", + "-v", + "--manifest-path", + manifest_path, + ], + ) + + conda_build_params = debug_dir.joinpath("conda_outputs_params.json") + assert conda_build_params.is_file() + + # Remove debug file to detect subsequent rebuilds + conda_build_params.unlink() + + verify_cli_command( + [ + pixi, + "install", + "-v", + "--manifest-path", + manifest_path, + ], + ) + + # Out-of-tree sources should be cached when unchanged + assert not conda_build_params.exists() + + external_file = target_dir.joinpath("out_of_tree_source", "external.txt") + # Modifying the external source should trigger a rebuild + external_file.write_text("updated content", encoding="utf-8") + + verify_cli_command( + [ + pixi, + "install", + "-v", + "--manifest-path", + manifest_path, + ], + ) + + # And it should be back because the package has been rebuilt + assert conda_build_params.is_file() + + def test_project_model_change_trigger_rebuild( pixi: Path, simple_workspace: Workspace, dummy_channel_1: Path ) -> None: