From bf1d20ee44017393dfe88d40eb6bed31b4e726dc Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 22 Apr 2026 10:18:34 -0700 Subject: [PATCH 1/2] refactor --- tools/ci/src/main.rs | 175 ++++++++++++++++++++++--------------------- 1 file changed, 90 insertions(+), 85 deletions(-) diff --git a/tools/ci/src/main.rs b/tools/ci/src/main.rs index 1743b67a814..d4150dcdf28 100644 --- a/tools/ci/src/main.rs +++ b/tools/ci/src/main.rs @@ -299,6 +299,84 @@ fn tracked_rs_files_under(path: &str) -> Result> { .collect()) } +fn run_dlls() -> Result<()> { + ensure_repo_root()?; + + cmd!( + "dotnet", + "pack", + "crates/bindings-csharp/BSATN.Runtime", + "-c", + "Release" + ) + .run()?; + cmd!("dotnet", "pack", "crates/bindings-csharp/Runtime", "-c", "Release").run()?; + + let repo_root = env::current_dir()?; + let bsatn_source = repo_root.join("crates/bindings-csharp/BSATN.Runtime/bin/Release"); + let runtime_source = repo_root.join("crates/bindings-csharp/Runtime/bin/Release"); + + let nuget_config_dir = tempfile::tempdir()?; + let nuget_config_path = nuget_config_dir.path().join("nuget.config"); + let nuget_config_contents = format!( + r#" + + + + + + + + + + + + + + + + + + + + "#, + bsatn_source.display(), + runtime_source.display(), + ); + fs::write(&nuget_config_path, nuget_config_contents)?; + + let nuget_config_path_str = nuget_config_path.to_string_lossy().to_string(); + + clear_restored_package_dirs("spacetimedb.bsatn.runtime")?; + clear_restored_package_dirs("spacetimedb.runtime")?; + + cmd!( + "dotnet", + "restore", + "SpacetimeDB.ClientSDK.csproj", + "--configfile", + &nuget_config_path_str, + ) + .dir("sdks/csharp") + .run()?; + + overlay_unity_meta_skeleton("spacetimedb.bsatn.runtime")?; + overlay_unity_meta_skeleton("spacetimedb.runtime")?; + + cmd!( + "dotnet", + "pack", + "SpacetimeDB.ClientSDK.csproj", + "-c", + "Release", + "--no-restore" + ) + .dir("sdks/csharp") + .run()?; + + Ok(()) +} + fn main() -> Result<()> { env_logger::init(); @@ -306,8 +384,6 @@ fn main() -> Result<()> { match cli.cmd { Some(CiCmd::Test) => { - cmd!("pnpm", "build").dir("crates/bindings-typescript").run()?; - // TODO: This doesn't work on at least user Linux machines, because something here apparently uses `sudo`? // Exclude smoketests from `cargo test --all` since they require pre-built binaries. @@ -461,83 +537,10 @@ fn main() -> Result<()> { } Some(CiCmd::Dlls) => { - ensure_repo_root()?; - - cmd!( - "dotnet", - "pack", - "crates/bindings-csharp/BSATN.Runtime", - "-c", - "Release" - ) - .run()?; - cmd!("dotnet", "pack", "crates/bindings-csharp/Runtime", "-c", "Release").run()?; - - let repo_root = env::current_dir()?; - let bsatn_source = repo_root.join("crates/bindings-csharp/BSATN.Runtime/bin/Release"); - let runtime_source = repo_root.join("crates/bindings-csharp/Runtime/bin/Release"); - - let nuget_config_dir = tempfile::tempdir()?; - let nuget_config_path = nuget_config_dir.path().join("nuget.config"); - let nuget_config_contents = format!( - r#" - - - - - - - - - - - - - - - - - - - - "#, - bsatn_source.display(), - runtime_source.display(), - ); - fs::write(&nuget_config_path, nuget_config_contents)?; - - let nuget_config_path_str = nuget_config_path.to_string_lossy().to_string(); - - clear_restored_package_dirs("spacetimedb.bsatn.runtime")?; - clear_restored_package_dirs("spacetimedb.runtime")?; - - cmd!( - "dotnet", - "restore", - "SpacetimeDB.ClientSDK.csproj", - "--configfile", - &nuget_config_path_str, - ) - .dir("sdks/csharp") - .run()?; - - overlay_unity_meta_skeleton("spacetimedb.bsatn.runtime")?; - overlay_unity_meta_skeleton("spacetimedb.runtime")?; - - cmd!( - "dotnet", - "pack", - "SpacetimeDB.ClientSDK.csproj", - "-c", - "Release", - "--no-restore" - ) - .dir("sdks/csharp") - .run()?; + run_dlls()?; } Some(CiCmd::Smoketests(args)) => { - ensure_repo_root()?; smoketest::run(args)?; } @@ -548,7 +551,7 @@ fn main() -> Result<()> { let mut common_args = vec![]; if let Some(target) = target.as_ref() { common_args.push("--target"); - common_args.push(target); + common_args.push(target.as_str()); log::info!("checking update flow for target: {target}"); } else { log::info!("checking update flow"); @@ -562,24 +565,26 @@ fn main() -> Result<()> { "cargo", ["build", "-p", "spacetimedb-update"] .into_iter() - .chain(common_args.clone()), + .chain(common_args.iter().copied()), ) .run()?; - // NOTE(bfops): We need the `github-token-auth` feature because we otherwise tend to get ratelimited when we try to fetch `/releases/latest`. - // My best guess is that, on the GitHub runners, the "anonymous" ratelimit is shared by *all* users of that runner (I think this because it - // happens very frequently on the `macos-runner`, but we haven't seen it on any others). + let root_dir = tempfile::tempdir()?; - let root_dir_string = root_dir.path().to_string_lossy().to_string(); - let root_arg = format!("--root-dir={}", root_dir_string); + let root_arg = format!("--root-dir={}", root_dir.path().display()); cmd( "cargo", ["run", "-p", "spacetimedb-update"] .into_iter() - .chain(common_args.clone()) + .chain(common_args.iter().copied()) .chain(["--", "self-install", &root_arg, "--yes"].into_iter()), ) .run()?; - cmd!(format!("{}/spacetime", root_dir_string), &root_arg, "help",).run()?; + + let mut spacetime_path = root_dir.path().join("spacetime"); + if !std::env::consts::EXE_EXTENSION.is_empty() { + spacetime_path.set_extension(std::env::consts::EXE_EXTENSION); + } + cmd(spacetime_path, [&root_arg, "help"]).run()?; } Some(CiCmd::CliDocs { spacetime_path }) => { From c6813bdc0cd0081c3ebcb1e51cbc1f9e1894a33d Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 22 Apr 2026 10:21:05 -0700 Subject: [PATCH 2/2] revert --- tools/ci/src/main.rs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tools/ci/src/main.rs b/tools/ci/src/main.rs index d4150dcdf28..7143907c467 100644 --- a/tools/ci/src/main.rs +++ b/tools/ci/src/main.rs @@ -384,6 +384,8 @@ fn main() -> Result<()> { match cli.cmd { Some(CiCmd::Test) => { + cmd!("pnpm", "build").dir("crates/bindings-typescript").run()?; + // TODO: This doesn't work on at least user Linux machines, because something here apparently uses `sudo`? // Exclude smoketests from `cargo test --all` since they require pre-built binaries. @@ -541,6 +543,7 @@ fn main() -> Result<()> { } Some(CiCmd::Smoketests(args)) => { + ensure_repo_root()?; smoketest::run(args)?; } @@ -551,7 +554,7 @@ fn main() -> Result<()> { let mut common_args = vec![]; if let Some(target) = target.as_ref() { common_args.push("--target"); - common_args.push(target.as_str()); + common_args.push(target); log::info!("checking update flow for target: {target}"); } else { log::info!("checking update flow"); @@ -565,26 +568,24 @@ fn main() -> Result<()> { "cargo", ["build", "-p", "spacetimedb-update"] .into_iter() - .chain(common_args.iter().copied()), + .chain(common_args.clone()), ) .run()?; - + // NOTE(bfops): We need the `github-token-auth` feature because we otherwise tend to get ratelimited when we try to fetch `/releases/latest`. + // My best guess is that, on the GitHub runners, the "anonymous" ratelimit is shared by *all* users of that runner (I think this because it + // happens very frequently on the `macos-runner`, but we haven't seen it on any others). let root_dir = tempfile::tempdir()?; - let root_arg = format!("--root-dir={}", root_dir.path().display()); + let root_dir_string = root_dir.path().to_string_lossy().to_string(); + let root_arg = format!("--root-dir={}", root_dir_string); cmd( "cargo", ["run", "-p", "spacetimedb-update"] .into_iter() - .chain(common_args.iter().copied()) + .chain(common_args.clone()) .chain(["--", "self-install", &root_arg, "--yes"].into_iter()), ) .run()?; - - let mut spacetime_path = root_dir.path().join("spacetime"); - if !std::env::consts::EXE_EXTENSION.is_empty() { - spacetime_path.set_extension(std::env::consts::EXE_EXTENSION); - } - cmd(spacetime_path, [&root_arg, "help"]).run()?; + cmd!(format!("{}/spacetime", root_dir_string), &root_arg, "help",).run()?; } Some(CiCmd::CliDocs { spacetime_path }) => {