Skip to content

Commit 2cda6c7

Browse files
committed
[bfops/rust-smoketests-lib]: Merge remote-tracking branch 'origin/master' into bfops/rust-smoketests-lib
2 parents b44ad02 + b391d73 commit 2cda6c7

2,733 files changed

Lines changed: 275281 additions & 86856 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/GREMLINS.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# GREMLINS.md — Who Lives in the Pipes
2+
3+
This file documents the automated agents and bots that operate on this repository.
4+
5+
## Clawd 🔧
6+
7+
- **What:** Anti-entropy gremlin / CI watchdog
8+
- **GitHub account:** `clockwork-labs-bot`
9+
- **Discord channel:** #gremlins (CL - SpacetimeDB)
10+
- **Powered by:** [OpenClaw](https://github.com/openclaw/openclaw) + Claude
11+
12+
### What Clawd does
13+
14+
- **Monitors CI** — watches for failures, flaky tests, and regressions
15+
- **Reviews PRs** — comments on obvious bugs (never approves)
16+
- **Surfaces stale PRs** — finds approved PRs that just need a rebase
17+
- **Documents testing** — creates and maintains `DEVELOP.md` files explaining CI and test infrastructure
18+
- **Alerts the team** — posts findings in #gremlins, pings DevOps when something needs attention
19+
20+
### What Clawd does NOT do
21+
22+
- Approve or merge PRs
23+
- Take any destructive action (delete branches, close PRs, force push)
24+
- Modify production infrastructure
25+
26+
### Contacting Clawd
27+
28+
- Mention `@Openclaw` in #gremlins on Discord
29+
- Tag `@clockwork-labs-bot` on GitHub PRs/issues
30+
31+
---
32+
33+
*To add a new gremlin, document it here.*

.github/workflows/ci.yml

Lines changed: 120 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jobs:
3232
timeout-minutes: 120
3333
env:
3434
CARGO_TARGET_DIR: ${{ github.workspace }}/target
35+
SPACETIMEDB_CPP_DIR: ${{ github.workspace }}/crates/bindings-cpp
3536
steps:
3637
- name: Find Git ref
3738
env:
@@ -79,10 +80,36 @@ jobs:
7980
with:
8081
run_install: true
8182

83+
# Install emscripten for C++ module compilation tests.
84+
- name: Install emscripten (Linux)
85+
if: runner.os == 'Linux'
86+
shell: bash
87+
run: |
88+
git clone https://github.com/emscripten-core/emsdk.git ~/emsdk
89+
cd ~/emsdk
90+
./emsdk install 4.0.21
91+
./emsdk activate 4.0.21
92+
93+
- name: Install emscripten (Windows)
94+
if: runner.os == 'Windows'
95+
shell: pwsh
96+
run: |
97+
git clone https://github.com/emscripten-core/emsdk.git $env:USERPROFILE\emsdk
98+
cd $env:USERPROFILE\emsdk
99+
.\emsdk install 4.0.21
100+
.\emsdk activate 4.0.21
101+
82102
- name: Install psql (Windows)
83103
if: runner.os == 'Windows'
84-
run: choco install psql -y --no-progress
85-
shell: powershell
104+
shell: pwsh
105+
run: |
106+
# Fail properly if any individual command fails
107+
$ErrorActionPreference = 'Stop'
108+
$PSNativeCommandUseErrorActionPreference = $true
109+
choco install psql -y --no-progress
110+
# Check for existence, since `choco` doesn't seem to fail the step if it fails to install..
111+
# See https://github.com/clockworklabs/SpacetimeDB/pull/4399 for more background.
112+
Get-Command psql
86113
87114
- name: Update dotnet workloads
88115
if: runner.os == 'Windows'
@@ -122,137 +149,34 @@ jobs:
122149
- name: Install cargo-nextest
123150
uses: taiki-e/install-action@nextest
124151

125-
- name: Run smoketests
126-
# --test-threads=1 eliminates contention in the C# tests where they fight over bindings
127-
# build artifacts.
128-
# It also seemed to improve performance a fair amount (11m -> 6m)
129-
run: cargo ci smoketests -- --test-threads=1
130-
131-
smoketests-python:
132-
needs: [lints]
133-
name: Smoketests (Python Legacy) (${{matrix.name}})
134-
strategy:
135-
matrix:
136-
include:
137-
- name: Linux
138-
runner: spacetimedb-new-runner-2
139-
smoketest_args: --docker
140-
- name: Windows
141-
runner: windows-latest
142-
smoketest_args: --no-build-cli
143-
runs-on: ${{ matrix.runner }}
144-
timeout-minutes: 120
145-
env:
146-
CARGO_TARGET_DIR: ${{ github.workspace }}/target
147-
steps:
148-
- name: Find Git ref
149-
env:
150-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
151-
shell: bash
152-
run: |
153-
PR_NUMBER="${{ github.event.inputs.pr_number || null }}"
154-
if test -n "${PR_NUMBER}"; then
155-
GIT_REF="$( gh pr view --repo clockworklabs/SpacetimeDB $PR_NUMBER --json headRefName --jq .headRefName )"
156-
else
157-
GIT_REF="${{ github.ref }}"
158-
fi
159-
echo "GIT_REF=${GIT_REF}" >>"$GITHUB_ENV"
160-
- name: Checkout sources
161-
uses: actions/checkout@v4
162-
with:
163-
ref: ${{ env.GIT_REF }}
164-
- uses: dsherret/rust-toolchain-file@v1
165-
- name: Set default rust toolchain
166-
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
167-
- name: Cache Rust dependencies
168-
uses: Swatinem/rust-cache@v2
169-
with:
170-
workspaces: ${{ github.workspace }}
171-
shared-key: spacetimedb
172-
cache-on-failure: false
173-
cache-all-crates: true
174-
cache-workspace-crates: true
175-
prefix-key: v1
176-
177-
# This step shouldn't be needed, but somehow we end up with caches that are missing librusty_v8.a.
178-
# ChatGPT suspects that this could be due to different build invocations using the same target dir,
179-
# and this makes sense to me because we only see it in this job where we mix `cargo build -p` with
180-
# `cargo build --manifest-path` (which apparently build different dependency trees).
181-
# However, we've been unable to fix it so... /shrug
182-
- name: Check v8 outputs
152+
# --test-threads=1 eliminates contention in the C# tests where they fight over bindings
153+
# build artifacts.
154+
# It also seemed to improve performance a fair amount (11m -> 6m)
155+
- name: Run smoketests (Linux)
156+
if: runner.os == 'Linux'
183157
shell: bash
184158
run: |
185-
find "${CARGO_TARGET_DIR}"/ -type f | grep '[/_]v8' || true
186-
if ! [ -f "${CARGO_TARGET_DIR}"/debug/gn_out/obj/librusty_v8.a ]; then
187-
echo "Could not find v8 output file librusty_v8.a; rebuilding manually."
188-
cargo clean -p v8 || true
189-
cargo build -p v8
159+
if [ -f ~/emsdk/emsdk_env.sh ]; then
160+
source ~/emsdk/emsdk_env.sh
190161
fi
162+
cargo ci smoketests -- --test-threads=1
191163
192-
- uses: actions/setup-dotnet@v4
193-
with:
194-
global-json-file: global.json
195-
196-
- name: Override NuGet packages
197-
shell: bash
198-
run: |
199-
dotnet pack -c Release crates/bindings-csharp/BSATN.Runtime
200-
dotnet pack -c Release crates/bindings-csharp/Runtime
201-
cd sdks/csharp
202-
./tools~/write-nuget-config.sh ../..
203-
204-
# nodejs and pnpm are required for the typescript quickstart smoketest
205-
- name: Set up Node.js
206-
uses: actions/setup-node@v4
207-
with:
208-
node-version: 22
209-
210-
- uses: pnpm/action-setup@v4
211-
with:
212-
run_install: true
213-
214-
- name: Install psql (Windows)
164+
# Due to Emscripten PATH issues this was separated to make sure OpenSSL still builds correctly
165+
- name: Run smoketests (Windows)
215166
if: runner.os == 'Windows'
216-
run: choco install psql -y --no-progress
217-
shell: powershell
218-
219-
- name: Build crates
220-
run: cargo build -p spacetimedb-cli -p spacetimedb-standalone -p spacetimedb-update
221-
222-
- name: Build and start database (Linux)
223-
if: runner.os == 'Linux'
167+
shell: pwsh
224168
run: |
225-
# Our .dockerignore omits `target`, which our CI Dockerfile needs.
226-
rm .dockerignore
227-
docker compose -f .github/docker-compose.yml up -d
169+
if (Test-Path "$env:USERPROFILE\emsdk\emsdk_env.ps1") {
170+
& "$env:USERPROFILE\emsdk\emsdk_env.ps1" | Out-Null
171+
}
172+
cargo ci smoketests -- --test-threads=1
228173
229-
- name: Build and start database (Windows)
230-
if: runner.os == 'Windows'
174+
- name: Check for changes
231175
run: |
232-
# Fail properly if any individual command fails
233-
$ErrorActionPreference = 'Stop'
234-
$PSNativeCommandUseErrorActionPreference = $true
235-
236-
Start-Process target/debug/spacetimedb-cli.exe -ArgumentList 'start --pg-port 5432'
237-
cd modules
238-
# the sdk-manifests on windows-latest are messed up, so we need to update them
239-
dotnet workload config --update-mode manifests
240-
dotnet workload update
241-
242-
- uses: actions/setup-python@v5
243-
with: { python-version: "3.12" }
244-
if: runner.os == 'Windows'
245-
246-
- name: Install python deps
247-
run: python -m pip install -r smoketests/requirements.txt
248-
249-
- name: Run Python smoketests
250-
# Note: clear_database and replication only work in private
251-
run: python -m smoketests ${{ matrix.smoketest_args }} -x clear_database replication teams
252-
253-
- name: Stop containers (Linux)
254-
if: always() && runner.os == 'Linux'
255-
run: docker compose -f .github/docker-compose.yml down
176+
tools/check-diff.sh crates/smoketests || {
177+
echo 'Error: There is a diff in the smoketests directory.'
178+
exit 1
179+
}
256180
257181
test:
258182
needs: [lints]
@@ -806,6 +730,12 @@ jobs:
806730
key: Unity-${{ github.head_ref }}
807731
restore-keys: Unity-
808732

733+
- name: Login to DockerHub
734+
uses: docker/login-action@v2
735+
with:
736+
username: ${{ vars.DOCKERHUB_USERNAME }}
737+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
738+
809739
- name: Run Unity tests
810740
uses: game-ci/unity-test-runner@v4
811741
with:
@@ -916,14 +846,15 @@ jobs:
916846
exit 1
917847
}
918848
919-
- name: Check client-api bindings are up to date
920-
working-directory: sdks/csharp
921-
run: |
922-
bash tools~/gen-client-api.sh
923-
"${GITHUB_WORKSPACE}"/tools/check-diff.sh src/SpacetimeDB/ClientApi || {
924-
echo 'Error: Client API bindings are dirty. Please run `sdks/csharp/tools~/gen-client-api.sh`.'
925-
exit 1
926-
}
849+
# TODO: Re-enable this once csharp is using the v2 ws api.
850+
# - name: Check client-api bindings are up to date
851+
# working-directory: sdks/csharp
852+
# run: |
853+
# bash tools~/gen-client-api.sh
854+
# "${GITHUB_WORKSPACE}"/tools/check-diff.sh src/SpacetimeDB/ClientApi || {
855+
# echo 'Error: Client API bindings are dirty. Please run `sdks/csharp/tools~/gen-client-api.sh`.'
856+
# exit 1
857+
# }
927858

928859
- name: Start SpacetimeDB
929860
run: |
@@ -1130,3 +1061,59 @@ jobs:
11301061
fi
11311062
11321063
echo "No Python smoketest changes detected."
1064+
1065+
smoketests_mod_rs_complete:
1066+
name: Check smoketests/mod.rs is complete
1067+
runs-on: ubuntu-latest
1068+
permissions:
1069+
contents: read
1070+
env:
1071+
CARGO_TARGET_DIR: ${{ github.workspace }}/target
1072+
steps:
1073+
- name: Find Git ref
1074+
env:
1075+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1076+
shell: bash
1077+
run: |
1078+
PR_NUMBER="${{ github.event.inputs.pr_number || null }}"
1079+
if test -n "${PR_NUMBER}"; then
1080+
GIT_REF="$( gh pr view --repo clockworklabs/SpacetimeDB $PR_NUMBER --json headRefName --jq .headRefName )"
1081+
else
1082+
GIT_REF="${{ github.ref }}"
1083+
fi
1084+
echo "GIT_REF=${GIT_REF}" >>"$GITHUB_ENV"
1085+
- name: Checkout sources
1086+
uses: actions/checkout@v4
1087+
with:
1088+
ref: ${{ env.GIT_REF }}
1089+
- uses: dsherret/rust-toolchain-file@v1
1090+
- name: Set default rust toolchain
1091+
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
1092+
- name: Cache Rust dependencies
1093+
uses: Swatinem/rust-cache@v2
1094+
with:
1095+
workspaces: ${{ github.workspace }}
1096+
shared-key: spacetimedb
1097+
cache-on-failure: false
1098+
cache-all-crates: true
1099+
cache-workspace-crates: true
1100+
prefix-key: v1
1101+
1102+
# This step shouldn't be needed, but somehow we end up with caches that are missing librusty_v8.a.
1103+
# ChatGPT suspects that this could be due to different build invocations using the same target dir,
1104+
# and this makes sense to me because we only see it in this job where we mix `cargo build -p` with
1105+
# `cargo build --manifest-path` (which apparently build different dependency trees).
1106+
# However, we've been unable to fix it so... /shrug
1107+
- name: Check v8 outputs
1108+
shell: bash
1109+
run: |
1110+
find "${CARGO_TARGET_DIR}"/ -type f | grep '[/_]v8' || true
1111+
if ! [ -f "${CARGO_TARGET_DIR}"/debug/gn_out/obj/librusty_v8.a ]; then
1112+
echo "Could not find v8 output file librusty_v8.a; rebuilding manually."
1113+
cargo clean -p v8 || true
1114+
cargo build -p v8
1115+
fi
1116+
1117+
- name: Verify crates/smoketests/tests/smoketests/mod.rs lists all entries
1118+
run: |
1119+
cargo ci smoketests check-mod-list

0 commit comments

Comments
 (0)