Skip to content

Commit 815d00c

Browse files
committed
Move everything under ci.yml
1 parent 8d1d37c commit 815d00c

2 files changed

Lines changed: 218 additions & 141 deletions

File tree

.github/workflows/ci.yml

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

.github/workflows/unity-test.yml

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

0 commit comments

Comments
 (0)