1
- name : Test Suite
1
+ name : C #/Unity - Test Suite
2
2
3
3
on :
4
4
push :
5
5
branches :
6
- - staging
6
+ - master
7
7
pull_request :
8
8
9
9
jobs :
@@ -12,88 +12,52 @@ jobs:
12
12
steps :
13
13
- name : Checkout repository
14
14
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~
53
15
54
16
# Run cheap .NET tests first. If those fail, no need to run expensive Unity tests.
55
17
56
18
- name : Setup dotnet
57
19
uses : actions/setup-dotnet@v3
58
20
with :
59
- global-json-file : SpacetimeDB~/ modules/global.json
21
+ global-json-file : modules/global.json
60
22
61
23
- name : Override NuGet packages
62
24
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
65
27
66
28
# Write out the nuget config file to `nuget.config`. This causes the spacetimedb-csharp-sdk repository
67
29
# to be aware of the local versions of the `bindings-csharp` packages in SpacetimeDB, and use them if
68
30
# available. Otherwise, `spacetimedb-csharp-sdk` will use the NuGet versions of the packages.
69
31
# This means that (if version numbers match) we will test the local versions of the C# packages, even
70
32
# if they're not pushed to NuGet.
71
33
# 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 ../..
73
36
74
37
- name : Run .NET tests
38
+ working-directory : sdks/csharp
75
39
run : dotnet test -warnaserror
76
40
77
41
- name : Verify C# formatting
42
+ working-directory : sdks/csharp
78
43
run : dotnet format --no-restore --verify-no-changes SpacetimeDB.ClientSDK.sln
79
44
80
45
# Now, setup the Unity tests.
81
46
82
47
- name : Patch spacetimedb dependency in Cargo.toml
83
- working-directory : unity-tests~ /server-rust
48
+ working-directory : demo/Blackholio /server-rust
84
49
run : |
85
- sed -i "s|spacetimedb *=.*|spacetimedb = \{ path = \"../../SpacetimeDB~ /crates/bindings\" \}|" Cargo.toml
50
+ sed -i "s|spacetimedb *=.*|spacetimedb = \{ path = \"../../.. /crates/bindings\" \}|" Cargo.toml
86
51
cat Cargo.toml
87
52
88
53
- name : Install Rust toolchain
89
54
uses : dtolnay/rust-toolchain@stable
90
-
91
55
92
56
- name : Cache Rust dependencies
93
57
uses : Swatinem/rust-cache@v2
94
58
id : cache-rust-deps
95
59
with :
96
- workspaces : unity-tests~ /server-rust
60
+ workspaces : demo/Blackholio /server-rust
97
61
key : ${{ steps.checkout-stdb.outputs.commit }}
98
62
# Cache Rust deps even if unit tests have failed.
99
63
cache-on-failure : true
@@ -104,21 +68,25 @@ jobs:
104
68
# Rebuild only if we didn't get a precise cache hit.
105
69
if : steps.cache-rust-deps.outputs.cache-hit == 'false'
106
70
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
109
73
# Add a handy alias using the old binary name, so that we don't have to rewrite all scripts (incl. in submodules).
110
74
ln -sf $HOME/.cargo/bin/spacetimedb-cli $HOME/.cargo/bin/spacetime
111
75
env :
112
76
# 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
114
78
115
79
- name : Generate client bindings
116
- working-directory : unity-tests~ /server-rust
80
+ working-directory : demo/Blackholio /server-rust
117
81
run : bash ./generate.sh -y
118
82
119
83
- name : Check for changes
120
84
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 || {
122
90
echo "Error: Bindings are dirty. Please generate bindings again and commit them to this branch."
123
91
exit 1
124
92
}
127
95
uses : DeNA/unity-meta-check@v3
128
96
with :
129
97
enable_pr_comment : ${{ github.event_name == 'pull_request' }}
98
+ target_path : sdks/csharp
130
99
env :
131
100
GITHUB_TOKEN : " ${{ secrets.GITHUB_TOKEN }}"
132
101
@@ -136,33 +105,34 @@ jobs:
136
105
disown
137
106
138
107
- name : Run regression tests
139
- run : bash tools~/run-regression-tests.sh SpacetimeDB~
108
+ run : bash sdks/csharp/ tools~/run-regression-tests.sh .
140
109
141
110
- name : Publish unity-tests module to SpacetimeDB
142
- working-directory : unity-tests~ /server-rust
111
+ working-directory : demo/Blackholio /server-rust
143
112
run : |
144
113
spacetime logout && spacetime login --server-issued-login local
145
114
bash ./publish.sh
146
115
147
116
- 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
149
118
run : |
150
119
# 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
153
123
cat manifest.json
154
124
155
125
- uses : actions/cache@v3
156
126
with :
157
- path : unity-tests~ /client-unity/Library
127
+ path : demo/Blackholio /client-unity/Library
158
128
key : Unity-${{ github.head_ref }}
159
129
restore-keys : Unity-
160
130
161
131
- name : Run Unity tests
162
132
uses : game-ci/unity-test-runner@v4
163
133
with :
164
134
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
166
136
githubToken : ${{ secrets.GITHUB_TOKEN }}
167
137
testMode : playmode
168
138
useHostNetwork : true
0 commit comments