Skip to content

Commit

Permalink
fix: actually install packages for cache (#1078)
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv authored Oct 2, 2024
1 parent 85f53f8 commit fad0b63
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 7 deletions.
8 changes: 7 additions & 1 deletion src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ use crate::{
metadata::{build_reindexed_channels, Output},
packaging::{contains_prefix_binary, contains_prefix_text, content_type, Files},
recipe::parser::{Dependency, Requirements},
render::resolved_dependencies::{resolve_dependencies, FinalizedDependencies},
render::resolved_dependencies::{
install_environments, resolve_dependencies, FinalizedDependencies,
},
source::copy_dir::{copy_file, create_symlink, CopyOptions},
};

Expand Down Expand Up @@ -178,6 +180,10 @@ impl Output {
.await
.unwrap();

install_environments(self, &finalized_dependencies, tool_configuration)
.await
.into_diagnostic()?;

cache
.build
.script()
Expand Down
13 changes: 7 additions & 6 deletions src/render/resolved_dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,13 +608,9 @@ async fn amend_run_exports(

pub async fn install_environments(
output: &Output,
dependencies: &FinalizedDependencies,
tool_configuration: &tool_configuration::Configuration,
) -> Result<(), ResolveError> {
let dependencies = output
.finalized_dependencies
.as_ref()
.ok_or(ResolveError::FinalizedDependencyNotFound)?;

const EMPTY_RECORDS: Vec<RepoDataRecord> = Vec::new();
install_packages(
"build",
Expand Down Expand Up @@ -1007,7 +1003,12 @@ impl Output {
&self,
tool_configuration: &Configuration,
) -> Result<(), ResolveError> {
install_environments(self, tool_configuration).await
let dependencies = self
.finalized_dependencies
.as_ref()
.ok_or(ResolveError::FinalizedDependencyNotFound)?;

install_environments(self, dependencies, tool_configuration).await
}
}

Expand Down
25 changes: 25 additions & 0 deletions test-data/recipes/cache/recipe-cmake.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
context:
version: 0.1.0
build_num: 0

recipe:
name: cache-installation
version: ${{ version }}

build:
number: ${{ build_num }}

cache:
requirements:
build:
- cmake
build:
script:
- cmake --version

outputs:
- package:
name: check-1

- package:
name: check-2
13 changes: 13 additions & 0 deletions test/end-to-end/test_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -956,3 +956,16 @@ def test_used_vars(rattler_build: RattlerBuild, recipes: Path, tmp_path: Path):
assert rendered[0]["build_configuration"]["variant"] == {
"target_platform": "noarch"
}


def test_cache_install(
rattler_build: RattlerBuild, recipes: Path, tmp_path: Path, snapshot_json
):
rattler_build.build(
recipes / "cache/recipe-cmake.yaml", tmp_path, extra_args=["--experimental"]
)

pkg1 = get_extracted_package(tmp_path, "check-1")
pkg2 = get_extracted_package(tmp_path, "check-2")
assert (pkg1 / "info/index.json").exists()
assert (pkg2 / "info/index.json").exists()

0 comments on commit fad0b63

Please sign in to comment.