diff --git a/.cargo/config.toml b/.cargo/config.toml index c478751cd..949d1ed00 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -5,7 +5,7 @@ rustflags = ["--cfg", "tokio_unstable"] bump-versions = "run -p upgrade-version --" llm = "run --package xtask-llm-benchmark --bin llm_benchmark --" ci = "run -p ci --" -smoketest = "run -p xtask-smoketest -- smoketest" +smoketest = "ci smoketests --" smoketests = "smoketest" [target.x86_64-pc-windows-msvc] diff --git a/Cargo.lock b/Cargo.lock index 5a98ba7e9..f2dadefea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11085,14 +11085,6 @@ dependencies = [ "urlencoding", ] -[[package]] -name = "xtask-smoketest" -version = "0.1.0" -dependencies = [ - "anyhow", - "clap 4.5.50", -] - [[package]] name = "xxhash-rust" version = "0.8.15" diff --git a/Cargo.toml b/Cargo.toml index e0f89952a..cbb16a759 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,7 +61,6 @@ members = [ "tools/generate-client-api", "tools/gen-bindings", "tools/xtask-llm-benchmark", - "tools/xtask-smoketest", "crates/bindings-typescript/test-app/server", "crates/bindings-typescript/test-react-router-app/server", "crates/query-builder", diff --git a/tools/ci/README.md b/tools/ci/README.md index e56fa4bc0..c3fc615dd 100644 --- a/tools/ci/README.md +++ b/tools/ci/README.md @@ -93,14 +93,45 @@ Executes the smoketests suite with some default exclusions. **Usage:** ```bash -Usage: smoketests [ARGS]... +Usage: smoketests [OPTIONS] [ARGS]... [COMMAND] ``` **Options:** -- `args`: Additional arguments to pass to the smoketests runner. These are usually set by the CI environment, such as `-- --docker` +- `--server`: Run tests against a remote server instead of spawning local servers. + +When specified, tests will connect to the given URL instead of starting local server instances. Tests that require local server control (like restart tests) will be skipped. + +- `--dotnet`: +- `args`: - `--help`: Print help (see a summary with '-h') +#### `prepare` + +Only build binaries without running tests + +Use this before running `cargo test --all` to ensure binaries are built. + +**Usage:** +```bash +Usage: prepare +``` + +**Options:** + +- `--help`: Print help (see a summary with '-h') + +#### `help` + +**Usage:** +```bash +Usage: help [COMMAND]... +``` + +**Options:** + +- `subcommand`: + ### `update-flow` Tests the update flow diff --git a/tools/ci/src/main.rs b/tools/ci/src/main.rs index 4e9a80f06..308cab389 100644 --- a/tools/ci/src/main.rs +++ b/tools/ci/src/main.rs @@ -11,6 +11,7 @@ use std::{env, fs}; const README_PATH: &str = "tools/ci/README.md"; mod ci_docs; +mod smoketest; /// SpacetimeDB CI tasks /// @@ -236,13 +237,7 @@ enum CiCmd { /// Runs smoketests /// /// Executes the smoketests suite with some default exclusions. - Smoketests { - #[arg( - trailing_var_arg = true, - long_help = "Additional arguments to pass to the smoketests runner. These are usually set by the CI environment, such as `-- --docker`" - )] - args: Vec, - }, + Smoketests(smoketest::SmoketestsArgs), /// Tests the update flow /// /// Tests the self-update flow by building the spacetimedb-update binary for the specified @@ -481,19 +476,8 @@ fn main() -> Result<()> { .run()?; } - Some(CiCmd::Smoketests { args: smoketest_args }) => { - // Use cargo smoketest (alias for xtask-smoketest) which handles: - // - Building binaries first (prevents race conditions) - // - Building precompiled modules - // - Using nextest if available, falling back to cargo test - // - Running in release mode with optimal parallelism - cmd( - "cargo", - ["smoketest", "--"] - .into_iter() - .chain(smoketest_args.iter().map(|s| s.as_str()).clone()), - ) - .run()?; + Some(CiCmd::Smoketests(args)) => { + smoketest::run(args)?; } Some(CiCmd::UpdateFlow { diff --git a/tools/xtask-smoketest/src/main.rs b/tools/ci/src/smoketest.rs similarity index 75% rename from tools/xtask-smoketest/src/main.rs rename to tools/ci/src/smoketest.rs index 44bb0a4b0..595f702a9 100644 --- a/tools/xtask-smoketest/src/main.rs +++ b/tools/ci/src/smoketest.rs @@ -1,44 +1,32 @@ #![allow(clippy::disallowed_macros)] use anyhow::{ensure, Result}; -use clap::{Parser, Subcommand}; +use clap::{Args, Subcommand}; use std::env; use std::process::{Command, Stdio}; -/// SpacetimeDB development tasks -#[derive(Parser)] -#[command(name = "cargo xtask")] -struct Cli { +#[derive(Args)] +/// This command first builds the spacetimedb-cli and spacetimedb-standalone binaries, +/// then runs the smoketests. This prevents race conditions when running tests in parallel +/// with nextest, where multiple test processes might try to build the same binaries +/// simultaneously. +pub struct SmoketestsArgs { #[command(subcommand)] - cmd: XtaskCmd, -} + cmd: Option, -#[derive(Subcommand)] -enum XtaskCmd { - /// Run smoketests with pre-built binaries + /// Run tests against a remote server instead of spawning local servers. /// - /// This command first builds the spacetimedb-cli and spacetimedb-standalone binaries, - /// then runs the smoketests. This prevents race conditions when running tests in parallel - /// with nextest, where multiple test processes might try to build the same binaries - /// simultaneously. - Smoketest { - #[command(subcommand)] - cmd: Option, + /// When specified, tests will connect to the given URL instead of starting + /// local server instances. Tests that require local server control (like + /// restart tests) will be skipped. + #[arg(long)] + server: Option, - /// Run tests against a remote server instead of spawning local servers. - /// - /// When specified, tests will connect to the given URL instead of starting - /// local server instances. Tests that require local server control (like - /// restart tests) will be skipped. - #[arg(long)] - server: Option, + #[arg(long, default_value_t = true, action = clap::ArgAction::Set)] + dotnet: bool, - #[arg(long, default_value_t = true, action = clap::ArgAction::Set)] - dotnet: bool, - - /// Additional arguments to pass to the test runner - #[arg(trailing_var_arg = true)] - args: Vec, - }, + /// Additional arguments to pass to the test runner + #[arg(trailing_var_arg = true)] + args: Vec, } #[derive(Subcommand)] @@ -49,24 +37,14 @@ enum SmoketestCmd { Prepare, } -fn main() -> Result<()> { - let cli = Cli::parse(); - - match cli.cmd { - XtaskCmd::Smoketest { - cmd: Some(SmoketestCmd::Prepare), - .. - } => { +pub fn run(args: SmoketestsArgs) -> Result<()> { + match args.cmd { + Some(SmoketestCmd::Prepare) => { build_binaries()?; eprintln!("Binaries ready. You can now run `cargo test --all`."); Ok(()) } - XtaskCmd::Smoketest { - cmd: None, - server, - args, - dotnet: use_dotnet, - } => run_smoketest(server, use_dotnet, args), + None => run_smoketest(args.server, args.dotnet, args.args), } } diff --git a/tools/xtask-smoketest/Cargo.toml b/tools/xtask-smoketest/Cargo.toml deleted file mode 100644 index 0af68c2d6..000000000 --- a/tools/xtask-smoketest/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "xtask-smoketest" -version = "0.1.0" -edition.workspace = true - -[dependencies] -anyhow.workspace = true -clap.workspace = true