mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-05-14 11:48:28 -04:00
7aae091d85
# Description of Changes I chose to regenerate all of the bindings in https://github.com/clockworklabs/SpacetimeDB/pull/3310, but that caused the snapshots to change. This PR follows up to update them. I also updated the outdated script `tools~/gen-quickstart-chat.sh` (which was generating from a different module than the CI was), and updated the CI to use it instead of manually running a similar command. # API and ABI breaking changes Test-only changes. # Expected complexity level and risk 1 # Testing - [x] unity-testsuite passes on this PR (which it does not on `master`). --------- Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
165 lines
6.9 KiB
YAML
165 lines
6.9 KiB
YAML
name: C#/Unity - Test Suite
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
pull_request:
|
|
|
|
jobs:
|
|
unity-testsuite:
|
|
runs-on: spacetimedb-runner
|
|
# Cancel any previous testsuites running on the same PR and/or ref.
|
|
concurrency:
|
|
group: unity-test-${{ github.event.pull_request.number || github.ref }}
|
|
cancel-in-progress: true
|
|
timeout-minutes: 30
|
|
steps:
|
|
- name: Checkout repository
|
|
id: checkout-stdb
|
|
uses: actions/checkout@v4
|
|
|
|
# Run cheap .NET tests first. If those fail, no need to run expensive Unity tests.
|
|
|
|
- name: Setup dotnet
|
|
uses: actions/setup-dotnet@v3
|
|
with:
|
|
global-json-file: global.json
|
|
|
|
- name: Override NuGet packages
|
|
run: |
|
|
dotnet pack crates/bindings-csharp/BSATN.Runtime
|
|
dotnet pack crates/bindings-csharp/Runtime
|
|
|
|
# Write out the nuget config file to `nuget.config`. This causes the spacetimedb-csharp-sdk repository
|
|
# to be aware of the local versions of the `bindings-csharp` packages in SpacetimeDB, and use them if
|
|
# available. Otherwise, `spacetimedb-csharp-sdk` will use the NuGet versions of the packages.
|
|
# This means that (if version numbers match) we will test the local versions of the C# packages, even
|
|
# if they're not pushed to NuGet.
|
|
# See https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file for more info on the config file.
|
|
cd sdks/csharp
|
|
./tools~/write-nuget-config.sh ../..
|
|
|
|
- name: Run .NET tests
|
|
working-directory: sdks/csharp
|
|
run: dotnet test -warnaserror
|
|
|
|
- name: Verify C# formatting
|
|
working-directory: sdks/csharp
|
|
run: dotnet format --no-restore --verify-no-changes SpacetimeDB.ClientSDK.sln
|
|
|
|
# Now, setup the Unity tests.
|
|
|
|
- name: Patch spacetimedb dependency in Cargo.toml
|
|
working-directory: demo/Blackholio/server-rust
|
|
run: |
|
|
sed -i "s|spacetimedb *=.*|spacetimedb = \{ path = \"../../../crates/bindings\" \}|" Cargo.toml
|
|
cat Cargo.toml
|
|
|
|
- name: Install Rust toolchain
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
- name: Cache Rust dependencies
|
|
uses: Swatinem/rust-cache@v2
|
|
id: cache-rust-deps
|
|
with:
|
|
workspaces: demo/Blackholio/server-rust
|
|
key: ${{ steps.checkout-stdb.outputs.commit }}
|
|
# Cache Rust deps even if unit tests have failed.
|
|
cache-on-failure: true
|
|
# Cache the CLI as well.
|
|
cache-all-crates: true
|
|
|
|
- name: Install SpacetimeDB CLI from the local checkout
|
|
# Rebuild only if we didn't get a precise cache hit.
|
|
if: steps.cache-rust-deps.outputs.cache-hit == 'false'
|
|
run: |
|
|
cargo install --force --path crates/cli --locked --message-format=short
|
|
cargo install --force --path crates/standalone --locked --message-format=short
|
|
# Add a handy alias using the old binary name, so that we don't have to rewrite all scripts (incl. in submodules).
|
|
ln -sf $HOME/.cargo/bin/spacetimedb-cli $HOME/.cargo/bin/spacetime
|
|
env:
|
|
# Share the target directory with our local project to avoid rebuilding same SpacetimeDB crates twice.
|
|
CARGO_TARGET_DIR: demo/Blackholio/server-rust/target
|
|
|
|
- name: Check quickstart-chat bindings are up to date
|
|
working-directory: sdks/csharp/examples~/quickstart-chat
|
|
run: |
|
|
bash ../../tools~/gen-quickstart.sh "${GITHUB_WORKSPACE}"
|
|
# This was copied from tools/check-diff.sh.
|
|
# It's required because `spacetime generate` creates lines with the SpacetimeDB commit
|
|
# version, which would make this `git diff` check very brittle if included.
|
|
PATTERN='^// This was generated using spacetimedb cli version.*'
|
|
git diff --exit-code --ignore-matching-lines="$PATTERN" -- . || {
|
|
echo "Error: quickstart-chat bindings have changed. Please regenerate the bindings and commit them to this branch."
|
|
exit 1
|
|
}
|
|
|
|
- name: Generate client bindings
|
|
working-directory: demo/Blackholio/server-rust
|
|
run: bash ./generate.sh -y
|
|
|
|
- name: Check for changes
|
|
run: |
|
|
# This was copied from tools/check-diff.sh.
|
|
# It's required because `spacetime generate` creates lines with the SpacetimeDB commit
|
|
# version, which would make this `git diff` check very brittle if included.
|
|
PATTERN='^// This was generated using spacetimedb cli version.*'
|
|
git diff --exit-code --ignore-matching-lines="$PATTERN" -- demo/Blackholio/client-unity/Assets/Scripts/autogen || {
|
|
echo "Error: Bindings are dirty. Please generate bindings again and commit them to this branch."
|
|
exit 1
|
|
}
|
|
|
|
- name: Check Unity meta files
|
|
uses: DeNA/unity-meta-check@v3
|
|
with:
|
|
enable_pr_comment: ${{ github.event_name == 'pull_request' }}
|
|
target_path: sdks/csharp
|
|
env:
|
|
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
|
|
|
- name: Start SpacetimeDB
|
|
run: |
|
|
spacetime start &
|
|
disown
|
|
|
|
- name: Run regression tests
|
|
run: bash sdks/csharp/tools~/run-regression-tests.sh .
|
|
|
|
- name: Publish unity-tests module to SpacetimeDB
|
|
working-directory: demo/Blackholio/server-rust
|
|
run: |
|
|
spacetime logout && spacetime login --server-issued-login local
|
|
bash ./publish.sh
|
|
|
|
- name: Patch com.clockworklabs.spacetimedbsdk dependency in manifest.json
|
|
working-directory: demo/Blackholio/client-unity/Packages
|
|
run: |
|
|
# Replace the com.clockworklabs.spacetimedbsdk dependency with the current branch.
|
|
# 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.
|
|
# codegen does not work properly).
|
|
yq e -i '.dependencies["com.clockworklabs.spacetimedbsdk"] = "https://github.com/clockworklabs/SpacetimeDB.git?path=sdks/csharp#${{ github.head_ref }}"' manifest.json
|
|
cat manifest.json
|
|
|
|
- uses: actions/cache@v3
|
|
with:
|
|
path: demo/Blackholio/client-unity/Library
|
|
key: Unity-${{ github.head_ref }}
|
|
restore-keys: Unity-
|
|
|
|
- name: Run Unity tests
|
|
uses: game-ci/unity-test-runner@v4
|
|
with:
|
|
unityVersion: 2022.3.32f1 # Adjust Unity version to a valid tag
|
|
projectPath: demo/Blackholio/client-unity # Path to the Unity project subdirectory
|
|
githubToken: ${{ secrets.GITHUB_TOKEN }}
|
|
testMode: playmode
|
|
useHostNetwork: true
|
|
env:
|
|
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
|
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
|
|
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
|
|
# Skip if this is an external contribution.
|
|
# The license secrets will be empty, so the step would fail anyway.
|
|
if: ${{ !github.event.pull_request.head.repo.fork }}
|