Skip to content

Commit e67863c

Browse files
Ludv1gLclaude
andcommitted
Merge upstream/master from clockworklabs/SpacetimeDB
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2 parents eee82bf + b5f3ce8 commit e67863c

274 files changed

Lines changed: 10321 additions & 3396 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: 231 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
container: null
3535
runs-on: ${{ matrix.runner }}
3636
container: ${{ matrix.container }}
37+
timeout-minutes: 120
3738
env:
3839
CARGO_TARGET_DIR: ${{ github.workspace }}/target
3940
steps:
@@ -317,16 +318,21 @@ jobs:
317318
fi
318319
319320
update:
320-
name: Test spacetimedb-update flow
321+
name: Test spacetimedb-update flow (${{ matrix.target }})
321322
permissions: read-all
322323
strategy:
323324
matrix:
324325
include:
325-
- { target: x86_64-unknown-linux-gnu, runner: spacetimedb-runner }
326+
- runner: spacetimedb-new-runner
327+
target: x86_64-unknown-linux-gnu
328+
container:
329+
image: localhost:5000/spacetimedb-ci:latest
330+
options: --privileged
326331
- { target: aarch64-unknown-linux-gnu, runner: arm-runner }
327332
- { target: aarch64-apple-darwin, runner: macos-latest }
328333
- { target: x86_64-pc-windows-msvc, runner: windows-latest }
329334
runs-on: ${{ matrix.runner }}
335+
container: ${{ matrix.container }}
330336
steps:
331337
- name: Checkout
332338
uses: actions/checkout@v3
@@ -512,9 +518,231 @@ jobs:
512518
cargo run --features markdown-docs -p spacetimedb-cli > docs/docs/cli-reference.md
513519
pnpm format
514520
git status
515-
if git diff --exit-code HEAD; then
521+
if git diff --exit-code HEAD -- docs/docs/cli-reference.md; then
516522
echo "No docs changes detected"
517523
else
518524
echo "It looks like the CLI docs have changed:"
519525
exit 1
520526
fi
527+
528+
unity-testsuite:
529+
permissions:
530+
contents: read
531+
checks: write
532+
runs-on: spacetimedb-new-runner
533+
container:
534+
image: localhost:5000/spacetimedb-ci:latest
535+
options: >-
536+
--privileged
537+
--cgroupns=host
538+
timeout-minutes: 30
539+
env:
540+
CARGO_TARGET_DIR: ${{ github.workspace }}/target
541+
steps:
542+
- name: Checkout repository
543+
id: checkout-stdb
544+
uses: actions/checkout@v4
545+
546+
# Run cheap .NET tests first. If those fail, no need to run expensive Unity tests.
547+
548+
- name: Setup dotnet
549+
uses: actions/setup-dotnet@v3
550+
with:
551+
global-json-file: global.json
552+
553+
- name: Override NuGet packages
554+
run: |
555+
dotnet pack crates/bindings-csharp/BSATN.Runtime
556+
dotnet pack crates/bindings-csharp/Runtime
557+
558+
# Write out the nuget config file to `nuget.config`. This causes the spacetimedb-csharp-sdk repository
559+
# to be aware of the local versions of the `bindings-csharp` packages in SpacetimeDB, and use them if
560+
# available. Otherwise, `spacetimedb-csharp-sdk` will use the NuGet versions of the packages.
561+
# This means that (if version numbers match) we will test the local versions of the C# packages, even
562+
# if they're not pushed to NuGet.
563+
# See https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file for more info on the config file.
564+
cd sdks/csharp
565+
./tools~/write-nuget-config.sh ../..
566+
567+
# Now, setup the Unity tests.
568+
- name: Patch spacetimedb dependency in Cargo.toml
569+
working-directory: demo/Blackholio/server-rust
570+
run: |
571+
sed -i "s|spacetimedb *=.*|spacetimedb = \{ path = \"../../../crates/bindings\" \}|" Cargo.toml
572+
cat Cargo.toml
573+
574+
- name: Install Rust toolchain
575+
uses: dtolnay/rust-toolchain@stable
576+
577+
- name: Cache Rust dependencies
578+
uses: Swatinem/rust-cache@v2
579+
with:
580+
workspaces: ${{ github.workspace }}
581+
shared-key: spacetimedb
582+
# Let the main CI job save the cache since it builds the most things
583+
save-if: false
584+
585+
- name: Install SpacetimeDB CLI from the local checkout
586+
run: |
587+
cargo install --force --path crates/cli --locked --message-format=short
588+
cargo install --force --path crates/standalone --locked --message-format=short
589+
# Add a handy alias using the old binary name, so that we don't have to rewrite all scripts (incl. in submodules).
590+
ln -sf $CARGO_HOME/bin/spacetimedb-cli $CARGO_HOME/bin/spacetime
591+
592+
- name: Generate client bindings
593+
working-directory: demo/Blackholio/server-rust
594+
run: bash ./generate.sh -y
595+
596+
- name: Check for changes
597+
run: |
598+
tools/check-diff.sh demo/Blackholio/client-unity/Assets/Scripts/autogen || {
599+
echo 'Error: Bindings are dirty. Please run `demo/Blackholio/server-rust/generate.sh`.'
600+
exit 1
601+
}
602+
603+
- name: Check Unity meta files
604+
uses: DeNA/unity-meta-check@v3
605+
with:
606+
enable_pr_comment: ${{ github.event_name == 'pull_request' }}
607+
target_path: sdks/csharp
608+
env:
609+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
610+
611+
- name: Start SpacetimeDB
612+
run: |
613+
spacetime start &
614+
disown
615+
616+
- name: Publish unity-tests module to SpacetimeDB
617+
working-directory: demo/Blackholio/server-rust
618+
run: |
619+
spacetime logout && spacetime login --server-issued-login local
620+
bash ./publish.sh
621+
622+
- name: Patch com.clockworklabs.spacetimedbsdk dependency in manifest.json
623+
working-directory: demo/Blackholio/client-unity/Packages
624+
run: |
625+
# Replace the com.clockworklabs.spacetimedbsdk dependency with the current branch.
626+
# Note: Pointing to a local directory does not work, because our earlier steps nuke our meta files, which then causes Unity to not properly respect the DLLs (e.g.
627+
# codegen does not work properly).
628+
yq e -i '.dependencies["com.clockworklabs.spacetimedbsdk"] = "https://github.com/clockworklabs/SpacetimeDB.git?path=sdks/csharp#${{ github.head_ref }}"' manifest.json
629+
cat manifest.json
630+
631+
- uses: actions/cache@v3
632+
with:
633+
path: demo/Blackholio/client-unity/Library
634+
key: Unity-${{ github.head_ref }}
635+
restore-keys: Unity-
636+
637+
# We need this to support "Docker in Docker"
638+
- name: Start Docker daemon
639+
run: /usr/local/bin/start-docker.sh
640+
- name: Run Unity tests
641+
uses: game-ci/unity-test-runner@v4
642+
with:
643+
unityVersion: 2022.3.32f1 # Adjust Unity version to a valid tag
644+
projectPath: demo/Blackholio/client-unity # Path to the Unity project subdirectory
645+
githubToken: ${{ secrets.GITHUB_TOKEN }}
646+
testMode: playmode
647+
useHostNetwork: true
648+
artifactsPath: ""
649+
env:
650+
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
651+
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
652+
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
653+
# Skip if this is an external contribution.
654+
# The license secrets will be empty, so the step would fail anyway.
655+
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork }}
656+
657+
csharp-testsuite:
658+
runs-on: spacetimedb-new-runner
659+
container:
660+
image: localhost:5000/spacetimedb-ci:latest
661+
options: >-
662+
--privileged
663+
--cgroupns=host
664+
timeout-minutes: 30
665+
env:
666+
CARGO_TARGET_DIR: ${{ github.workspace }}/target
667+
steps:
668+
- name: Checkout repository
669+
id: checkout-stdb
670+
uses: actions/checkout@v4
671+
672+
# Run cheap .NET tests first. If those fail, no need to run expensive Unity tests.
673+
674+
- name: Setup dotnet
675+
uses: actions/setup-dotnet@v3
676+
with:
677+
global-json-file: global.json
678+
679+
- name: Override NuGet packages
680+
run: |
681+
dotnet pack crates/bindings-csharp/BSATN.Runtime
682+
dotnet pack crates/bindings-csharp/Runtime
683+
684+
# Write out the nuget config file to `nuget.config`. This causes the spacetimedb-csharp-sdk repository
685+
# to be aware of the local versions of the `bindings-csharp` packages in SpacetimeDB, and use them if
686+
# available. Otherwise, `spacetimedb-csharp-sdk` will use the NuGet versions of the packages.
687+
# This means that (if version numbers match) we will test the local versions of the C# packages, even
688+
# if they're not pushed to NuGet.
689+
# See https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file for more info on the config file.
690+
cd sdks/csharp
691+
./tools~/write-nuget-config.sh ../..
692+
693+
- name: Run .NET tests
694+
working-directory: sdks/csharp
695+
run: dotnet test -warnaserror
696+
697+
- name: Verify C# formatting
698+
working-directory: sdks/csharp
699+
run: dotnet format --no-restore --verify-no-changes SpacetimeDB.ClientSDK.sln
700+
701+
- name: Install Rust toolchain
702+
uses: dtolnay/rust-toolchain@stable
703+
704+
- name: Cache Rust dependencies
705+
uses: Swatinem/rust-cache@v2
706+
with:
707+
workspaces: ${{ github.workspace }}
708+
shared-key: spacetimedb
709+
# Let the main CI job save the cache since it builds the most things
710+
save-if: false
711+
712+
- name: Install SpacetimeDB CLI from the local checkout
713+
run: |
714+
cargo install --force --path crates/cli --locked --message-format=short
715+
cargo install --force --path crates/standalone --locked --message-format=short
716+
# Add a handy alias using the old binary name, so that we don't have to rewrite all scripts (incl. in submodules).
717+
ln -sf $CARGO_HOME/bin/spacetimedb-cli $CARGO_HOME/bin/spacetime
718+
719+
- name: Check quickstart-chat bindings are up to date
720+
working-directory: sdks/csharp
721+
run: |
722+
bash tools~/gen-quickstart.sh
723+
"${GITHUB_WORKSPACE}"/tools/check-diff.sh examples~/quickstart-chat || {
724+
echo 'Error: quickstart-chat bindings have changed. Please run `sdks/csharp/tools~/gen-quickstart.sh`.'
725+
exit 1
726+
}
727+
728+
- name: Check client-api bindings are up to date
729+
working-directory: sdks/csharp
730+
run: |
731+
bash tools~/gen-client-api.sh
732+
"${GITHUB_WORKSPACE}"/tools/check-diff.sh src/SpacetimeDB/ClientApi || {
733+
echo 'Error: Client API bindings are dirty. Please run `sdks/csharp/tools~/gen-client-api.sh`.'
734+
exit 1
735+
}
736+
737+
- name: Start SpacetimeDB
738+
run: |
739+
spacetime start &
740+
disown
741+
742+
- name: Run regression tests
743+
run: |
744+
bash sdks/csharp/tools~/run-regression-tests.sh
745+
tools/check-diff.sh sdks/csharp/examples~/regression-tests || {
746+
echo 'Error: Bindings are dirty. Please run `sdks/csharp/tools~/gen-regression-tests.sh`.'
747+
exit 1
748+
}

0 commit comments

Comments
 (0)