Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ rustflags = ["--cfg", "tokio_unstable"]
bump-versions = "run -p upgrade-version --"
llm = "run --package xtask-llm-benchmark --bin llm_benchmark --"
ci = "run -p ci --"
csharp = "run -p csharp-tools --"
regen = "run -p regen --"
smoketest = "ci smoketests --"
smoketests = "smoketest"
Expand Down
44 changes: 20 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ jobs:
run: |
dotnet pack -c Release crates/bindings-csharp/BSATN.Runtime
dotnet pack -c Release crates/bindings-csharp/Runtime
cd sdks/csharp
./tools~/write-nuget-config.sh ../..
cargo csharp write-nuget-config sdks/csharp .

# This step shouldn't be needed, but somehow we end up with caches that are missing librusty_v8.a.
# ChatGPT suspects that this could be due to different build invocations using the same target dir,
Expand Down Expand Up @@ -615,6 +614,11 @@ jobs:
with:
global-json-file: global.json

- name: Install Rust toolchain
uses: dsherret/rust-toolchain-file@v1
- name: Set default rust toolchain
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)

- name: Override NuGet packages
run: |
dotnet pack crates/bindings-csharp/BSATN.Runtime
Expand All @@ -626,8 +630,7 @@ jobs:
# 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 ../..
cargo csharp write-nuget-config sdks/csharp .

- name: Restore .NET solution
working-directory: sdks/csharp
Expand All @@ -640,11 +643,6 @@ jobs:
sed -i "s|spacetimedb *=.*|spacetimedb = \{ path = \"../../../crates/bindings\" \}|" Cargo.toml
cat Cargo.toml

- name: Install Rust toolchain
uses: dsherret/rust-toolchain-file@v1
- name: Set default rust toolchain
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)

- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
Expand Down Expand Up @@ -683,7 +681,7 @@ jobs:

- name: Check for changes
run: |
tools/check-diff.sh demo/Blackholio/client-unity/Assets/Scripts/autogen || {
cargo ci check-diff demo/Blackholio/client-unity/Assets/Scripts/autogen || {
echo 'Error: Bindings are dirty. Please run `demo/Blackholio/server-rust/generate.sh`.'
exit 1
}
Expand Down Expand Up @@ -760,6 +758,11 @@ jobs:
with:
global-json-file: global.json

- name: Install Rust toolchain
uses: dsherret/rust-toolchain-file@v1
- name: Set default rust toolchain
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)

- name: Override NuGet packages
run: |
dotnet pack crates/bindings-csharp/BSATN.Runtime
Expand All @@ -771,8 +774,7 @@ jobs:
# 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 ../..
cargo csharp write-nuget-config sdks/csharp .

- name: Restore .NET solution
working-directory: sdks/csharp
Expand All @@ -786,11 +788,6 @@ jobs:
working-directory: sdks/csharp
run: dotnet format --no-restore --verify-no-changes SpacetimeDB.ClientSDK.sln

- name: Install Rust toolchain
uses: dsherret/rust-toolchain-file@v1
- name: Set default rust toolchain
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)

- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
Expand Down Expand Up @@ -830,11 +827,10 @@ jobs:
ln -sf $CARGO_HOME/bin/spacetimedb-cli $CARGO_HOME/bin/spacetime

- name: Check quickstart-chat bindings are up to date
working-directory: sdks/csharp
run: |
bash tools~/gen-quickstart.sh
"${GITHUB_WORKSPACE}"/tools/check-diff.sh examples~/quickstart-chat || {
echo 'Error: quickstart-chat bindings have changed. Please run `sdks/csharp/tools~/gen-quickstart.sh`.'
cargo regen csharp quickstart
cargo ci check-diff templates/chat-console-cs/module_bindings || {
echo 'Error: quickstart-chat bindings have changed. Please run `cargo regen csharp quickstart`.'
exit 1
}

Expand All @@ -843,7 +839,7 @@ jobs:
# working-directory: sdks/csharp
# run: |
# bash tools~/gen-client-api.sh
# "${GITHUB_WORKSPACE}"/tools/check-diff.sh src/SpacetimeDB/ClientApi || {
# cargo ci check-diff sdks/csharp/src/SpacetimeDB/ClientApi || {
# echo 'Error: Client API bindings are dirty. Please run `sdks/csharp/tools~/gen-client-api.sh`.'
# exit 1
# }
Expand All @@ -856,8 +852,8 @@ jobs:
- name: Run regression tests
run: |
bash sdks/csharp/tools~/run-regression-tests.sh
tools/check-diff.sh sdks/csharp/examples~/regression-tests || {
echo 'Error: Bindings are dirty. Please run `sdks/csharp/tools~/gen-regression-tests.sh`.'
cargo ci check-diff sdks/csharp/examples~/regression-tests || {
echo 'Error: Bindings are dirty. Please run `cargo regen csharp regression-tests`.'
exit 1
}

Expand Down
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ members = [
"sdks/rust/tests/view-pk-client",
"sdks/rust/tests/event-table-client",
"tools/ci",
"tools/csharp-tools",
"tools/upgrade-version",
"tools/license-check",
"tools/replace-spacetimedb",
Expand Down
3 changes: 1 addition & 2 deletions sdks/csharp/DEVELOP.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ When developing against a local clone of SpacetimeDB, you'll need to ensure that
To develop against a local clone of SpacetimeDB at `../SpacetimeDB`, run the following command:

```sh
dotnet pack ../SpacetimeDB/crates/bindings-csharp/BSATN.Runtime && ./tools~/write-nuget-config.sh ../SpacetimeDB
dotnet pack ../SpacetimeDB/crates/bindings-csharp/BSATN.Runtime && cargo csharp write-nuget-config . --stdb-path ../SpacetimeDB
```

This will create a (`.gitignore`d) `nuget.config` file that uses the local build of the package, instead of the package on NuGet.
Expand Down Expand Up @@ -99,4 +99,3 @@ We could deduplicate multiply-subscribed rows server-side, but this represents a
There is also a class `MultiDictionaryDelta`. This represents a pre-processed batch of changes to a `MultiDictionary`. We prepare `MultiDictionaryDelta`s on a background thread and `Apply` them on the main thread. This allows us to do at least some work without blocking the main thread.

Note that if multiple subscriptions are subscribed to a row, when a server-side transaction updates that row, exactly the right number of updates will be sent over the network, in a single `ServerMessage`. `MultiDictionary` and `MultiDictionaryDelta` rely on this guarantee for correct operation, and will throw exceptions in debug mode if it is not met.

4 changes: 2 additions & 2 deletions sdks/csharp/tests~/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ You can use `dotnet test` (either in this directory or in the project root direc
# Using a different SpacetimeDB version
To run tests using a local version of the `SpacetimeDB` repo, you can add a `nuget.config` file in the **root** of this repository.

The `tools/write-nuget-config.sh` script can generate the `nuget.config`. It takes one parameter: the path to the root SpacetimeDB repository (relative or absolute).
The `cargo csharp write-nuget-config` command can generate `NuGet.Config`. It takes one or more directories where `NuGet.Config` should be written. Use `--stdb-path` to point at a different SpacetimeDB repository.

Then, you need to `dotnet pack` the `BSATN.Runtime` package in the `SpacetimeDB` repo.

Expand All @@ -13,7 +13,7 @@ Lastly, before running `dotnet test`, you should `dotnet nuget locals all --clea
Example:
```bash
$ export SPACETIMEDB_REPO_PATH="../SpacetimeDB"
$ tools/write-nuget-config.sh "${SPACETIMEDB_REPO_PATH}"
$ cargo csharp write-nuget-config . --stdb-path "${SPACETIMEDB_REPO_PATH}"
$ ( cd "${SPACETIMEDB_REPO_PATH}"/crates/bindings-csharp/BSATN.Runtime && dotnet pack )
$ dotnet nuget locals all --clear
$ dotnet test
Expand Down
10 changes: 0 additions & 10 deletions sdks/csharp/tools~/gen-quickstart.sh

This file was deleted.

12 changes: 0 additions & 12 deletions sdks/csharp/tools~/gen-regression-tests.sh

This file was deleted.

2 changes: 1 addition & 1 deletion sdks/csharp/tools~/run-regression-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ STDB_PATH="$SDK_PATH/../.."
SPACETIMEDB_SERVER_URL="${SPACETIMEDB_SERVER_URL:-local}"

# Regenerate Bindings
"$SDK_PATH/tools~/gen-regression-tests.sh"
cargo regen csharp regression-tests

# Build and run SpacetimeDB server
cargo build --manifest-path "$STDB_PATH/crates/standalone/Cargo.toml"
Expand Down
8 changes: 3 additions & 5 deletions sdks/csharp/tools~/update-against-stdb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ STDB_PATH="$1"
SDK_PATH="$(dirname "$0")/.."
SDK_PATH="$(realpath "$SDK_PATH")"

"$SDK_PATH/tools~/write-nuget-config.sh" "$STDB_PATH"
cargo csharp write-nuget-config "$SDK_PATH" "$STDB_PATH" --stdb-path "$STDB_PATH"
"$SDK_PATH/tools~/gen-client-api.sh"
"$SDK_PATH/tools~/gen-quickstart.sh"
"$SDK_PATH/tools~/gen-regression-tests.sh"
cargo regen csharp quickstart
cargo regen csharp regression-tests
dotnet nuget locals all --clear
dotnet pack "$STDB_PATH/crates/bindings-csharp"
rm -rf "$SDK_PATH/packages"
dotnet pack
dotnet test
pushd "$SDK_PATH"; git checkout -- 'packages/*.meta' 'packages/**/*.meta' packages/.gitignore; popd


84 changes: 0 additions & 84 deletions sdks/csharp/tools~/write-nuget-config.sh

This file was deleted.

12 changes: 0 additions & 12 deletions tools/check-diff.sh

This file was deleted.

12 changes: 12 additions & 0 deletions tools/ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,18 @@ Usage: version-upgrade-check

- `--help`: Print help

### `check-diff`

**Usage:**
```bash
Usage: check-diff [SUBDIR]
```

**Options:**

- `subdir`: Subdirectory to check. Defaults to the whole repository
- `--help`: Print help

### `docs`

**Usage:**
Expand Down
Loading
Loading