Skip to content

Commit 10c7997

Browse files
committed
[bfops/csharp-ci]: Update GitHub files for C#/Unity import
1 parent 2c7b668 commit 10c7997

5 files changed

Lines changed: 25 additions & 108 deletions

File tree

Lines changed: 20 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Test Suite
33
on:
44
push:
55
branches:
6-
- staging
6+
- master
77
pull_request:
88

99
jobs:
@@ -15,85 +15,51 @@ jobs:
1515
with:
1616
submodules: true
1717

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-
5418
# Run cheap .NET tests first. If those fail, no need to run expensive Unity tests.
5519

5620
- name: Setup dotnet
5721
uses: actions/setup-dotnet@v3
5822
with:
59-
global-json-file: SpacetimeDB~/modules/global.json
23+
global-json-file: modules/global.json
6024

6125
- name: Override NuGet packages
6226
run: |
63-
dotnet pack SpacetimeDB~/crates/bindings-csharp/BSATN.Runtime
64-
dotnet pack SpacetimeDB~/crates/bindings-csharp/Runtime
27+
dotnet pack crates/bindings-csharp/BSATN.Runtime
28+
dotnet pack crates/bindings-csharp/Runtime
6529
6630
# Write out the nuget config file to `nuget.config`. This causes the spacetimedb-csharp-sdk repository
6731
# to be aware of the local versions of the `bindings-csharp` packages in SpacetimeDB, and use them if
6832
# available. Otherwise, `spacetimedb-csharp-sdk` will use the NuGet versions of the packages.
6933
# This means that (if version numbers match) we will test the local versions of the C# packages, even
7034
# if they're not pushed to NuGet.
7135
# 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~
36+
cd sdks/csharp
37+
./tools~/write-nuget-config.sh ../..
7338
7439
- name: Run .NET tests
40+
working-directory: sdks/csharp
7541
run: dotnet test -warnaserror
7642

7743
- name: Verify C# formatting
44+
working-directory: sdks/csharp
7845
run: dotnet format --no-restore --verify-no-changes SpacetimeDB.ClientSDK.sln
7946

8047
# Now, setup the Unity tests.
8148

8249
- name: Patch spacetimedb dependency in Cargo.toml
83-
working-directory: unity-tests~/server-rust
50+
working-directory: sdks/csharp/unity-tests~/server-rust
8451
run: |
8552
sed -i "s|spacetimedb *=.*|spacetimedb = \{ path = \"../../SpacetimeDB~/crates/bindings\" \}|" Cargo.toml
8653
cat Cargo.toml
8754
8855
- name: Install Rust toolchain
8956
uses: dtolnay/rust-toolchain@stable
90-
9157

9258
- name: Cache Rust dependencies
9359
uses: Swatinem/rust-cache@v2
9460
id: cache-rust-deps
9561
with:
96-
workspaces: unity-tests~/server-rust
62+
workspaces: sdks/csharp/unity-tests~/server-rust
9763
key: ${{ steps.checkout-stdb.outputs.commit }}
9864
# Cache Rust deps even if unit tests have failed.
9965
cache-on-failure: true
@@ -104,21 +70,21 @@ jobs:
10470
# Rebuild only if we didn't get a precise cache hit.
10571
if: steps.cache-rust-deps.outputs.cache-hit == 'false'
10672
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
73+
cargo install --force --path crates/cli --locked --message-format=short
74+
cargo install --force --path crates/standalone --locked --message-format=short
10975
# Add a handy alias using the old binary name, so that we don't have to rewrite all scripts (incl. in submodules).
11076
ln -sf $HOME/.cargo/bin/spacetimedb-cli $HOME/.cargo/bin/spacetime
11177
env:
11278
# Share the target directory with our local project to avoid rebuilding same SpacetimeDB crates twice.
113-
CARGO_TARGET_DIR: unity-tests~/server-rust/target
79+
CARGO_TARGET_DIR: sdks/csharp/unity-tests~/server-rust/target
11480

11581
- name: Generate client bindings
116-
working-directory: unity-tests~/server-rust
82+
working-directory: sdks/csharp/unity-tests~/server-rust
11783
run: bash ./generate.sh -y
11884

11985
- name: Check for changes
12086
run: |
121-
git diff --exit-code unity-tests~/client-unity/Assets/Scripts/autogen || {
87+
git diff --exit-code sdks/csharp/unity-tests~/client-unity/Assets/Scripts/autogen || {
12288
echo "Error: Bindings are dirty. Please generate bindings again and commit them to this branch."
12389
exit 1
12490
}
@@ -136,16 +102,16 @@ jobs:
136102
disown
137103
138104
- name: Run regression tests
139-
run: bash tools~/run-regression-tests.sh SpacetimeDB~
105+
run: bash sdks/csharp/tools~/run-regression-tests.sh .
140106

141107
- name: Publish unity-tests module to SpacetimeDB
142-
working-directory: unity-tests~/server-rust
108+
working-directory: sdks/csharp/unity-tests~/server-rust
143109
run: |
144110
spacetime logout && spacetime login --server-issued-login local
145111
bash ./publish.sh
146112
147113
- name: Patch com.clockworklabs.spacetimedbsdk dependency in manifest.json
148-
working-directory: unity-tests~/client-unity/Packages
114+
working-directory: sdks/csharp/unity-tests~/client-unity/Packages
149115
run: |
150116
# Replace the com.clockworklabs.spacetimedbsdk dependency with the current branch.
151117
# TODO: find out why pointing to a local directory doesn't work - is it because Unity CI action uses Docker?
@@ -154,15 +120,15 @@ jobs:
154120
155121
- uses: actions/cache@v3
156122
with:
157-
path: unity-tests~/client-unity/Library
123+
path: sdks/csharp/unity-tests~/client-unity/Library
158124
key: Unity-${{ github.head_ref }}
159125
restore-keys: Unity-
160126

161127
- name: Run Unity tests
162128
uses: game-ci/unity-test-runner@v4
163129
with:
164130
unityVersion: 2022.3.32f1 # Adjust Unity version to a valid tag
165-
projectPath: unity-tests~/client-unity # Path to the Unity project subdirectory
131+
projectPath: sdks/csharp/unity-tests~/client-unity # Path to the Unity project subdirectory
166132
githubToken: ${{ secrets.GITHUB_TOKEN }}
167133
testMode: playmode
168134
useHostNetwork: true

sdks/csharp/.github/pull_request_template.md

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

sdks/csharp/.github/workflows/check-pr-base.yml

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

sdks/csharp/DEVELOP.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Migration note
2+
3+
We are in the process of moving from the `com.clockworklabs.spacetimedbsdk` repo to the `sdks/csharp` subdirectory of [SpacetimeDB](https://github.com/clockworklabs/SpacetimeDB). **Any new changes should be made there**. The `com.clockworklabs.spacetimedbsdk` repo will only be updated on release. Apologies in advance for any sharp edges while the migration is in progress.
4+
15
# Notes for maintainers
26

37
## `SpacetimeDB.ClientApi`

sdks/csharp/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@ The Unity SDK uses the same code as the C# SDK. You can find the documentation f
1010

1111
There is also a comprehensive Unity tutorial/demo available:
1212
- [Unity Tutorial](https://spacetimedb.com/docs/unity/part-1) Doc
13-
- [Unity Demo](https://github.com/clockworklabs/Blackholio) Repo
14-
-
13+
- [Unity Demo](https://github.com/clockworklabs/SpacetimeDB/tree/master/demo/Blackholio) Repo

0 commit comments

Comments
 (0)