Skip to content

Commit 2d0d5e4

Browse files
authored
Merge branch 'master' into rekhoff/force-websocket-disconnect
Signed-off-by: rekhoff <r.ekhoff@clockworklabs.io>
2 parents 69c86e0 + 0a3dda7 commit 2d0d5e4

864 files changed

Lines changed: 49048 additions & 22148 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.

.env.sample

Lines changed: 0 additions & 2 deletions
This file was deleted.

.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
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Attach client binaries to release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release_tag:
7+
description: "Release tag (e.g. v1.9.0)"
8+
required: true
9+
10+
jobs:
11+
upload-assets:
12+
runs-on: spacetimedb-new-runner
13+
container:
14+
image: localhost:5000/spacetimedb-ci:latest
15+
options: >-
16+
--privileged
17+
permissions:
18+
contents: write # needed to modify releases
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Download artifacts from private base URL
25+
env:
26+
RELEASE_TAG: ${{ github.event.inputs.release_tag }}
27+
BASE_URL: ${{ secrets.ARTIFACT_BASE_URL }}
28+
run: |
29+
set -euo pipefail
30+
31+
FULL_URL="$BASE_URL/$RELEASE_TAG"
32+
33+
mkdir -p artifacts
34+
cd artifacts
35+
36+
download() {
37+
local filename="$1"
38+
if ! wget -q "${FULL_URL}/${filename}" -O "${filename}"; then
39+
echo "Failed to download ${filename}"
40+
exit 1
41+
fi
42+
}
43+
44+
download "spacetime-aarch64-apple-darwin.tar.gz"
45+
download "spacetime-aarch64-unknown-linux-gnu.tar.gz"
46+
download "spacetime-x86_64-apple-darwin.tar.gz"
47+
download "spacetime-x86_64-pc-windows-msvc.zip"
48+
download "spacetime-x86_64-unknown-linux-gnu.tar.gz"
49+
download "spacetimedb-update-aarch64-apple-darwin"
50+
download "spacetimedb-update-aarch64-unknown-linux-gnu"
51+
download "spacetimedb-update-x86_64-apple-darwin"
52+
download "spacetimedb-update-x86_64-pc-windows-msvc.exe"
53+
download "spacetimedb-update-x86_64-unknown-linux-gnu"
54+
55+
- name: Upload artifacts to GitHub Release
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
RELEASE_TAG: ${{ github.event.inputs.release_tag }}
59+
run: |
60+
set -euo pipefail
61+
62+
cd artifacts
63+
64+
gh release upload "$RELEASE_TAG" ./* \
65+
--repo "$GITHUB_REPOSITORY" \
66+
--clobber
67+

.github/workflows/ci.yml

Lines changed: 128 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,28 @@ on:
1414
name: CI
1515

1616
concurrency:
17-
# When a PR number isn't available, the event won't be a `pull_request` event so it won't matter.
18-
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
19-
# Only cancel when the event is a pull_request
20-
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
17+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.inputs.pr_number || format('sha-{0}', github.sha) }}
18+
cancel-in-progress: true
2119

2220
jobs:
2321
docker_smoketests:
2422
name: Smoketests
2523
strategy:
2624
matrix:
25+
runner: [spacetimedb-new-runner, windows-latest]
2726
include:
28-
- { runner: spacetimedb-runner, smoketest_args: --docker }
29-
- { runner: windows-latest, smoketest_args: --no-build-cli }
30-
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
3135
runs-on: ${{ matrix.runner }}
36+
container: ${{ matrix.container }}
37+
env:
38+
CARGO_TARGET_DIR: ${{ github.workspace }}/target
3239
steps:
3340
- name: Find Git ref
3441
env:
@@ -47,24 +54,52 @@ jobs:
4754
with:
4855
ref: ${{ env.GIT_REF }}
4956
- 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+
5066
- uses: actions/setup-dotnet@v4
5167
with:
5268
global-json-file: global.json
69+
70+
# nodejs and pnpm are required for the typescript quickstart smoketest
71+
- name: Set up Node.js
72+
uses: actions/setup-node@v4
73+
with:
74+
node-version: 18
75+
76+
- uses: pnpm/action-setup@v4
77+
with:
78+
run_install: true
79+
5380
- name: Install psql (Windows)
5481
if: runner.os == 'Windows'
5582
run: choco install psql -y --no-progress
5683
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+
5790
- name: Build and start database (Linux)
5891
if: runner.os == 'Linux'
59-
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
6096
- name: Build and start database (Windows)
6197
if: runner.os == 'Windows'
6298
run: |
6399
# Fail properly if any individual command fails
64100
$ErrorActionPreference = 'Stop'
65101
$PSNativeCommandUseErrorActionPreference = $true
66102
67-
cargo build -p spacetimedb-cli -p spacetimedb-standalone -p spacetimedb-update
68103
Start-Process target/debug/spacetimedb-cli.exe -ArgumentList 'start --pg-port 5432'
69104
cd modules
70105
# the sdk-manifests on windows-latest are messed up, so we need to update them
@@ -74,17 +109,23 @@ jobs:
74109
with: { python-version: '3.12' }
75110
if: runner.os == 'Windows'
76111
- name: Install python deps
77-
run: python -m pip install psycopg2-binary xmltodict
112+
run: python -m pip install -r smoketests/requirements.txt
78113
- name: Run smoketests
79114
# Note: clear_database and replication only work in private
80-
run: python -m smoketests ${{ matrix.smoketest_args }} -x clear_database replication
115+
run: python -m smoketests ${{ matrix.smoketest_args }} -x clear_database replication teams
81116
- name: Stop containers (Linux)
82117
if: always() && runner.os == 'Linux'
83-
run: docker compose down
118+
run: docker compose -f .github/docker-compose.yml down
84119

85120
test:
86121
name: Test Suite
87-
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
88129
steps:
89130
- name: Find Git ref
90131
env:
@@ -104,6 +145,13 @@ jobs:
104145
ref: ${{ env.GIT_REF }}
105146

106147
- 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
107155

108156
- uses: actions/setup-dotnet@v3
109157
with:
@@ -131,6 +179,10 @@ jobs:
131179
#Note: Unreal tests will be run separately
132180
run: cargo test --all -- --skip unreal
133181

182+
# The fallocate tests have been flakely when running in parallel
183+
- name: Run fallocate tests
184+
run: cargo test -p spacetimedb-durability --features fallocate -- --test-threads=1
185+
134186
- name: Check that the test outputs are up-to-date
135187
run: bash tools/check-diff.sh
136188

@@ -145,14 +197,28 @@ jobs:
145197

146198
lints:
147199
name: Lints
148-
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
149207
steps:
150208
- name: Checkout sources
151209
uses: actions/checkout@v3
152210

153211
- uses: dsherret/rust-toolchain-file@v1
154212
- run: echo ::add-matcher::.github/workflows/rust_matcher.json
155213

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+
156222
- uses: actions/setup-dotnet@v3
157223
with:
158224
global-json-file: global.json
@@ -184,13 +250,27 @@ jobs:
184250
185251
wasm_bindings:
186252
name: Build and test wasm bindings
187-
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
188260
steps:
189261
- uses: actions/checkout@v3
190262

191263
- uses: dsherret/rust-toolchain-file@v1
192264
- run: echo ::add-matcher::.github/workflows/rust_matcher.json
193265

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+
194274
- name: Run bindgen tests
195275
run: cargo test -p spacetimedb-codegen
196276

@@ -209,7 +289,11 @@ jobs:
209289

210290
publish_checks:
211291
name: Check that packages are publishable
212-
runs-on: ubuntu-latest
292+
runs-on: spacetimedb-new-runner
293+
container:
294+
image: localhost:5000/spacetimedb-ci:latest
295+
options: >-
296+
--privileged
213297
permissions: read-all
214298
steps:
215299
- uses: actions/checkout@v3
@@ -219,11 +303,12 @@ jobs:
219303
venv/bin/pip3 install argparse toml
220304
- name: Run checks
221305
run: |
306+
set -ueo pipefail
222307
FAILED=0
223-
# This definition of ROOTS and invocation of find-publish-list.py is copied from publish-crates.sh
224-
ROOTS=(bindings sdk cli standalone)
225-
for crate in $(venv/bin/python3 tools/find-publish-list.py --recursive --quiet "${ROOTS[@]}"); do
226-
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
227312
FAILED=$(( $FAILED + 1 ))
228313
fi
229314
done
@@ -276,7 +361,12 @@ jobs:
276361
name: Unreal Engine Tests
277362
# 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
278363
# a custom runner.
279-
runs-on: spacetimedb-runner
364+
runs-on: spacetimedb-new-runner
365+
# Disable the tests because they are very flaky at the moment.
366+
# TODO: Remove this line and re-enable the `if` line just below here.
367+
if: false
368+
# Skip if this is an external contribution. GitHub secrets will be empty, so the step would fail anyway.
369+
# if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork }}
280370
container:
281371
image: ghcr.io/epicgames/unreal-engine:dev-5.6
282372
credentials:
@@ -353,13 +443,19 @@ jobs:
353443
354444
cd "$GITHUB_WORKSPACE/sdks/unreal"
355445
cargo --version
356-
cargo test
446+
cargo test -- --test-threads=1
357447
'
358448
359449
cli_docs:
360450
name: Check CLI docs
361451
permissions: read-all
362-
runs-on: ubuntu-latest
452+
runs-on: spacetimedb-new-runner
453+
container:
454+
image: localhost:5000/spacetimedb-ci:latest
455+
options: >-
456+
--privileged
457+
env:
458+
CARGO_TARGET_DIR: ${{ github.workspace }}/target
363459
steps:
364460
- name: Find Git ref
365461
env:
@@ -403,12 +499,20 @@ jobs:
403499
404500
- uses: dsherret/rust-toolchain-file@v1
405501

502+
- name: Cache Rust dependencies
503+
uses: Swatinem/rust-cache@v2
504+
with:
505+
workspaces: ${{ github.workspace }}
506+
shared-key: spacetimedb
507+
# Let the smoketests job save the cache since it builds the most things
508+
save-if: false
509+
406510
- name: Check for docs change
407511
run: |
408512
cargo run --features markdown-docs -p spacetimedb-cli > docs/docs/cli-reference.md
409513
pnpm format
410514
git status
411-
if git diff --exit-code HEAD; then
515+
if git diff --exit-code HEAD -- docs/docs/cli-reference.md; then
412516
echo "No docs changes detected"
413517
else
414518
echo "It looks like the CLI docs have changed:"

0 commit comments

Comments
 (0)