From 601ce51b78066d43da80497dbe6a8f5b95659fbc Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Tue, 28 Oct 2025 10:33:57 -0700 Subject: [PATCH 01/91] [bfops/ci-caching]: CI - Cache more of our build outputs --- .github/workflows/ci.yml | 9 +++++++++ .github/workflows/csharp-test.yml | 5 ++--- .github/workflows/typescript-test.yml | 5 ++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6704b937e5e..7e456e1554f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,6 +47,13 @@ jobs: with: ref: ${{ env.GIT_REF }} - uses: dsherret/rust-toolchain-file@v1 + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + with: + shared-key: spacetimedb + key: ${{ github.ref }} + cache-on-failure: true + cache-all-crates: true - uses: actions/setup-dotnet@v4 with: global-json-file: global.json @@ -54,6 +61,8 @@ jobs: if: runner.os == 'Windows' run: choco install psql -y --no-progress shell: powershell + - name: Build crates + run: cargo build -p spacetimedb-cli -p spacetimedb-standalone -p spacetimedb-update - name: Build and start database (Linux) if: runner.os == 'Linux' run: docker compose up -d diff --git a/.github/workflows/csharp-test.yml b/.github/workflows/csharp-test.yml index 86ed1740814..df9dbba3363 100644 --- a/.github/workflows/csharp-test.yml +++ b/.github/workflows/csharp-test.yml @@ -70,15 +70,14 @@ jobs: id: cache-rust-deps with: workspaces: demo/Blackholio/server-rust - key: ${{ steps.checkout-stdb.outputs.commit }} + shared-key: spacetimedb + key: ${{ github.ref }} # Cache Rust deps even if unit tests have failed. cache-on-failure: true # Cache the CLI as well. cache-all-crates: true - name: Install SpacetimeDB CLI from the local checkout - # Rebuild only if we didn't get a precise cache hit. - if: steps.cache-rust-deps.outputs.cache-hit == 'false' run: | cargo install --force --path crates/cli --locked --message-format=short cargo install --force --path crates/standalone --locked --message-format=short diff --git a/.github/workflows/typescript-test.yml b/.github/workflows/typescript-test.yml index 572f3e8f7a5..a0d45ad1b43 100644 --- a/.github/workflows/typescript-test.yml +++ b/.github/workflows/typescript-test.yml @@ -86,7 +86,10 @@ jobs: workspaces: | . modules/quickstart-chat - shared-key: quickstart-chat-test + shared-key: spacetimedb + key: ${{ github.ref }} + cache-on-failure: true + cache-all-crates: true - name: Install SpacetimeDB CLI from the local checkout run: | From 818bdf05bb61545c1a695e8ae50cfc01d3fdd99d Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Tue, 28 Oct 2025 11:17:40 -0700 Subject: [PATCH 02/91] [bfops/ci-caching]: empty commit to bump CI From 85fd6f9c9d7a27910a141cce5cfcd0f997fb3541 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Tue, 28 Oct 2025 11:19:09 -0700 Subject: [PATCH 03/91] [bfops/ci-caching]: empty commit to bump CI From 20bfe62f25a94d2cee1d7d66ca4af7775e964c41 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Tue, 28 Oct 2025 11:36:04 -0700 Subject: [PATCH 04/91] [bfops/ci-caching]: empty commit to bump CI From fa1b9ca5c668bf5ff44fb5cea8ddee885f13c170 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 12 Nov 2025 14:27:14 -0800 Subject: [PATCH 05/91] [bfops/ci-caching]: try simpler run --- .github/workflows/ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7e456e1554f..8c79db94528 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,6 +29,8 @@ jobs: - { runner: windows-latest, smoketest_args: --no-build-cli } runner: [ spacetimedb-runner, windows-latest ] runs-on: ${{ matrix.runner }} + env: + CARGO_TARGET_DIR: target steps: - name: Find Git ref env: @@ -65,7 +67,7 @@ jobs: run: cargo build -p spacetimedb-cli -p spacetimedb-standalone -p spacetimedb-update - name: Build and start database (Linux) if: runner.os == 'Linux' - run: docker compose up -d + run: cargo run -p spacetimedb-cli -- start & - name: Build and start database (Windows) if: runner.os == 'Windows' run: | @@ -73,7 +75,6 @@ jobs: $ErrorActionPreference = 'Stop' $PSNativeCommandUseErrorActionPreference = $true - cargo build -p spacetimedb-cli -p spacetimedb-standalone -p spacetimedb-update Start-Process target/debug/spacetimedb-cli.exe -ArgumentList 'start --pg-port 5432' cd modules # the sdk-manifests on windows-latest are messed up, so we need to update them @@ -86,7 +87,7 @@ jobs: run: python -m pip install psycopg2-binary xmltodict - name: Run smoketests # Note: clear_database and replication only work in private - run: python -m smoketests ${{ matrix.smoketest_args }} -x clear_database replication + run: python -m smoketests ${{ matrix.smoketest_args }} -x clear_database replication teams - name: Stop containers (Linux) if: always() && runner.os == 'Linux' run: docker compose down From 643ff442c4881743adac84567764df7cdfcaf72d Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 12 Nov 2025 14:30:35 -0800 Subject: [PATCH 06/91] [bfops/ci-caching]: env vars in other workflows --- .github/workflows/csharp-test.yml | 5 ++--- .github/workflows/typescript-test.yml | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/csharp-test.yml b/.github/workflows/csharp-test.yml index df9dbba3363..2aa1a604437 100644 --- a/.github/workflows/csharp-test.yml +++ b/.github/workflows/csharp-test.yml @@ -20,6 +20,8 @@ jobs: group: unity-test-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true timeout-minutes: 30 + env: + CARGO_TARGET_DIR: target steps: - name: Checkout repository id: checkout-stdb @@ -83,9 +85,6 @@ jobs: cargo install --force --path crates/standalone --locked --message-format=short # Add a handy alias using the old binary name, so that we don't have to rewrite all scripts (incl. in submodules). ln -sf $HOME/.cargo/bin/spacetimedb-cli $HOME/.cargo/bin/spacetime - env: - # Share the target directory with our local project to avoid rebuilding same SpacetimeDB crates twice. - CARGO_TARGET_DIR: demo/Blackholio/server-rust/target - name: Check quickstart-chat bindings are up to date working-directory: sdks/csharp diff --git a/.github/workflows/typescript-test.yml b/.github/workflows/typescript-test.yml index a0d45ad1b43..2ac6f396463 100644 --- a/.github/workflows/typescript-test.yml +++ b/.github/workflows/typescript-test.yml @@ -16,6 +16,8 @@ concurrency: jobs: build-and-test: runs-on: ubuntu-latest + env: + CARGO_TARGET_DIR: target steps: - name: Checkout repository @@ -83,9 +85,6 @@ jobs: - name: Cache Rust dependencies uses: Swatinem/rust-cache@v2 with: - workspaces: | - . - modules/quickstart-chat shared-key: spacetimedb key: ${{ github.ref }} cache-on-failure: true From 0a0e222b760fc9732aa42d78a1c118ef2f422ddd Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 12 Nov 2025 14:42:37 -0800 Subject: [PATCH 07/91] [bfops/ci-caching]: try cache refactor --- .github/workflows/ci.yml | 40 ++++++++++++++++++++++++++- .github/workflows/csharp-test.yml | 8 +----- .github/workflows/typescript-test.yml | 4 +-- 3 files changed, 41 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8c79db94528..3bad4f94ce7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,7 +53,6 @@ jobs: uses: Swatinem/rust-cache@v2 with: shared-key: spacetimedb - key: ${{ github.ref }} cache-on-failure: true cache-all-crates: true - uses: actions/setup-dotnet@v4 @@ -95,6 +94,8 @@ jobs: test: name: Test Suite runs-on: spacetimedb-runner + env: + CARGO_TARGET_DIR: target steps: - name: Find Git ref env: @@ -114,6 +115,11 @@ jobs: ref: ${{ env.GIT_REF }} - uses: dsherret/rust-toolchain-file@v1 + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + with: + shared-key: spacetimedb + save-cache: false - uses: actions/setup-dotnet@v3 with: @@ -156,6 +162,8 @@ jobs: lints: name: Lints runs-on: spacetimedb-runner + env: + CARGO_TARGET_DIR: target steps: - name: Checkout sources uses: actions/checkout@v3 @@ -163,6 +171,12 @@ jobs: - uses: dsherret/rust-toolchain-file@v1 - run: echo ::add-matcher::.github/workflows/rust_matcher.json + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + with: + shared-key: spacetimedb + save-cache: false + - uses: actions/setup-dotnet@v3 with: global-json-file: global.json @@ -195,12 +209,20 @@ jobs: wasm_bindings: name: Build and test wasm bindings runs-on: spacetimedb-runner + env: + CARGO_TARGET_DIR: target steps: - uses: actions/checkout@v3 - uses: dsherret/rust-toolchain-file@v1 - run: echo ::add-matcher::.github/workflows/rust_matcher.json + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + with: + shared-key: spacetimedb + save-cache: false + - name: Run bindgen tests run: cargo test -p spacetimedb-codegen @@ -252,6 +274,8 @@ jobs: - { target: aarch64-apple-darwin, runner: macos-latest } - { target: x86_64-pc-windows-msvc, runner: windows-latest } runs-on: ${{ matrix.runner }} + env: + CARGO_TARGET_DIR: target steps: - name: Checkout uses: actions/checkout@v3 @@ -262,6 +286,12 @@ jobs: - name: Install rust target run: rustup target add ${{ matrix.target }} + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + with: + shared-key: spacetimedb + save-cache: false + - name: Install packages if: ${{ matrix.runner == 'arm-runner' }} shell: bash @@ -370,6 +400,8 @@ jobs: name: Check CLI docs permissions: read-all runs-on: ubuntu-latest + env: + CARGO_TARGET_DIR: target steps: - name: Find Git ref env: @@ -413,6 +445,12 @@ jobs: - uses: dsherret/rust-toolchain-file@v1 + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + with: + shared-key: spacetimedb + save-cache: false + - name: Check for docs change run: | cargo run --features markdown-docs -p spacetimedb-cli > docs/docs/cli-reference.md diff --git a/.github/workflows/csharp-test.yml b/.github/workflows/csharp-test.yml index 2aa1a604437..d02714c7b37 100644 --- a/.github/workflows/csharp-test.yml +++ b/.github/workflows/csharp-test.yml @@ -69,15 +69,9 @@ jobs: - name: Cache Rust dependencies uses: Swatinem/rust-cache@v2 - id: cache-rust-deps with: - workspaces: demo/Blackholio/server-rust shared-key: spacetimedb - key: ${{ github.ref }} - # Cache Rust deps even if unit tests have failed. - cache-on-failure: true - # Cache the CLI as well. - cache-all-crates: true + save-cache: false - name: Install SpacetimeDB CLI from the local checkout run: | diff --git a/.github/workflows/typescript-test.yml b/.github/workflows/typescript-test.yml index 2ac6f396463..19a915a3044 100644 --- a/.github/workflows/typescript-test.yml +++ b/.github/workflows/typescript-test.yml @@ -86,9 +86,7 @@ jobs: uses: Swatinem/rust-cache@v2 with: shared-key: spacetimedb - key: ${{ github.ref }} - cache-on-failure: true - cache-all-crates: true + save-cache: false - name: Install SpacetimeDB CLI from the local checkout run: | From 644d5b1f75fc5a90a34e1d075042b8d0aeec311f Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 12 Nov 2025 14:53:48 -0800 Subject: [PATCH 08/91] [bfops/ci-caching]: docker slim --- Dockerfile | 2 +- docker-compose.yml | 12 +----------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 25ad97dad93..4ad1f5b6cf9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ FROM rust:bookworm AS builder WORKDIR /usr/src/app COPY . . -RUN cargo build -p spacetimedb-standalone -p spacetimedb-cli --release --locked +RUN cargo build -p spacetimedb-standalone -p spacetimedb-cli --locked FROM rust:bookworm diff --git a/docker-compose.yml b/docker-compose.yml index 718281892dd..9095cfa170b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,19 +29,9 @@ services: - "5432:5432" # Tracy - "8086:8086" - entrypoint: cargo watch -i flamegraphs -i log.conf --why -C crates/standalone -x 'run start --data-dir=/stdb/data --jwt-pub-key-path=/etc/spacetimedb/id_ecdsa.pub --jwt-priv-key-path=/etc/spacetimedb/id_ecdsa --pg-port 5432' + entrypoint: start --data-dir=/stdb/data --jwt-pub-key-path=/etc/spacetimedb/id_ecdsa.pub --jwt-priv-key-path=/etc/spacetimedb/id_ecdsa --pg-port 5432 privileged: true environment: - SPACETIMEDB_FLAMEGRAPH_PATH: ../../../../flamegraphs/flamegraph.folded - SPACETIMEDB_TRACY: 1 - # Tracy utilizes the Time Stamp Counter (TSC) in CPUs for high-resolution timing. - # The invariant TSC is a feature that ensures the TSC runs at a constant rate, - # regardless of power-saving modes or frequency changes. - # - # This flag will instruct Tracy to proceed without verifying the presence of an invariant TSC. - # If the CPU lacks this feature, Tracy cannot guarantee accurate timing. - # So use this approach with caution, as it may affect profiling accuracy. - # TRACY_NO_INVARIANT_CHECK: 1 RUST_BACKTRACE: 1 ENV: dev networks: From de21a678c2025e1bd2eacf749f6a6f313326fee0 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 12 Nov 2025 14:54:23 -0800 Subject: [PATCH 09/91] [bfops/ci-caching]: back to docker --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3bad4f94ce7..7e0ae233c0e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,7 +66,7 @@ jobs: run: cargo build -p spacetimedb-cli -p spacetimedb-standalone -p spacetimedb-update - name: Build and start database (Linux) if: runner.os == 'Linux' - run: cargo run -p spacetimedb-cli -- start & + run: docker compose up -d - name: Build and start database (Windows) if: runner.os == 'Windows' run: | From 6a4391f14f9bd7a6221b595bc94d68bef9df3a49 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 12 Nov 2025 16:04:32 -0800 Subject: [PATCH 10/91] [bfops/ci-caching]: slim --- Dockerfile | 44 ++------------------------------------------ docker-compose.yml | 3 ++- 2 files changed, 4 insertions(+), 43 deletions(-) diff --git a/Dockerfile b/Dockerfile index b76f2c2c0ae..98fe97a151e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,50 +1,10 @@ # Use a base image that supports multi-arch -FROM rust:bookworm AS builder +FROM rust:slim AS builder WORKDIR /usr/src/app COPY . . -# If we're in a git submodule, we'll have a corrupted/nonfunctional .git file instead of a proper .git directory. -# To make the errors more sane, remove .git entirely. -RUN if [ -f .git ]; then \ - echo "❌ ERROR: .git is a file (likely a submodule pointer), not a directory." >&2; \ - echo "This will cause errors in the build process, because git operations will fail." >&2; \ - echo "To address this, replace the .git file with a proper .git directory." >&2; \ - exit 1; \ - fi - -RUN cargo build -p spacetimedb-standalone -p spacetimedb-cli --locked - -FROM rust:bookworm - -# Install dependencies -RUN apt-get update && apt-get install -y \ - curl \ - ca-certificates \ - binaryen \ - build-essential \ - && rm -rf /var/lib/apt/lists/* - -# Determine architecture for .NET installation -ARG TARGETARCH -ENV DOTNET_ARCH=${TARGETARCH} - -RUN if [ "$DOTNET_ARCH" = "amd64" ]; then \ - DOTNET_ARCH="x64"; \ - elif [ "$DOTNET_ARCH" = "arm64" ]; then \ - DOTNET_ARCH="arm64"; \ - else \ - echo "Unsupported architecture: $DOTNET_ARCH" && exit 1; \ - fi && \ - curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel 8.0 --install-dir /usr/share/dotnet --architecture $DOTNET_ARCH - -ENV PATH="/usr/share/dotnet:${PATH}" - -# Install the experimental WASI workload -RUN dotnet workload install wasi-experimental - -# Install Rust WASM target -RUN rustup target add wasm32-unknown-unknown +FROM rust:slim # Copy over SpacetimeDB COPY --from=builder --chmod=755 /usr/src/app/target/release/spacetimedb-standalone /usr/src/app/target/release/spacetimedb-cli /opt/spacetime/ diff --git a/docker-compose.yml b/docker-compose.yml index 9095cfa170b..039fd8d8e76 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,6 +21,7 @@ services: - ./crates/client-api-messages:/usr/src/app/crates/client-api-messages - ./Cargo.toml:/usr/src/app/Cargo.toml - ./flamegraphs:/usr/src/app/flamegraphs + - ./target:/usr/src/app/target - key_files:/etc/spacetimedb - /stdb ports: @@ -29,7 +30,7 @@ services: - "5432:5432" # Tracy - "8086:8086" - entrypoint: start --data-dir=/stdb/data --jwt-pub-key-path=/etc/spacetimedb/id_ecdsa.pub --jwt-priv-key-path=/etc/spacetimedb/id_ecdsa --pg-port 5432 + entrypoint: target/debug/spacetimedb-cli --data-dir=/stdb/data --jwt-pub-key-path=/etc/spacetimedb/id_ecdsa.pub --jwt-priv-key-path=/etc/spacetimedb/id_ecdsa --pg-port 5432 privileged: true environment: RUST_BACKTRACE: 1 From d3dc60f525d01d1d7ee345efe90563bc0a16edcd Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Thu, 13 Nov 2025 00:11:21 +0000 Subject: [PATCH 11/91] Use new runner for testsuite --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad29363688d..0e7895aec02 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -93,7 +93,7 @@ jobs: test: name: Test Suite - runs-on: spacetimedb-runner + runs-on: spacetimedb-new-runner steps: - name: Find Git ref env: From db4f1a7fe44a04f4f434b2bc5c31b7d35f67b125 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 12 Nov 2025 16:12:25 -0800 Subject: [PATCH 12/91] [bfops/ci-caching]: slimmer --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 98fe97a151e..752e671bc5b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,10 @@ # Use a base image that supports multi-arch -FROM rust:slim AS builder +FROM debian:bookworm-slim AS builder WORKDIR /usr/src/app COPY . . -FROM rust:slim +FROM debian:bookworm-slim # Copy over SpacetimeDB COPY --from=builder --chmod=755 /usr/src/app/target/release/spacetimedb-standalone /usr/src/app/target/release/spacetimedb-cli /opt/spacetime/ From 8f0e79d6e533a13fee35435fb0a8d2aa06e5b378 Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Thu, 13 Nov 2025 00:37:27 +0000 Subject: [PATCH 13/91] Run job in container --- .github/workflows/ci.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e7895aec02..03f361e6d8d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -94,6 +94,16 @@ jobs: test: name: Test Suite runs-on: spacetimedb-new-runner + + # Add this for isolation: + container: + image: spacetimedb-ci:latest + options: >- + --user runner + -v /var/run/docker.sock:/var/run/docker.sock + -v /opt/github-runner/cargo-cache:/home/runner/.cargo/registry + -v /opt/github-runner/cargo-git:/home/runner/.cargo/git + steps: - name: Find Git ref env: From eefdd0bb0fa58b9cdf23ad323d363f7c024aca35 Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Thu, 13 Nov 2025 00:41:07 +0000 Subject: [PATCH 14/91] Use custom container --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 03f361e6d8d..8eb10835987 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,7 +97,7 @@ jobs: # Add this for isolation: container: - image: spacetimedb-ci:latest + image: localhost/spacetimedb-ci:latest options: >- --user runner -v /var/run/docker.sock:/var/run/docker.sock From 71980d36bfa369df3bf6acfb7301f77e73408b36 Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Thu, 13 Nov 2025 00:48:25 +0000 Subject: [PATCH 15/91] Use local container --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8eb10835987..83f2bd5a451 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,13 +97,12 @@ jobs: # Add this for isolation: container: - image: localhost/spacetimedb-ci:latest + image: localhost:5000/spacetimedb-ci:latest options: >- --user runner -v /var/run/docker.sock:/var/run/docker.sock -v /opt/github-runner/cargo-cache:/home/runner/.cargo/registry -v /opt/github-runner/cargo-git:/home/runner/.cargo/git - steps: - name: Find Git ref env: From f5e5c067fb1314ba13bcb5fc27283b8da605ac20 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 12 Nov 2025 16:49:06 -0800 Subject: [PATCH 16/91] [bfops/ci-caching]: update correct dockerfile --- crates/standalone/Dockerfile | 51 ++++++++++-------------------------- 1 file changed, 14 insertions(+), 37 deletions(-) diff --git a/crates/standalone/Dockerfile b/crates/standalone/Dockerfile index 41d4ca713d7..ace152a6eb0 100644 --- a/crates/standalone/Dockerfile +++ b/crates/standalone/Dockerfile @@ -1,47 +1,24 @@ -ARG CARGO_PROFILE=release +# Use a base image that supports multi-arch +FROM debian:bookworm-slim AS builder - -FROM rust:1.90.0 AS chef -RUN rust_target=$(rustc -vV | awk '/^host:/{ print $2 }') && \ - curl https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-$rust_target.tgz -fL | tar xz -C $CARGO_HOME/bin -RUN cargo binstall -y cargo-chef@0.1.70 WORKDIR /usr/src/app - -FROM chef AS planner COPY . . -RUN cargo chef prepare --recipe-path recipe.json - -FROM chef AS builder - -RUN cargo binstall -y cargo-watch@8.4.0 -RUN cargo binstall -y flamegraph@0.6.2 - -COPY --from=planner /usr/src/app/recipe.json . -ENV CARGO_INCREMENTAL=0 - -ARG CARGO_PROFILE=release - -RUN cargo chef cook -p spacetimedb-standalone --profile=${CARGO_PROFILE} - -COPY . . -RUN cargo build -p spacetimedb-standalone --profile=${CARGO_PROFILE} --locked +FROM debian:bookworm-slim -FROM builder as env-dev -RUN mkdir -p /stdb/data && ln -s /usr/src/app/crates/standalone/config.toml /stdb/data/config.toml -ENV PATH="/usr/src/app/target/debug:${PATH}" +# Copy over SpacetimeDB +COPY --from=builder --chmod=755 /usr/src/app/target/release/spacetimedb-standalone /usr/src/app/target/release/spacetimedb-cli /opt/spacetime/ +RUN ln -s /opt/spacetime/spacetimedb-cli /usr/local/bin/spacetime -FROM debian as env-release -RUN apt-get update && \ - apt-get install -y ca-certificates libssl-dev && \ - rm -rf /var/lib/apt/lists/* -COPY --from=builder /usr/src/app/target/release/spacetimedb-standalone /usr/local/bin/ -COPY --from=builder /usr/src/app/crates/standalone/config.toml /stdb/data/config.toml +# Create and switch to a non-root user +RUN useradd -m spacetime +USER spacetime -FROM env-${CARGO_PROFILE} +# Set working directory +WORKDIR /app +# Expose the necessary port EXPOSE 3000 -ENV RUST_BACKTRACE=1 -ENTRYPOINT ["spacetimedb-standalone"] -CMD ["start", "--data-dir=/stdb/data", "--jwt-pub-key-path=/etc/spacetimedb/id_ecdsa.pub", "--jwt-priv-key-path=/etc/spacetimedb/id_ecdsa"] +# Define the entrypoint +ENTRYPOINT ["spacetime"] From 3d22d05ec0c8c59b09158a907d0f9c5cda9c49ff Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Thu, 13 Nov 2025 00:53:53 +0000 Subject: [PATCH 17/91] updated workflow --- .github/workflows/ci.yml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 83f2bd5a451..645e2351b4b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -121,11 +121,10 @@ jobs: with: ref: ${{ env.GIT_REF }} - - uses: dsherret/rust-toolchain-file@v1 + - name: Verify .NET + run: dotnet --version - - uses: actions/setup-dotnet@v3 - with: - global-json-file: global.json + - uses: dsherret/rust-toolchain-file@v1 - name: Set up Node.js uses: actions/setup-node@v4 @@ -136,11 +135,6 @@ jobs: with: run_install: true - - name: Create /stdb dir - run: | - sudo mkdir /stdb - sudo chmod 777 /stdb - - name: Build typescript module sdk working-directory: crates/bindings-typescript run: pnpm build From 62a4f7e146eaf5112eed61a17ba5de5470360379 Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Thu, 13 Nov 2025 01:17:00 +0000 Subject: [PATCH 18/91] Fix run for fallocate test --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 645e2351b4b..e0426074b8b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -100,6 +100,7 @@ jobs: image: localhost:5000/spacetimedb-ci:latest options: >- --user runner + --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /opt/github-runner/cargo-cache:/home/runner/.cargo/registry -v /opt/github-runner/cargo-git:/home/runner/.cargo/git From bea3a3e2d85c4004fc638c5681c998e6a068920b Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 12 Nov 2025 17:50:16 -0800 Subject: [PATCH 19/91] [bfops/ci-caching]: fix --- crates/standalone/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/standalone/Dockerfile b/crates/standalone/Dockerfile index ace152a6eb0..f17a9c9fe14 100644 --- a/crates/standalone/Dockerfile +++ b/crates/standalone/Dockerfile @@ -7,7 +7,7 @@ COPY . . FROM debian:bookworm-slim # Copy over SpacetimeDB -COPY --from=builder --chmod=755 /usr/src/app/target/release/spacetimedb-standalone /usr/src/app/target/release/spacetimedb-cli /opt/spacetime/ +COPY --from=builder --chmod=755 /usr/src/app/target/debug/spacetimedb-standalone /usr/src/app/target/debug/spacetimedb-cli /opt/spacetime/ RUN ln -s /opt/spacetime/spacetimedb-cli /usr/local/bin/spacetime # Create and switch to a non-root user From 18f280dfa0bf10f24b00a03850c772f639e425c1 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 12 Nov 2025 17:50:52 -0800 Subject: [PATCH 20/91] [bfops/ci-caching]: slim down --- .github/workflows/ci.yml | 377 -------------------------- .github/workflows/csharp-test.yml | 166 ------------ .github/workflows/typescript-lint.yml | 41 --- .github/workflows/typescript-test.yml | 141 ---------- 4 files changed, 725 deletions(-) delete mode 100644 .github/workflows/csharp-test.yml delete mode 100644 .github/workflows/typescript-lint.yml delete mode 100644 .github/workflows/typescript-test.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 11c0f04a29a..eee3a5dbcc2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -99,380 +99,3 @@ jobs: - name: Stop containers (Linux) if: always() && runner.os == 'Linux' run: docker compose down - - test: - name: Test Suite - runs-on: spacetimedb-runner - env: - CARGO_TARGET_DIR: target - steps: - - name: Find Git ref - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - PR_NUMBER="${{ github.event.inputs.pr_number || null }}" - if test -n "${PR_NUMBER}"; then - GIT_REF="$( gh pr view --repo clockworklabs/SpacetimeDB $PR_NUMBER --json headRefName --jq .headRefName )" - else - GIT_REF="${{ github.ref }}" - fi - echo "GIT_REF=${GIT_REF}" >>"$GITHUB_ENV" - - - name: Checkout sources - uses: actions/checkout@v4 - with: - ref: ${{ env.GIT_REF }} - - - uses: dsherret/rust-toolchain-file@v1 - - name: Cache Rust dependencies - uses: Swatinem/rust-cache@v2 - with: - shared-key: spacetimedb - save-cache: false - - - uses: actions/setup-dotnet@v3 - with: - global-json-file: global.json - - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: 18 - - - uses: pnpm/action-setup@v4 - with: - run_install: true - - - name: Create /stdb dir - run: | - sudo mkdir /stdb - sudo chmod 777 /stdb - - - name: Build typescript module sdk - working-directory: crates/bindings-typescript - run: pnpm build - - - name: Run cargo test - #Note: Unreal tests will be run separately - run: cargo test --all -- --skip unreal - - - name: Run fallocate tests - run: cargo test -p spacetimedb-durability --features fallocate - - - name: Check that the test outputs are up-to-date - run: bash tools/check-diff.sh - - - name: Ensure C# autogen bindings are up-to-date - run: | - cargo run -p spacetimedb-codegen --example regen-csharp-moduledef - bash tools/check-diff.sh crates/bindings-csharp - - - name: C# bindings tests - working-directory: crates/bindings-csharp - run: dotnet test -warnaserror - - lints: - name: Lints - runs-on: spacetimedb-runner - env: - CARGO_TARGET_DIR: target - steps: - - name: Checkout sources - uses: actions/checkout@v3 - - - uses: dsherret/rust-toolchain-file@v1 - - run: echo ::add-matcher::.github/workflows/rust_matcher.json - - - name: Cache Rust dependencies - uses: Swatinem/rust-cache@v2 - with: - shared-key: spacetimedb - save-cache: false - - - uses: actions/setup-dotnet@v3 - with: - global-json-file: global.json - - - name: Run cargo fmt - run: cargo fmt --all -- --check - - - name: Run cargo clippy - run: cargo clippy --all --tests --benches -- -D warnings - - - name: Run C# formatting check - working-directory: crates/bindings-csharp - run: | - dotnet tool restore - dotnet csharpier --check . - - - name: Run `cargo doc` for bindings crate - # `bindings` is the only crate we care strongly about documenting, - # since we link to its docs.rs from our website. - # We won't pass `--no-deps`, though, - # since we want everything reachable through it to also work. - # This includes `sats` and `lib`. - working-directory: crates/bindings - env: - # Make `cargo doc` exit with error on warnings, most notably broken links - RUSTDOCFLAGS: '--deny warnings' - run: | - cargo doc - - wasm_bindings: - name: Build and test wasm bindings - runs-on: spacetimedb-runner - env: - CARGO_TARGET_DIR: target - steps: - - uses: actions/checkout@v3 - - - uses: dsherret/rust-toolchain-file@v1 - - run: echo ::add-matcher::.github/workflows/rust_matcher.json - - - name: Cache Rust dependencies - uses: Swatinem/rust-cache@v2 - with: - shared-key: spacetimedb - save-cache: false - - - name: Run bindgen tests - run: cargo test -p spacetimedb-codegen - - # Make sure the `Cargo.lock` file reflects the latest available versions. - # This is what users would end up with on a fresh module, so we want to - # catch any compile errors arising from a different transitive closure - # of dependencies than what is in the workspace lock file. - # - # For context see also: https://github.com/clockworklabs/SpacetimeDB/pull/2714 - - name: Update dependencies - run: cargo update - - - name: Build module-test - run: cargo run -p spacetimedb-cli -- build --project-path modules/module-test - - - publish_checks: - name: Check that packages are publishable - runs-on: ubuntu-latest - permissions: read-all - steps: - - uses: actions/checkout@v3 - - name: Set up Python env - run: | - test -d venv || python3 -m venv venv - venv/bin/pip3 install argparse toml - - name: Run checks - run: | - FAILED=0 - # This definition of ROOTS and invocation of find-publish-list.py is copied from publish-crates.sh - ROOTS=(bindings sdk cli standalone) - for crate in $(venv/bin/python3 tools/find-publish-list.py --recursive --quiet "${ROOTS[@]}"); do - if ! venv/bin/python3 tools/crate-publish-checks.py "crates/$crate"; then - FAILED=$(( $FAILED + 1 )) - fi - done - if [ $FAILED -gt 0 ]; then - exit 1 - fi - - update: - name: Test spacetimedb-update flow - permissions: read-all - strategy: - matrix: - include: - - { target: x86_64-unknown-linux-gnu, runner: spacetimedb-runner } - - { target: aarch64-unknown-linux-gnu, runner: arm-runner } - - { target: aarch64-apple-darwin, runner: macos-latest } - - { target: x86_64-pc-windows-msvc, runner: windows-latest } - runs-on: ${{ matrix.runner }} - env: - CARGO_TARGET_DIR: target - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Install Rust - uses: dsherret/rust-toolchain-file@v1 - - - name: Install rust target - run: rustup target add ${{ matrix.target }} - - - name: Cache Rust dependencies - uses: Swatinem/rust-cache@v2 - with: - shared-key: spacetimedb - save-cache: false - - - name: Install packages - if: ${{ matrix.runner == 'arm-runner' }} - shell: bash - run: sudo apt install -y libssl-dev - - - name: Build spacetimedb-update - run: cargo build --features github-token-auth --target ${{ matrix.target }} -p spacetimedb-update - - - name: Run self-install - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - shell: bash - run: | - ROOT_DIR="$(mktemp -d)" - # 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). - cargo run --features github-token-auth --target ${{ matrix.target }} -p spacetimedb-update -- self-install --root-dir="${ROOT_DIR}" --yes - "${ROOT_DIR}"/spacetime --root-dir="${ROOT_DIR}" help - - unreal_engine_tests: - name: Unreal Engine Tests - # This can't go on e.g. ubuntu-latest because that runner runs out of disk space. ChatGPT suggested that the general solution tends to be to use - # a custom runner. - runs-on: spacetimedb-runner - # Skip if this is an external contribution. GitHub secrets will be empty, so the step would fail anyway. - if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork }} - container: - image: ghcr.io/epicgames/unreal-engine:dev-5.6 - credentials: - # Note(bfops): I don't think that `github.actor` needs to match the user that the token is for, because I'm using a token for my account and - # it seems to be totally happy. - # However, the token needs to be for a user that has access to the EpicGames org (see - # https://dev.epicgames.com/documentation/en-us/unreal-engine/downloading-source-code-in-unreal-engine?application_version=5.6) - username: ${{ github.actor }} - password: ${{ secrets.GHCR_TOKEN }} - # Run as root because otherwise we get permission denied for various directories inside the container. I tried doing dances to allow it to run - # without this (reassigning env vars and stuff), but was unable to get it to work and it felt like an uphill battle. - options: --user 0:0 - steps: -# Uncomment this before merging so that it will run properly if run manually through the GH actions flow. It was playing weird with rolled back -# commits though. -# - name: Find Git ref -# env: -# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# shell: bash -# run: | -# PR_NUMBER="${{ github.event.inputs.pr_number || null }}" -# if test -n "${PR_NUMBER}"; then -# GIT_REF="$( gh pr view --repo clockworklabs/SpacetimeDB $PR_NUMBER --json headRefName --jq .headRefName )" -# else -# GIT_REF="${{ github.ref }}" -# fi -# echo "GIT_REF=${GIT_REF}" >>"$GITHUB_ENV" - - name: Checkout sources - uses: actions/checkout@v4 - with: - ref: ${{ env.GIT_REF }} - - uses: dsherret/rust-toolchain-file@v1 - - name: Run Unreal Engine tests - working-directory: sdks/unreal - env: - UE_ROOT_PATH: /home/ue4/UnrealEngine - run: | - - apt-get update - apt-get install -y acl curl ca-certificates - - REPO="$GITHUB_WORKSPACE" - # Let ue4 read/write the workspace & tool caches without changing ownership - for p in "$REPO" "${RUNNER_TEMP:-/__t}" "${RUNNER_TOOL_CACHE:-/__t}"; do - [ -d "$p" ] && setfacl -R -m u:ue4:rwX -m d:u:ue4:rwX "$p" || true - done - - # Rust tool caches live under the runner tool cache so they persist - export CARGO_HOME="${RUNNER_TOOL_CACHE:-/__t}/cargo" - export RUSTUP_HOME="${RUNNER_TOOL_CACHE:-/__t}/rustup" - mkdir -p "$CARGO_HOME" "$RUSTUP_HOME" - chown -R ue4:ue4 "$CARGO_HOME" "$RUSTUP_HOME" - - # Make sure the UE build script is executable (and parents traversable) - UE_DIR="${UE_ROOT_PATH:-/home/ue4/UnrealEngine}" - chmod a+rx "$UE_DIR" "$UE_DIR/Engine" "$UE_DIR/Engine/Build" "$UE_DIR/Engine/Build/BatchFiles/Linux" || true - chmod a+rx "$UE_DIR/Engine/Build/BatchFiles/Linux/Build.sh" || true - - # Run the build & tests as ue4 (who owns the UE tree) - sudo -E -H -u ue4 env \ - HOME=/home/ue4 \ - XDG_CONFIG_HOME=/home/ue4/.config \ - CARGO_HOME="$CARGO_HOME" \ - RUSTUP_HOME="$RUSTUP_HOME" \ - PATH="$CARGO_HOME/bin:$PATH" \ - bash -lc ' - set -euxo pipefail - # Install rustup for ue4 if needed (uses the shared caches) - if ! command -v cargo >/dev/null 2>&1; then - curl -sSf https://sh.rustup.rs | sh -s -- -y - fi - rustup show >/dev/null - git config --global --add safe.directory "$GITHUB_WORKSPACE" || true - - cd "$GITHUB_WORKSPACE/sdks/unreal" - cargo --version - cargo test - ' - - cli_docs: - name: Check CLI docs - permissions: read-all - runs-on: ubuntu-latest - env: - CARGO_TARGET_DIR: target - steps: - - name: Find Git ref - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - shell: bash - run: | - PR_NUMBER="${{ github.event.inputs.pr_number || null }}" - if test -n "${PR_NUMBER}"; then - GIT_REF="$( gh pr view --repo clockworklabs/SpacetimeDB $PR_NUMBER --json headRefName --jq .headRefName )" - else - GIT_REF="${{ github.ref }}" - fi - echo "GIT_REF=${GIT_REF}" >>"$GITHUB_ENV" - - - name: Checkout sources - uses: actions/checkout@v4 - with: - ref: ${{ env.GIT_REF }} - - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: 18 - - - uses: pnpm/action-setup@v4 - with: - run_install: true - - - name: Get pnpm store directory - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - - uses: actions/cache@v4 - name: Setup pnpm cache - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - uses: dsherret/rust-toolchain-file@v1 - - - name: Cache Rust dependencies - uses: Swatinem/rust-cache@v2 - with: - shared-key: spacetimedb - save-cache: false - - - name: Check for docs change - run: | - cargo run --features markdown-docs -p spacetimedb-cli > docs/docs/cli-reference.md - pnpm format - git status - if git diff --exit-code HEAD; then - echo "No docs changes detected" - else - echo "It looks like the CLI docs have changed:" - exit 1 - fi diff --git a/.github/workflows/csharp-test.yml b/.github/workflows/csharp-test.yml deleted file mode 100644 index 72885aa91a3..00000000000 --- a/.github/workflows/csharp-test.yml +++ /dev/null @@ -1,166 +0,0 @@ -name: C#/Unity - Test Suite - -on: - push: - branches: - - master - pull_request: - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || format('sha-{0}', github.sha) }} - cancel-in-progress: true - -jobs: - unity-testsuite: - runs-on: spacetimedb-runner - # Cancel any previous testsuites running on the same PR and/or ref. - concurrency: - group: unity-test-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - timeout-minutes: 30 - env: - CARGO_TARGET_DIR: target - steps: - - name: Checkout repository - id: checkout-stdb - uses: actions/checkout@v4 - - # Run cheap .NET tests first. If those fail, no need to run expensive Unity tests. - - - name: Setup dotnet - uses: actions/setup-dotnet@v3 - with: - global-json-file: global.json - - - name: Override NuGet packages - run: | - dotnet pack crates/bindings-csharp/BSATN.Runtime - dotnet pack crates/bindings-csharp/Runtime - - # Write out the nuget config file to `nuget.config`. This causes the spacetimedb-csharp-sdk repository - # to be aware of the local versions of the `bindings-csharp` packages in SpacetimeDB, and use them if - # available. Otherwise, `spacetimedb-csharp-sdk` will use the NuGet versions of the packages. - # This means that (if version numbers match) we will test the local versions of the C# packages, even - # if they're not pushed to NuGet. - # See https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file for more info on the config file. - cd sdks/csharp - ./tools~/write-nuget-config.sh ../.. - - - name: Run .NET tests - working-directory: sdks/csharp - run: dotnet test -warnaserror - - - name: Verify C# formatting - working-directory: sdks/csharp - run: dotnet format --no-restore --verify-no-changes SpacetimeDB.ClientSDK.sln - - # Now, setup the Unity tests. - - - name: Patch spacetimedb dependency in Cargo.toml - working-directory: demo/Blackholio/server-rust - run: | - sed -i "s|spacetimedb *=.*|spacetimedb = \{ path = \"../../../crates/bindings\" \}|" Cargo.toml - cat Cargo.toml - - - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@stable - - - name: Cache Rust dependencies - uses: Swatinem/rust-cache@v2 - with: - shared-key: spacetimedb - save-cache: false - - - name: Install SpacetimeDB CLI from the local checkout - run: | - cargo install --force --path crates/cli --locked --message-format=short - cargo install --force --path crates/standalone --locked --message-format=short - # Add a handy alias using the old binary name, so that we don't have to rewrite all scripts (incl. in submodules). - ln -sf $HOME/.cargo/bin/spacetimedb-cli $HOME/.cargo/bin/spacetime - - - name: Check quickstart-chat bindings are up to date - working-directory: sdks/csharp - run: | - bash tools~/gen-quickstart.sh - "${GITHUB_WORKSPACE}"/tools/check-diff.sh examples~/quickstart-chat || { - echo 'Error: quickstart-chat bindings have changed. Please run `sdks/csharp/tools~/gen-quickstart.sh`.' - exit 1 - } - - - name: Check client-api bindings are up to date - working-directory: sdks/csharp - run: | - bash tools~/gen-client-api.sh - "${GITHUB_WORKSPACE}"/tools/check-diff.sh src/SpacetimeDB/ClientApi || { - echo 'Error: Client API bindings are dirty. Please run `sdks/csharp/tools~/gen-client-api.sh`.' - exit 1 - } - - - name: Generate client bindings - working-directory: demo/Blackholio/server-rust - run: bash ./generate.sh -y - - - name: Check for changes - run: | - tools/check-diff.sh demo/Blackholio/client-unity/Assets/Scripts/autogen || { - echo 'Error: Bindings are dirty. Please run `demo/Blackholio/server-rust/generate.sh`.' - exit 1 - } - - - name: Check Unity meta files - uses: DeNA/unity-meta-check@v3 - with: - enable_pr_comment: ${{ github.event_name == 'pull_request' }} - target_path: sdks/csharp - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - - - name: Start SpacetimeDB - run: | - spacetime start & - disown - - - name: Run regression tests - run: | - bash sdks/csharp/tools~/run-regression-tests.sh - tools/check-diff.sh sdks/csharp/examples~/regression-tests || { - echo 'Error: Bindings are dirty. Please run `sdks/csharp/tools~/gen-regression-tests.sh`.' - exit 1 - } - - - name: Publish unity-tests module to SpacetimeDB - working-directory: demo/Blackholio/server-rust - run: | - spacetime logout && spacetime login --server-issued-login local - bash ./publish.sh - - - name: Patch com.clockworklabs.spacetimedbsdk dependency in manifest.json - working-directory: demo/Blackholio/client-unity/Packages - run: | - # Replace the com.clockworklabs.spacetimedbsdk dependency with the current branch. - # Note: Pointing to a local directory does not work, because our earlier steps nuke our meta files, which then causes Unity to not properly respect the DLLs (e.g. - # codegen does not work properly). - yq e -i '.dependencies["com.clockworklabs.spacetimedbsdk"] = "https://github.com/clockworklabs/SpacetimeDB.git?path=sdks/csharp#${{ github.head_ref }}"' manifest.json - cat manifest.json - - - uses: actions/cache@v3 - with: - path: demo/Blackholio/client-unity/Library - key: Unity-${{ github.head_ref }} - restore-keys: Unity- - - - name: Run Unity tests - uses: game-ci/unity-test-runner@v4 - with: - unityVersion: 2022.3.32f1 # Adjust Unity version to a valid tag - projectPath: demo/Blackholio/client-unity # Path to the Unity project subdirectory - githubToken: ${{ secrets.GITHUB_TOKEN }} - testMode: playmode - useHostNetwork: true - env: - UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} - UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} - UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }} - # Skip if this is an external contribution. - # The license secrets will be empty, so the step would fail anyway. - if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork }} diff --git a/.github/workflows/typescript-lint.yml b/.github/workflows/typescript-lint.yml deleted file mode 100644 index fe6649fd501..00000000000 --- a/.github/workflows/typescript-lint.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: TypeScript - Lint - -on: - pull_request: - push: - branches: - - master - merge_group: - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: 18 - - - uses: pnpm/action-setup@v4 - with: - run_install: true - - - name: Get pnpm store directory - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - - uses: actions/cache@v4 - name: Setup pnpm cache - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: Lint - run: pnpm lint diff --git a/.github/workflows/typescript-test.yml b/.github/workflows/typescript-test.yml deleted file mode 100644 index 9a1924eec56..00000000000 --- a/.github/workflows/typescript-test.yml +++ /dev/null @@ -1,141 +0,0 @@ -name: TypeScript - Tests - -on: - push: - branches: - - master - pull_request: - merge_group: - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || format('sha-{0}', github.sha) }} - cancel-in-progress: true - -jobs: - build-and-test: - runs-on: ubuntu-latest - env: - CARGO_TARGET_DIR: target - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: 18 - - - uses: pnpm/action-setup@v4 - with: - run_install: true - - - name: Get pnpm store directory - shell: bash - working-directory: crates/bindings-typescript - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - - uses: actions/cache@v4 - name: Setup pnpm cache - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: Build module library and SDK - working-directory: crates/bindings-typescript - run: pnpm build - - - name: Run module library and SDK tests - working-directory: crates/bindings-typescript - run: pnpm test - - # - name: Extract SpacetimeDB branch name from file - # id: extract-branch - # run: | - # # Define the path to the branch file - # BRANCH_FILE=".github/spacetimedb-branch.txt" - - # # Default to master if file doesn't exist - # if [ ! -f "$BRANCH_FILE" ]; then - # echo "::notice::No SpacetimeDB branch file found, using 'master'" - # echo "branch=master" >> $GITHUB_OUTPUT - # exit 0 - # fi - - # # Read and trim whitespace from the file - # branch=$(cat "$BRANCH_FILE" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') - - # # Fallback to master if empty - # if [ -z "$branch" ]; then - # echo "::warning::SpacetimeDB branch file is empty, using 'master'" - # branch="master" - # fi - - # echo "branch=$branch" >> $GITHUB_OUTPUT - # echo "Using SpacetimeDB branch from file: $branch" - - - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@stable - - - name: Cache Rust dependencies - uses: Swatinem/rust-cache@v2 - with: - shared-key: spacetimedb - save-cache: false - - - name: Install SpacetimeDB CLI from the local checkout - run: | - cargo install --force --path crates/cli --locked --message-format=short - cargo install --force --path crates/standalone --locked --message-format=short - # Add a handy alias using the old binary name, so that we don't have to rewrite all scripts (incl. in submodules). - rm -f $HOME/.cargo/bin/spacetime - ln -s $HOME/.cargo/bin/spacetimedb-cli $HOME/.cargo/bin/spacetime - # Clear any existing information - spacetime server clear -y - - - name: Generate client bindings - working-directory: modules/quickstart-chat - run: | - spacetime generate --lang typescript --out-dir ../../crates/bindings-typescript/examples/quickstart-chat/src/module_bindings - cd ../../crates/bindings-typescript - pnpm format - - - name: Check for changes - working-directory: crates/bindings-typescript - run: | - "${GITHUB_WORKSPACE}"/tools/check-diff.sh examples/quickstart-chat/src/module_bindings || { - echo "Error: Bindings are dirty. Please generate bindings again and commit them to this branch." - exit 1 - } - - # - name: Start SpacetimeDB - # run: | - # spacetime start & - # disown - - # - name: Publish module to SpacetimeDB - # working-directory: SpacetimeDB/modules/quickstart-chat - # run: | - # spacetime logout && spacetime login --server-issued-login local - # spacetime publish -s local quickstart-chat -c -y - - # - name: Publish module to SpacetimeDB - # working-directory: SpacetimeDB/modules/quickstart-chat - # run: | - # spacetime logs quickstart-chat - - - name: Check that quickstart-chat builds - working-directory: crates/bindings-typescript/examples/quickstart-chat - run: pnpm build - - # - name: Run quickstart-chat tests - # working-directory: examples/quickstart-chat - # run: pnpm test - # - # # Run this step always, even if the previous steps fail - # - name: Print rows in the user table - # if: always() - # run: spacetime sql quickstart-chat "SELECT * FROM user" From 3b5e57d580b58a4b7734f4bcc123de38fb926978 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 12 Nov 2025 17:52:11 -0800 Subject: [PATCH 21/91] [bfops/ci-caching]: reduce ci --- .github/workflows/docs-publish.yaml | 56 -------------- .github/workflows/docs-test.yaml | 44 ----------- .github/workflows/internal-tests.yml | 112 --------------------------- 3 files changed, 212 deletions(-) delete mode 100644 .github/workflows/docs-publish.yaml delete mode 100644 .github/workflows/docs-test.yaml delete mode 100644 .github/workflows/internal-tests.yml diff --git a/.github/workflows/docs-publish.yaml b/.github/workflows/docs-publish.yaml deleted file mode 100644 index 71aa42ae8df..00000000000 --- a/.github/workflows/docs-publish.yaml +++ /dev/null @@ -1,56 +0,0 @@ -name: Docs / Publish - -permissions: - contents: read - -on: - push: - branches: - - docs/release - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: '22' - - - uses: pnpm/action-setup@v4 - with: - run_install: true - - - name: Get pnpm store directory - working-directory: sdks/typescript - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - - uses: actions/cache@v4 - name: Setup pnpm cache - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: Install dependencies - working-directory: docs - run: pnpm install - - - name: Docusaurus build - working-directory: docs - run: pnpm build - - - name: Publish docs to S3 - uses: shallwefootball/s3-upload-action@master - with: - aws_key_id: ${{ secrets.DOCS_AWS_KEY_ID }} - aws_secret_access_key: ${{ secrets.DOCS_AWS_SECRET_ACCESS_KEY}} - aws_bucket: spacetimedb-docs - source_dir: docs/build - destination_dir: 'docs' diff --git a/.github/workflows/docs-test.yaml b/.github/workflows/docs-test.yaml deleted file mode 100644 index 489f1fb194b..00000000000 --- a/.github/workflows/docs-test.yaml +++ /dev/null @@ -1,44 +0,0 @@ -name: Docs / Test -permissions: - contents: read - -on: - pull_request: - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: '22' - - - uses: pnpm/action-setup@v4 - with: - run_install: true - - - name: Get pnpm store directory - working-directory: sdks/typescript - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - - uses: actions/cache@v4 - name: Setup pnpm cache - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: Install dependencies - working-directory: docs - run: pnpm install - - - name: Docusaurus build - working-directory: docs - run: pnpm build diff --git a/.github/workflows/internal-tests.yml b/.github/workflows/internal-tests.yml deleted file mode 100644 index 3afdc6c0dde..00000000000 --- a/.github/workflows/internal-tests.yml +++ /dev/null @@ -1,112 +0,0 @@ -on: - pull_request: - push: - branches: - - master - -name: Internal Tests - -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || format('sha-{0}', github.sha) }} - cancel-in-progress: true - -jobs: - run-tests: - # Skip if this is an external contribution. GitHub secrets will be empty, so the step would fail anyway. - if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork }} - runs-on: ubuntu-latest - steps: - - name: Trigger and wait for Internal Tests - uses: actions/github-script@v7 - with: - github-token: ${{ secrets.SPACETIMEDB_PRIVATE_TOKEN }} - script: | - const targetOwner = 'clockworklabs'; - const targetRepo = 'SpacetimeDBPrivate'; - const workflowId = 'ci.yml'; - const targetRef = 'master'; - // Use the ref for pull requests because the head sha is brittle (github does some extra dance where it merges in master). - const publicRef = (context.eventName === 'pull_request') ? context.payload.pull_request.head.ref : context.sha; - const preDispatch = new Date().toISOString(); - - console.log("context.eventName =", context.eventName); - console.log("context.ref =", context.ref); - console.log("context.sha =", context.sha); - console.log("Dispatch workflow with publicRef =", publicRef); - - // Dispatch the workflow in the target repository - await github.rest.actions.createWorkflowDispatch({ - owner: targetOwner, - repo: targetRepo, - workflow_id: workflowId, - ref: targetRef, - inputs: { public_ref: publicRef } - }); - - const sleep = (ms) => new Promise(r => setTimeout(r, ms)); - - // Wait for workflow to be kicked off - await sleep(30000); - - // Find the dispatched run by name - let runId = null; - for (let attempt = 0; attempt < 20 && !runId; attempt++) { // up to ~10 minutes to locate the run - const runsResp = await github.rest.actions.listWorkflowRuns({ - owner: targetOwner, - repo: targetRepo, - workflow_id: workflowId, - event: 'workflow_dispatch', - branch: targetRef, - per_page: 50, - }); - - const expectedName = `CI [public_ref=${publicRef}]`; - const candidates = runsResp.data.workflow_runs - .filter(r => r.name === expectedName && new Date(r.created_at) >= new Date(preDispatch)) - .sort((a, b) => new Date(b.created_at) - new Date(a.created_at)); - - if (candidates.length > 0) { - runId = candidates[0].id; - break; - } - await sleep(30000); - } - - if (!runId) { - core.setFailed('Failed to locate dispatched run in the private repository.'); - return; - } - - // Provide direct link and context prior to waiting - const runUrl = `https://github.com/${targetOwner}/${targetRepo}/actions/runs/${runId}`; - core.info(`View run: ${runUrl}`); - core.info('Waiting for workflow result...'); - - // Wait for completion - let conclusion = null; - for (let attempt = 0; attempt < 240; attempt++) { // up to ~2 hours - const runResp = await github.rest.actions.getWorkflowRun({ - owner: targetOwner, - repo: targetRepo, - run_id: runId - }); - const { status, conclusion: c } = runResp.data; - if (status === 'completed') { - conclusion = c || 'success'; - break; - } - await sleep(30000); - } - - if (!conclusion) { - core.setFailed('Timed out waiting for private workflow to complete.'); - return; - } - - core.info(`Private workflow conclusion: ${conclusion}`); - if (conclusion !== 'success') { - core.setFailed(`Private workflow failed with conclusion: ${conclusion}`); - } From ac437f840a4e502a0064bb307af832d12aa53855 Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Thu, 13 Nov 2025 02:10:28 +0000 Subject: [PATCH 22/91] Run smoketests on the custom runner --- .github/workflows/ci.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e0426074b8b..275ce260a07 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,10 +23,14 @@ jobs: strategy: matrix: include: - - { runner: spacetimedb-runner, smoketest_args: --docker } + - { runner: spacetimedb-new-runner, smoketest_args: --docker } - { runner: windows-latest, smoketest_args: --no-build-cli } - runner: [ spacetimedb-runner, windows-latest ] runs-on: ${{ matrix.runner }} + + # Add container only for Linux runner + container: ${{ matrix.runner == 'spacetimedb-new-runner' && 'localhost:5000/spacetimedb-ci:latest' || '' }} + runs-on: ${{ matrix.runner }} + steps: - name: Find Git ref env: From 3adead23e7cefd394fcc44cd138bdb070dd4429a Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 12 Nov 2025 19:25:58 -0800 Subject: [PATCH 23/91] [bfops/ci-caching]: debugging --- .github/workflows/ci.yml | 4 +++- crates/standalone/Dockerfile | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eee3a5dbcc2..1e4a7b59796 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -75,7 +75,9 @@ jobs: run: cargo build -p spacetimedb-cli -p spacetimedb-standalone -p spacetimedb-update - name: Build and start database (Linux) if: runner.os == 'Linux' - run: docker compose up -d + run: | + find target/ + docker compose up -d - name: Build and start database (Windows) if: runner.os == 'Windows' run: | diff --git a/crates/standalone/Dockerfile b/crates/standalone/Dockerfile index f17a9c9fe14..516d0487058 100644 --- a/crates/standalone/Dockerfile +++ b/crates/standalone/Dockerfile @@ -3,11 +3,12 @@ FROM debian:bookworm-slim AS builder WORKDIR /usr/src/app COPY . . +RUN find target/ FROM debian:bookworm-slim # Copy over SpacetimeDB -COPY --from=builder --chmod=755 /usr/src/app/target/debug/spacetimedb-standalone /usr/src/app/target/debug/spacetimedb-cli /opt/spacetime/ +COPY --chmod=755 target/debug/spacetimedb-standalone target/debug/spacetimedb-cli /opt/spacetime/ RUN ln -s /opt/spacetime/spacetimedb-cli /usr/local/bin/spacetime # Create and switch to a non-root user From bb4aff89ca963df099a8c37f0fde637162d170b7 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 12 Nov 2025 19:30:53 -0800 Subject: [PATCH 24/91] [bfops/ci-caching]: output --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e4a7b59796..eba45569f28 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,7 +76,10 @@ jobs: - name: Build and start database (Linux) if: runner.os == 'Linux' run: | + set -x find target/ + echo "${CARGO_TARGET_DIR}" + find "${CARGO_TARGET_DIR}" docker compose up -d - name: Build and start database (Windows) if: runner.os == 'Windows' From f2d184b42b4656269e8102fe0fb89f45114ce243 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 12 Nov 2025 19:31:39 -0800 Subject: [PATCH 25/91] [bfops/ci-caching]: reduce --- .github/workflows/ci.yml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eba45569f28..a6f82998715 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,19 +53,6 @@ jobs: shared-key: spacetimedb cache-on-failure: true cache-all-crates: true - - uses: actions/setup-dotnet@v4 - with: - global-json-file: global.json - - # nodejs and pnpm are required for the typescript quickstart smoketest - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: 18 - - - uses: pnpm/action-setup@v4 - with: - run_install: true - name: Install psql (Windows) if: runner.os == 'Windows' From beb7dbc3208883be17b11674b72743969713c4ed Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 12 Nov 2025 19:36:07 -0800 Subject: [PATCH 26/91] [bfops/ci-caching]: more --- .github/workflows/ci.yml | 7 +------ crates/standalone/Dockerfile | 1 + 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a6f82998715..3d6a9d50597 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,12 +62,7 @@ jobs: run: cargo build -p spacetimedb-cli -p spacetimedb-standalone -p spacetimedb-update - name: Build and start database (Linux) if: runner.os == 'Linux' - run: | - set -x - find target/ - echo "${CARGO_TARGET_DIR}" - find "${CARGO_TARGET_DIR}" - docker compose up -d + run: docker compose up -d - name: Build and start database (Windows) if: runner.os == 'Windows' run: | diff --git a/crates/standalone/Dockerfile b/crates/standalone/Dockerfile index 516d0487058..e9466478871 100644 --- a/crates/standalone/Dockerfile +++ b/crates/standalone/Dockerfile @@ -9,6 +9,7 @@ FROM debian:bookworm-slim # Copy over SpacetimeDB COPY --chmod=755 target/debug/spacetimedb-standalone target/debug/spacetimedb-cli /opt/spacetime/ +COPY --from=builder --chmod=755 /usr/src/app/target/debug/spacetimedb-standalone /usr/src/app/target/debug/spacetimedb-cli /opt/spacetime/ RUN ln -s /opt/spacetime/spacetimedb-cli /usr/local/bin/spacetime # Create and switch to a non-root user From 04d575d46deb3fbfb2cc350ba43fa67d53aabb59 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 12 Nov 2025 19:36:45 -0800 Subject: [PATCH 27/91] [bfops/ci-caching]: fix --- crates/standalone/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/standalone/Dockerfile b/crates/standalone/Dockerfile index e9466478871..b5c05d4ab6e 100644 --- a/crates/standalone/Dockerfile +++ b/crates/standalone/Dockerfile @@ -4,12 +4,13 @@ FROM debian:bookworm-slim AS builder WORKDIR /usr/src/app COPY . . RUN find target/ +RUN find /usr/src/app/target FROM debian:bookworm-slim # Copy over SpacetimeDB -COPY --chmod=755 target/debug/spacetimedb-standalone target/debug/spacetimedb-cli /opt/spacetime/ COPY --from=builder --chmod=755 /usr/src/app/target/debug/spacetimedb-standalone /usr/src/app/target/debug/spacetimedb-cli /opt/spacetime/ +COPY --chmod=755 target/debug/spacetimedb-standalone target/debug/spacetimedb-cli /opt/spacetime/ RUN ln -s /opt/spacetime/spacetimedb-cli /usr/local/bin/spacetime # Create and switch to a non-root user From b468015e51ee33a812d6fd1d94cc135ad5496702 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 12 Nov 2025 19:37:42 -0800 Subject: [PATCH 28/91] [bfops/ci-caching]: confusing --- Dockerfile | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 752e671bc5b..00000000000 --- a/Dockerfile +++ /dev/null @@ -1,25 +0,0 @@ -# Use a base image that supports multi-arch -FROM debian:bookworm-slim AS builder - -WORKDIR /usr/src/app -COPY . . - -FROM debian:bookworm-slim - -# Copy over SpacetimeDB -COPY --from=builder --chmod=755 /usr/src/app/target/release/spacetimedb-standalone /usr/src/app/target/release/spacetimedb-cli /opt/spacetime/ -RUN ln -s /opt/spacetime/spacetimedb-cli /usr/local/bin/spacetime - -# Create and switch to a non-root user -RUN useradd -m spacetime -USER spacetime - -# Set working directory -WORKDIR /app - -# Expose the necessary port -EXPOSE 3000 - -# Define the entrypoint -ENTRYPOINT ["spacetime"] - From bf002631c56dffb34dacd3427484b6674c2ceabe Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 12 Nov 2025 19:38:18 -0800 Subject: [PATCH 29/91] [bfops/ci-caching]: maybe --- crates/standalone/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/standalone/Dockerfile b/crates/standalone/Dockerfile index b5c05d4ab6e..2b112485ee3 100644 --- a/crates/standalone/Dockerfile +++ b/crates/standalone/Dockerfile @@ -10,7 +10,7 @@ FROM debian:bookworm-slim # Copy over SpacetimeDB COPY --from=builder --chmod=755 /usr/src/app/target/debug/spacetimedb-standalone /usr/src/app/target/debug/spacetimedb-cli /opt/spacetime/ -COPY --chmod=755 target/debug/spacetimedb-standalone target/debug/spacetimedb-cli /opt/spacetime/ +COPY --chmod=755 ./target/debug/spacetimedb-standalone ./target/debug/spacetimedb-cli /opt/spacetime/ RUN ln -s /opt/spacetime/spacetimedb-cli /usr/local/bin/spacetime # Create and switch to a non-root user From 58c284c1810d4f11f8d5986c148d554c86d49c65 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 12 Nov 2025 19:42:50 -0800 Subject: [PATCH 30/91] [bfops/ci-caching]: review --- crates/standalone/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/standalone/Dockerfile b/crates/standalone/Dockerfile index 2b112485ee3..9947d6626f7 100644 --- a/crates/standalone/Dockerfile +++ b/crates/standalone/Dockerfile @@ -10,7 +10,6 @@ FROM debian:bookworm-slim # Copy over SpacetimeDB COPY --from=builder --chmod=755 /usr/src/app/target/debug/spacetimedb-standalone /usr/src/app/target/debug/spacetimedb-cli /opt/spacetime/ -COPY --chmod=755 ./target/debug/spacetimedb-standalone ./target/debug/spacetimedb-cli /opt/spacetime/ RUN ln -s /opt/spacetime/spacetimedb-cli /usr/local/bin/spacetime # Create and switch to a non-root user From ce882d48521b21e870ce2697bed3979cd9d05c6c Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 12 Nov 2025 19:46:38 -0800 Subject: [PATCH 31/91] [bfops/ci-caching]: review --- crates/standalone/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/standalone/Dockerfile b/crates/standalone/Dockerfile index 9947d6626f7..c1a58895496 100644 --- a/crates/standalone/Dockerfile +++ b/crates/standalone/Dockerfile @@ -3,7 +3,6 @@ FROM debian:bookworm-slim AS builder WORKDIR /usr/src/app COPY . . -RUN find target/ RUN find /usr/src/app/target FROM debian:bookworm-slim From fa624f90db73c3c4257efc9e6165e8a47d1604d1 Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Thu, 13 Nov 2025 02:13:14 +0000 Subject: [PATCH 32/91] Rerun CI Updated Runner fix Don't install dotnet in the container for smoketests Rerun Use container settings Rerun again Try again Yet another run Dont use runner user Try again Test ephemeral runners --- .github/workflows/ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 275ce260a07..b6489385d53 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,14 +23,13 @@ jobs: strategy: matrix: include: - - { runner: spacetimedb-new-runner, smoketest_args: --docker } - - { runner: windows-latest, smoketest_args: --no-build-cli } + - { runner: spacetimedb-new-runner, smoketest_args: --docker, use_container: true } + - { runner: windows-latest, smoketest_args: --no-build-cli, use_container: false } runs-on: ${{ matrix.runner }} # Add container only for Linux runner - container: ${{ matrix.runner == 'spacetimedb-new-runner' && 'localhost:5000/spacetimedb-ci:latest' || '' }} - runs-on: ${{ matrix.runner }} - + container: ${{ matrix.use_container && fromJSON('{"image":"localhost:5000/spacetimedb-ci:latest","options":"--privileged -v /opt/github-runner/cargo-cache:/home/runner/.cargo/registry -v /opt/github-runner/cargo-git:/home/runner/.cargo/git"}') || null }} + steps: - name: Find Git ref env: @@ -49,7 +48,9 @@ jobs: with: ref: ${{ env.GIT_REF }} - uses: dsherret/rust-toolchain-file@v1 + # Only install .NET on Windows (not in container where it's pre-installed) - uses: actions/setup-dotnet@v4 + if: ${{ !matrix.use_container }} with: global-json-file: global.json @@ -103,7 +104,6 @@ jobs: container: image: localhost:5000/spacetimedb-ci:latest options: >- - --user runner --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /opt/github-runner/cargo-cache:/home/runner/.cargo/registry From 06d54171338f262bfeb6d46675ce1155da33d40e Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Thu, 13 Nov 2025 10:43:34 -0800 Subject: [PATCH 33/91] [bfops/ci-caching]: maybe? --- crates/standalone/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/standalone/Dockerfile b/crates/standalone/Dockerfile index c1a58895496..e12645acc97 100644 --- a/crates/standalone/Dockerfile +++ b/crates/standalone/Dockerfile @@ -3,7 +3,8 @@ FROM debian:bookworm-slim AS builder WORKDIR /usr/src/app COPY . . -RUN find /usr/src/app/target +RUN find ./target/ +RUN find /usr/src/app/ FROM debian:bookworm-slim From 75680369466ce65979643def28bce2c6e90af0ba Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Thu, 13 Nov 2025 10:46:01 -0800 Subject: [PATCH 34/91] [bfops/ci-caching]: more --- crates/standalone/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/standalone/Dockerfile b/crates/standalone/Dockerfile index e12645acc97..ee0544ec5f0 100644 --- a/crates/standalone/Dockerfile +++ b/crates/standalone/Dockerfile @@ -3,7 +3,7 @@ FROM debian:bookworm-slim AS builder WORKDIR /usr/src/app COPY . . -RUN find ./target/ +RUN find ./ RUN find /usr/src/app/ FROM debian:bookworm-slim From 139f85362f549e49e133c21d5ce37b2f644284e9 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Thu, 13 Nov 2025 10:51:25 -0800 Subject: [PATCH 35/91] [bfops/ci-caching]: debug --- .github/workflows/ci.yml | 5 ++++- crates/standalone/Dockerfile | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3d6a9d50597..b4566821990 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,7 +62,10 @@ jobs: run: cargo build -p spacetimedb-cli -p spacetimedb-standalone -p spacetimedb-update - name: Build and start database (Linux) if: runner.os == 'Linux' - run: docker compose up -d + run: | + echo "target dir is ${CARGO_TARGET_DIR}" + find "${CARGO_TARGET_DIR}" -type f -executable + docker compose up -d - name: Build and start database (Windows) if: runner.os == 'Windows' run: | diff --git a/crates/standalone/Dockerfile b/crates/standalone/Dockerfile index ee0544ec5f0..06ea3bddf8f 100644 --- a/crates/standalone/Dockerfile +++ b/crates/standalone/Dockerfile @@ -3,8 +3,8 @@ FROM debian:bookworm-slim AS builder WORKDIR /usr/src/app COPY . . -RUN find ./ -RUN find /usr/src/app/ +RUN pwd +RUN find ./ -maxdepth 1 FROM debian:bookworm-slim From 1e4f47fb43852a4002539805b9c40df4fc6f787d Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Thu, 13 Nov 2025 10:52:05 -0800 Subject: [PATCH 36/91] [bfops/ci-caching]: more --- crates/standalone/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/standalone/Dockerfile b/crates/standalone/Dockerfile index 06ea3bddf8f..19968c5c86f 100644 --- a/crates/standalone/Dockerfile +++ b/crates/standalone/Dockerfile @@ -5,6 +5,7 @@ WORKDIR /usr/src/app COPY . . RUN pwd RUN find ./ -maxdepth 1 +RUN find ./ -type f -executable FROM debian:bookworm-slim From e3efd65d266618834b2a35a03715b666e4eb49a0 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Thu, 13 Nov 2025 10:55:49 -0800 Subject: [PATCH 37/91] [bfops/ci-caching]: no ignore --- .dockerignore | 3 --- 1 file changed, 3 deletions(-) diff --git a/.dockerignore b/.dockerignore index a0014596128..e69de29bb2d 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +0,0 @@ -**/target -# we do our own version pinning in the Dockerfile -rust-toolchain.toml From e3afbda4fa4f6fb6605915cca09d4f5d1d800862 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Thu, 13 Nov 2025 10:57:14 -0800 Subject: [PATCH 38/91] [bfops/ci-caching]: reduce --- crates/standalone/Dockerfile | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/crates/standalone/Dockerfile b/crates/standalone/Dockerfile index 19968c5c86f..106ed91b1e6 100644 --- a/crates/standalone/Dockerfile +++ b/crates/standalone/Dockerfile @@ -1,16 +1,7 @@ -# Use a base image that supports multi-arch -FROM debian:bookworm-slim AS builder - -WORKDIR /usr/src/app -COPY . . -RUN pwd -RUN find ./ -maxdepth 1 -RUN find ./ -type f -executable - FROM debian:bookworm-slim # Copy over SpacetimeDB -COPY --from=builder --chmod=755 /usr/src/app/target/debug/spacetimedb-standalone /usr/src/app/target/debug/spacetimedb-cli /opt/spacetime/ +COPY --chmod=755 ./target/debug/spacetimedb-standalone ./target/debug/spacetimedb-cli /opt/spacetime/ RUN ln -s /opt/spacetime/spacetimedb-cli /usr/local/bin/spacetime # Create and switch to a non-root user From 22eaec5e10be943bf15cfd4e14d363a44b3d62c9 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Thu, 13 Nov 2025 10:58:24 -0800 Subject: [PATCH 39/91] [bfops/ci-caching]: remove volume --- docker-compose.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 039fd8d8e76..40f398a60a7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,7 +21,6 @@ services: - ./crates/client-api-messages:/usr/src/app/crates/client-api-messages - ./Cargo.toml:/usr/src/app/Cargo.toml - ./flamegraphs:/usr/src/app/flamegraphs - - ./target:/usr/src/app/target - key_files:/etc/spacetimedb - /stdb ports: From 7aa773b23065c2c123475e7cf2a1007d16b05aea Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Thu, 13 Nov 2025 11:00:59 -0800 Subject: [PATCH 40/91] [bfops/ci-caching]: fix --- crates/standalone/Dockerfile | 3 --- docker-compose.yml | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/standalone/Dockerfile b/crates/standalone/Dockerfile index 106ed91b1e6..0993b1d85a8 100644 --- a/crates/standalone/Dockerfile +++ b/crates/standalone/Dockerfile @@ -13,6 +13,3 @@ WORKDIR /app # Expose the necessary port EXPOSE 3000 - -# Define the entrypoint -ENTRYPOINT ["spacetime"] diff --git a/docker-compose.yml b/docker-compose.yml index 40f398a60a7..35328050d1a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,7 +29,7 @@ services: - "5432:5432" # Tracy - "8086:8086" - entrypoint: target/debug/spacetimedb-cli --data-dir=/stdb/data --jwt-pub-key-path=/etc/spacetimedb/id_ecdsa.pub --jwt-priv-key-path=/etc/spacetimedb/id_ecdsa --pg-port 5432 + entrypoint: spacetime start --data-dir=/stdb/data --jwt-pub-key-path=/etc/spacetimedb/id_ecdsa.pub --jwt-priv-key-path=/etc/spacetimedb/id_ecdsa --pg-port 5432 privileged: true environment: RUST_BACKTRACE: 1 From 7742d30ee53d57471ea92eb589945c9862b81e10 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Thu, 13 Nov 2025 11:11:51 -0800 Subject: [PATCH 41/91] [bfops/ci-caching]: logs --- .github/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b4566821990..01564bf9878 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,10 +62,7 @@ jobs: run: cargo build -p spacetimedb-cli -p spacetimedb-standalone -p spacetimedb-update - name: Build and start database (Linux) if: runner.os == 'Linux' - run: | - echo "target dir is ${CARGO_TARGET_DIR}" - find "${CARGO_TARGET_DIR}" -type f -executable - docker compose up -d + run: docker compose up -d - name: Build and start database (Windows) if: runner.os == 'Windows' run: | @@ -88,4 +85,7 @@ jobs: run: python -m smoketests ${{ matrix.smoketest_args }} -x clear_database replication teams - name: Stop containers (Linux) if: always() && runner.os == 'Linux' - run: docker compose down + run: | + docker ps || true + docker logs node || true + docker compose down From ee08d475559417a1060e50aaddfc82b1b366ee70 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Thu, 13 Nov 2025 11:20:26 -0800 Subject: [PATCH 42/91] [bfops/ci-caching]: WIP --- .github/workflows/ci.yml | 3 ++- crates/standalone/Dockerfile | 6 ++++-- docker-compose.yml | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 01564bf9878..26b8cd87053 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -86,6 +86,7 @@ jobs: - name: Stop containers (Linux) if: always() && runner.os == 'Linux' run: | - docker ps || true + set -x + docker ps -a || true docker logs node || true docker compose down diff --git a/crates/standalone/Dockerfile b/crates/standalone/Dockerfile index 0993b1d85a8..3ada7a610b6 100644 --- a/crates/standalone/Dockerfile +++ b/crates/standalone/Dockerfile @@ -1,9 +1,11 @@ -FROM debian:bookworm-slim +FROM ubuntu:24.04 # Copy over SpacetimeDB -COPY --chmod=755 ./target/debug/spacetimedb-standalone ./target/debug/spacetimedb-cli /opt/spacetime/ +COPY --chmod=755 ./spacetimedb-standalone ./spacetimedb-cli /opt/spacetime/ RUN ln -s /opt/spacetime/spacetimedb-cli /usr/local/bin/spacetime +RUN mkdir /stdb && chmod 777 /stdb + # Create and switch to a non-root user RUN useradd -m spacetime USER spacetime diff --git a/docker-compose.yml b/docker-compose.yml index 35328050d1a..a507ee62efa 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,11 +22,11 @@ services: - ./Cargo.toml:/usr/src/app/Cargo.toml - ./flamegraphs:/usr/src/app/flamegraphs - key_files:/etc/spacetimedb - - /stdb + - ./stdb:/stdb ports: - "3000:3000" # Postgres - - "5432:5432" + - "5433:5432" # Tracy - "8086:8086" entrypoint: spacetime start --data-dir=/stdb/data --jwt-pub-key-path=/etc/spacetimedb/id_ecdsa.pub --jwt-priv-key-path=/etc/spacetimedb/id_ecdsa --pg-port 5432 From d3bb169d5da8c682c72c1881b8d926afc80ee9aa Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Thu, 13 Nov 2025 11:27:58 -0800 Subject: [PATCH 43/91] [bfops/ci-caching]: update --- crates/standalone/Dockerfile | 23 ++++++++--------------- docker-compose.yml | 14 ++++++++++++-- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/crates/standalone/Dockerfile b/crates/standalone/Dockerfile index 3ada7a610b6..436230262a0 100644 --- a/crates/standalone/Dockerfile +++ b/crates/standalone/Dockerfile @@ -1,17 +1,10 @@ -FROM ubuntu:24.04 +FROM rust:1.90.0 +RUN mkdir -p /stdb/data +COPY ./target/debug/spacetimedb-standalone ./target/debug/spacetimedb-cli /usr/local/bin/ +COPY ./crates/standalone/config.toml /stdb/data/config.toml -# Copy over SpacetimeDB -COPY --chmod=755 ./spacetimedb-standalone ./spacetimedb-cli /opt/spacetime/ -RUN ln -s /opt/spacetime/spacetimedb-cli /usr/local/bin/spacetime - -RUN mkdir /stdb && chmod 777 /stdb - -# Create and switch to a non-root user -RUN useradd -m spacetime -USER spacetime - -# Set working directory -WORKDIR /app - -# Expose the necessary port EXPOSE 3000 + +ENV RUST_BACKTRACE=1 +ENTRYPOINT ["spacetimedb-standalone"] +CMD ["start", "--data-dir=/stdb/data", "--jwt-pub-key-path=/etc/spacetimedb/id_ecdsa.pub", "--jwt-priv-key-path=/etc/spacetimedb/id_ecdsa"] diff --git a/docker-compose.yml b/docker-compose.yml index a507ee62efa..9667e3024e3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,16 +22,26 @@ services: - ./Cargo.toml:/usr/src/app/Cargo.toml - ./flamegraphs:/usr/src/app/flamegraphs - key_files:/etc/spacetimedb - - ./stdb:/stdb + - /stdb ports: - "3000:3000" # Postgres - "5433:5432" # Tracy - "8086:8086" - entrypoint: spacetime start --data-dir=/stdb/data --jwt-pub-key-path=/etc/spacetimedb/id_ecdsa.pub --jwt-priv-key-path=/etc/spacetimedb/id_ecdsa --pg-port 5432 + entrypoint: spacetimedb-standalone start --data-dir=/stdb/data --jwt-pub-key-path=/etc/spacetimedb/id_ecdsa.pub --jwt-priv-key-path=/etc/spacetimedb/id_ecdsa --pg-port 5432 privileged: true environment: + SPACETIMEDB_FLAMEGRAPH_PATH: ../../../../flamegraphs/flamegraph.folded + SPACETIMEDB_TRACY: 1 + # Tracy utilizes the Time Stamp Counter (TSC) in CPUs for high-resolution timing. + # The invariant TSC is a feature that ensures the TSC runs at a constant rate, + # regardless of power-saving modes or frequency changes. + # + # This flag will instruct Tracy to proceed without verifying the presence of an invariant TSC. + # If the CPU lacks this feature, Tracy cannot guarantee accurate timing. + # So use this approach with caution, as it may affect profiling accuracy. + # TRACY_NO_INVARIANT_CHECK: 1 RUST_BACKTRACE: 1 ENV: dev networks: From 0a757924aacfdb232fed4e3f94391f8ed1eb4bfa Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Thu, 13 Nov 2025 11:41:02 -0800 Subject: [PATCH 44/91] [bfops/ci-caching]: fix --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 9667e3024e3..2b56f012abc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,7 +26,7 @@ services: ports: - "3000:3000" # Postgres - - "5433:5432" + - "5432:5432" # Tracy - "8086:8086" entrypoint: spacetimedb-standalone start --data-dir=/stdb/data --jwt-pub-key-path=/etc/spacetimedb/id_ecdsa.pub --jwt-priv-key-path=/etc/spacetimedb/id_ecdsa --pg-port 5432 From dbc13c5627bd6fa04bd8f1b867225647d264f11c Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Thu, 13 Nov 2025 11:44:59 -0800 Subject: [PATCH 45/91] [bfops/ci-caching]: absolute --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 26b8cd87053..ed1c79c7d1b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,7 +28,7 @@ jobs: runner: [ spacetimedb-runner, windows-latest ] runs-on: ${{ matrix.runner }} env: - CARGO_TARGET_DIR: target + CARGO_TARGET_DIR: ${{ github.workspace }}/target steps: - name: Find Git ref env: From 2b37cc17f646e3a367e6e4ed917d288cf70d28d7 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Thu, 13 Nov 2025 12:04:29 -0800 Subject: [PATCH 46/91] [bfops/ci-caching]: update --- .github/workflows/ci.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed1c79c7d1b..1e46cd3af47 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,6 +54,20 @@ jobs: cache-on-failure: true cache-all-crates: true + - uses: actions/setup-dotnet@v4 + with: + global-json-file: global.json + + # nodejs and pnpm are required for the typescript quickstart smoketest + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 18 + + - uses: pnpm/action-setup@v4 + with: + run_install: true + - name: Install psql (Windows) if: runner.os == 'Windows' run: choco install psql -y --no-progress From 359e55c74c46bffa16146e5367b6673e353e65b0 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Thu, 13 Nov 2025 12:09:29 -0800 Subject: [PATCH 47/91] [bfops/ci-caching]: cache more --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e46cd3af47..fcd022a4dfe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,9 +50,11 @@ jobs: - name: Cache Rust dependencies uses: Swatinem/rust-cache@v2 with: + workspaces: ${{ github.workspace }} shared-key: spacetimedb cache-on-failure: true cache-all-crates: true + cache-workspace-crates: true - uses: actions/setup-dotnet@v4 with: From d167bc010b93dd69c64968d1f42a1399d4f0178e Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Thu, 13 Nov 2025 12:20:22 -0800 Subject: [PATCH 48/91] [bfops/ci-caching]: empty commit to bump CI From 7ba5a74c88223ce75537dc05f16e0098260988a9 Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Thu, 13 Nov 2025 05:06:59 +0000 Subject: [PATCH 49/91] Potential fix Another CI run Remove comment Concurrency test Concurrency test 2 concurrency test 3 Test test 2 Attempt fix Add more jobs to the new runner Use container Remove a small diff Another diff fix Enable cancel in progress --- .github/workflows/ci.yml | 44 ++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6489385d53..ed315daa485 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,7 +28,10 @@ jobs: runs-on: ${{ matrix.runner }} # Add container only for Linux runner - container: ${{ matrix.use_container && fromJSON('{"image":"localhost:5000/spacetimedb-ci:latest","options":"--privileged -v /opt/github-runner/cargo-cache:/home/runner/.cargo/registry -v /opt/github-runner/cargo-git:/home/runner/.cargo/git"}') || null }} + container: ${{ matrix.use_container && fromJSON('{ + "image": "localhost:5000/spacetimedb-ci:latest", + "options": "--privileged" + }') || null }} steps: - name: Find Git ref @@ -48,9 +51,7 @@ jobs: with: ref: ${{ env.GIT_REF }} - uses: dsherret/rust-toolchain-file@v1 - # Only install .NET on Windows (not in container where it's pre-installed) - uses: actions/setup-dotnet@v4 - if: ${{ !matrix.use_container }} with: global-json-file: global.json @@ -99,15 +100,11 @@ jobs: test: name: Test Suite runs-on: spacetimedb-new-runner - - # Add this for isolation: container: image: localhost:5000/spacetimedb-ci:latest options: >- --privileged -v /var/run/docker.sock:/var/run/docker.sock - -v /opt/github-runner/cargo-cache:/home/runner/.cargo/registry - -v /opt/github-runner/cargo-git:/home/runner/.cargo/git steps: - name: Find Git ref env: @@ -126,11 +123,12 @@ jobs: with: ref: ${{ env.GIT_REF }} - - name: Verify .NET - run: dotnet --version - - uses: dsherret/rust-toolchain-file@v1 + - uses: actions/setup-dotnet@v3 + with: + global-json-file: global.json + - name: Set up Node.js uses: actions/setup-node@v4 with: @@ -140,6 +138,11 @@ jobs: with: run_install: true + - name: Create /stdb dir + run: | + sudo mkdir /stdb + sudo chmod 777 /stdb + - name: Build typescript module sdk working-directory: crates/bindings-typescript run: pnpm build @@ -165,7 +168,12 @@ jobs: lints: name: Lints - runs-on: spacetimedb-runner + runs-on: spacetimedb-new-runner + container: + image: localhost:5000/spacetimedb-ci:latest + options: >- + --privileged + -v /var/run/docker.sock:/var/run/docker.sock steps: - name: Checkout sources uses: actions/checkout@v3 @@ -204,7 +212,12 @@ jobs: wasm_bindings: name: Build and test wasm bindings - runs-on: spacetimedb-runner + runs-on: spacetimedb-new-runner + container: + image: localhost:5000/spacetimedb-ci:latest + options: >- + --privileged + -v /var/run/docker.sock:/var/run/docker.sock steps: - uses: actions/checkout@v3 @@ -229,7 +242,12 @@ jobs: publish_checks: name: Check that packages are publishable - runs-on: ubuntu-latest + runs-on: spacetimedb-new-runner + container: + image: localhost:5000/spacetimedb-ci:latest + options: >- + --privileged + -v /var/run/docker.sock:/var/run/docker.sock permissions: read-all steps: - uses: actions/checkout@v3 From d50a3471bbbc671ea08f99af2956e923ad54478b Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Thu, 13 Nov 2025 20:44:59 +0000 Subject: [PATCH 50/91] One-liner --- .github/workflows/ci.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed315daa485..2f36442eef4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,10 +28,8 @@ jobs: runs-on: ${{ matrix.runner }} # Add container only for Linux runner - container: ${{ matrix.use_container && fromJSON('{ - "image": "localhost:5000/spacetimedb-ci:latest", - "options": "--privileged" - }') || null }} + container: ${{ matrix.use_container && fromJSON('{"image":"localhost:5000/spacetimedb-ci:latest","options":"--privileged"}') || null }} + steps: - name: Find Git ref From 9e92535d4b980b9937762128f56759f075c8144f Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Thu, 13 Nov 2025 20:46:27 +0000 Subject: [PATCH 51/91] Indenting fix --- .github/workflows/ci.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2f36442eef4..b17a7bcd3fb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,13 +23,18 @@ jobs: strategy: matrix: include: - - { runner: spacetimedb-new-runner, smoketest_args: --docker, use_container: true } - - { runner: windows-latest, smoketest_args: --no-build-cli, use_container: false } + - runner: spacetimedb-new-runner + smoketest_args: --docker + container: + image: localhost:5000/spacetimedb-ci:latest + options: --privileged + - runner: windows-latest + smoketest_args: --no-build-cli + container: null + runs-on: ${{ matrix.runner }} - - # Add container only for Linux runner - container: ${{ matrix.use_container && fromJSON('{"image":"localhost:5000/spacetimedb-ci:latest","options":"--privileged"}') || null }} + container: ${{ matrix.container }} steps: - name: Find Git ref From 4cd95dcd7249860d5df56dc321819867d9a077c0 Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Thu, 13 Nov 2025 21:51:14 +0000 Subject: [PATCH 52/91] Use docker in docker --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b17a7bcd3fb..a8cc8bf4f8d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -74,6 +74,9 @@ jobs: shell: powershell - name: Build and start database (Linux) if: runner.os == 'Linux' + - name: Start Docker daemon + if: runner.os == 'Linux' + run: /usr/local/bin/start-docker.sh run: docker compose up -d - name: Build and start database (Windows) if: runner.os == 'Windows' From 29b085909f7a9bc93f8bf457b152ad9cc4952fca Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Thu, 13 Nov 2025 21:56:03 +0000 Subject: [PATCH 53/91] Fix copy/paste issue --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a8cc8bf4f8d..72f23af5f5f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,11 +72,11 @@ jobs: if: runner.os == 'Windows' run: choco install psql -y --no-progress shell: powershell - - name: Build and start database (Linux) - if: runner.os == 'Linux' - name: Start Docker daemon if: runner.os == 'Linux' run: /usr/local/bin/start-docker.sh + - name: Build and start database (Linux) + if: runner.os == 'Linux' run: docker compose up -d - name: Build and start database (Windows) if: runner.os == 'Windows' From b8769b7e2066273d5675d339086d8508d44cb1c8 Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Thu, 13 Nov 2025 21:59:34 +0000 Subject: [PATCH 54/91] Add debug step --- .github/workflows/ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 72f23af5f5f..06659ee9469 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -75,6 +75,11 @@ jobs: - name: Start Docker daemon if: runner.os == 'Linux' run: /usr/local/bin/start-docker.sh + + - name: Debug - Check files exist + run: | + ls -la /__w/SpacetimeDB/SpacetimeDB/Cargo.toml + pwd - name: Build and start database (Linux) if: runner.os == 'Linux' run: docker compose up -d From 5112401f9ff4678deee247fe797f35d51f32a28b Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Thu, 13 Nov 2025 22:48:16 +0000 Subject: [PATCH 55/91] Remove debug --- .github/workflows/ci.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 06659ee9469..5f08ace3215 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,10 +76,6 @@ jobs: if: runner.os == 'Linux' run: /usr/local/bin/start-docker.sh - - name: Debug - Check files exist - run: | - ls -la /__w/SpacetimeDB/SpacetimeDB/Cargo.toml - pwd - name: Build and start database (Linux) if: runner.os == 'Linux' run: docker compose up -d From a910289ebd79663aa36f05418bf4c32de952d775 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Thu, 13 Nov 2025 16:46:00 -0800 Subject: [PATCH 56/91] [bfops/ci-caching]: restore --- .github/workflows/csharp-test.yml | 166 ++++++++++++++++++++++++++ .github/workflows/docs-publish.yaml | 56 +++++++++ .github/workflows/docs-test.yaml | 44 +++++++ .github/workflows/internal-tests.yml | 112 +++++++++++++++++ .github/workflows/typescript-lint.yml | 41 +++++++ .github/workflows/typescript-test.yml | 141 ++++++++++++++++++++++ 6 files changed, 560 insertions(+) create mode 100644 .github/workflows/csharp-test.yml create mode 100644 .github/workflows/docs-publish.yaml create mode 100644 .github/workflows/docs-test.yaml create mode 100644 .github/workflows/internal-tests.yml create mode 100644 .github/workflows/typescript-lint.yml create mode 100644 .github/workflows/typescript-test.yml diff --git a/.github/workflows/csharp-test.yml b/.github/workflows/csharp-test.yml new file mode 100644 index 00000000000..72885aa91a3 --- /dev/null +++ b/.github/workflows/csharp-test.yml @@ -0,0 +1,166 @@ +name: C#/Unity - Test Suite + +on: + push: + branches: + - master + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || format('sha-{0}', github.sha) }} + cancel-in-progress: true + +jobs: + unity-testsuite: + runs-on: spacetimedb-runner + # Cancel any previous testsuites running on the same PR and/or ref. + concurrency: + group: unity-test-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + timeout-minutes: 30 + env: + CARGO_TARGET_DIR: target + steps: + - name: Checkout repository + id: checkout-stdb + uses: actions/checkout@v4 + + # Run cheap .NET tests first. If those fail, no need to run expensive Unity tests. + + - name: Setup dotnet + uses: actions/setup-dotnet@v3 + with: + global-json-file: global.json + + - name: Override NuGet packages + run: | + dotnet pack crates/bindings-csharp/BSATN.Runtime + dotnet pack crates/bindings-csharp/Runtime + + # Write out the nuget config file to `nuget.config`. This causes the spacetimedb-csharp-sdk repository + # to be aware of the local versions of the `bindings-csharp` packages in SpacetimeDB, and use them if + # available. Otherwise, `spacetimedb-csharp-sdk` will use the NuGet versions of the packages. + # This means that (if version numbers match) we will test the local versions of the C# packages, even + # if they're not pushed to NuGet. + # See https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file for more info on the config file. + cd sdks/csharp + ./tools~/write-nuget-config.sh ../.. + + - name: Run .NET tests + working-directory: sdks/csharp + run: dotnet test -warnaserror + + - name: Verify C# formatting + working-directory: sdks/csharp + run: dotnet format --no-restore --verify-no-changes SpacetimeDB.ClientSDK.sln + + # Now, setup the Unity tests. + + - name: Patch spacetimedb dependency in Cargo.toml + working-directory: demo/Blackholio/server-rust + run: | + sed -i "s|spacetimedb *=.*|spacetimedb = \{ path = \"../../../crates/bindings\" \}|" Cargo.toml + cat Cargo.toml + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + with: + shared-key: spacetimedb + save-cache: false + + - name: Install SpacetimeDB CLI from the local checkout + run: | + cargo install --force --path crates/cli --locked --message-format=short + cargo install --force --path crates/standalone --locked --message-format=short + # Add a handy alias using the old binary name, so that we don't have to rewrite all scripts (incl. in submodules). + ln -sf $HOME/.cargo/bin/spacetimedb-cli $HOME/.cargo/bin/spacetime + + - name: Check quickstart-chat bindings are up to date + working-directory: sdks/csharp + run: | + bash tools~/gen-quickstart.sh + "${GITHUB_WORKSPACE}"/tools/check-diff.sh examples~/quickstart-chat || { + echo 'Error: quickstart-chat bindings have changed. Please run `sdks/csharp/tools~/gen-quickstart.sh`.' + exit 1 + } + + - name: Check client-api bindings are up to date + working-directory: sdks/csharp + run: | + bash tools~/gen-client-api.sh + "${GITHUB_WORKSPACE}"/tools/check-diff.sh src/SpacetimeDB/ClientApi || { + echo 'Error: Client API bindings are dirty. Please run `sdks/csharp/tools~/gen-client-api.sh`.' + exit 1 + } + + - name: Generate client bindings + working-directory: demo/Blackholio/server-rust + run: bash ./generate.sh -y + + - name: Check for changes + run: | + tools/check-diff.sh demo/Blackholio/client-unity/Assets/Scripts/autogen || { + echo 'Error: Bindings are dirty. Please run `demo/Blackholio/server-rust/generate.sh`.' + exit 1 + } + + - name: Check Unity meta files + uses: DeNA/unity-meta-check@v3 + with: + enable_pr_comment: ${{ github.event_name == 'pull_request' }} + target_path: sdks/csharp + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + - name: Start SpacetimeDB + run: | + spacetime start & + disown + + - name: Run regression tests + run: | + bash sdks/csharp/tools~/run-regression-tests.sh + tools/check-diff.sh sdks/csharp/examples~/regression-tests || { + echo 'Error: Bindings are dirty. Please run `sdks/csharp/tools~/gen-regression-tests.sh`.' + exit 1 + } + + - name: Publish unity-tests module to SpacetimeDB + working-directory: demo/Blackholio/server-rust + run: | + spacetime logout && spacetime login --server-issued-login local + bash ./publish.sh + + - name: Patch com.clockworklabs.spacetimedbsdk dependency in manifest.json + working-directory: demo/Blackholio/client-unity/Packages + run: | + # Replace the com.clockworklabs.spacetimedbsdk dependency with the current branch. + # Note: Pointing to a local directory does not work, because our earlier steps nuke our meta files, which then causes Unity to not properly respect the DLLs (e.g. + # codegen does not work properly). + yq e -i '.dependencies["com.clockworklabs.spacetimedbsdk"] = "https://github.com/clockworklabs/SpacetimeDB.git?path=sdks/csharp#${{ github.head_ref }}"' manifest.json + cat manifest.json + + - uses: actions/cache@v3 + with: + path: demo/Blackholio/client-unity/Library + key: Unity-${{ github.head_ref }} + restore-keys: Unity- + + - name: Run Unity tests + uses: game-ci/unity-test-runner@v4 + with: + unityVersion: 2022.3.32f1 # Adjust Unity version to a valid tag + projectPath: demo/Blackholio/client-unity # Path to the Unity project subdirectory + githubToken: ${{ secrets.GITHUB_TOKEN }} + testMode: playmode + useHostNetwork: true + env: + UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} + UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} + UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }} + # Skip if this is an external contribution. + # The license secrets will be empty, so the step would fail anyway. + if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork }} diff --git a/.github/workflows/docs-publish.yaml b/.github/workflows/docs-publish.yaml new file mode 100644 index 00000000000..71aa42ae8df --- /dev/null +++ b/.github/workflows/docs-publish.yaml @@ -0,0 +1,56 @@ +name: Docs / Publish + +permissions: + contents: read + +on: + push: + branches: + - docs/release + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '22' + + - uses: pnpm/action-setup@v4 + with: + run_install: true + + - name: Get pnpm store directory + working-directory: sdks/typescript + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - uses: actions/cache@v4 + name: Setup pnpm cache + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + working-directory: docs + run: pnpm install + + - name: Docusaurus build + working-directory: docs + run: pnpm build + + - name: Publish docs to S3 + uses: shallwefootball/s3-upload-action@master + with: + aws_key_id: ${{ secrets.DOCS_AWS_KEY_ID }} + aws_secret_access_key: ${{ secrets.DOCS_AWS_SECRET_ACCESS_KEY}} + aws_bucket: spacetimedb-docs + source_dir: docs/build + destination_dir: 'docs' diff --git a/.github/workflows/docs-test.yaml b/.github/workflows/docs-test.yaml new file mode 100644 index 00000000000..489f1fb194b --- /dev/null +++ b/.github/workflows/docs-test.yaml @@ -0,0 +1,44 @@ +name: Docs / Test +permissions: + contents: read + +on: + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '22' + + - uses: pnpm/action-setup@v4 + with: + run_install: true + + - name: Get pnpm store directory + working-directory: sdks/typescript + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - uses: actions/cache@v4 + name: Setup pnpm cache + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + working-directory: docs + run: pnpm install + + - name: Docusaurus build + working-directory: docs + run: pnpm build diff --git a/.github/workflows/internal-tests.yml b/.github/workflows/internal-tests.yml new file mode 100644 index 00000000000..3afdc6c0dde --- /dev/null +++ b/.github/workflows/internal-tests.yml @@ -0,0 +1,112 @@ +on: + pull_request: + push: + branches: + - master + +name: Internal Tests + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || format('sha-{0}', github.sha) }} + cancel-in-progress: true + +jobs: + run-tests: + # Skip if this is an external contribution. GitHub secrets will be empty, so the step would fail anyway. + if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork }} + runs-on: ubuntu-latest + steps: + - name: Trigger and wait for Internal Tests + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.SPACETIMEDB_PRIVATE_TOKEN }} + script: | + const targetOwner = 'clockworklabs'; + const targetRepo = 'SpacetimeDBPrivate'; + const workflowId = 'ci.yml'; + const targetRef = 'master'; + // Use the ref for pull requests because the head sha is brittle (github does some extra dance where it merges in master). + const publicRef = (context.eventName === 'pull_request') ? context.payload.pull_request.head.ref : context.sha; + const preDispatch = new Date().toISOString(); + + console.log("context.eventName =", context.eventName); + console.log("context.ref =", context.ref); + console.log("context.sha =", context.sha); + console.log("Dispatch workflow with publicRef =", publicRef); + + // Dispatch the workflow in the target repository + await github.rest.actions.createWorkflowDispatch({ + owner: targetOwner, + repo: targetRepo, + workflow_id: workflowId, + ref: targetRef, + inputs: { public_ref: publicRef } + }); + + const sleep = (ms) => new Promise(r => setTimeout(r, ms)); + + // Wait for workflow to be kicked off + await sleep(30000); + + // Find the dispatched run by name + let runId = null; + for (let attempt = 0; attempt < 20 && !runId; attempt++) { // up to ~10 minutes to locate the run + const runsResp = await github.rest.actions.listWorkflowRuns({ + owner: targetOwner, + repo: targetRepo, + workflow_id: workflowId, + event: 'workflow_dispatch', + branch: targetRef, + per_page: 50, + }); + + const expectedName = `CI [public_ref=${publicRef}]`; + const candidates = runsResp.data.workflow_runs + .filter(r => r.name === expectedName && new Date(r.created_at) >= new Date(preDispatch)) + .sort((a, b) => new Date(b.created_at) - new Date(a.created_at)); + + if (candidates.length > 0) { + runId = candidates[0].id; + break; + } + await sleep(30000); + } + + if (!runId) { + core.setFailed('Failed to locate dispatched run in the private repository.'); + return; + } + + // Provide direct link and context prior to waiting + const runUrl = `https://github.com/${targetOwner}/${targetRepo}/actions/runs/${runId}`; + core.info(`View run: ${runUrl}`); + core.info('Waiting for workflow result...'); + + // Wait for completion + let conclusion = null; + for (let attempt = 0; attempt < 240; attempt++) { // up to ~2 hours + const runResp = await github.rest.actions.getWorkflowRun({ + owner: targetOwner, + repo: targetRepo, + run_id: runId + }); + const { status, conclusion: c } = runResp.data; + if (status === 'completed') { + conclusion = c || 'success'; + break; + } + await sleep(30000); + } + + if (!conclusion) { + core.setFailed('Timed out waiting for private workflow to complete.'); + return; + } + + core.info(`Private workflow conclusion: ${conclusion}`); + if (conclusion !== 'success') { + core.setFailed(`Private workflow failed with conclusion: ${conclusion}`); + } diff --git a/.github/workflows/typescript-lint.yml b/.github/workflows/typescript-lint.yml new file mode 100644 index 00000000000..fe6649fd501 --- /dev/null +++ b/.github/workflows/typescript-lint.yml @@ -0,0 +1,41 @@ +name: TypeScript - Lint + +on: + pull_request: + push: + branches: + - master + merge_group: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 18 + + - uses: pnpm/action-setup@v4 + with: + run_install: true + + - name: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - uses: actions/cache@v4 + name: Setup pnpm cache + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Lint + run: pnpm lint diff --git a/.github/workflows/typescript-test.yml b/.github/workflows/typescript-test.yml new file mode 100644 index 00000000000..9a1924eec56 --- /dev/null +++ b/.github/workflows/typescript-test.yml @@ -0,0 +1,141 @@ +name: TypeScript - Tests + +on: + push: + branches: + - master + pull_request: + merge_group: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || format('sha-{0}', github.sha) }} + cancel-in-progress: true + +jobs: + build-and-test: + runs-on: ubuntu-latest + env: + CARGO_TARGET_DIR: target + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 18 + + - uses: pnpm/action-setup@v4 + with: + run_install: true + + - name: Get pnpm store directory + shell: bash + working-directory: crates/bindings-typescript + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - uses: actions/cache@v4 + name: Setup pnpm cache + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Build module library and SDK + working-directory: crates/bindings-typescript + run: pnpm build + + - name: Run module library and SDK tests + working-directory: crates/bindings-typescript + run: pnpm test + + # - name: Extract SpacetimeDB branch name from file + # id: extract-branch + # run: | + # # Define the path to the branch file + # BRANCH_FILE=".github/spacetimedb-branch.txt" + + # # Default to master if file doesn't exist + # if [ ! -f "$BRANCH_FILE" ]; then + # echo "::notice::No SpacetimeDB branch file found, using 'master'" + # echo "branch=master" >> $GITHUB_OUTPUT + # exit 0 + # fi + + # # Read and trim whitespace from the file + # branch=$(cat "$BRANCH_FILE" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') + + # # Fallback to master if empty + # if [ -z "$branch" ]; then + # echo "::warning::SpacetimeDB branch file is empty, using 'master'" + # branch="master" + # fi + + # echo "branch=$branch" >> $GITHUB_OUTPUT + # echo "Using SpacetimeDB branch from file: $branch" + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + with: + shared-key: spacetimedb + save-cache: false + + - name: Install SpacetimeDB CLI from the local checkout + run: | + cargo install --force --path crates/cli --locked --message-format=short + cargo install --force --path crates/standalone --locked --message-format=short + # Add a handy alias using the old binary name, so that we don't have to rewrite all scripts (incl. in submodules). + rm -f $HOME/.cargo/bin/spacetime + ln -s $HOME/.cargo/bin/spacetimedb-cli $HOME/.cargo/bin/spacetime + # Clear any existing information + spacetime server clear -y + + - name: Generate client bindings + working-directory: modules/quickstart-chat + run: | + spacetime generate --lang typescript --out-dir ../../crates/bindings-typescript/examples/quickstart-chat/src/module_bindings + cd ../../crates/bindings-typescript + pnpm format + + - name: Check for changes + working-directory: crates/bindings-typescript + run: | + "${GITHUB_WORKSPACE}"/tools/check-diff.sh examples/quickstart-chat/src/module_bindings || { + echo "Error: Bindings are dirty. Please generate bindings again and commit them to this branch." + exit 1 + } + + # - name: Start SpacetimeDB + # run: | + # spacetime start & + # disown + + # - name: Publish module to SpacetimeDB + # working-directory: SpacetimeDB/modules/quickstart-chat + # run: | + # spacetime logout && spacetime login --server-issued-login local + # spacetime publish -s local quickstart-chat -c -y + + # - name: Publish module to SpacetimeDB + # working-directory: SpacetimeDB/modules/quickstart-chat + # run: | + # spacetime logs quickstart-chat + + - name: Check that quickstart-chat builds + working-directory: crates/bindings-typescript/examples/quickstart-chat + run: pnpm build + + # - name: Run quickstart-chat tests + # working-directory: examples/quickstart-chat + # run: pnpm test + # + # # Run this step always, even if the previous steps fail + # - name: Print rows in the user table + # if: always() + # run: spacetime sql quickstart-chat "SELECT * FROM user" From 6a32b0a2b1a4758eb80e56a7861b637bfe94b9e5 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Thu, 13 Nov 2025 16:46:08 -0800 Subject: [PATCH 57/91] [bfops/ci-caching]: fix target dir --- .github/workflows/csharp-test.yml | 2 +- .github/workflows/typescript-test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/csharp-test.yml b/.github/workflows/csharp-test.yml index 72885aa91a3..4246e5adbbf 100644 --- a/.github/workflows/csharp-test.yml +++ b/.github/workflows/csharp-test.yml @@ -19,7 +19,7 @@ jobs: cancel-in-progress: true timeout-minutes: 30 env: - CARGO_TARGET_DIR: target + CARGO_TARGET_DIR: ${{ github.workspace }}/target steps: - name: Checkout repository id: checkout-stdb diff --git a/.github/workflows/typescript-test.yml b/.github/workflows/typescript-test.yml index 9a1924eec56..206857a5fe4 100644 --- a/.github/workflows/typescript-test.yml +++ b/.github/workflows/typescript-test.yml @@ -15,7 +15,7 @@ jobs: build-and-test: runs-on: ubuntu-latest env: - CARGO_TARGET_DIR: target + CARGO_TARGET_DIR: ${{ github.workspace }}/target steps: - name: Checkout repository From 905892c15a3a02624f3f6c2374189a4368d05a04 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Thu, 13 Nov 2025 16:47:29 -0800 Subject: [PATCH 58/91] [bfops/ci-caching]: tweak --- .github/workflows/csharp-test.yml | 3 ++- .github/workflows/typescript-test.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/csharp-test.yml b/.github/workflows/csharp-test.yml index 4246e5adbbf..1311f8525a2 100644 --- a/.github/workflows/csharp-test.yml +++ b/.github/workflows/csharp-test.yml @@ -69,7 +69,8 @@ jobs: uses: Swatinem/rust-cache@v2 with: shared-key: spacetimedb - save-cache: false + # Let the main CI job save the cache since it builds the most things + save-if: false - name: Install SpacetimeDB CLI from the local checkout run: | diff --git a/.github/workflows/typescript-test.yml b/.github/workflows/typescript-test.yml index 206857a5fe4..60eb0b72b95 100644 --- a/.github/workflows/typescript-test.yml +++ b/.github/workflows/typescript-test.yml @@ -84,7 +84,8 @@ jobs: uses: Swatinem/rust-cache@v2 with: shared-key: spacetimedb - save-cache: false + # Let the main CI job save the cache since it builds the most things + save-if: false - name: Install SpacetimeDB CLI from the local checkout run: | From 7b9ea8c4e761a62946a0201c96c17c824967db93 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Thu, 13 Nov 2025 16:50:51 -0800 Subject: [PATCH 59/91] [bfops/ci-caching]: review --- .github/workflows/ci.yml | 392 +++++++++++++++++++++++++- .github/workflows/csharp-test.yml | 1 + .github/workflows/typescript-test.yml | 1 + 3 files changed, 390 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fcd022a4dfe..19c34d0729f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -101,8 +101,392 @@ jobs: run: python -m smoketests ${{ matrix.smoketest_args }} -x clear_database replication teams - name: Stop containers (Linux) if: always() && runner.os == 'Linux' + run: docker compose down + + test: + name: Test Suite + runs-on: spacetimedb-runner + env: + CARGO_TARGET_DIR: ${{ github.workspace }}/target + steps: + - name: Find Git ref + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + PR_NUMBER="${{ github.event.inputs.pr_number || null }}" + if test -n "${PR_NUMBER}"; then + GIT_REF="$( gh pr view --repo clockworklabs/SpacetimeDB $PR_NUMBER --json headRefName --jq .headRefName )" + else + GIT_REF="${{ github.ref }}" + fi + echo "GIT_REF=${GIT_REF}" >>"$GITHUB_ENV" + + - name: Checkout sources + uses: actions/checkout@v4 + with: + ref: ${{ env.GIT_REF }} + + - uses: dsherret/rust-toolchain-file@v1 + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + with: + workspaces: ${{ github.workspace }} + shared-key: spacetimedb + # Let the smoketests job save the cache since it builds the most things + save-if: false + + - uses: actions/setup-dotnet@v3 + with: + global-json-file: global.json + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 18 + + - uses: pnpm/action-setup@v4 + with: + run_install: true + + - name: Create /stdb dir + run: | + sudo mkdir /stdb + sudo chmod 777 /stdb + + - name: Build typescript module sdk + working-directory: crates/bindings-typescript + run: pnpm build + + - name: Run cargo test + #Note: Unreal tests will be run separately + run: cargo test --all -- --skip unreal + + - name: Run fallocate tests + run: cargo test -p spacetimedb-durability --features fallocate + + - name: Check that the test outputs are up-to-date + run: bash tools/check-diff.sh + + - name: Ensure C# autogen bindings are up-to-date + run: | + cargo run -p spacetimedb-codegen --example regen-csharp-moduledef + bash tools/check-diff.sh crates/bindings-csharp + + - name: C# bindings tests + working-directory: crates/bindings-csharp + run: dotnet test -warnaserror + + lints: + name: Lints + runs-on: spacetimedb-runner + env: + CARGO_TARGET_DIR: ${{ github.workspace }}/target + steps: + - name: Checkout sources + uses: actions/checkout@v3 + + - uses: dsherret/rust-toolchain-file@v1 + - run: echo ::add-matcher::.github/workflows/rust_matcher.json + + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + with: + workspaces: ${{ github.workspace }} + shared-key: spacetimedb + # Let the smoketests job save the cache since it builds the most things + save-if: false + + - uses: actions/setup-dotnet@v3 + with: + global-json-file: global.json + + - name: Run cargo fmt + run: cargo fmt --all -- --check + + - name: Run cargo clippy + run: cargo clippy --all --tests --benches -- -D warnings + + - name: Run C# formatting check + working-directory: crates/bindings-csharp + run: | + dotnet tool restore + dotnet csharpier --check . + + - name: Run `cargo doc` for bindings crate + # `bindings` is the only crate we care strongly about documenting, + # since we link to its docs.rs from our website. + # We won't pass `--no-deps`, though, + # since we want everything reachable through it to also work. + # This includes `sats` and `lib`. + working-directory: crates/bindings + env: + # Make `cargo doc` exit with error on warnings, most notably broken links + RUSTDOCFLAGS: '--deny warnings' + run: | + cargo doc + + wasm_bindings: + name: Build and test wasm bindings + runs-on: spacetimedb-runner + env: + CARGO_TARGET_DIR: ${{ github.workspace }}/target + steps: + - uses: actions/checkout@v3 + + - uses: dsherret/rust-toolchain-file@v1 + - run: echo ::add-matcher::.github/workflows/rust_matcher.json + + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + with: + workspaces: ${{ github.workspace }} + shared-key: spacetimedb + # Let the smoketests job save the cache since it builds the most things + save-if: false + + - name: Run bindgen tests + run: cargo test -p spacetimedb-codegen + + # Make sure the `Cargo.lock` file reflects the latest available versions. + # This is what users would end up with on a fresh module, so we want to + # catch any compile errors arising from a different transitive closure + # of dependencies than what is in the workspace lock file. + # + # For context see also: https://github.com/clockworklabs/SpacetimeDB/pull/2714 + - name: Update dependencies + run: cargo update + + - name: Build module-test + run: cargo run -p spacetimedb-cli -- build --project-path modules/module-test + + + publish_checks: + name: Check that packages are publishable + runs-on: ubuntu-latest + permissions: read-all + steps: + - uses: actions/checkout@v3 + - name: Set up Python env run: | - set -x - docker ps -a || true - docker logs node || true - docker compose down + test -d venv || python3 -m venv venv + venv/bin/pip3 install argparse toml + - name: Run checks + run: | + FAILED=0 + # This definition of ROOTS and invocation of find-publish-list.py is copied from publish-crates.sh + ROOTS=(bindings sdk cli standalone) + for crate in $(venv/bin/python3 tools/find-publish-list.py --recursive --quiet "${ROOTS[@]}"); do + if ! venv/bin/python3 tools/crate-publish-checks.py "crates/$crate"; then + FAILED=$(( $FAILED + 1 )) + fi + done + if [ $FAILED -gt 0 ]; then + exit 1 + fi + + update: + name: Test spacetimedb-update flow + permissions: read-all + strategy: + matrix: + include: + - { target: x86_64-unknown-linux-gnu, runner: spacetimedb-runner } + - { target: aarch64-unknown-linux-gnu, runner: arm-runner } + - { target: aarch64-apple-darwin, runner: macos-latest } + - { target: x86_64-pc-windows-msvc, runner: windows-latest } + runs-on: ${{ matrix.runner }} + env: + CARGO_TARGET_DIR: ${{ github.workspace }}/target + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Rust + uses: dsherret/rust-toolchain-file@v1 + + - name: Install rust target + run: rustup target add ${{ matrix.target }} + + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + with: + workspaces: ${{ github.workspace }} + shared-key: spacetimedb + # Let the smoketests job save the cache since it builds the most things + save-if: false + + + - name: Install packages + if: ${{ matrix.runner == 'arm-runner' }} + shell: bash + run: sudo apt install -y libssl-dev + + - name: Build spacetimedb-update + run: cargo build --features github-token-auth --target ${{ matrix.target }} -p spacetimedb-update + + - name: Run self-install + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + shell: bash + run: | + ROOT_DIR="$(mktemp -d)" + # 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). + cargo run --features github-token-auth --target ${{ matrix.target }} -p spacetimedb-update -- self-install --root-dir="${ROOT_DIR}" --yes + "${ROOT_DIR}"/spacetime --root-dir="${ROOT_DIR}" help + + unreal_engine_tests: + name: Unreal Engine Tests + # This can't go on e.g. ubuntu-latest because that runner runs out of disk space. ChatGPT suggested that the general solution tends to be to use + # a custom runner. + runs-on: spacetimedb-runner + # Skip if this is an external contribution. GitHub secrets will be empty, so the step would fail anyway. + if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork }} + container: + image: ghcr.io/epicgames/unreal-engine:dev-5.6 + credentials: + # Note(bfops): I don't think that `github.actor` needs to match the user that the token is for, because I'm using a token for my account and + # it seems to be totally happy. + # However, the token needs to be for a user that has access to the EpicGames org (see + # https://dev.epicgames.com/documentation/en-us/unreal-engine/downloading-source-code-in-unreal-engine?application_version=5.6) + username: ${{ github.actor }} + password: ${{ secrets.GHCR_TOKEN }} + # Run as root because otherwise we get permission denied for various directories inside the container. I tried doing dances to allow it to run + # without this (reassigning env vars and stuff), but was unable to get it to work and it felt like an uphill battle. + options: --user 0:0 + steps: +# Uncomment this before merging so that it will run properly if run manually through the GH actions flow. It was playing weird with rolled back +# commits though. +# - name: Find Git ref +# env: +# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# shell: bash +# run: | +# PR_NUMBER="${{ github.event.inputs.pr_number || null }}" +# if test -n "${PR_NUMBER}"; then +# GIT_REF="$( gh pr view --repo clockworklabs/SpacetimeDB $PR_NUMBER --json headRefName --jq .headRefName )" +# else +# GIT_REF="${{ github.ref }}" +# fi +# echo "GIT_REF=${GIT_REF}" >>"$GITHUB_ENV" + - name: Checkout sources + uses: actions/checkout@v4 + with: + ref: ${{ env.GIT_REF }} + - uses: dsherret/rust-toolchain-file@v1 + - name: Run Unreal Engine tests + working-directory: sdks/unreal + env: + UE_ROOT_PATH: /home/ue4/UnrealEngine + run: | + + apt-get update + apt-get install -y acl curl ca-certificates + + REPO="$GITHUB_WORKSPACE" + # Let ue4 read/write the workspace & tool caches without changing ownership + for p in "$REPO" "${RUNNER_TEMP:-/__t}" "${RUNNER_TOOL_CACHE:-/__t}"; do + [ -d "$p" ] && setfacl -R -m u:ue4:rwX -m d:u:ue4:rwX "$p" || true + done + + # Rust tool caches live under the runner tool cache so they persist + export CARGO_HOME="${RUNNER_TOOL_CACHE:-/__t}/cargo" + export RUSTUP_HOME="${RUNNER_TOOL_CACHE:-/__t}/rustup" + mkdir -p "$CARGO_HOME" "$RUSTUP_HOME" + chown -R ue4:ue4 "$CARGO_HOME" "$RUSTUP_HOME" + + # Make sure the UE build script is executable (and parents traversable) + UE_DIR="${UE_ROOT_PATH:-/home/ue4/UnrealEngine}" + chmod a+rx "$UE_DIR" "$UE_DIR/Engine" "$UE_DIR/Engine/Build" "$UE_DIR/Engine/Build/BatchFiles/Linux" || true + chmod a+rx "$UE_DIR/Engine/Build/BatchFiles/Linux/Build.sh" || true + + # Run the build & tests as ue4 (who owns the UE tree) + sudo -E -H -u ue4 env \ + HOME=/home/ue4 \ + XDG_CONFIG_HOME=/home/ue4/.config \ + CARGO_HOME="$CARGO_HOME" \ + RUSTUP_HOME="$RUSTUP_HOME" \ + PATH="$CARGO_HOME/bin:$PATH" \ + bash -lc ' + set -euxo pipefail + # Install rustup for ue4 if needed (uses the shared caches) + if ! command -v cargo >/dev/null 2>&1; then + curl -sSf https://sh.rustup.rs | sh -s -- -y + fi + rustup show >/dev/null + git config --global --add safe.directory "$GITHUB_WORKSPACE" || true + + cd "$GITHUB_WORKSPACE/sdks/unreal" + cargo --version + cargo test + ' + + cli_docs: + name: Check CLI docs + permissions: read-all + runs-on: ubuntu-latest + env: + CARGO_TARGET_DIR: ${{ github.workspace }}/target + steps: + - name: Find Git ref + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + shell: bash + run: | + PR_NUMBER="${{ github.event.inputs.pr_number || null }}" + if test -n "${PR_NUMBER}"; then + GIT_REF="$( gh pr view --repo clockworklabs/SpacetimeDB $PR_NUMBER --json headRefName --jq .headRefName )" + else + GIT_REF="${{ github.ref }}" + fi + echo "GIT_REF=${GIT_REF}" >>"$GITHUB_ENV" + + - name: Checkout sources + uses: actions/checkout@v4 + with: + ref: ${{ env.GIT_REF }} + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 18 + + - uses: pnpm/action-setup@v4 + with: + run_install: true + + - name: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - uses: actions/cache@v4 + name: Setup pnpm cache + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - uses: dsherret/rust-toolchain-file@v1 + + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + with: + workspaces: ${{ github.workspace }} + shared-key: spacetimedb + # Let the smoketests job save the cache since it builds the most things + save-if: false + + - name: Check for docs change + run: | + cargo run --features markdown-docs -p spacetimedb-cli > docs/docs/cli-reference.md + pnpm format + git status + if git diff --exit-code HEAD; then + echo "No docs changes detected" + else + echo "It looks like the CLI docs have changed:" + exit 1 + fi diff --git a/.github/workflows/csharp-test.yml b/.github/workflows/csharp-test.yml index 1311f8525a2..cc93c7a6a3a 100644 --- a/.github/workflows/csharp-test.yml +++ b/.github/workflows/csharp-test.yml @@ -68,6 +68,7 @@ jobs: - name: Cache Rust dependencies uses: Swatinem/rust-cache@v2 with: + workspaces: ${{ github.workspace }} shared-key: spacetimedb # Let the main CI job save the cache since it builds the most things save-if: false diff --git a/.github/workflows/typescript-test.yml b/.github/workflows/typescript-test.yml index 60eb0b72b95..ab0af1171b5 100644 --- a/.github/workflows/typescript-test.yml +++ b/.github/workflows/typescript-test.yml @@ -83,6 +83,7 @@ jobs: - name: Cache Rust dependencies uses: Swatinem/rust-cache@v2 with: + workspaces: ${{ github.workspace }} shared-key: spacetimedb # Let the main CI job save the cache since it builds the most things save-if: false From 729aff5998c9f6943d9e91ea6928c14f1e194c70 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Thu, 13 Nov 2025 17:11:29 -0800 Subject: [PATCH 60/91] [bfops/ci-caching]: stop caching for test spacetimedb-update because already fast --- .github/workflows/ci.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 19c34d0729f..f909cf2bddc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -295,8 +295,6 @@ jobs: - { target: aarch64-apple-darwin, runner: macos-latest } - { target: x86_64-pc-windows-msvc, runner: windows-latest } runs-on: ${{ matrix.runner }} - env: - CARGO_TARGET_DIR: ${{ github.workspace }}/target steps: - name: Checkout uses: actions/checkout@v3 @@ -307,15 +305,6 @@ jobs: - name: Install rust target run: rustup target add ${{ matrix.target }} - - name: Cache Rust dependencies - uses: Swatinem/rust-cache@v2 - with: - workspaces: ${{ github.workspace }} - shared-key: spacetimedb - # Let the smoketests job save the cache since it builds the most things - save-if: false - - - name: Install packages if: ${{ matrix.runner == 'arm-runner' }} shell: bash From c8d92cc8a0436a4f7fa44adbb0cbc168ef884750 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Thu, 13 Nov 2025 17:12:59 -0800 Subject: [PATCH 61/91] [bfops/ci-caching]: empty From 6ef59ebc22c6909eb4edaa694339ac57e0f0b4bb Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Fri, 14 Nov 2025 01:21:38 +0000 Subject: [PATCH 62/91] Few docker updates --- .github/workflows/ci.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5f08ace3215..a9e5e5e7fdb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -111,7 +111,6 @@ jobs: image: localhost:5000/spacetimedb-ci:latest options: >- --privileged - -v /var/run/docker.sock:/var/run/docker.sock steps: - name: Find Git ref env: @@ -180,7 +179,6 @@ jobs: image: localhost:5000/spacetimedb-ci:latest options: >- --privileged - -v /var/run/docker.sock:/var/run/docker.sock steps: - name: Checkout sources uses: actions/checkout@v3 @@ -224,7 +222,6 @@ jobs: image: localhost:5000/spacetimedb-ci:latest options: >- --privileged - -v /var/run/docker.sock:/var/run/docker.sock steps: - uses: actions/checkout@v3 @@ -254,7 +251,6 @@ jobs: image: localhost:5000/spacetimedb-ci:latest options: >- --privileged - -v /var/run/docker.sock:/var/run/docker.sock permissions: read-all steps: - uses: actions/checkout@v3 From 325901f64a23a359a5c8074aeef7ac6aa804c9b8 Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Fri, 14 Nov 2025 01:32:30 +0000 Subject: [PATCH 63/91] Let's give the unreal engine testsuite a try --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a9e5e5e7fdb..636607900f2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -317,7 +317,7 @@ jobs: name: Unreal Engine Tests # This can't go on e.g. ubuntu-latest because that runner runs out of disk space. ChatGPT suggested that the general solution tends to be to use # a custom runner. - runs-on: spacetimedb-runner + runs-on: spacetimedb-new-runner # Skip if this is an external contribution. GitHub secrets will be empty, so the step would fail anyway. if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork }} container: @@ -402,7 +402,7 @@ jobs: cli_docs: name: Check CLI docs permissions: read-all - runs-on: ubuntu-latest + runs-on: spacetimedb-new-runner steps: - name: Find Git ref env: From 14a2f1f9b290dcea69614e5f48f9532d30ad39f2 Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Fri, 14 Nov 2025 01:34:44 +0000 Subject: [PATCH 64/91] Fix --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 636607900f2..9eadf79923d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -403,6 +403,10 @@ jobs: name: Check CLI docs permissions: read-all runs-on: spacetimedb-new-runner + container: + image: localhost:5000/spacetimedb-ci:latest + options: >- + --privileged steps: - name: Find Git ref env: From 4ec0cfe937a7aaca5d6c361fa97d354ccdacf904 Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Fri, 14 Nov 2025 01:48:37 +0000 Subject: [PATCH 65/91] Let's try the Unity tests as well --- .github/workflows/csharp-test.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/csharp-test.yml b/.github/workflows/csharp-test.yml index 8bb3f766cc2..82ecf8ae33e 100644 --- a/.github/workflows/csharp-test.yml +++ b/.github/workflows/csharp-test.yml @@ -12,7 +12,11 @@ concurrency: jobs: unity-testsuite: - runs-on: spacetimedb-runner + runs-on: spacetimedb-new-runner + container: + image: localhost:5000/spacetimedb-ci:latest + options: >- + --privileged # Cancel any previous testsuites running on the same PR and/or ref. concurrency: group: unity-test-${{ github.event.pull_request.number || github.ref }} From 04b25fac269c744333a6c36b2b06de0d1b9387fb Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Fri, 14 Nov 2025 02:07:02 +0000 Subject: [PATCH 66/91] Try unity testsuite again From 27bb5c07f5935455fb1d89b29e940c2875ce9061 Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Fri, 14 Nov 2025 02:39:50 +0000 Subject: [PATCH 67/91] Use start docker so that the testsuite can access docker --- .github/workflows/ci.yml | 2 -- .github/workflows/csharp-test.yml | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9eadf79923d..9f90caf5f62 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,9 +31,7 @@ jobs: - runner: windows-latest smoketest_args: --no-build-cli container: null - runs-on: ${{ matrix.runner }} - container: ${{ matrix.container }} steps: diff --git a/.github/workflows/csharp-test.yml b/.github/workflows/csharp-test.yml index 82ecf8ae33e..eab290e4821 100644 --- a/.github/workflows/csharp-test.yml +++ b/.github/workflows/csharp-test.yml @@ -161,6 +161,8 @@ jobs: key: Unity-${{ github.head_ref }} restore-keys: Unity- + - name: Start Docker daemon + run: /usr/local/bin/start-docker.sh - name: Run Unity tests uses: game-ci/unity-test-runner@v4 with: From 84e344ebed8cd48e8f1923ae0dba3b034dff90fd Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Fri, 14 Nov 2025 03:18:57 +0000 Subject: [PATCH 68/91] Rebuild From 54586478f95131097646e2131a47eac6d1fae4bd Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Fri, 14 Nov 2025 03:26:40 +0000 Subject: [PATCH 69/91] Rebuild again From 96090a0cc6849ab891796efeed027e0cf4f45a80 Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Fri, 14 Nov 2025 03:42:03 +0000 Subject: [PATCH 70/91] Use cargo home instead --- .github/workflows/csharp-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/csharp-test.yml b/.github/workflows/csharp-test.yml index eab290e4821..7ffa0461700 100644 --- a/.github/workflows/csharp-test.yml +++ b/.github/workflows/csharp-test.yml @@ -85,7 +85,7 @@ jobs: cargo install --force --path crates/cli --locked --message-format=short cargo install --force --path crates/standalone --locked --message-format=short # Add a handy alias using the old binary name, so that we don't have to rewrite all scripts (incl. in submodules). - ln -sf $HOME/.cargo/bin/spacetimedb-cli $HOME/.cargo/bin/spacetime + ln -sf $CARGO_HOME/bin/spacetimedb-cli $CARGO_HOME/bin/spacetime env: # Share the target directory with our local project to avoid rebuilding same SpacetimeDB crates twice. CARGO_TARGET_DIR: demo/Blackholio/server-rust/target From c3faf0ce030ae8c8f72ed91f809126807b62ea65 Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Fri, 14 Nov 2025 04:17:20 +0000 Subject: [PATCH 71/91] Fix cgroups error --- .github/workflows/csharp-test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/csharp-test.yml b/.github/workflows/csharp-test.yml index 7ffa0461700..8dca9fb01bb 100644 --- a/.github/workflows/csharp-test.yml +++ b/.github/workflows/csharp-test.yml @@ -17,6 +17,7 @@ jobs: image: localhost:5000/spacetimedb-ci:latest options: >- --privileged + --cgroupns=host # Cancel any previous testsuites running on the same PR and/or ref. concurrency: group: unity-test-${{ github.event.pull_request.number || github.ref }} @@ -163,6 +164,9 @@ jobs: - name: Start Docker daemon run: /usr/local/bin/start-docker.sh + - name: Debug Docker info + run: | + docker info - name: Run Unity tests uses: game-ci/unity-test-runner@v4 with: From bb2462e80130ed6f2bdb7f26f894509d6d081faf Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Fri, 14 Nov 2025 04:39:11 +0000 Subject: [PATCH 72/91] Remove debug --- .github/workflows/csharp-test.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/csharp-test.yml b/.github/workflows/csharp-test.yml index 8dca9fb01bb..2b237c062de 100644 --- a/.github/workflows/csharp-test.yml +++ b/.github/workflows/csharp-test.yml @@ -164,9 +164,6 @@ jobs: - name: Start Docker daemon run: /usr/local/bin/start-docker.sh - - name: Debug Docker info - run: | - docker info - name: Run Unity tests uses: game-ci/unity-test-runner@v4 with: From 4d33efd0c9fdf07cf240952a20799f2d321ac9a1 Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Fri, 14 Nov 2025 13:09:08 +0000 Subject: [PATCH 73/91] All tests are passing From 8384f9aa8df5840c3b7c91c32bee2ce5efccbd46 Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Fri, 14 Nov 2025 16:41:19 +0000 Subject: [PATCH 74/91] Try sequential testing for UnrealEngine --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9f90caf5f62..418a5e6c525 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -394,7 +394,7 @@ jobs: cd "$GITHUB_WORKSPACE/sdks/unreal" cargo --version - cargo test + cargo test --test-threads=1 ' cli_docs: From 5eec82c091668fd6079b9daa8002b40cc0d1207a Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Mon, 17 Nov 2025 16:20:12 +0000 Subject: [PATCH 75/91] Serial test --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 76ea6451d18..05714a1c8aa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -155,8 +155,9 @@ jobs: #Note: Unreal tests will be run separately run: cargo test --all -- --skip unreal + # The fallocate tests have been flakely when running in parallel - name: Run fallocate tests - run: cargo test -p spacetimedb-durability --features fallocate + run: cargo test -p spacetimedb-durability --features fallocate --test-threads=1 - name: Check that the test outputs are up-to-date run: bash tools/check-diff.sh From d6ac573af73274a16236f3175143864bb4649e93 Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Mon, 17 Nov 2025 16:39:52 +0000 Subject: [PATCH 76/91] Use --test-threads properly --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 05714a1c8aa..0a566652100 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -157,7 +157,7 @@ jobs: # The fallocate tests have been flakely when running in parallel - name: Run fallocate tests - run: cargo test -p spacetimedb-durability --features fallocate --test-threads=1 + run: cargo test -p spacetimedb-durability --features fallocate -- --test-threads=1 - name: Check that the test outputs are up-to-date run: bash tools/check-diff.sh From 5552c9af6688a4feb49a280618184781e820e223 Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Mon, 17 Nov 2025 11:28:27 -0600 Subject: [PATCH 77/91] Update comment --- .github/workflows/csharp-test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/csharp-test.yml b/.github/workflows/csharp-test.yml index 2b237c062de..2f9e5b4f6b7 100644 --- a/.github/workflows/csharp-test.yml +++ b/.github/workflows/csharp-test.yml @@ -162,6 +162,7 @@ jobs: key: Unity-${{ github.head_ref }} restore-keys: Unity- + # We need this to support "Docker in Docker" - name: Start Docker daemon run: /usr/local/bin/start-docker.sh - name: Run Unity tests From 7213e9108b7827b9e082f7d82807c7f5fd79fb7f Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Mon, 17 Nov 2025 11:30:26 -0600 Subject: [PATCH 78/91] Restored runner line --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0a566652100..9415a47dff2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,6 +22,7 @@ jobs: name: Smoketests strategy: matrix: + runner: [spacetimedb-new-runner, windows-latest] include: - runner: spacetimedb-new-runner smoketest_args: --docker From d9208b4ec64c1e4767bba028551b8fb83111979c Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Mon, 17 Nov 2025 10:07:41 -0800 Subject: [PATCH 79/91] [bfops/ci-caching]: revert --- .dockerignore | 3 ++ Dockerfile | 65 ++++++++++++++++++++++++++++++++++++ crates/standalone/Dockerfile | 45 ++++++++++++++++++++++--- docker-compose.yml | 2 +- 4 files changed, 110 insertions(+), 5 deletions(-) create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore index e69de29bb2d..a0014596128 100644 --- a/.dockerignore +++ b/.dockerignore @@ -0,0 +1,3 @@ +**/target +# we do our own version pinning in the Dockerfile +rust-toolchain.toml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000000..e37332b8af1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,65 @@ +# Use a base image that supports multi-arch +FROM rust:bookworm AS builder + +WORKDIR /usr/src/app +COPY . . + +# If we're in a git submodule, we'll have a corrupted/nonfunctional .git file instead of a proper .git directory. +# To make the errors more sane, remove .git entirely. +RUN if [ -f .git ]; then \ + echo "❌ ERROR: .git is a file (likely a submodule pointer), not a directory." >&2; \ + echo "This will cause errors in the build process, because git operations will fail." >&2; \ + echo "To address this, replace the .git file with a proper .git directory." >&2; \ + exit 1; \ + fi + +RUN cargo build -p spacetimedb-standalone -p spacetimedb-cli --release --locked + +FROM rust:bookworm + +# Install dependencies +RUN apt-get update && apt-get install -y \ + curl \ + ca-certificates \ + binaryen \ + build-essential \ + && rm -rf /var/lib/apt/lists/* + +# Determine architecture for .NET installation +ARG TARGETARCH +ENV DOTNET_ARCH=${TARGETARCH} + +RUN if [ "$DOTNET_ARCH" = "amd64" ]; then \ + DOTNET_ARCH="x64"; \ + elif [ "$DOTNET_ARCH" = "arm64" ]; then \ + DOTNET_ARCH="arm64"; \ + else \ + echo "Unsupported architecture: $DOTNET_ARCH" && exit 1; \ + fi && \ + curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel 8.0 --install-dir /usr/share/dotnet --architecture $DOTNET_ARCH + +ENV PATH="/usr/share/dotnet:${PATH}" + +# Install the experimental WASI workload +RUN dotnet workload install wasi-experimental + +# Install Rust WASM target +RUN rustup target add wasm32-unknown-unknown + +# Copy over SpacetimeDB +COPY --from=builder --chmod=755 /usr/src/app/target/release/spacetimedb-standalone /usr/src/app/target/release/spacetimedb-cli /opt/spacetime/ +RUN ln -s /opt/spacetime/spacetimedb-cli /usr/local/bin/spacetime + +# Create and switch to a non-root user +RUN useradd -m spacetime +USER spacetime + +# Set working directory +WORKDIR /app + +# Expose the necessary port +EXPOSE 3000 + +# Define the entrypoint +ENTRYPOINT ["spacetime"] + diff --git a/crates/standalone/Dockerfile b/crates/standalone/Dockerfile index 436230262a0..41d4ca713d7 100644 --- a/crates/standalone/Dockerfile +++ b/crates/standalone/Dockerfile @@ -1,7 +1,44 @@ -FROM rust:1.90.0 -RUN mkdir -p /stdb/data -COPY ./target/debug/spacetimedb-standalone ./target/debug/spacetimedb-cli /usr/local/bin/ -COPY ./crates/standalone/config.toml /stdb/data/config.toml +ARG CARGO_PROFILE=release + + +FROM rust:1.90.0 AS chef +RUN rust_target=$(rustc -vV | awk '/^host:/{ print $2 }') && \ + curl https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-$rust_target.tgz -fL | tar xz -C $CARGO_HOME/bin +RUN cargo binstall -y cargo-chef@0.1.70 +WORKDIR /usr/src/app + +FROM chef AS planner +COPY . . +RUN cargo chef prepare --recipe-path recipe.json + +FROM chef AS builder + +RUN cargo binstall -y cargo-watch@8.4.0 +RUN cargo binstall -y flamegraph@0.6.2 + +COPY --from=planner /usr/src/app/recipe.json . + +ENV CARGO_INCREMENTAL=0 + +ARG CARGO_PROFILE=release + +RUN cargo chef cook -p spacetimedb-standalone --profile=${CARGO_PROFILE} + +COPY . . +RUN cargo build -p spacetimedb-standalone --profile=${CARGO_PROFILE} --locked + +FROM builder as env-dev +RUN mkdir -p /stdb/data && ln -s /usr/src/app/crates/standalone/config.toml /stdb/data/config.toml +ENV PATH="/usr/src/app/target/debug:${PATH}" + +FROM debian as env-release +RUN apt-get update && \ + apt-get install -y ca-certificates libssl-dev && \ + rm -rf /var/lib/apt/lists/* +COPY --from=builder /usr/src/app/target/release/spacetimedb-standalone /usr/local/bin/ +COPY --from=builder /usr/src/app/crates/standalone/config.toml /stdb/data/config.toml + +FROM env-${CARGO_PROFILE} EXPOSE 3000 diff --git a/docker-compose.yml b/docker-compose.yml index 2b56f012abc..718281892dd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,7 +29,7 @@ services: - "5432:5432" # Tracy - "8086:8086" - entrypoint: spacetimedb-standalone start --data-dir=/stdb/data --jwt-pub-key-path=/etc/spacetimedb/id_ecdsa.pub --jwt-priv-key-path=/etc/spacetimedb/id_ecdsa --pg-port 5432 + entrypoint: cargo watch -i flamegraphs -i log.conf --why -C crates/standalone -x 'run start --data-dir=/stdb/data --jwt-pub-key-path=/etc/spacetimedb/id_ecdsa.pub --jwt-priv-key-path=/etc/spacetimedb/id_ecdsa --pg-port 5432' privileged: true environment: SPACETIMEDB_FLAMEGRAPH_PATH: ../../../../flamegraphs/flamegraph.folded From bc73a14f7eae43698a2adccc2dce006dcc8a346a Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Mon, 17 Nov 2025 10:12:07 -0800 Subject: [PATCH 80/91] [bfops/ci-caching]: use custom docker-compose file --- .github/Dockerfile | 4 ++++ .github/docker-compose.yml | 42 ++++++++++++++++++++++++++++++++++++++ .github/workflows/ci.yml | 2 +- 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 .github/Dockerfile create mode 100644 .github/docker-compose.yml diff --git a/.github/Dockerfile b/.github/Dockerfile new file mode 100644 index 00000000000..457a54f5b5f --- /dev/null +++ b/.github/Dockerfile @@ -0,0 +1,4 @@ +FROM rust:1.90.0 +RUN mkdir -p /stdb/data +COPY ./target/debug/spacetimedb-standalone ./target/debug/spacetimedb-cli /usr/local/bin/ +COPY ./crates/standalone/config.toml /stdb/data/config.toml diff --git a/.github/docker-compose.yml b/.github/docker-compose.yml new file mode 100644 index 00000000000..02a1a626239 --- /dev/null +++ b/.github/docker-compose.yml @@ -0,0 +1,42 @@ +services: + node: + labels: + app: spacetimedb + build: + context: ../ + dockerfile: ./Dockerfile + args: + CARGO_PROFILE: dev + volumes: + - ./crates/standalone:/usr/src/app/crates/standalone + - ./crates/core:/usr/src/app/crates/core + - ./crates/client-api:/usr/src/app/crates/client-api + - ./crates/lib:/usr/src/app/crates/lib + - ./crates/sats:/usr/src/app/crates/sats + - ./crates/bindings:/usr/src/app/crates/bindings + - ./crates/bindings-macro:/usr/src/app/crates/bindings-macro + - ./crates/bindings-sys:/usr/src/app/crates/bindings-sys + - ./crates/vm:/usr/src/app/crates/vm + - ./crates/metrics:/usr/src/app/crates/metrics + - ./crates/client-api-messages:/usr/src/app/crates/client-api-messages + - ./Cargo.toml:/usr/src/app/Cargo.toml + - ./flamegraphs:/usr/src/app/flamegraphs + - key_files:/etc/spacetimedb + - /stdb + ports: + - "3000:3000" + # Postgres + - "5432:5432" + entrypoint: spacetimedb-standalone start --data-dir=/stdb/data --jwt-pub-key-path=/etc/spacetimedb/id_ecdsa.pub --jwt-priv-key-path=/etc/spacetimedb/id_ecdsa --pg-port 5432 + privileged: true + environment: + RUST_BACKTRACE: 1 + ENV: dev + networks: + - spacetimedb_default + +networks: + spacetimedb_default: + name: spacetimedb_default +volumes: + key_files: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f909cf2bddc..011f3746eb6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,7 +78,7 @@ jobs: run: cargo build -p spacetimedb-cli -p spacetimedb-standalone -p spacetimedb-update - name: Build and start database (Linux) if: runner.os == 'Linux' - run: docker compose up -d + run: docker compose up -f .github/docker-compose.yml -d - name: Build and start database (Windows) if: runner.os == 'Windows' run: | From a01d261d26771df3024e92e33e8fd073597bbf5d Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Mon, 17 Nov 2025 10:14:15 -0800 Subject: [PATCH 81/91] [bfops/ci-caching]: reduce --- .github/docker-compose.yml | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/.github/docker-compose.yml b/.github/docker-compose.yml index 02a1a626239..be3c8336c23 100644 --- a/.github/docker-compose.yml +++ b/.github/docker-compose.yml @@ -5,22 +5,7 @@ services: build: context: ../ dockerfile: ./Dockerfile - args: - CARGO_PROFILE: dev volumes: - - ./crates/standalone:/usr/src/app/crates/standalone - - ./crates/core:/usr/src/app/crates/core - - ./crates/client-api:/usr/src/app/crates/client-api - - ./crates/lib:/usr/src/app/crates/lib - - ./crates/sats:/usr/src/app/crates/sats - - ./crates/bindings:/usr/src/app/crates/bindings - - ./crates/bindings-macro:/usr/src/app/crates/bindings-macro - - ./crates/bindings-sys:/usr/src/app/crates/bindings-sys - - ./crates/vm:/usr/src/app/crates/vm - - ./crates/metrics:/usr/src/app/crates/metrics - - ./crates/client-api-messages:/usr/src/app/crates/client-api-messages - - ./Cargo.toml:/usr/src/app/Cargo.toml - - ./flamegraphs:/usr/src/app/flamegraphs - key_files:/etc/spacetimedb - /stdb ports: @@ -31,12 +16,6 @@ services: privileged: true environment: RUST_BACKTRACE: 1 - ENV: dev - networks: - - spacetimedb_default -networks: - spacetimedb_default: - name: spacetimedb_default volumes: key_files: From 642d3f0de032897eb8ada35a5dd3c8f5a13e4c9c Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Mon, 17 Nov 2025 10:16:55 -0800 Subject: [PATCH 82/91] [bfops/ci-caching]: comment --- .github/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/Dockerfile b/.github/Dockerfile index 457a54f5b5f..e3d75d6617e 100644 --- a/.github/Dockerfile +++ b/.github/Dockerfile @@ -1,3 +1,4 @@ +# Minimal Dockerfile that just wraps pre-built binaries, so we can test the server inside docker FROM rust:1.90.0 RUN mkdir -p /stdb/data COPY ./target/debug/spacetimedb-standalone ./target/debug/spacetimedb-cli /usr/local/bin/ From 46fd69af8116b91d8f79582f5aba3cb5f96e8b54 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Mon, 17 Nov 2025 10:38:59 -0800 Subject: [PATCH 83/91] [bfops/ci-caching]: fix compose invoke --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 011f3746eb6..25a0ff72eea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,7 +78,7 @@ jobs: run: cargo build -p spacetimedb-cli -p spacetimedb-standalone -p spacetimedb-update - name: Build and start database (Linux) if: runner.os == 'Linux' - run: docker compose up -f .github/docker-compose.yml -d + run: docker compose -f .github/docker-compose.yml up -d - name: Build and start database (Windows) if: runner.os == 'Windows' run: | From 4b3d28bf3a2a3444bb77e2f7c81332929d583f3b Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Mon, 17 Nov 2025 11:04:17 -0800 Subject: [PATCH 84/91] [bfops/ci-caching]: fix --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 25a0ff72eea..695b47504d3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -101,7 +101,7 @@ jobs: run: python -m smoketests ${{ matrix.smoketest_args }} -x clear_database replication teams - name: Stop containers (Linux) if: always() && runner.os == 'Linux' - run: docker compose down + run: docker compose -f .github/docker-compose.yml down test: name: Test Suite From e87402aca85fdbc4b9dfacd37ccaf6dd80582e1b Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Mon, 17 Nov 2025 11:04:39 -0800 Subject: [PATCH 85/91] [bfops/ci-caching]: fix --- .github/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/docker-compose.yml b/.github/docker-compose.yml index be3c8336c23..b9c671f2f1b 100644 --- a/.github/docker-compose.yml +++ b/.github/docker-compose.yml @@ -4,7 +4,7 @@ services: app: spacetimedb build: context: ../ - dockerfile: ./Dockerfile + dockerfile: .github/Dockerfile volumes: - key_files:/etc/spacetimedb - /stdb From 9b6c337de828f9b14bf99bc51d4efe94641b9814 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Mon, 17 Nov 2025 11:12:23 -0800 Subject: [PATCH 86/91] [bfops/ci-caching]: fix --- .github/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 695b47504d3..179e13b4c35 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,7 +78,10 @@ jobs: run: cargo build -p spacetimedb-cli -p spacetimedb-standalone -p spacetimedb-update - name: Build and start database (Linux) if: runner.os == 'Linux' - run: docker compose -f .github/docker-compose.yml up -d + run: | + # Our .dockerignore omits `target`, which our CI Dockerfile needs. + rm .dockerignore + docker compose -f .github/docker-compose.yml up -d - name: Build and start database (Windows) if: runner.os == 'Windows' run: | From 1494ee48951c79fb54e5f140447a311bc62867ab Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Mon, 17 Nov 2025 11:30:54 -0800 Subject: [PATCH 87/91] [bfops/ci-caching]: fix compose file --- smoketests/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smoketests/__init__.py b/smoketests/__init__.py index 66d33a175d5..93e179e30dd 100644 --- a/smoketests/__init__.py +++ b/smoketests/__init__.py @@ -48,7 +48,7 @@ REMOTE_SERVER = False # default value can be overridden by `--compose-file` flag -COMPOSE_FILE = "./docker-compose.yml" +COMPOSE_FILE = ".github/docker-compose.yml" # this will be initialized by main() STDB_CONFIG = '' From 8c22386c8975904dad386bd04c74c0f3a6ccd17e Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Mon, 17 Nov 2025 19:37:39 +0000 Subject: [PATCH 88/91] Eliminated some options in running the unreal tests --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9415a47dff2..21a1c6154a9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -397,7 +397,7 @@ jobs: cd "$GITHUB_WORKSPACE/sdks/unreal" cargo --version - cargo test -p sdk-unreal-test-harness --test test -- --test-threads=1 --nocapture + cargo test -- --test-threads=1 ' cli_docs: From c3ebef01c25fbf941dc27148f602fc28edec925e Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Mon, 17 Nov 2025 11:57:33 -0800 Subject: [PATCH 89/91] [bfops/ci-caching]: revert docker changes to see how long things take --- .github/workflows/ci.yml | 4 ++-- smoketests/__init__.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 179e13b4c35..a6b67b19665 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,7 +81,7 @@ jobs: run: | # Our .dockerignore omits `target`, which our CI Dockerfile needs. rm .dockerignore - docker compose -f .github/docker-compose.yml up -d + docker compose up -d - name: Build and start database (Windows) if: runner.os == 'Windows' run: | @@ -104,7 +104,7 @@ jobs: run: python -m smoketests ${{ matrix.smoketest_args }} -x clear_database replication teams - name: Stop containers (Linux) if: always() && runner.os == 'Linux' - run: docker compose -f .github/docker-compose.yml down + run: docker compose down test: name: Test Suite diff --git a/smoketests/__init__.py b/smoketests/__init__.py index 93e179e30dd..66d33a175d5 100644 --- a/smoketests/__init__.py +++ b/smoketests/__init__.py @@ -48,7 +48,7 @@ REMOTE_SERVER = False # default value can be overridden by `--compose-file` flag -COMPOSE_FILE = ".github/docker-compose.yml" +COMPOSE_FILE = "./docker-compose.yml" # this will be initialized by main() STDB_CONFIG = '' From 99b147cd50511df90e79a72988ba97d37e114258 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Mon, 17 Nov 2025 12:05:13 -0800 Subject: [PATCH 90/91] Revert "[bfops/ci-caching]: revert docker changes to see how long things take" This reverts commit c3ebef01c25fbf941dc27148f602fc28edec925e. --- .github/workflows/ci.yml | 4 ++-- smoketests/__init__.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c60a3e1f639..e2e71076a13 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,7 +81,7 @@ jobs: run: | # Our .dockerignore omits `target`, which our CI Dockerfile needs. rm .dockerignore - docker compose up -d + docker compose -f .github/docker-compose.yml up -d - name: Build and start database (Windows) if: runner.os == 'Windows' run: | @@ -104,7 +104,7 @@ jobs: run: python -m smoketests ${{ matrix.smoketest_args }} -x clear_database replication teams - name: Stop containers (Linux) if: always() && runner.os == 'Linux' - run: docker compose down + run: docker compose -f .github/docker-compose.yml down test: name: Test Suite diff --git a/smoketests/__init__.py b/smoketests/__init__.py index 66d33a175d5..93e179e30dd 100644 --- a/smoketests/__init__.py +++ b/smoketests/__init__.py @@ -48,7 +48,7 @@ REMOTE_SERVER = False # default value can be overridden by `--compose-file` flag -COMPOSE_FILE = "./docker-compose.yml" +COMPOSE_FILE = ".github/docker-compose.yml" # this will be initialized by main() STDB_CONFIG = '' From ce31ca51a9ccf87b48a31212c50e49c237bf28df Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Mon, 17 Nov 2025 12:16:24 -0800 Subject: [PATCH 91/91] [bfops/ci-caching]: simpler? --- .github/Dockerfile | 1 + .github/docker-compose.yml | 8 +------- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/Dockerfile b/.github/Dockerfile index e3d75d6617e..00d20a86386 100644 --- a/.github/Dockerfile +++ b/.github/Dockerfile @@ -3,3 +3,4 @@ FROM rust:1.90.0 RUN mkdir -p /stdb/data COPY ./target/debug/spacetimedb-standalone ./target/debug/spacetimedb-cli /usr/local/bin/ COPY ./crates/standalone/config.toml /stdb/data/config.toml +RUN ln -s /usr/local/bin/spacetimedb-cli /usr/local/bin/spacetime diff --git a/.github/docker-compose.yml b/.github/docker-compose.yml index b9c671f2f1b..400c044c4ed 100644 --- a/.github/docker-compose.yml +++ b/.github/docker-compose.yml @@ -5,17 +5,11 @@ services: build: context: ../ dockerfile: .github/Dockerfile - volumes: - - key_files:/etc/spacetimedb - - /stdb ports: - "3000:3000" # Postgres - "5432:5432" - entrypoint: spacetimedb-standalone start --data-dir=/stdb/data --jwt-pub-key-path=/etc/spacetimedb/id_ecdsa.pub --jwt-priv-key-path=/etc/spacetimedb/id_ecdsa --pg-port 5432 + entrypoint: spacetime start --pg-port 5432 privileged: true environment: RUST_BACKTRACE: 1 - -volumes: - key_files: