diff --git a/Cargo.lock b/Cargo.lock index 468ee72c..d2cfb1e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2077,8 +2077,8 @@ dependencies = [ [[package]] name = "kinode_process_lib" -version = "0.9.0" -source = "git+https://github.com/kinode-dao/process_lib.git?tag=v0.9.0#284f202376b3cd3ce0c03aa660a006fc6187f236" +version = "0.9.2" +source = "git+https://github.com/kinode-dao/process_lib.git?rev=9ac9e51#9ac9e513c0228f2dcfe8999ed4ca2c38246ee3db" dependencies = [ "alloy", "alloy-primitives", @@ -2099,7 +2099,7 @@ dependencies = [ [[package]] name = "kit" -version = "0.7.2" +version = "0.7.3" dependencies = [ "alloy", "alloy-sol-macro", diff --git a/Cargo.toml b/Cargo.toml index 2b30fa56..5e6c6143 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "kit" -version = "0.7.2" +version = "0.7.3" edition = "2021" [build-dependencies] @@ -36,7 +36,7 @@ color-eyre = { version = "0.6", features = ["capture-spantrace"] } dirs = "5.0" fs-err = "2.11" hex = "0.4" -kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib.git", tag = "v0.9.0" } +kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib.git", rev = "9ac9e51" } nix = { version = "0.27", features = ["process", "signal", "term"] } regex = "1" reqwest = { version = "0.12", features = ["json"] } diff --git a/src/build/mod.rs b/src/build/mod.rs index 86c8710a..d9da5a2a 100644 --- a/src/build/mod.rs +++ b/src/build/mod.rs @@ -886,15 +886,21 @@ async fn fetch_dependencies( true, )).await { debug!("Failed to build self as dependency: {e:?}"); - } else if let Err(e) = fetch_local_built_dependency( + } else if let Err(e) = fetch_local_built_dependency( apis, wasm_paths, package_dir, ) { debug!("Failed to fetch self as dependency: {e:?}"); }; + let canon_package_dir = package_dir.canonicalize()?; for local_dependency in &local_dependencies { // build dependency + let local_dep_deps = local_dependencies + .clone() + .into_iter() + .filter(|d| *d != canon_package_dir) + .collect(); Box::pin(execute( local_dependency, true, @@ -904,7 +910,7 @@ async fn fetch_dependencies( url.clone(), download_from, default_world, - vec![], // TODO: what about deps-of-deps? + local_dep_deps, vec![], force, verbose, @@ -1246,7 +1252,11 @@ async fn compile_package( // zip & place API inside of pkg/ to publish API if target_api_dir.exists() { - for path in add_paths_to_api { + let mut api_includes = add_paths_to_api.clone(); + if let Some(ref metadata_includes) = metadata.properties.api_includes { + api_includes.extend_from_slice(metadata_includes); + } + for path in api_includes { let path = if path.exists() { path } else { diff --git a/src/run_tests/mod.rs b/src/run_tests/mod.rs index cab204fe..3c57293b 100644 --- a/src/run_tests/mod.rs +++ b/src/run_tests/mod.rs @@ -25,11 +25,17 @@ pub mod types; use types::*; impl Config { - fn expand_home_paths(mut self: Config) -> Config { + fn expand_home_paths(mut self: Config, config_path: &Path) -> Config { + let config_path = config_path.parent().unwrap(); self.runtime = match self.runtime { Runtime::FetchVersion(version) => Runtime::FetchVersion(version), Runtime::RepoPath(runtime_path) => { - Runtime::RepoPath(expand_home_path(&runtime_path).unwrap_or(runtime_path)) + Runtime::RepoPath(expand_home_path(&runtime_path) + .unwrap_or_else(|| { + fs::canonicalize(config_path.join(&runtime_path)) + .unwrap_or_else(|_| runtime_path) + }) + ) } }; for test in self.tests.iter_mut() { @@ -39,7 +45,11 @@ impl Config { .map(|p| expand_home_path(&p).unwrap_or_else(|| p.clone())) .collect(); for node in test.nodes.iter_mut() { - node.home = expand_home_path(&node.home).unwrap_or_else(|| node.home.clone()); + node.home = expand_home_path(&node.home) + .unwrap_or_else(|| { + fs::canonicalize(config_path.join(&node.home)) + .unwrap_or_else(|_| node.home.clone()) + }); } } self @@ -82,8 +92,8 @@ fn load_config(config_path: &Path) -> Result<(PathBuf, Config)> { let content = fs::read_to_string(&config_path)?; Ok(( - config_path, - toml::from_str::(&content)?.expand_home_paths(), + config_path.clone(), + toml::from_str::(&content)?.expand_home_paths(&config_path), )) } @@ -315,7 +325,7 @@ async fn build_packages( let SetupCleanupReturn { send_to_cleanup, send_to_kill, - task_handles: _, + task_handles, cleanup_context: _cleanup_context, mut master_node_port, node_cleanup_infos, @@ -327,7 +337,6 @@ async fn build_packages( let anvil_process = chain::start_chain(test.fakechain_router, true, recv_kill_in_start_chain, false).await?; - // Process each node boot_nodes( &nodes, &test.fakechain_router, @@ -408,6 +417,9 @@ async fn build_packages( info!("Cleaning up node to host dependencies."); let _ = send_to_cleanup.send(false); + for handle in task_handles { + handle.await.unwrap(); + } Ok((setup_packages, test_package_paths)) } @@ -680,11 +692,21 @@ async fn handle_test( let setup_scripts: Vec = test .setup_scripts .iter() - .map(|s| { - let p = test_dir_path.join(&s.path).canonicalize().unwrap(); - let p = p.to_str().unwrap(); + .map(|script| { + let command = script + .split_whitespace() + .map(|item| { + test_dir_path + .join(&item) + .canonicalize() + .ok() + .and_then(|p| p.to_str().map(|s| s.to_string())) + .unwrap_or_else(|| item.to_string()) + }) + .collect::>() + .join(" "); Command::new("bash") - .args(["-c", &format!("{} {}", p, &s.args)]) + .args(["-c", &command]) .spawn() .expect("") .id() as i32 @@ -728,13 +750,18 @@ async fn handle_test( .await; for script in test.test_scripts { - let p = test_dir_path.join(&script.path).canonicalize().unwrap(); - let p = p.to_str().unwrap(); - let command = if script.args.is_empty() { - p.to_string() - } else { - format!("{} {}", p, script.args) - }; + let command = script + .split_whitespace() + .map(|item| { + test_dir_path + .join(&item) + .canonicalize() + .ok() + .and_then(|p| p.to_str().map(|s| s.to_string())) + .unwrap_or_else(|| item.to_string()) + }) + .collect::>() + .join(" "); build::run_command(Command::new("bash").args(["-c", &command]), false)?; } @@ -757,6 +784,7 @@ pub async fn execute(config_path: PathBuf) -> Result<()> { let (config_path, config) = load_config(&config_path)?; + println!("{:?}", std::env::current_dir()); debug!("{:?}", config); // TODO: factor out with boot_fake_node? diff --git a/src/run_tests/types.rs b/src/run_tests/types.rs index 20de8542..7c4fa8ab 100644 --- a/src/run_tests/types.rs +++ b/src/run_tests/types.rs @@ -25,9 +25,9 @@ pub enum Runtime { pub struct Test { pub dependency_package_paths: Vec, pub setup_packages: Vec, - pub setup_scripts: Vec