From 61bff951f36d2eb9909fb624be834a77968b8201 Mon Sep 17 00:00:00 2001 From: Colin Casey Date: Wed, 30 Aug 2023 16:23:24 -0300 Subject: [PATCH 1/8] Support local buildpacks and meta-buildpacks in libcnb-test The test runner has been modified to support a `BuildpackReference::LibCnbRs(BuildpackId)` variant which represents a buildpack (and any of it's dependencies) within the workspace that needs to be compiled for testing. This is similar to `BuildpackReference::Crate` but also supports meta-buildpacks. --- .gitignore | 1 + libcnb-test/Cargo.toml | 2 +- libcnb-test/src/build.rs | 134 ++++++++++++++---- libcnb-test/src/build_config.rs | 3 + libcnb-test/src/pack.rs | 11 ++ libcnb-test/src/test_runner.rs | 61 ++++++-- .../buildpacks/libcnb-test-a/Cargo.toml | 5 + .../buildpacks/libcnb-test-a/buildpack.toml | 8 ++ .../buildpacks/libcnb-test-a/src/main.rs | 3 + .../buildpacks/libcnb-test-b/Cargo.toml | 5 + .../buildpacks/libcnb-test-b/buildpack.toml | 8 ++ .../buildpacks/libcnb-test-b/src/main.rs | 3 + .../libcnb-test-meta/buildpack.toml | 22 +++ .../buildpacks/libcnb-test-meta/package.toml | 9 ++ libcnb-test/tests/integration_test.rs | 84 +++++++++-- 15 files changed, 304 insertions(+), 55 deletions(-) create mode 100644 libcnb-test/test-fixtures/buildpacks/libcnb-test-a/Cargo.toml create mode 100644 libcnb-test/test-fixtures/buildpacks/libcnb-test-a/buildpack.toml create mode 100644 libcnb-test/test-fixtures/buildpacks/libcnb-test-a/src/main.rs create mode 100644 libcnb-test/test-fixtures/buildpacks/libcnb-test-b/Cargo.toml create mode 100644 libcnb-test/test-fixtures/buildpacks/libcnb-test-b/buildpack.toml create mode 100644 libcnb-test/test-fixtures/buildpacks/libcnb-test-b/src/main.rs create mode 100644 libcnb-test/test-fixtures/buildpacks/libcnb-test-meta/buildpack.toml create mode 100644 libcnb-test/test-fixtures/buildpacks/libcnb-test-meta/package.toml diff --git a/.gitignore b/.gitignore index 6addfe54..8f9e1c79 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ Cargo.lock **/fixtures/*/target/ **/fixtures/*/packaged/ +**/test-fixtures/buildpacks/*/target/ diff --git a/libcnb-test/Cargo.toml b/libcnb-test/Cargo.toml index 9c67538c..0958b8a4 100644 --- a/libcnb-test/Cargo.toml +++ b/libcnb-test/Cargo.toml @@ -12,9 +12,9 @@ readme = "README.md" include = ["src/**/*", "LICENSE", "README.md"] [dependencies] -cargo_metadata = "0.17.0" fastrand = "2.0.0" fs_extra = "1.3.0" +libcnb-common.workspace = true libcnb-data.workspace = true libcnb-package.workspace = true tempfile = "3.7.1" diff --git a/libcnb-test/src/build.rs b/libcnb-test/src/build.rs index bfde88c9..673c14ef 100644 --- a/libcnb-test/src/build.rs +++ b/libcnb-test/src/build.rs @@ -1,7 +1,15 @@ -use cargo_metadata::MetadataCommand; -use libcnb_package::build::{build_buildpack_binaries, BuildBinariesError}; +use libcnb_common::toml_file::{read_toml_file, TomlFileError}; +use libcnb_data::buildpack::{BuildpackDescriptor, BuildpackId}; +use libcnb_package::buildpack_dependency_graph::{ + build_libcnb_buildpacks_dependency_graph, BuildBuildpackDependencyGraphError, +}; use libcnb_package::cross_compile::{cross_compile_assistance, CrossCompileAssistance}; -use libcnb_package::{assemble_buildpack_directory, CargoProfile}; +use libcnb_package::dependency_graph::{get_dependencies, GetDependenciesError}; +use libcnb_package::output::create_packaged_buildpack_dir_resolver; +use libcnb_package::package::PackageBuildpackError; +use libcnb_package::{find_cargo_workspace_root_dir, CargoProfile, FindCargoWorkspaceRootError}; +use std::collections::BTreeMap; +use std::fs; use std::path::PathBuf; use tempfile::{tempdir, TempDir}; @@ -9,19 +17,41 @@ use tempfile::{tempdir, TempDir}; pub(crate) fn package_crate_buildpack( cargo_profile: CargoProfile, target_triple: impl AsRef, -) -> Result { +) -> Result { let cargo_manifest_dir = std::env::var("CARGO_MANIFEST_DIR") .map(PathBuf::from) - .map_err(PackageCrateBuildpackError::CannotDetermineCrateDirectory)?; + .map_err(PackageTestBuildpackError::CannotDetermineCrateDirectory)?; - let cargo_metadata = MetadataCommand::new() - .manifest_path(&cargo_manifest_dir.join("Cargo.toml")) - .exec() - .map_err(PackageCrateBuildpackError::CargoMetadataError)?; + let buildpack_toml = cargo_manifest_dir.join("buildpack.toml"); - let cargo_env = match cross_compile_assistance(target_triple.as_ref()) { + assert!( + buildpack_toml.exists(), + "Could not package directory as buildpack! No `buildpack.toml` file exists at {}", + cargo_manifest_dir.display() + ); + + let buildpack_descriptor: BuildpackDescriptor = + read_toml_file(buildpack_toml).map_err(PackageTestBuildpackError::CannotReadBuildpack)?; + + package_buildpack( + &buildpack_descriptor.buildpack().id, + cargo_profile, + target_triple, + ) +} + +pub(crate) fn package_buildpack( + buildpack_id: &BuildpackId, + cargo_profile: CargoProfile, + target_triple: impl AsRef, +) -> Result { + let cargo_manifest_dir = std::env::var("CARGO_MANIFEST_DIR") + .map(PathBuf::from) + .map_err(PackageTestBuildpackError::CannotDetermineCrateDirectory)?; + + let cargo_build_env = match cross_compile_assistance(target_triple.as_ref()) { CrossCompileAssistance::HelpText(help_text) => { - return Err(PackageCrateBuildpackError::CrossCompileConfigurationError( + return Err(PackageTestBuildpackError::CrossCompileConfigurationError( help_text, )); } @@ -29,34 +59,80 @@ pub(crate) fn package_crate_buildpack( CrossCompileAssistance::Configuration { cargo_env } => cargo_env, }; - let buildpack_dir = - tempdir().map_err(PackageCrateBuildpackError::CannotCreateBuildpackTempDirectory)?; + let workspace_root_path = find_cargo_workspace_root_dir(&cargo_manifest_dir) + .map_err(PackageTestBuildpackError::FindCargoWorkspace)?; - let buildpack_binaries = build_buildpack_binaries( - &cargo_manifest_dir, - &cargo_metadata, + let package_dir = + tempdir().map_err(PackageTestBuildpackError::CannotCreateBuildpackTempDirectory)?; + + let buildpack_dir_resolver = create_packaged_buildpack_dir_resolver( + package_dir.as_ref(), cargo_profile, - &cargo_env, target_triple.as_ref(), - ) - .map_err(PackageCrateBuildpackError::BuildBinariesError)?; + ); + + // TODO: this could accidentally detect a packaged meta-buildpack twice. how should we ignore directories + // containing packaged buildpacks that might get detected now that the user controls --package-dir? + // - support .gitignore or some other persistent configuration? + // - during packaging should we create some type of file that indicates the output is a packaged buildpack? + let buildpack_dependency_graph = + build_libcnb_buildpacks_dependency_graph(&workspace_root_path, &[]) + .map_err(PackageTestBuildpackError::CreateBuildpackDependencyGraph)?; - assemble_buildpack_directory( - buildpack_dir.path(), - cargo_manifest_dir.join("buildpack.toml"), - &buildpack_binaries, + let root_node = buildpack_dependency_graph + .node_weights() + .find(|node| node.buildpack_id == buildpack_id.clone()); + + assert!( + root_node.is_some(), + "Could not package directory as buildpack! No buildpack with id `{buildpack_id}` exists in the workspace at {}", + workspace_root_path.display() + ); + + let build_order = get_dependencies( + &buildpack_dependency_graph, + &[root_node.expect("The root node should exist")], ) - .map_err(PackageCrateBuildpackError::CannotAssembleBuildpackDirectory)?; + .map_err(PackageTestBuildpackError::GetDependencies)?; + + let mut packaged_buildpack_dirs = BTreeMap::new(); + for node in &build_order { + let buildpack_destination_dir = buildpack_dir_resolver(&node.buildpack_id); + + fs::create_dir_all(&buildpack_destination_dir).unwrap(); + + libcnb_package::package::package_buildpack( + &node.path, + cargo_profile, + target_triple.as_ref(), + &cargo_build_env, + &buildpack_destination_dir, + &packaged_buildpack_dirs, + ) + .map_err(PackageTestBuildpackError::PackageBuildpack)?; + + packaged_buildpack_dirs.insert(node.buildpack_id.clone(), buildpack_destination_dir); + } + + Ok(PackagedBuildpackDir { + _root: package_dir, + path: buildpack_dir_resolver(buildpack_id), + }) +} - Ok(buildpack_dir) +pub(crate) struct PackagedBuildpackDir { + _root: TempDir, + pub(crate) path: PathBuf, } #[derive(Debug)] -pub(crate) enum PackageCrateBuildpackError { - BuildBinariesError(BuildBinariesError), - CannotAssembleBuildpackDirectory(std::io::Error), +pub(crate) enum PackageTestBuildpackError { CannotCreateBuildpackTempDirectory(std::io::Error), CannotDetermineCrateDirectory(std::env::VarError), - CargoMetadataError(cargo_metadata::Error), + CannotReadBuildpack(TomlFileError), + CreateBuildpackDependencyGraph(BuildBuildpackDependencyGraphError), CrossCompileConfigurationError(String), + FindCargoWorkspace(FindCargoWorkspaceRootError), + GetDependencies(GetDependenciesError), + PackageBuildpack(PackageBuildpackError), } diff --git a/libcnb-test/src/build_config.rs b/libcnb-test/src/build_config.rs index 8466a7fb..7a056cdb 100644 --- a/libcnb-test/src/build_config.rs +++ b/libcnb-test/src/build_config.rs @@ -1,3 +1,4 @@ +use libcnb_data::buildpack::BuildpackId; use std::collections::HashMap; use std::path::{Path, PathBuf}; use std::rc::Rc; @@ -251,6 +252,8 @@ impl BuildConfig { pub enum BuildpackReference { /// References the buildpack in the Rust Crate currently being tested. Crate, + /// References a libcnb.rs buildpack within the Rust Workspace that needs to be packaged into a buildpack + LibCnbRs(BuildpackId), /// References another buildpack by id, local directory or tarball. Other(String), } diff --git a/libcnb-test/src/pack.rs b/libcnb-test/src/pack.rs index da2fc6d0..075aa30a 100644 --- a/libcnb-test/src/pack.rs +++ b/libcnb-test/src/pack.rs @@ -162,6 +162,17 @@ impl From for Command { } } +#[derive(Clone, Debug)] +pub(crate) struct PackVersionCommand; + +impl From for Command { + fn from(_: PackVersionCommand) -> Self { + let mut command = Self::new("pack"); + command.arg("--version"); + command + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/libcnb-test/src/test_runner.rs b/libcnb-test/src/test_runner.rs index 67284e71..018d6970 100644 --- a/libcnb-test/src/test_runner.rs +++ b/libcnb-test/src/test_runner.rs @@ -1,5 +1,5 @@ use crate::docker::DockerRemoveImageCommand; -use crate::pack::PackBuildCommand; +use crate::pack::{PackBuildCommand, PackVersionCommand}; use crate::util::CommandError; use crate::{app, build, util, BuildConfig, BuildpackReference, PackResult, TestContext}; use std::borrow::Borrow; @@ -56,6 +56,8 @@ impl TestRunner { config: C, f: F, ) { + check_required_pack_version(); + let config = config.borrow(); let app_dir = { @@ -88,14 +90,7 @@ impl TestRunner { } }; - let temp_crate_buildpack_dir = - config - .buildpacks - .contains(&BuildpackReference::Crate) - .then(|| { - build::package_crate_buildpack(config.cargo_profile, &config.target_triple) - .expect("Could not package current crate as buildpack") - }); + let mut buildpack_dirs = vec![]; let mut pack_command = PackBuildCommand::new(&config.builder_name, &app_dir, &image_name); @@ -106,10 +101,22 @@ impl TestRunner { for buildpack in &config.buildpacks { match buildpack { BuildpackReference::Crate => { - pack_command.buildpack(temp_crate_buildpack_dir.as_ref() - .expect("Test references crate buildpack, but crate wasn't packaged as a buildpack. This is an internal libcnb-test error, please report any occurrences.")) + let crate_buildpack_dir = build::package_crate_buildpack(config.cargo_profile, &config.target_triple) + .expect("Test references crate buildpack, but crate wasn't packaged as a buildpack. This is an internal libcnb-test error, please report any occurrences"); + pack_command.buildpack(crate_buildpack_dir.path.clone()); + buildpack_dirs.push(crate_buildpack_dir); + } + + BuildpackReference::LibCnbRs(builpack_id) => { + let buildpack_dir = build::package_buildpack(builpack_id, config.cargo_profile, &config.target_triple) + .unwrap_or_else(|_| panic!("Test references buildpack `{builpack_id}`, but this directory wasn't packaged as a buildpack. This is an internal libcnb-test error, please report any occurrences")); + pack_command.buildpack(buildpack_dir.path.clone()); + buildpack_dirs.push(buildpack_dir); + } + + BuildpackReference::Other(id) => { + pack_command.buildpack(id.clone()); } - BuildpackReference::Other(id) => pack_command.buildpack(id.clone()), }; } @@ -146,3 +153,33 @@ impl TestRunner { f(test_context); } } + +fn check_required_pack_version() { + match util::run_command(PackVersionCommand) { + Ok(output) => { + let version = output.stdout.trim(); + let mut split = version.split('.'); + let major: u32 = split + .next() + .map(|value| { + value + .parse::() + .expect("Major coordinate should be a number") + }) + .expect("Major coordinate should be present in pack --version output"); + let minor: u32 = split + .next() + .map(|value| { + value + .parse::() + .expect("Minor coordinate should be a number") + }) + .expect("Minor coordinate should be present in pack --version output"); + let is_min_version = major == 0 && minor >= 30 || major >= 1; + assert!(is_min_version, "Pack version 0.30+ is required but {version} is installed. Please upgrade your pack CLI."); + } + Err(error) => { + panic!("Error determinging pack version:\n\n{error}"); + } + } +} diff --git a/libcnb-test/test-fixtures/buildpacks/libcnb-test-a/Cargo.toml b/libcnb-test/test-fixtures/buildpacks/libcnb-test-a/Cargo.toml new file mode 100644 index 00000000..d8e77621 --- /dev/null +++ b/libcnb-test/test-fixtures/buildpacks/libcnb-test-a/Cargo.toml @@ -0,0 +1,5 @@ +[package] +name = "one" +version = "0.0.0" + +[workspace] diff --git a/libcnb-test/test-fixtures/buildpacks/libcnb-test-a/buildpack.toml b/libcnb-test/test-fixtures/buildpacks/libcnb-test-a/buildpack.toml new file mode 100644 index 00000000..f2e10539 --- /dev/null +++ b/libcnb-test/test-fixtures/buildpacks/libcnb-test-a/buildpack.toml @@ -0,0 +1,8 @@ +api = "0.8" + +[buildpack] +id = "libcnb-test/a" +version = "0.0.0" + +[[stacks]] +id = "*" diff --git a/libcnb-test/test-fixtures/buildpacks/libcnb-test-a/src/main.rs b/libcnb-test/test-fixtures/buildpacks/libcnb-test-a/src/main.rs new file mode 100644 index 00000000..89cd3f18 --- /dev/null +++ b/libcnb-test/test-fixtures/buildpacks/libcnb-test-a/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Buildpack A"); +} diff --git a/libcnb-test/test-fixtures/buildpacks/libcnb-test-b/Cargo.toml b/libcnb-test/test-fixtures/buildpacks/libcnb-test-b/Cargo.toml new file mode 100644 index 00000000..504aeb84 --- /dev/null +++ b/libcnb-test/test-fixtures/buildpacks/libcnb-test-b/Cargo.toml @@ -0,0 +1,5 @@ +[package] +name = "two" +version = "0.0.0" + +[workspace] diff --git a/libcnb-test/test-fixtures/buildpacks/libcnb-test-b/buildpack.toml b/libcnb-test/test-fixtures/buildpacks/libcnb-test-b/buildpack.toml new file mode 100644 index 00000000..fd1940bf --- /dev/null +++ b/libcnb-test/test-fixtures/buildpacks/libcnb-test-b/buildpack.toml @@ -0,0 +1,8 @@ +api = "0.8" + +[buildpack] +id = "libcnb-test/b" +version = "0.0.0" + +[[stacks]] +id = "*" diff --git a/libcnb-test/test-fixtures/buildpacks/libcnb-test-b/src/main.rs b/libcnb-test/test-fixtures/buildpacks/libcnb-test-b/src/main.rs new file mode 100644 index 00000000..2e9f2ee2 --- /dev/null +++ b/libcnb-test/test-fixtures/buildpacks/libcnb-test-b/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Buildpack B"); +} diff --git a/libcnb-test/test-fixtures/buildpacks/libcnb-test-meta/buildpack.toml b/libcnb-test/test-fixtures/buildpacks/libcnb-test-meta/buildpack.toml new file mode 100644 index 00000000..b21aeca3 --- /dev/null +++ b/libcnb-test/test-fixtures/buildpacks/libcnb-test-meta/buildpack.toml @@ -0,0 +1,22 @@ +api = "0.8" + +[buildpack] +id = "libcnb-test/meta" +name = "Meta-buildpack Test" +version = "0.0.0" +homepage = "https://example.com" +description = "Official test example" +keywords = ["test"] + +[[buildpack.licenses]] +type = "BSD-3-Clause" + +[[order]] + +[[order.group]] +id = "libcnb-test/a" +version = "0.0.0" + +[[order.group]] +id = "libcnb-test/b" +version = "0.0.0" diff --git a/libcnb-test/test-fixtures/buildpacks/libcnb-test-meta/package.toml b/libcnb-test/test-fixtures/buildpacks/libcnb-test-meta/package.toml new file mode 100644 index 00000000..5371f16a --- /dev/null +++ b/libcnb-test/test-fixtures/buildpacks/libcnb-test-meta/package.toml @@ -0,0 +1,9 @@ +[buildpack] +uri = "." + +[[dependencies]] +uri = "libcnb:libcnb-test/a" + +[[dependencies]] +uri = "libcnb:libcnb-test/b" + diff --git a/libcnb-test/tests/integration_test.rs b/libcnb-test/tests/integration_test.rs index 0eabc1b3..c04e2841 100644 --- a/libcnb-test/tests/integration_test.rs +++ b/libcnb-test/tests/integration_test.rs @@ -8,6 +8,7 @@ #![warn(clippy::pedantic)] use indoc::indoc; +use libcnb_data::buildpack_id; use libcnb_test::{ assert_contains, assert_empty, assert_not_contains, BuildConfig, BuildpackReference, ContainerConfig, PackResult, TestRunner, @@ -63,13 +64,21 @@ fn rebuild() { #[test] #[ignore = "integration test"] -#[should_panic( - expected = "Could not package current crate as buildpack: BuildBinariesError(CannotDetermineBuildpackCargoTargetName(NoBinTargets))" -)] fn buildpack_packaging_failure() { - TestRunner::default().build(BuildConfig::new("invalid!", "test-fixtures/empty"), |_| { - unreachable!("The test should panic prior to the TestContext being invoked."); + let result = std::panic::catch_unwind(|| { + TestRunner::default().build(BuildConfig::new("invalid!", "test-fixtures/empty"), |_| { + unreachable!("The test should panic prior to the TestContext being invoked."); + }); }); + match result { + Ok(_) => panic!("expected a failure"), + Err(error) => { + assert_eq!( + error.downcast_ref::().unwrap().to_string(), + format!("Could not package directory as buildpack! No `buildpack.toml` file exists at {}", env::var("CARGO_MANIFEST_DIR").unwrap()) + ); + } + } } #[test] @@ -131,15 +140,25 @@ fn expected_pack_failure() { #[test] #[ignore = "integration test"] -#[should_panic( - expected = "Could not package current crate as buildpack: BuildBinariesError(CannotDetermineBuildpackCargoTargetName(NoBinTargets))" -)] fn expected_pack_failure_still_panics_for_non_pack_failure() { - TestRunner::default().build( - BuildConfig::new("invalid!", "test-fixtures/empty") - .expected_pack_result(PackResult::Failure), - |_| {}, - ); + let result = std::panic::catch_unwind(|| { + TestRunner::default().build( + BuildConfig::new("invalid!", "test-fixtures/empty") + .expected_pack_result(PackResult::Failure), + |_| { + unreachable!("The test should panic prior to the TestContext being invoked."); + }, + ); + }); + match result { + Ok(_) => panic!("expected a failure"), + Err(error) => { + assert_eq!( + error.downcast_ref::().unwrap().to_string(), + format!("Could not package directory as buildpack! No `buildpack.toml` file exists at {}", env::var("CARGO_MANIFEST_DIR").unwrap()) + ); + } + } } #[test] @@ -522,3 +541,42 @@ fn address_for_port_when_container_crashed() { }, ); } + +#[test] +#[ignore = "integration test"] +fn basic_build_with_libcnb_reference_to_single_buildpack() { + TestRunner::default().build( + BuildConfig::new("heroku/builder:22", "test-fixtures/procfile").buildpacks(vec![ + BuildpackReference::LibCnbRs(buildpack_id!("libcnb-test/a")), + ]), + |context| { + assert_empty!(context.pack_stderr); + assert_contains!( + context.pack_stdout, + indoc! {" + Buildpack A + "} + ); + }, + ); +} + +#[test] +#[ignore = "integration test"] +fn basic_build_with_libcnb_reference_to_meta_buildpack() { + TestRunner::default().build( + BuildConfig::new("heroku/builder:22", "test-fixtures/procfile").buildpacks(vec![ + BuildpackReference::LibCnbRs(buildpack_id!("libcnb-test/meta")), + ]), + |context| { + assert_empty!(context.pack_stderr); + assert_contains!( + context.pack_stdout, + indoc! {" + Buildpack A + Buildpack B + "} + ); + }, + ); +} From bb714d98ad13537e1a9c79f03d7dbdf7ecb062d5 Mon Sep 17 00:00:00 2001 From: Colin Casey Date: Tue, 5 Sep 2023 12:17:11 -0300 Subject: [PATCH 2/8] Remove pack CLI check --- libcnb-test/src/pack.rs | 11 ----------- libcnb-test/src/test_runner.rs | 34 +--------------------------------- 2 files changed, 1 insertion(+), 44 deletions(-) diff --git a/libcnb-test/src/pack.rs b/libcnb-test/src/pack.rs index 075aa30a..da2fc6d0 100644 --- a/libcnb-test/src/pack.rs +++ b/libcnb-test/src/pack.rs @@ -162,17 +162,6 @@ impl From for Command { } } -#[derive(Clone, Debug)] -pub(crate) struct PackVersionCommand; - -impl From for Command { - fn from(_: PackVersionCommand) -> Self { - let mut command = Self::new("pack"); - command.arg("--version"); - command - } -} - #[cfg(test)] mod tests { use super::*; diff --git a/libcnb-test/src/test_runner.rs b/libcnb-test/src/test_runner.rs index 018d6970..6b7038da 100644 --- a/libcnb-test/src/test_runner.rs +++ b/libcnb-test/src/test_runner.rs @@ -1,5 +1,5 @@ use crate::docker::DockerRemoveImageCommand; -use crate::pack::{PackBuildCommand, PackVersionCommand}; +use crate::pack::PackBuildCommand; use crate::util::CommandError; use crate::{app, build, util, BuildConfig, BuildpackReference, PackResult, TestContext}; use std::borrow::Borrow; @@ -56,8 +56,6 @@ impl TestRunner { config: C, f: F, ) { - check_required_pack_version(); - let config = config.borrow(); let app_dir = { @@ -153,33 +151,3 @@ impl TestRunner { f(test_context); } } - -fn check_required_pack_version() { - match util::run_command(PackVersionCommand) { - Ok(output) => { - let version = output.stdout.trim(); - let mut split = version.split('.'); - let major: u32 = split - .next() - .map(|value| { - value - .parse::() - .expect("Major coordinate should be a number") - }) - .expect("Major coordinate should be present in pack --version output"); - let minor: u32 = split - .next() - .map(|value| { - value - .parse::() - .expect("Minor coordinate should be a number") - }) - .expect("Minor coordinate should be present in pack --version output"); - let is_min_version = major == 0 && minor >= 30 || major >= 1; - assert!(is_min_version, "Pack version 0.30+ is required but {version} is installed. Please upgrade your pack CLI."); - } - Err(error) => { - panic!("Error determinging pack version:\n\n{error}"); - } - } -} From 3863a6953997ab63c1d93fabe33d2071cc15c175 Mon Sep 17 00:00:00 2001 From: Colin Casey Date: Fri, 8 Sep 2023 17:50:32 -0300 Subject: [PATCH 3/8] Code review feedback * Renamed `LibCnbRs` to `WorkspaceBuildpack` * Renamed `Crate` to `CurrentCrate` * Updated CHANGELOG.md and doc example --- CHANGELOG.md | 5 +++++ libcnb-test/README.md | 4 +++- libcnb-test/src/build_config.rs | 10 +++++----- libcnb-test/src/test_runner.rs | 4 ++-- libcnb-test/tests/integration_test.rs | 4 ++-- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 692dad2d..db45e27e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `libcnb-data`: - `ExecDProgramOutputKey`, `ProcessType`, `LayerName`, `BuildpackId` and `StackId` now implement `Ord` and `PartialOrd`. ([#658](https://github.com/heroku/libcnb.rs/pull/658)) - Add `generic::GenericMetadata` as a generic metadata type. Also makes it the default for `BuildpackDescriptor`, `SingleBuildpackDescriptor`, `MetaBuildpackDescriptor` and `LayerContentMetadata`. ([#664](https://github.com/heroku/libcnb.rs/pull/664)) +- `libcnb-test`: + - Added the variant `WorkspaceBuildpack` to the `build_config::BuildpackReference` enum which allows any buildpack within the Rust workspace to be referenced for testing. ([#666](https://github.com/heroku/libcnb.rs/pull/666)) + - Testing of composite buildpacks is now supported using the `WorkspaceBuildpack` variant - **Requires `pack` CLI version `>=0.30`**. ([#666](https://github.com/heroku/libcnb.rs/pull/666)) ### Changed @@ -21,6 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `libcnb-cargo`: - No longer outputs paths for non-libcnb.rs and non-meta buildpacks. ([#657](https://github.com/heroku/libcnb.rs/pull/657)) - Build output for humans changed slightly, output intended for machines/scripting didn't change. ([#657](https://github.com/heroku/libcnb.rs/pull/657)) +- `libcnb-test`: + - Renamed the variant `Crate` to `CurrentCrate` for the `build_config::BuildpackReference` enum which references the buildpack within the Rust Crate currently being tested. ([#666](https://github.com/heroku/libcnb.rs/pull/666)) ## [0.14.0] - 2023-08-18 diff --git a/libcnb-test/README.md b/libcnb-test/README.md index 8f8d0e28..0e2a3587 100644 --- a/libcnb-test/README.md +++ b/libcnb-test/README.md @@ -191,13 +191,15 @@ fn dynamic_fixture() { Building with multiple buildpacks, using [`BuildConfig::buildpacks`]: ```rust,no_run +use libcnb_data::buildpack_id; use libcnb_test::{BuildConfig, BuildpackReference, TestRunner}; // #[test] fn additional_buildpacks() { TestRunner::default().build( BuildConfig::new("heroku/builder:22", "test-fixtures/app").buildpacks(vec![ - BuildpackReference::Crate, + BuildpackReference::CurrentCrate, + BuildpackReference::WorkspaceBuildpack(buildpack_id!("my-project/buildpack")), BuildpackReference::Other(String::from("heroku/another-buildpack")), ]), |context| { diff --git a/libcnb-test/src/build_config.rs b/libcnb-test/src/build_config.rs index 7a056cdb..152c0691 100644 --- a/libcnb-test/src/build_config.rs +++ b/libcnb-test/src/build_config.rs @@ -42,7 +42,7 @@ impl BuildConfig { cargo_profile: CargoProfile::Dev, target_triple: String::from("x86_64-unknown-linux-musl"), builder_name: builder_name.into(), - buildpacks: vec![BuildpackReference::Crate], + buildpacks: vec![BuildpackReference::CurrentCrate], env: HashMap::new(), app_dir_preprocessor: None, expected_pack_result: PackResult::Success, @@ -51,7 +51,7 @@ impl BuildConfig { /// Sets the buildpacks (and their ordering) to use when building the app. /// - /// Defaults to [`BuildpackReference::Crate`]. + /// Defaults to [`BuildpackReference::CurrentCrate`]. /// /// # Example /// ```no_run @@ -60,7 +60,7 @@ impl BuildConfig { /// TestRunner::default().build( /// BuildConfig::new("heroku/builder:22", "test-fixtures/app").buildpacks(vec![ /// BuildpackReference::Other(String::from("heroku/another-buildpack")), - /// BuildpackReference::Crate, + /// BuildpackReference::CurrentCrate, /// ]), /// |context| { /// // ... @@ -251,9 +251,9 @@ impl BuildConfig { #[derive(Debug, Clone, Eq, PartialEq)] pub enum BuildpackReference { /// References the buildpack in the Rust Crate currently being tested. - Crate, + CurrentCrate, /// References a libcnb.rs buildpack within the Rust Workspace that needs to be packaged into a buildpack - LibCnbRs(BuildpackId), + WorkspaceBuildpack(BuildpackId), /// References another buildpack by id, local directory or tarball. Other(String), } diff --git a/libcnb-test/src/test_runner.rs b/libcnb-test/src/test_runner.rs index 6b7038da..91ee6379 100644 --- a/libcnb-test/src/test_runner.rs +++ b/libcnb-test/src/test_runner.rs @@ -98,14 +98,14 @@ impl TestRunner { for buildpack in &config.buildpacks { match buildpack { - BuildpackReference::Crate => { + BuildpackReference::CurrentCrate => { let crate_buildpack_dir = build::package_crate_buildpack(config.cargo_profile, &config.target_triple) .expect("Test references crate buildpack, but crate wasn't packaged as a buildpack. This is an internal libcnb-test error, please report any occurrences"); pack_command.buildpack(crate_buildpack_dir.path.clone()); buildpack_dirs.push(crate_buildpack_dir); } - BuildpackReference::LibCnbRs(builpack_id) => { + BuildpackReference::WorkspaceBuildpack(builpack_id) => { let buildpack_dir = build::package_buildpack(builpack_id, config.cargo_profile, &config.target_triple) .unwrap_or_else(|_| panic!("Test references buildpack `{builpack_id}`, but this directory wasn't packaged as a buildpack. This is an internal libcnb-test error, please report any occurrences")); pack_command.buildpack(buildpack_dir.path.clone()); diff --git a/libcnb-test/tests/integration_test.rs b/libcnb-test/tests/integration_test.rs index c04e2841..096ae4ca 100644 --- a/libcnb-test/tests/integration_test.rs +++ b/libcnb-test/tests/integration_test.rs @@ -547,7 +547,7 @@ fn address_for_port_when_container_crashed() { fn basic_build_with_libcnb_reference_to_single_buildpack() { TestRunner::default().build( BuildConfig::new("heroku/builder:22", "test-fixtures/procfile").buildpacks(vec![ - BuildpackReference::LibCnbRs(buildpack_id!("libcnb-test/a")), + BuildpackReference::WorkspaceBuildpack(buildpack_id!("libcnb-test/a")), ]), |context| { assert_empty!(context.pack_stderr); @@ -566,7 +566,7 @@ fn basic_build_with_libcnb_reference_to_single_buildpack() { fn basic_build_with_libcnb_reference_to_meta_buildpack() { TestRunner::default().build( BuildConfig::new("heroku/builder:22", "test-fixtures/procfile").buildpacks(vec![ - BuildpackReference::LibCnbRs(buildpack_id!("libcnb-test/meta")), + BuildpackReference::WorkspaceBuildpack(buildpack_id!("libcnb-test/meta")), ]), |context| { assert_empty!(context.pack_stderr); From fa6015896ae3c7882dbcc345a08a6537872145b2 Mon Sep 17 00:00:00 2001 From: Colin Casey Date: Mon, 18 Sep 2023 14:59:13 -0300 Subject: [PATCH 4/8] PR feedback * updated error enum names * removed need for wrapper struct for packaged buildpacks --- libcnb-test/src/build.rs | 58 +++++++++++----------------------- libcnb-test/src/test_runner.rs | 36 +++++++++++++-------- 2 files changed, 42 insertions(+), 52 deletions(-) diff --git a/libcnb-test/src/build.rs b/libcnb-test/src/build.rs index 673c14ef..a7af840b 100644 --- a/libcnb-test/src/build.rs +++ b/libcnb-test/src/build.rs @@ -10,18 +10,15 @@ use libcnb_package::package::PackageBuildpackError; use libcnb_package::{find_cargo_workspace_root_dir, CargoProfile, FindCargoWorkspaceRootError}; use std::collections::BTreeMap; use std::fs; -use std::path::PathBuf; -use tempfile::{tempdir, TempDir}; +use std::path::{Path, PathBuf}; /// Packages the current crate as a buildpack into a temporary directory. pub(crate) fn package_crate_buildpack( cargo_profile: CargoProfile, target_triple: impl AsRef, -) -> Result { - let cargo_manifest_dir = std::env::var("CARGO_MANIFEST_DIR") - .map(PathBuf::from) - .map_err(PackageTestBuildpackError::CannotDetermineCrateDirectory)?; - + cargo_manifest_dir: &Path, + target_buildpack_dir: &Path, +) -> Result { let buildpack_toml = cargo_manifest_dir.join("buildpack.toml"); assert!( @@ -30,13 +27,15 @@ pub(crate) fn package_crate_buildpack( cargo_manifest_dir.display() ); - let buildpack_descriptor: BuildpackDescriptor = - read_toml_file(buildpack_toml).map_err(PackageTestBuildpackError::CannotReadBuildpack)?; + let buildpack_descriptor: BuildpackDescriptor = read_toml_file(buildpack_toml) + .map_err(PackageTestBuildpackError::CannotReadBuildpackDescriptor)?; package_buildpack( &buildpack_descriptor.buildpack().id, cargo_profile, target_triple, + cargo_manifest_dir, + target_buildpack_dir, ) } @@ -44,11 +43,9 @@ pub(crate) fn package_buildpack( buildpack_id: &BuildpackId, cargo_profile: CargoProfile, target_triple: impl AsRef, -) -> Result { - let cargo_manifest_dir = std::env::var("CARGO_MANIFEST_DIR") - .map(PathBuf::from) - .map_err(PackageTestBuildpackError::CannotDetermineCrateDirectory)?; - + cargo_manifest_dir: &Path, + target_buildpack_dir: &Path, +) -> Result { let cargo_build_env = match cross_compile_assistance(target_triple.as_ref()) { CrossCompileAssistance::HelpText(help_text) => { return Err(PackageTestBuildpackError::CrossCompileConfigurationError( @@ -59,25 +56,18 @@ pub(crate) fn package_buildpack( CrossCompileAssistance::Configuration { cargo_env } => cargo_env, }; - let workspace_root_path = find_cargo_workspace_root_dir(&cargo_manifest_dir) - .map_err(PackageTestBuildpackError::FindCargoWorkspace)?; - - let package_dir = - tempdir().map_err(PackageTestBuildpackError::CannotCreateBuildpackTempDirectory)?; + let workspace_root_path = find_cargo_workspace_root_dir(cargo_manifest_dir) + .map_err(PackageTestBuildpackError::FindCargoWorkspaceRoot)?; let buildpack_dir_resolver = create_packaged_buildpack_dir_resolver( - package_dir.as_ref(), + target_buildpack_dir, cargo_profile, target_triple.as_ref(), ); - // TODO: this could accidentally detect a packaged meta-buildpack twice. how should we ignore directories - // containing packaged buildpacks that might get detected now that the user controls --package-dir? - // - support .gitignore or some other persistent configuration? - // - during packaging should we create some type of file that indicates the output is a packaged buildpack? let buildpack_dependency_graph = build_libcnb_buildpacks_dependency_graph(&workspace_root_path, &[]) - .map_err(PackageTestBuildpackError::CreateBuildpackDependencyGraph)?; + .map_err(PackageTestBuildpackError::BuildBuildpackDependencyGraph)?; let root_node = buildpack_dependency_graph .node_weights() @@ -114,25 +104,15 @@ pub(crate) fn package_buildpack( packaged_buildpack_dirs.insert(node.buildpack_id.clone(), buildpack_destination_dir); } - Ok(PackagedBuildpackDir { - _root: package_dir, - path: buildpack_dir_resolver(buildpack_id), - }) -} - -pub(crate) struct PackagedBuildpackDir { - _root: TempDir, - pub(crate) path: PathBuf, + Ok(buildpack_dir_resolver(buildpack_id)) } #[derive(Debug)] pub(crate) enum PackageTestBuildpackError { - CannotCreateBuildpackTempDirectory(std::io::Error), - CannotDetermineCrateDirectory(std::env::VarError), - CannotReadBuildpack(TomlFileError), - CreateBuildpackDependencyGraph(BuildBuildpackDependencyGraphError), + CannotReadBuildpackDescriptor(TomlFileError), + BuildBuildpackDependencyGraph(BuildBuildpackDependencyGraphError), CrossCompileConfigurationError(String), - FindCargoWorkspace(FindCargoWorkspaceRootError), + FindCargoWorkspaceRoot(FindCargoWorkspaceRootError), GetDependencies(GetDependenciesError), PackageBuildpack(PackageBuildpackError), } diff --git a/libcnb-test/src/test_runner.rs b/libcnb-test/src/test_runner.rs index 91ee6379..ef5eccfe 100644 --- a/libcnb-test/src/test_runner.rs +++ b/libcnb-test/src/test_runner.rs @@ -5,6 +5,7 @@ use crate::{app, build, util, BuildConfig, BuildpackReference, PackResult, TestC use std::borrow::Borrow; use std::env; use std::path::PathBuf; +use tempfile::tempdir; /// Runner for libcnb integration tests. /// @@ -58,12 +59,13 @@ impl TestRunner { ) { let config = config.borrow(); + let cargo_manifest_dir = env::var("CARGO_MANIFEST_DIR") + .map(PathBuf::from) + .expect("Could not determine Cargo manifest directory"); + let app_dir = { let normalized_app_dir_path = if config.app_dir.is_relative() { - env::var("CARGO_MANIFEST_DIR") - .map(PathBuf::from) - .expect("Could not determine Cargo manifest directory") - .join(&config.app_dir) + cargo_manifest_dir.join(&config.app_dir) } else { config.app_dir.clone() }; @@ -88,7 +90,8 @@ impl TestRunner { } }; - let mut buildpack_dirs = vec![]; + let buildpacks_target_dir = + tempdir().expect("Could not create a temporary directory for compiled buildpacks"); let mut pack_command = PackBuildCommand::new(&config.builder_name, &app_dir, &image_name); @@ -99,17 +102,24 @@ impl TestRunner { for buildpack in &config.buildpacks { match buildpack { BuildpackReference::CurrentCrate => { - let crate_buildpack_dir = build::package_crate_buildpack(config.cargo_profile, &config.target_triple) - .expect("Test references crate buildpack, but crate wasn't packaged as a buildpack. This is an internal libcnb-test error, please report any occurrences"); - pack_command.buildpack(crate_buildpack_dir.path.clone()); - buildpack_dirs.push(crate_buildpack_dir); + let crate_buildpack_dir = build::package_crate_buildpack( + config.cargo_profile, + &config.target_triple, + &cargo_manifest_dir, + buildpacks_target_dir.path(), + ).expect("Test references crate buildpack, but crate wasn't packaged as a buildpack. This is an internal libcnb-test error, please report any occurrences"); + pack_command.buildpack(crate_buildpack_dir); } BuildpackReference::WorkspaceBuildpack(builpack_id) => { - let buildpack_dir = build::package_buildpack(builpack_id, config.cargo_profile, &config.target_triple) - .unwrap_or_else(|_| panic!("Test references buildpack `{builpack_id}`, but this directory wasn't packaged as a buildpack. This is an internal libcnb-test error, please report any occurrences")); - pack_command.buildpack(buildpack_dir.path.clone()); - buildpack_dirs.push(buildpack_dir); + let buildpack_dir = build::package_buildpack( + builpack_id, + config.cargo_profile, + &config.target_triple, + &cargo_manifest_dir, + buildpacks_target_dir.path() + ).unwrap_or_else(|_| panic!("Test references buildpack `{builpack_id}`, but this directory wasn't packaged as a buildpack. This is an internal libcnb-test error, please report any occurrences")); + pack_command.buildpack(buildpack_dir); } BuildpackReference::Other(id) => { From cde292f0778b89d718847c946a0661f247558bdc Mon Sep 17 00:00:00 2001 From: Colin Casey Date: Tue, 19 Sep 2023 09:36:09 -0300 Subject: [PATCH 5/8] Update libcnb-test/README.md Co-authored-by: Ed Morley <501702+edmorley@users.noreply.github.com> --- libcnb-test/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcnb-test/README.md b/libcnb-test/README.md index 0e2a3587..b903f200 100644 --- a/libcnb-test/README.md +++ b/libcnb-test/README.md @@ -191,7 +191,7 @@ fn dynamic_fixture() { Building with multiple buildpacks, using [`BuildConfig::buildpacks`]: ```rust,no_run -use libcnb_data::buildpack_id; +use libcnb::data::buildpack_id; use libcnb_test::{BuildConfig, BuildpackReference, TestRunner}; // #[test] From 51d49693388e05d8f28301710fa67a3151b71f53 Mon Sep 17 00:00:00 2001 From: Colin Casey Date: Tue, 19 Sep 2023 09:37:03 -0300 Subject: [PATCH 6/8] Update libcnb-test/tests/integration_test.rs Co-authored-by: Ed Morley <501702+edmorley@users.noreply.github.com> --- libcnb-test/tests/integration_test.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcnb-test/tests/integration_test.rs b/libcnb-test/tests/integration_test.rs index 096ae4ca..0ab1c0b3 100644 --- a/libcnb-test/tests/integration_test.rs +++ b/libcnb-test/tests/integration_test.rs @@ -546,7 +546,7 @@ fn address_for_port_when_container_crashed() { #[ignore = "integration test"] fn basic_build_with_libcnb_reference_to_single_buildpack() { TestRunner::default().build( - BuildConfig::new("heroku/builder:22", "test-fixtures/procfile").buildpacks(vec![ + BuildConfig::new("heroku/builder:22", "test-fixtures/empty").buildpacks(vec![ BuildpackReference::WorkspaceBuildpack(buildpack_id!("libcnb-test/a")), ]), |context| { From a66b0303c7ca634e587bd2cbe18b316ad1077902 Mon Sep 17 00:00:00 2001 From: Colin Casey Date: Tue, 19 Sep 2023 09:37:11 -0300 Subject: [PATCH 7/8] Update libcnb-test/tests/integration_test.rs Co-authored-by: Ed Morley <501702+edmorley@users.noreply.github.com> --- libcnb-test/tests/integration_test.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcnb-test/tests/integration_test.rs b/libcnb-test/tests/integration_test.rs index 0ab1c0b3..529f92ae 100644 --- a/libcnb-test/tests/integration_test.rs +++ b/libcnb-test/tests/integration_test.rs @@ -565,7 +565,7 @@ fn basic_build_with_libcnb_reference_to_single_buildpack() { #[ignore = "integration test"] fn basic_build_with_libcnb_reference_to_meta_buildpack() { TestRunner::default().build( - BuildConfig::new("heroku/builder:22", "test-fixtures/procfile").buildpacks(vec![ + BuildConfig::new("heroku/builder:22", "test-fixtures/empty").buildpacks(vec![ BuildpackReference::WorkspaceBuildpack(buildpack_id!("libcnb-test/meta")), ]), |context| { From 48df15f25836cd25e8b055ffb794a1410eafdee3 Mon Sep 17 00:00:00 2001 From: Colin Casey Date: Wed, 20 Sep 2023 14:18:13 -0300 Subject: [PATCH 8/8] PR feedback * updated error enum from `PackageTestBuildpackError` to `PackageBuildpackError` * added newline to Cargo.toml --- libcnb-test/Cargo.toml | 2 +- libcnb-test/src/build.rs | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/libcnb-test/Cargo.toml b/libcnb-test/Cargo.toml index 1c8e9635..ec5dbc04 100644 --- a/libcnb-test/Cargo.toml +++ b/libcnb-test/Cargo.toml @@ -22,4 +22,4 @@ tempfile = "3.7.1" [dev-dependencies] indoc = "2.0.3" ureq = { version = "2.7.1", default-features = false } -libcnb.workspace = true \ No newline at end of file +libcnb.workspace = true diff --git a/libcnb-test/src/build.rs b/libcnb-test/src/build.rs index 0b2d82f1..9114f224 100644 --- a/libcnb-test/src/build.rs +++ b/libcnb-test/src/build.rs @@ -6,7 +6,6 @@ use libcnb_package::buildpack_dependency_graph::{ use libcnb_package::cross_compile::{cross_compile_assistance, CrossCompileAssistance}; use libcnb_package::dependency_graph::{get_dependencies, GetDependenciesError}; use libcnb_package::output::create_packaged_buildpack_dir_resolver; -use libcnb_package::package::PackageBuildpackError; use libcnb_package::{find_cargo_workspace_root_dir, CargoProfile, FindCargoWorkspaceRootError}; use std::collections::BTreeMap; use std::fs; @@ -18,7 +17,7 @@ pub(crate) fn package_crate_buildpack( target_triple: impl AsRef, cargo_manifest_dir: &Path, target_buildpack_dir: &Path, -) -> Result { +) -> Result { let buildpack_toml = cargo_manifest_dir.join("buildpack.toml"); assert!( @@ -28,7 +27,7 @@ pub(crate) fn package_crate_buildpack( ); let buildpack_descriptor: BuildpackDescriptor = read_toml_file(buildpack_toml) - .map_err(PackageTestBuildpackError::CannotReadBuildpackDescriptor)?; + .map_err(PackageBuildpackError::CannotReadBuildpackDescriptor)?; package_buildpack( &buildpack_descriptor.buildpack().id, @@ -45,10 +44,10 @@ pub(crate) fn package_buildpack( target_triple: impl AsRef, cargo_manifest_dir: &Path, target_buildpack_dir: &Path, -) -> Result { +) -> Result { let cargo_build_env = match cross_compile_assistance(target_triple.as_ref()) { CrossCompileAssistance::HelpText(help_text) => { - return Err(PackageTestBuildpackError::CrossCompileConfigurationError( + return Err(PackageBuildpackError::CrossCompileConfigurationError( help_text, )); } @@ -57,7 +56,7 @@ pub(crate) fn package_buildpack( }; let workspace_root_path = find_cargo_workspace_root_dir(cargo_manifest_dir) - .map_err(PackageTestBuildpackError::FindCargoWorkspaceRoot)?; + .map_err(PackageBuildpackError::FindCargoWorkspaceRoot)?; let buildpack_dir_resolver = create_packaged_buildpack_dir_resolver( target_buildpack_dir, @@ -66,7 +65,7 @@ pub(crate) fn package_buildpack( ); let buildpack_dependency_graph = build_libcnb_buildpacks_dependency_graph(&workspace_root_path) - .map_err(PackageTestBuildpackError::BuildBuildpackDependencyGraph)?; + .map_err(PackageBuildpackError::BuildBuildpackDependencyGraph)?; let root_node = buildpack_dependency_graph .node_weights() @@ -82,7 +81,7 @@ pub(crate) fn package_buildpack( &buildpack_dependency_graph, &[root_node.expect("The root node should exist")], ) - .map_err(PackageTestBuildpackError::GetDependencies)?; + .map_err(PackageBuildpackError::GetDependencies)?; let mut packaged_buildpack_dirs = BTreeMap::new(); for node in &build_order { @@ -98,7 +97,7 @@ pub(crate) fn package_buildpack( &buildpack_destination_dir, &packaged_buildpack_dirs, ) - .map_err(PackageTestBuildpackError::PackageBuildpack)?; + .map_err(PackageBuildpackError::PackageBuildpack)?; packaged_buildpack_dirs.insert(node.buildpack_id.clone(), buildpack_destination_dir); } @@ -107,11 +106,11 @@ pub(crate) fn package_buildpack( } #[derive(Debug)] -pub(crate) enum PackageTestBuildpackError { +pub(crate) enum PackageBuildpackError { CannotReadBuildpackDescriptor(TomlFileError), BuildBuildpackDependencyGraph(BuildBuildpackDependencyGraphError), CrossCompileConfigurationError(String), FindCargoWorkspaceRoot(FindCargoWorkspaceRootError), GetDependencies(GetDependenciesError), - PackageBuildpack(PackageBuildpackError), + PackageBuildpack(libcnb_package::package::PackageBuildpackError), }