Skip to content

Commit 608043d

Browse files
Merge branch 'master' into drogus/subscription-query-metrics
2 parents 9cf4564 + f1b6328 commit 608043d

File tree

336 files changed

+11023
-16661
lines changed

Some content is hidden

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

336 files changed

+11023
-16661
lines changed

.github/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Minimal Dockerfile that just wraps pre-built binaries, so we can test the server inside docker
2+
FROM rust:1.90.0
3+
RUN mkdir -p /stdb/data
4+
COPY ./target/debug/spacetimedb-standalone ./target/debug/spacetimedb-cli /usr/local/bin/
5+
COPY ./crates/standalone/config.toml /stdb/data/config.toml
6+
RUN ln -s /usr/local/bin/spacetimedb-cli /usr/local/bin/spacetime

.github/docker-compose.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
services:
2+
node:
3+
labels:
4+
app: spacetimedb
5+
build:
6+
context: ../
7+
dockerfile: .github/Dockerfile
8+
ports:
9+
- "3000:3000"
10+
# Postgres
11+
- "5432:5432"
12+
entrypoint: spacetime start --pg-port 5432
13+
privileged: true
14+
environment:
15+
RUST_BACKTRACE: 1

.github/workflows/ci.yml

Lines changed: 106 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,20 @@ jobs:
2222
name: Smoketests
2323
strategy:
2424
matrix:
25+
runner: [spacetimedb-new-runner, windows-latest]
2526
include:
26-
- { runner: spacetimedb-runner, smoketest_args: --docker }
27-
- { runner: windows-latest, smoketest_args: --no-build-cli }
28-
runner: [ spacetimedb-runner, windows-latest ]
27+
- runner: spacetimedb-new-runner
28+
smoketest_args: --docker
29+
container:
30+
image: localhost:5000/spacetimedb-ci:latest
31+
options: --privileged
32+
- runner: windows-latest
33+
smoketest_args: --no-build-cli
34+
container: null
2935
runs-on: ${{ matrix.runner }}
36+
container: ${{ matrix.container }}
37+
env:
38+
CARGO_TARGET_DIR: ${{ github.workspace }}/target
3039
steps:
3140
- name: Find Git ref
3241
env:
@@ -45,6 +54,15 @@ jobs:
4554
with:
4655
ref: ${{ env.GIT_REF }}
4756
- uses: dsherret/rust-toolchain-file@v1
57+
- name: Cache Rust dependencies
58+
uses: Swatinem/rust-cache@v2
59+
with:
60+
workspaces: ${{ github.workspace }}
61+
shared-key: spacetimedb
62+
cache-on-failure: true
63+
cache-all-crates: true
64+
cache-workspace-crates: true
65+
4866
- uses: actions/setup-dotnet@v4
4967
with:
5068
global-json-file: global.json
@@ -63,17 +81,25 @@ jobs:
6381
if: runner.os == 'Windows'
6482
run: choco install psql -y --no-progress
6583
shell: powershell
84+
- name: Build crates
85+
run: cargo build -p spacetimedb-cli -p spacetimedb-standalone -p spacetimedb-update
86+
- name: Start Docker daemon
87+
if: runner.os == 'Linux'
88+
run: /usr/local/bin/start-docker.sh
89+
6690
- name: Build and start database (Linux)
6791
if: runner.os == 'Linux'
68-
run: docker compose up -d
92+
run: |
93+
# Our .dockerignore omits `target`, which our CI Dockerfile needs.
94+
rm .dockerignore
95+
docker compose -f .github/docker-compose.yml up -d
6996
- name: Build and start database (Windows)
7097
if: runner.os == 'Windows'
7198
run: |
7299
# Fail properly if any individual command fails
73100
$ErrorActionPreference = 'Stop'
74101
$PSNativeCommandUseErrorActionPreference = $true
75102
76-
cargo build -p spacetimedb-cli -p spacetimedb-standalone -p spacetimedb-update
77103
Start-Process target/debug/spacetimedb-cli.exe -ArgumentList 'start --pg-port 5432'
78104
cd modules
79105
# the sdk-manifests on windows-latest are messed up, so we need to update them
@@ -83,17 +109,23 @@ jobs:
83109
with: { python-version: '3.12' }
84110
if: runner.os == 'Windows'
85111
- name: Install python deps
86-
run: python -m pip install psycopg2-binary xmltodict
112+
run: python -m pip install -r smoketests/requirements.txt
87113
- name: Run smoketests
88114
# Note: clear_database and replication only work in private
89115
run: python -m smoketests ${{ matrix.smoketest_args }} -x clear_database replication teams
90116
- name: Stop containers (Linux)
91117
if: always() && runner.os == 'Linux'
92-
run: docker compose down
118+
run: docker compose -f .github/docker-compose.yml down
93119

94120
test:
95121
name: Test Suite
96-
runs-on: spacetimedb-runner
122+
runs-on: spacetimedb-new-runner
123+
container:
124+
image: localhost:5000/spacetimedb-ci:latest
125+
options: >-
126+
--privileged
127+
env:
128+
CARGO_TARGET_DIR: ${{ github.workspace }}/target
97129
steps:
98130
- name: Find Git ref
99131
env:
@@ -113,6 +145,13 @@ jobs:
113145
ref: ${{ env.GIT_REF }}
114146

115147
- uses: dsherret/rust-toolchain-file@v1
148+
- name: Cache Rust dependencies
149+
uses: Swatinem/rust-cache@v2
150+
with:
151+
workspaces: ${{ github.workspace }}
152+
shared-key: spacetimedb
153+
# Let the smoketests job save the cache since it builds the most things
154+
save-if: false
116155

117156
- uses: actions/setup-dotnet@v3
118157
with:
@@ -140,8 +179,9 @@ jobs:
140179
#Note: Unreal tests will be run separately
141180
run: cargo test --all -- --skip unreal
142181

182+
# The fallocate tests have been flakely when running in parallel
143183
- name: Run fallocate tests
144-
run: cargo test -p spacetimedb-durability --features fallocate
184+
run: cargo test -p spacetimedb-durability --features fallocate -- --test-threads=1
145185

146186
- name: Check that the test outputs are up-to-date
147187
run: bash tools/check-diff.sh
@@ -157,14 +197,28 @@ jobs:
157197

158198
lints:
159199
name: Lints
160-
runs-on: spacetimedb-runner
200+
runs-on: spacetimedb-new-runner
201+
container:
202+
image: localhost:5000/spacetimedb-ci:latest
203+
options: >-
204+
--privileged
205+
env:
206+
CARGO_TARGET_DIR: ${{ github.workspace }}/target
161207
steps:
162208
- name: Checkout sources
163209
uses: actions/checkout@v3
164210

165211
- uses: dsherret/rust-toolchain-file@v1
166212
- run: echo ::add-matcher::.github/workflows/rust_matcher.json
167213

214+
- name: Cache Rust dependencies
215+
uses: Swatinem/rust-cache@v2
216+
with:
217+
workspaces: ${{ github.workspace }}
218+
shared-key: spacetimedb
219+
# Let the smoketests job save the cache since it builds the most things
220+
save-if: false
221+
168222
- uses: actions/setup-dotnet@v3
169223
with:
170224
global-json-file: global.json
@@ -196,13 +250,27 @@ jobs:
196250
197251
wasm_bindings:
198252
name: Build and test wasm bindings
199-
runs-on: spacetimedb-runner
253+
runs-on: spacetimedb-new-runner
254+
container:
255+
image: localhost:5000/spacetimedb-ci:latest
256+
options: >-
257+
--privileged
258+
env:
259+
CARGO_TARGET_DIR: ${{ github.workspace }}/target
200260
steps:
201261
- uses: actions/checkout@v3
202262

203263
- uses: dsherret/rust-toolchain-file@v1
204264
- run: echo ::add-matcher::.github/workflows/rust_matcher.json
205265

266+
- name: Cache Rust dependencies
267+
uses: Swatinem/rust-cache@v2
268+
with:
269+
workspaces: ${{ github.workspace }}
270+
shared-key: spacetimedb
271+
# Let the smoketests job save the cache since it builds the most things
272+
save-if: false
273+
206274
- name: Run bindgen tests
207275
run: cargo test -p spacetimedb-codegen
208276

@@ -221,7 +289,11 @@ jobs:
221289

222290
publish_checks:
223291
name: Check that packages are publishable
224-
runs-on: ubuntu-latest
292+
runs-on: spacetimedb-new-runner
293+
container:
294+
image: localhost:5000/spacetimedb-ci:latest
295+
options: >-
296+
--privileged
225297
permissions: read-all
226298
steps:
227299
- uses: actions/checkout@v3
@@ -231,11 +303,12 @@ jobs:
231303
venv/bin/pip3 install argparse toml
232304
- name: Run checks
233305
run: |
306+
set -ueo pipefail
234307
FAILED=0
235-
# This definition of ROOTS and invocation of find-publish-list.py is copied from publish-crates.sh
236-
ROOTS=(bindings sdk cli standalone)
237-
for crate in $(venv/bin/python3 tools/find-publish-list.py --recursive --quiet "${ROOTS[@]}"); do
238-
if ! venv/bin/python3 tools/crate-publish-checks.py "crates/$crate"; then
308+
ROOTS=(spacetimedb spacetimedb-sdk)
309+
CRATES=$(venv/bin/python3 tools/find-publish-list.py --recursive --directories --quiet "${ROOTS[@]}")
310+
for crate_dir in $CRATES; do
311+
if ! venv/bin/python3 tools/crate-publish-checks.py "${crate_dir}"; then
239312
FAILED=$(( $FAILED + 1 ))
240313
fi
241314
done
@@ -288,7 +361,7 @@ jobs:
288361
name: Unreal Engine Tests
289362
# 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
290363
# a custom runner.
291-
runs-on: spacetimedb-runner
364+
runs-on: spacetimedb-new-runner
292365
# Skip if this is an external contribution. GitHub secrets will be empty, so the step would fail anyway.
293366
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork }}
294367
container:
@@ -367,13 +440,19 @@ jobs:
367440
368441
cd "$GITHUB_WORKSPACE/sdks/unreal"
369442
cargo --version
370-
cargo test
443+
cargo test -- --test-threads=1
371444
'
372445
373446
cli_docs:
374447
name: Check CLI docs
375448
permissions: read-all
376-
runs-on: ubuntu-latest
449+
runs-on: spacetimedb-new-runner
450+
container:
451+
image: localhost:5000/spacetimedb-ci:latest
452+
options: >-
453+
--privileged
454+
env:
455+
CARGO_TARGET_DIR: ${{ github.workspace }}/target
377456
steps:
378457
- name: Find Git ref
379458
env:
@@ -417,6 +496,14 @@ jobs:
417496
418497
- uses: dsherret/rust-toolchain-file@v1
419498

499+
- name: Cache Rust dependencies
500+
uses: Swatinem/rust-cache@v2
501+
with:
502+
workspaces: ${{ github.workspace }}
503+
shared-key: spacetimedb
504+
# Let the smoketests job save the cache since it builds the most things
505+
save-if: false
506+
420507
- name: Check for docs change
421508
run: |
422509
cargo run --features markdown-docs -p spacetimedb-cli > docs/docs/cli-reference.md

.github/workflows/csharp-test.yml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,19 @@ concurrency:
1212

1313
jobs:
1414
unity-testsuite:
15-
runs-on: spacetimedb-runner
15+
runs-on: spacetimedb-new-runner
16+
container:
17+
image: localhost:5000/spacetimedb-ci:latest
18+
options: >-
19+
--privileged
20+
--cgroupns=host
1621
# Cancel any previous testsuites running on the same PR and/or ref.
1722
concurrency:
1823
group: unity-test-${{ github.event.pull_request.number || github.ref }}
1924
cancel-in-progress: true
2025
timeout-minutes: 30
26+
env:
27+
CARGO_TARGET_DIR: ${{ github.workspace }}/target
2128
steps:
2229
- name: Checkout repository
2330
id: checkout-stdb
@@ -65,26 +72,18 @@ jobs:
6572

6673
- name: Cache Rust dependencies
6774
uses: Swatinem/rust-cache@v2
68-
id: cache-rust-deps
6975
with:
70-
workspaces: demo/Blackholio/server-rust
71-
key: ${{ steps.checkout-stdb.outputs.commit }}
72-
# Cache Rust deps even if unit tests have failed.
73-
cache-on-failure: true
74-
# Cache the CLI as well.
75-
cache-all-crates: true
76+
workspaces: ${{ github.workspace }}
77+
shared-key: spacetimedb
78+
# Let the main CI job save the cache since it builds the most things
79+
save-if: false
7680

7781
- name: Install SpacetimeDB CLI from the local checkout
78-
# Rebuild only if we didn't get a precise cache hit.
79-
if: steps.cache-rust-deps.outputs.cache-hit == 'false'
8082
run: |
8183
cargo install --force --path crates/cli --locked --message-format=short
8284
cargo install --force --path crates/standalone --locked --message-format=short
8385
# Add a handy alias using the old binary name, so that we don't have to rewrite all scripts (incl. in submodules).
84-
ln -sf $HOME/.cargo/bin/spacetimedb-cli $HOME/.cargo/bin/spacetime
85-
env:
86-
# Share the target directory with our local project to avoid rebuilding same SpacetimeDB crates twice.
87-
CARGO_TARGET_DIR: demo/Blackholio/server-rust/target
86+
ln -sf $CARGO_HOME/bin/spacetimedb-cli $CARGO_HOME/bin/spacetime
8887
8988
- name: Check quickstart-chat bindings are up to date
9089
working-directory: sdks/csharp
@@ -157,6 +156,9 @@ jobs:
157156
key: Unity-${{ github.head_ref }}
158157
restore-keys: Unity-
159158

159+
# We need this to support "Docker in Docker"
160+
- name: Start Docker daemon
161+
run: /usr/local/bin/start-docker.sh
160162
- name: Run Unity tests
161163
uses: game-ci/unity-test-runner@v4
162164
with:

0 commit comments

Comments
 (0)