1- name : Test Suite
1+ name : C #/Unity - Test Suite
22
33on :
44 push :
55 branches :
6- - staging
6+ - master
77 pull_request :
88
99jobs :
@@ -12,88 +12,52 @@ jobs:
1212 steps :
1313 - name : Checkout repository
1414 uses : actions/checkout@v4
15- with :
16- submodules : true
17-
18- # Grab the SpacetimeDB branch name from the PR description. If it's not found, master will be used instead.
19- # We'll use this branch name for any integration tests with SpacetimeDB.
20-
21- - name : Extract SpacetimeDB branch name or PR link from PR description
22- id : extract-branch
23- if : github.event_name == 'pull_request'
24- env :
25- description : ${{ github.event.pull_request.body }}
26- run : |
27- # Check if description contains a branch name or a PR link
28- branch_or_pr=$(echo "$description" | grep -oP '(?<=SpacetimeDB branch name:\s).+')
29- echo "Branch or PR found: $branch_or_pr"
30-
31- if [[ -z "$branch_or_pr" ]]; then
32- branch="master"
33- elif [[ "$branch_or_pr" =~ ^https://github.com/.*/pull/[0-9]+$ ]]; then
34- # If it's a PR link, extract the branch name from the PR
35- pr_number=$(echo "$branch_or_pr" | grep -oP '[0-9]+$')
36- branch=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
37- https://api.github.com/repos/clockworklabs/SpacetimeDB/pulls/$pr_number | jq -r '.head.ref')
38- else
39- # It's already a branch name
40- branch="$branch_or_pr"
41- fi
42-
43- echo "branch=$branch" >> $GITHUB_OUTPUT
44- echo "Final branch name: $branch"
45-
46- - name : Checkout SpacetimeDB
47- uses : actions/checkout@v4
48- id : checkout-stdb
49- with :
50- repository : clockworklabs/SpacetimeDB
51- ref : ${{ steps.extract-branch.outputs.branch }}
52- path : SpacetimeDB~
5315
5416 # Run cheap .NET tests first. If those fail, no need to run expensive Unity tests.
5517
5618 - name : Setup dotnet
5719 uses : actions/setup-dotnet@v3
5820 with :
59- global-json-file : SpacetimeDB~/ modules/global.json
21+ global-json-file : modules/global.json
6022
6123 - name : Override NuGet packages
6224 run : |
63- dotnet pack SpacetimeDB~/ crates/bindings-csharp/BSATN.Runtime
64- dotnet pack SpacetimeDB~/ crates/bindings-csharp/Runtime
25+ dotnet pack crates/bindings-csharp/BSATN.Runtime
26+ dotnet pack crates/bindings-csharp/Runtime
6527
6628 # Write out the nuget config file to `nuget.config`. This causes the spacetimedb-csharp-sdk repository
6729 # to be aware of the local versions of the `bindings-csharp` packages in SpacetimeDB, and use them if
6830 # available. Otherwise, `spacetimedb-csharp-sdk` will use the NuGet versions of the packages.
6931 # This means that (if version numbers match) we will test the local versions of the C# packages, even
7032 # if they're not pushed to NuGet.
7133 # See https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file for more info on the config file.
72- ./tools~/write-nuget-config.sh SpacetimeDB~
34+ cd sdks/csharp
35+ ./tools~/write-nuget-config.sh ../..
7336
7437 - name : Run .NET tests
38+ working-directory : sdks/csharp
7539 run : dotnet test -warnaserror
7640
7741 - name : Verify C# formatting
42+ working-directory : sdks/csharp
7843 run : dotnet format --no-restore --verify-no-changes SpacetimeDB.ClientSDK.sln
7944
8045 # Now, setup the Unity tests.
8146
8247 - name : Patch spacetimedb dependency in Cargo.toml
83- working-directory : unity-tests~ /server-rust
48+ working-directory : demo/Blackholio /server-rust
8449 run : |
85- sed -i "s|spacetimedb *=.*|spacetimedb = \{ path = \"../../SpacetimeDB~ /crates/bindings\" \}|" Cargo.toml
50+ sed -i "s|spacetimedb *=.*|spacetimedb = \{ path = \"../../.. /crates/bindings\" \}|" Cargo.toml
8651 cat Cargo.toml
8752
8853 - name : Install Rust toolchain
8954 uses : dtolnay/rust-toolchain@stable
90-
9155
9256 - name : Cache Rust dependencies
9357 uses : Swatinem/rust-cache@v2
9458 id : cache-rust-deps
9559 with :
96- workspaces : unity-tests~ /server-rust
60+ workspaces : demo/Blackholio /server-rust
9761 key : ${{ steps.checkout-stdb.outputs.commit }}
9862 # Cache Rust deps even if unit tests have failed.
9963 cache-on-failure : true
@@ -104,21 +68,25 @@ jobs:
10468 # Rebuild only if we didn't get a precise cache hit.
10569 if : steps.cache-rust-deps.outputs.cache-hit == 'false'
10670 run : |
107- cargo install --force --path SpacetimeDB~/ crates/cli --locked --message-format=short
108- cargo install --force --path SpacetimeDB~/ crates/standalone --locked --message-format=short
71+ cargo install --force --path crates/cli --locked --message-format=short
72+ cargo install --force --path crates/standalone --locked --message-format=short
10973 # Add a handy alias using the old binary name, so that we don't have to rewrite all scripts (incl. in submodules).
11074 ln -sf $HOME/.cargo/bin/spacetimedb-cli $HOME/.cargo/bin/spacetime
11175 env :
11276 # Share the target directory with our local project to avoid rebuilding same SpacetimeDB crates twice.
113- CARGO_TARGET_DIR : unity-tests~ /server-rust/target
77+ CARGO_TARGET_DIR : demo/Blackholio /server-rust/target
11478
11579 - name : Generate client bindings
116- working-directory : unity-tests~ /server-rust
80+ working-directory : demo/Blackholio /server-rust
11781 run : bash ./generate.sh -y
11882
11983 - name : Check for changes
12084 run : |
121- git diff --exit-code unity-tests~/client-unity/Assets/Scripts/autogen || {
85+ # This was copied from tools/check-diff.sh.
86+ # It's required because `spacetime generate` creates lines with the SpacetimeDB commit
87+ # version, which would make this `git diff` check very brittle if included.
88+ PATTERN='^// This was generated using spacetimedb cli version.*'
89+ git diff --exit-code --ignore-matching-lines="$PATTERN" -- demo/Blackholio/client-unity/Assets/Scripts/autogen || {
12290 echo "Error: Bindings are dirty. Please generate bindings again and commit them to this branch."
12391 exit 1
12492 }
12795 uses : DeNA/unity-meta-check@v3
12896 with :
12997 enable_pr_comment : ${{ github.event_name == 'pull_request' }}
98+ target_path : sdks/csharp
13099 env :
131100 GITHUB_TOKEN : " ${{ secrets.GITHUB_TOKEN }}"
132101
@@ -136,33 +105,34 @@ jobs:
136105 disown
137106
138107 - name : Run regression tests
139- run : bash tools~/run-regression-tests.sh SpacetimeDB~
108+ run : bash sdks/csharp/ tools~/run-regression-tests.sh .
140109
141110 - name : Publish unity-tests module to SpacetimeDB
142- working-directory : unity-tests~ /server-rust
111+ working-directory : demo/Blackholio /server-rust
143112 run : |
144113 spacetime logout && spacetime login --server-issued-login local
145114 bash ./publish.sh
146115
147116 - name : Patch com.clockworklabs.spacetimedbsdk dependency in manifest.json
148- working-directory : unity-tests~ /client-unity/Packages
117+ working-directory : demo/Blackholio /client-unity/Packages
149118 run : |
150119 # Replace the com.clockworklabs.spacetimedbsdk dependency with the current branch.
151- # TODO: find out why pointing to a local directory doesn't work - is it because Unity CI action uses Docker?
152- yq e -i '.dependencies["com.clockworklabs.spacetimedbsdk"] = "https://github.com/clockworklabs/com.clockworklabs.spacetimedbsdk.git#${{ github.head_ref }}"' manifest.json
120+ # 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.
121+ # codegen does not work properly).
122+ yq e -i '.dependencies["com.clockworklabs.spacetimedbsdk"] = "https://github.com/clockworklabs/SpacetimeDB.git?path=sdks/csharp#${{ github.head_ref }}"' manifest.json
153123 cat manifest.json
154124
155125 - uses : actions/cache@v3
156126 with :
157- path : unity-tests~ /client-unity/Library
127+ path : demo/Blackholio /client-unity/Library
158128 key : Unity-${{ github.head_ref }}
159129 restore-keys : Unity-
160130
161131 - name : Run Unity tests
162132 uses : game-ci/unity-test-runner@v4
163133 with :
164134 unityVersion : 2022.3.32f1 # Adjust Unity version to a valid tag
165- projectPath : unity-tests~ /client-unity # Path to the Unity project subdirectory
135+ projectPath : demo/Blackholio /client-unity # Path to the Unity project subdirectory
166136 githubToken : ${{ secrets.GITHUB_TOKEN }}
167137 testMode : playmode
168138 useHostNetwork : true
0 commit comments