Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kit"
version = "0.7.2"
version = "0.7.3"
edition = "2021"

[build-dependencies]
Expand Down Expand Up @@ -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"] }
Expand Down
16 changes: 13 additions & 3 deletions src/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
64 changes: 46 additions & 18 deletions src/run_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
Expand Down Expand Up @@ -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::<Config>(&content)?.expand_home_paths(),
config_path.clone(),
toml::from_str::<Config>(&content)?.expand_home_paths(&config_path),
))
}

Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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))
}
Expand Down Expand Up @@ -680,11 +692,21 @@ async fn handle_test(
let setup_scripts: Vec<i32> = 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::<Vec<String>>()
.join(" ");
Command::new("bash")
.args(["-c", &format!("{} {}", p, &s.args)])
.args(["-c", &command])
.spawn()
.expect("")
.id() as i32
Expand Down Expand Up @@ -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::<Vec<String>>()
.join(" ");
build::run_command(Command::new("bash").args(["-c", &command]), false)?;
}

Expand All @@ -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?
Expand Down
10 changes: 2 additions & 8 deletions src/run_tests/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ pub enum Runtime {
pub struct Test {
pub dependency_package_paths: Vec<PathBuf>,
pub setup_packages: Vec<SetupPackage>,
pub setup_scripts: Vec<Script>,
pub setup_scripts: Vec<String>,
pub test_package_paths: Vec<PathBuf>,
pub test_scripts: Vec<Script>,
pub test_scripts: Vec<String>,
pub timeout_secs: u64,
pub fakechain_router: u16,
pub nodes: Vec<Node>,
Expand All @@ -39,12 +39,6 @@ pub struct SetupPackage {
pub run: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Script {
pub path: PathBuf,
pub args: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Node {
pub port: u16,
Expand Down
9 changes: 7 additions & 2 deletions src/setup/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,13 @@ pub fn get_newest_valid_node_version(
if fields.len() == 1 {
versions.push(fields[0].to_string());
} else if fields.len() == 2 {
assert_eq!("->", fields[0]);
versions.push(fields[1].to_string());
if "->" == fields[0] {
versions.push(fields[1].to_string());
} else if fields[1] == "*" {
versions.push(fields[0].to_string());
} else {
warn!("unexpected line {line} in `nvm ls --no-alias`; skipping:\n{nvm_ls}");
}
}
}

Expand Down
Loading