Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
8 changes: 0 additions & 8 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
35 changes: 33 additions & 2 deletions tools/ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 4 additions & 20 deletions tools/ci/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use std::{env, fs};
const README_PATH: &str = "tools/ci/README.md";

mod ci_docs;
mod smoketest;

/// SpacetimeDB CI tasks
///
Expand Down Expand Up @@ -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<String>,
},
Smoketests(smoketest::SmoketestsArgs),
/// Tests the update flow
///
/// Tests the self-update flow by building the spacetimedb-update binary for the specified
Expand Down Expand Up @@ -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 {
Expand Down
72 changes: 25 additions & 47 deletions tools/xtask-smoketest/src/main.rs → tools/ci/src/smoketest.rs
Original file line number Diff line number Diff line change
@@ -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<SmoketestCmd>,

#[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<SmoketestCmd>,

/// 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<String>,

#[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<String>,
},
/// 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<String>,

#[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<String>,
}

#[derive(Subcommand)]
Expand All @@ -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),
}
}

Expand Down
8 changes: 0 additions & 8 deletions tools/xtask-smoketest/Cargo.toml

This file was deleted.

Loading