Skip to content

Commit e58ec47

Browse files
authored
Merge branch 'master' into jdetter/move-docs-to-new-runner
2 parents fb10cb9 + b13f12d commit e58ec47

81 files changed

Lines changed: 2821 additions & 594 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/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: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ jobs:
3434
container: null
3535
runs-on: ${{ matrix.runner }}
3636
container: ${{ matrix.container }}
37-
37+
env:
38+
CARGO_TARGET_DIR: ${{ github.workspace }}/target
3839
steps:
3940
- name: Find Git ref
4041
env:
@@ -53,6 +54,15 @@ jobs:
5354
with:
5455
ref: ${{ env.GIT_REF }}
5556
- 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+
5666
- uses: actions/setup-dotnet@v4
5767
with:
5868
global-json-file: global.json
@@ -71,21 +81,25 @@ jobs:
7181
if: runner.os == 'Windows'
7282
run: choco install psql -y --no-progress
7383
shell: powershell
84+
- name: Build crates
85+
run: cargo build -p spacetimedb-cli -p spacetimedb-standalone -p spacetimedb-update
7486
- name: Start Docker daemon
7587
if: runner.os == 'Linux'
7688
run: /usr/local/bin/start-docker.sh
7789

7890
- name: Build and start database (Linux)
7991
if: runner.os == 'Linux'
80-
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
8196
- name: Build and start database (Windows)
8297
if: runner.os == 'Windows'
8398
run: |
8499
# Fail properly if any individual command fails
85100
$ErrorActionPreference = 'Stop'
86101
$PSNativeCommandUseErrorActionPreference = $true
87102
88-
cargo build -p spacetimedb-cli -p spacetimedb-standalone -p spacetimedb-update
89103
Start-Process target/debug/spacetimedb-cli.exe -ArgumentList 'start --pg-port 5432'
90104
cd modules
91105
# the sdk-manifests on windows-latest are messed up, so we need to update them
@@ -95,13 +109,13 @@ jobs:
95109
with: { python-version: '3.12' }
96110
if: runner.os == 'Windows'
97111
- name: Install python deps
98-
run: python -m pip install psycopg2-binary xmltodict
112+
run: python -m pip install -r smoketests/requirements.txt
99113
- name: Run smoketests
100114
# Note: clear_database and replication only work in private
101115
run: python -m smoketests ${{ matrix.smoketest_args }} -x clear_database replication teams
102116
- name: Stop containers (Linux)
103117
if: always() && runner.os == 'Linux'
104-
run: docker compose down
118+
run: docker compose -f .github/docker-compose.yml down
105119

106120
test:
107121
name: Test Suite
@@ -110,6 +124,8 @@ jobs:
110124
image: localhost:5000/spacetimedb-ci:latest
111125
options: >-
112126
--privileged
127+
env:
128+
CARGO_TARGET_DIR: ${{ github.workspace }}/target
113129
steps:
114130
- name: Find Git ref
115131
env:
@@ -129,6 +145,13 @@ jobs:
129145
ref: ${{ env.GIT_REF }}
130146

131147
- 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
132155

133156
- uses: actions/setup-dotnet@v3
134157
with:
@@ -179,13 +202,23 @@ jobs:
179202
image: localhost:5000/spacetimedb-ci:latest
180203
options: >-
181204
--privileged
205+
env:
206+
CARGO_TARGET_DIR: ${{ github.workspace }}/target
182207
steps:
183208
- name: Checkout sources
184209
uses: actions/checkout@v3
185210

186211
- uses: dsherret/rust-toolchain-file@v1
187212
- run: echo ::add-matcher::.github/workflows/rust_matcher.json
188213

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+
189222
- uses: actions/setup-dotnet@v3
190223
with:
191224
global-json-file: global.json
@@ -222,12 +255,22 @@ jobs:
222255
image: localhost:5000/spacetimedb-ci:latest
223256
options: >-
224257
--privileged
258+
env:
259+
CARGO_TARGET_DIR: ${{ github.workspace }}/target
225260
steps:
226261
- uses: actions/checkout@v3
227262

228263
- uses: dsherret/rust-toolchain-file@v1
229264
- run: echo ::add-matcher::.github/workflows/rust_matcher.json
230265

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+
231274
- name: Run bindgen tests
232275
run: cargo test -p spacetimedb-codegen
233276

@@ -408,6 +451,8 @@ jobs:
408451
image: localhost:5000/spacetimedb-ci:latest
409452
options: >-
410453
--privileged
454+
env:
455+
CARGO_TARGET_DIR: ${{ github.workspace }}/target
411456
steps:
412457
- name: Find Git ref
413458
env:
@@ -451,6 +496,14 @@ jobs:
451496
452497
- uses: dsherret/rust-toolchain-file@v1
453498

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+
454507
- name: Check for docs change
455508
run: |
456509
cargo run --features markdown-docs -p spacetimedb-cli > docs/docs/cli-reference.md

.github/workflows/csharp-test.yml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ jobs:
2323
group: unity-test-${{ github.event.pull_request.number || github.ref }}
2424
cancel-in-progress: true
2525
timeout-minutes: 30
26+
env:
27+
CARGO_TARGET_DIR: ${{ github.workspace }}/target
2628
steps:
2729
- name: Checkout repository
2830
id: checkout-stdb
@@ -70,26 +72,18 @@ jobs:
7072

7173
- name: Cache Rust dependencies
7274
uses: Swatinem/rust-cache@v2
73-
id: cache-rust-deps
7475
with:
75-
workspaces: demo/Blackholio/server-rust
76-
key: ${{ steps.checkout-stdb.outputs.commit }}
77-
# Cache Rust deps even if unit tests have failed.
78-
cache-on-failure: true
79-
# Cache the CLI as well.
80-
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
8180

8281
- name: Install SpacetimeDB CLI from the local checkout
83-
# Rebuild only if we didn't get a precise cache hit.
84-
if: steps.cache-rust-deps.outputs.cache-hit == 'false'
8582
run: |
8683
cargo install --force --path crates/cli --locked --message-format=short
8784
cargo install --force --path crates/standalone --locked --message-format=short
8885
# Add a handy alias using the old binary name, so that we don't have to rewrite all scripts (incl. in submodules).
8986
ln -sf $CARGO_HOME/bin/spacetimedb-cli $CARGO_HOME/bin/spacetime
90-
env:
91-
# Share the target directory with our local project to avoid rebuilding same SpacetimeDB crates twice.
92-
CARGO_TARGET_DIR: demo/Blackholio/server-rust/target
9387
9488
- name: Check quickstart-chat bindings are up to date
9589
working-directory: sdks/csharp

.github/workflows/typescript-lint.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ on:
99

1010
jobs:
1111
build:
12-
runs-on: ubuntu-latest
12+
runs-on: spacetimedb-new-runner
13+
container:
14+
image: localhost:5000/spacetimedb-ci:latest
15+
options: --privileged
16+
1317

1418
steps:
1519
- name: Checkout repository

.github/workflows/typescript-test.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ concurrency:
1313

1414
jobs:
1515
build-and-test:
16-
runs-on: ubuntu-latest
16+
runs-on: spacetimedb-new-runner
17+
container:
18+
image: localhost:5000/spacetimedb-ci:latest
19+
options: --privileged
20+
env:
21+
CARGO_TARGET_DIR: ${{ github.workspace }}/target
1722

1823
steps:
1924
- name: Checkout repository
@@ -81,18 +86,18 @@ jobs:
8186
- name: Cache Rust dependencies
8287
uses: Swatinem/rust-cache@v2
8388
with:
84-
workspaces: |
85-
.
86-
modules/quickstart-chat
87-
shared-key: quickstart-chat-test
89+
workspaces: ${{ github.workspace }}
90+
shared-key: spacetimedb
91+
# Let the main CI job save the cache since it builds the most things
92+
save-if: false
8893

8994
- name: Install SpacetimeDB CLI from the local checkout
9095
run: |
9196
cargo install --force --path crates/cli --locked --message-format=short
9297
cargo install --force --path crates/standalone --locked --message-format=short
9398
# Add a handy alias using the old binary name, so that we don't have to rewrite all scripts (incl. in submodules).
94-
rm -f $HOME/.cargo/bin/spacetime
95-
ln -s $HOME/.cargo/bin/spacetimedb-cli $HOME/.cargo/bin/spacetime
99+
rm -f $CARGO_HOME/bin/spacetime
100+
ln -s $CARGO_HOME/bin/spacetimedb-cli $CARGO_HOME/bin/spacetime
96101
# Clear any existing information
97102
spacetime server clear -y
98103

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,6 @@ new.json
226226

227227
# Symlinked output from `nix build`
228228
result
229+
230+
# Python venv directories
231+
venv/

crates/auth/src/identity.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pub use jsonwebtoken::{DecodingKey, EncodingKey};
44
use serde::Deserializer;
55
use serde::{Deserialize, Serialize};
66
use spacetimedb_lib::Identity;
7+
use std::collections::HashMap;
78
use std::time::SystemTime;
89

910
#[derive(Debug, Clone)]
@@ -41,6 +42,9 @@ pub struct SpacetimeIdentityClaims {
4142
pub iat: SystemTime,
4243
#[serde_as(as = "Option<serde_with::TimestampSeconds>")]
4344
pub exp: Option<SystemTime>,
45+
46+
#[serde(flatten)]
47+
pub extra: Option<HashMap<String, serde_json::Value>>,
4448
}
4549

4650
fn deserialize_audience<'de, D>(deserializer: D) -> Result<Vec<String>, D::Error>
@@ -84,6 +88,10 @@ pub struct IncomingClaims {
8488
pub iat: SystemTime,
8589
#[serde_as(as = "Option<serde_with::TimestampSeconds>")]
8690
pub exp: Option<SystemTime>,
91+
92+
/// All remaining claims from the JWT payload
93+
#[serde(flatten)]
94+
pub extra: Option<HashMap<String, serde_json::Value>>,
8795
}
8896

8997
impl TryInto<SpacetimeIdentityClaims> for IncomingClaims {
@@ -122,6 +130,7 @@ impl TryInto<SpacetimeIdentityClaims> for IncomingClaims {
122130
audience: self.audience,
123131
iat: self.iat,
124132
exp: self.exp,
133+
extra: self.extra,
125134
})
126135
}
127136
}

crates/bindings-csharp/BSATN.Runtime/BSATN/Runtime.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,12 @@ public void Write(BinaryWriter writer, Inner? value)
228228

229229
public AlgebraicType GetAlgebraicType(ITypeRegistrar registrar) =>
230230
AlgebraicType.MakeOption(innerRW.GetAlgebraicType(registrar));
231+
232+
// Return a List BSATN serializer that can serialize this option as an array
233+
public static List<Inner, InnerRW> GetListSerializer()
234+
{
235+
return new List<Inner, InnerRW>();
236+
}
231237
}
232238

233239
public readonly struct Bool : IReadWrite<bool>

crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/ExtraCompilationErrors.verified.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public partial struct TestDefaultFieldValues
233233

234234
var returnValue = Module.ViewDefWrongContext((SpacetimeDB.ViewContext)ctx);
235235
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
236-
using var output = new System.IO.MemoryStream();
236+
SpacetimeDB.BSATN.List<Player, Player.BSATN> returnRW = new();
237237
*/
238238
Message: Argument 1: cannot convert from 'SpacetimeDB.ViewContext' to 'SpacetimeDB.ReducerContext',
239239
Severity: Error,
@@ -279,7 +279,7 @@ SpacetimeDB.Internal.Module.RegisterClientVisibilityFilter(global::Module.MY_THI
279279

280280
var returnValue = Module.ViewDefNoContext((SpacetimeDB.ViewContext)ctx);
281281
^^^^^^^^^^^^^^^^
282-
using var output = new System.IO.MemoryStream();
282+
SpacetimeDB.BSATN.List<Player, Player.BSATN> returnRW = new();
283283
*/
284284
Message: No overload for method 'ViewDefNoContext' takes 1 arguments,
285285
Severity: Error,
@@ -299,10 +299,10 @@ SpacetimeDB.Internal.Module.RegisterClientVisibilityFilter(global::Module.MY_THI
299299
}
300300
},
301301
{/*
302-
303-
private static readonly SpacetimeDB.BSATN.ValueOption<NotSpacetimeType, NotSpacetimeType.BSATN> returnRW = new();
304-
^^^^^
305-
302+
Params: [],
303+
ReturnType: new SpacetimeDB.BSATN.ValueOption<NotSpacetimeType, NotSpacetimeType.BSATN>().GetAlgebraicType(registrar)
304+
^^^^^
305+
);
306306
*/
307307
Message: The type name 'BSATN' does not exist in the type 'NotSpacetimeType',
308308
Severity: Error,
@@ -322,10 +322,10 @@ SpacetimeDB.Internal.Module.RegisterClientVisibilityFilter(global::Module.MY_THI
322322
}
323323
},
324324
{/*
325-
Params: [],
326-
ReturnType: new SpacetimeDB.BSATN.ValueOption<NotSpacetimeType, NotSpacetimeType.BSATN>().GetAlgebraicType(registrar)
327-
^^^^^
328-
);
325+
var returnValue = Module.ViewDefReturnsNotASpacetimeType((SpacetimeDB.AnonymousViewContext)ctx);
326+
var listSerializer = SpacetimeDB.BSATN.ValueOption<NotSpacetimeType, NotSpacetimeType.BSATN>.GetListSerializer();
327+
^^^^^
328+
var listValue = ModuleRegistration.ToListOrEmpty(returnValue);
329329
*/
330330
Message: The type name 'BSATN' does not exist in the type 'NotSpacetimeType',
331331
Severity: Error,

0 commit comments

Comments
 (0)