Skip to content

Commit 08c31c2

Browse files
authored
Merge branch 'master' into jlarabie/unreal-docs
2 parents 4bfa50f + 34d8cd4 commit 08c31c2

891 files changed

Lines changed: 80984 additions & 2599 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/workflows/ci.yml

Lines changed: 87 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,10 @@ jobs:
103103
run: |
104104
sudo mkdir /stdb
105105
sudo chmod 777 /stdb
106-
106+
107107
- name: Run cargo test
108-
run: cargo test --all
108+
#Note: Unreal tests will be run separately
109+
run: cargo test --all -- --skip unreal
109110

110111
- name: Check that the test outputs are up-to-date
111112
run: bash tools/check-diff.sh
@@ -243,6 +244,90 @@ jobs:
243244
cargo run --features github-token-auth --target ${{ matrix.target }} -p spacetimedb-update -- self-install --root-dir="${ROOT_DIR}" --yes
244245
"${ROOT_DIR}"/spacetime --root-dir="${ROOT_DIR}" help
245246
247+
unreal_engine_tests:
248+
name: Unreal Engine Tests
249+
# 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
250+
# a custom runner.
251+
runs-on: spacetimedb-runner
252+
container:
253+
image: ghcr.io/epicgames/unreal-engine:dev-5.6
254+
credentials:
255+
# 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
256+
# it seems to be totally happy.
257+
# However, the token needs to be for a user that has access to the EpicGames org (see
258+
# https://dev.epicgames.com/documentation/en-us/unreal-engine/downloading-source-code-in-unreal-engine?application_version=5.6)
259+
username: ${{ github.actor }}
260+
password: ${{ secrets.GHCR_TOKEN }}
261+
# Run as root because otherwise we get permission denied for various directories inside the container. I tried doing dances to allow it to run
262+
# without this (reassigning env vars and stuff), but was unable to get it to work and it felt like an uphill battle.
263+
options: --user 0:0
264+
steps:
265+
# 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
266+
# commits though.
267+
# - name: Find Git ref
268+
# env:
269+
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
270+
# shell: bash
271+
# run: |
272+
# PR_NUMBER="${{ github.event.inputs.pr_number || null }}"
273+
# if test -n "${PR_NUMBER}"; then
274+
# GIT_REF="$( gh pr view --repo clockworklabs/SpacetimeDB $PR_NUMBER --json headRefName --jq .headRefName )"
275+
# else
276+
# GIT_REF="${{ github.ref }}"
277+
# fi
278+
# echo "GIT_REF=${GIT_REF}" >>"$GITHUB_ENV"
279+
- name: Checkout sources
280+
uses: actions/checkout@v4
281+
with:
282+
ref: ${{ env.GIT_REF }}
283+
- uses: dsherret/rust-toolchain-file@v1
284+
- name: Run Unreal Engine tests
285+
working-directory: sdks/unreal
286+
env:
287+
UE_ROOT_PATH: /home/ue4/UnrealEngine
288+
run: |
289+
290+
apt-get update
291+
apt-get install -y acl curl ca-certificates
292+
293+
REPO="$GITHUB_WORKSPACE"
294+
# Let ue4 read/write the workspace & tool caches without changing ownership
295+
for p in "$REPO" "${RUNNER_TEMP:-/__t}" "${RUNNER_TOOL_CACHE:-/__t}"; do
296+
[ -d "$p" ] && setfacl -R -m u:ue4:rwX -m d:u:ue4:rwX "$p" || true
297+
done
298+
299+
# Rust tool caches live under the runner tool cache so they persist
300+
export CARGO_HOME="${RUNNER_TOOL_CACHE:-/__t}/cargo"
301+
export RUSTUP_HOME="${RUNNER_TOOL_CACHE:-/__t}/rustup"
302+
mkdir -p "$CARGO_HOME" "$RUSTUP_HOME"
303+
chown -R ue4:ue4 "$CARGO_HOME" "$RUSTUP_HOME"
304+
305+
# Make sure the UE build script is executable (and parents traversable)
306+
UE_DIR="${UE_ROOT_PATH:-/home/ue4/UnrealEngine}"
307+
chmod a+rx "$UE_DIR" "$UE_DIR/Engine" "$UE_DIR/Engine/Build" "$UE_DIR/Engine/Build/BatchFiles/Linux" || true
308+
chmod a+rx "$UE_DIR/Engine/Build/BatchFiles/Linux/Build.sh" || true
309+
310+
# Run the build & tests as ue4 (who owns the UE tree)
311+
sudo -E -H -u ue4 env \
312+
HOME=/home/ue4 \
313+
XDG_CONFIG_HOME=/home/ue4/.config \
314+
CARGO_HOME="$CARGO_HOME" \
315+
RUSTUP_HOME="$RUSTUP_HOME" \
316+
PATH="$CARGO_HOME/bin:$PATH" \
317+
bash -lc '
318+
set -euxo pipefail
319+
# Install rustup for ue4 if needed (uses the shared caches)
320+
if ! command -v cargo >/dev/null 2>&1; then
321+
curl -sSf https://sh.rustup.rs | sh -s -- -y
322+
fi
323+
rustup show >/dev/null
324+
git config --global --add safe.directory "$GITHUB_WORKSPACE" || true
325+
326+
cd "$GITHUB_WORKSPACE/sdks/unreal"
327+
cargo --version
328+
cargo test
329+
'
330+
246331
cli_docs:
247332
name: Check CLI docs
248333
permissions: read-all

.github/workflows/typescript-lint.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ jobs:
2525
run_install: true
2626

2727
- name: Get pnpm store directory
28-
working-directory: sdks/typescript
2928
shell: bash
3029
run: |
3130
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
@@ -39,5 +38,4 @@ jobs:
3938
${{ runner.os }}-pnpm-store-
4039
4140
- name: Lint
42-
working-directory: sdks/typescript
4341
run: pnpm lint

.github/workflows/typescript-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
run: pnpm build
5252

5353
- name: Run SDK tests
54-
working-directory: sdks/typescript/packages/sdk
54+
working-directory: sdks/typescript
5555
run: pnpm test
5656

5757
# - name: Extract SpacetimeDB branch name from file

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,6 @@ new.json
216216
# Keys
217217
*.pem
218218
.ok.sql
219+
220+
# Test data
221+
!crates/core/testdata/

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ pnpm-lock.yaml
33
dist
44
target
55
.github
6+
coverage

Cargo.lock

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ members = [
2626
"crates/sats",
2727
"crates/schema",
2828
"sdks/rust",
29+
"sdks/unreal",
2930
"crates/snapshot",
3031
"crates/sqltest",
3132
"crates/sql-parser",
@@ -47,7 +48,7 @@ members = [
4748
"sdks/rust/tests/connect_disconnect_client",
4849
"tools/upgrade-version",
4950
"tools/license-check",
50-
"sdks/typescript/packages/test-app/server",
51+
"crates/bindings-typescript/test-app/server",
5152
]
5253
default-members = ["crates/cli", "crates/standalone", "crates/update"]
5354
# cargo feature graph resolver. v3 is default in edition2024 but workspace

crates/auth/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ spacetimedb-lib = { workspace = true, features = ["serde"] }
1111

1212
anyhow.workspace = true
1313
serde.workspace = true
14+
serde_json.workspace = true
1415
serde_with.workspace = true
1516
jsonwebtoken.workspace = true
1617

crates/auth/src/identity.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,27 @@ use serde::{Deserialize, Serialize};
66
use spacetimedb_lib::Identity;
77
use std::time::SystemTime;
88

9+
#[derive(Debug, Clone)]
10+
pub struct ConnectionAuthCtx {
11+
pub claims: SpacetimeIdentityClaims,
12+
pub jwt_payload: String,
13+
}
14+
15+
impl TryFrom<SpacetimeIdentityClaims> for ConnectionAuthCtx {
16+
type Error = anyhow::Error;
17+
fn try_from(claims: SpacetimeIdentityClaims) -> Result<Self, Self::Error> {
18+
let payload =
19+
serde_json::to_string(&claims).map_err(|e| anyhow::anyhow!("Failed to serialize claims: {}", e))?;
20+
Ok(ConnectionAuthCtx {
21+
claims,
22+
jwt_payload: payload,
23+
})
24+
}
25+
}
26+
927
// These are the claims that can be attached to a request/connection.
1028
#[serde_with::serde_as]
11-
#[derive(Debug, Serialize, Deserialize)]
29+
#[derive(Debug, Serialize, Deserialize, Clone)]
1230
pub struct SpacetimeIdentityClaims {
1331
#[serde(rename = "hex_identity")]
1432
pub identity: Identity,

crates/bindings-typescript/eslint.config.js

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

0 commit comments

Comments
 (0)