diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 69d6b8b1..643a1628 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -36,28 +36,9 @@ jobs: # 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, - # and https://tldp.org/LDP/abs/html/here-docs.html for more info on this bash feature. - cat >nuget.config < - - - - - - - - - - - - - - - - - - EOF + # See https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file for more info on the config file. + ./tools~/write-nuget-config.sh ../SpacetimeDB + - name: Restore dependencies working-directory: spacetimedb-csharp-sdk run: dotnet restore diff --git a/tests~/README.md b/tests~/README.md new file mode 100644 index 00000000..95f9a400 --- /dev/null +++ b/tests~/README.md @@ -0,0 +1,20 @@ +# Running tests +You can use `dotnet test` (either in this directory or in the project root directory) to run the tests. + +# 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). + +Then, you need to `dotnet pack` the `BSATN.Runtime` package in the `SpacetimeDB` repo. + +Lastly, before running `dotnet test`, you should `dotnet nuget locals all --clear` to clear out any cached packages. This ensures you're actually testing with the new package you just built. + +Example: +```bash +$ export SPACETIMEDB_REPO_PATH="../SpacetimeDB" +$ tools/write-nuget-config.sh "${SPACETIMEDB_REPO_PATH}" +$ ( cd "${SPACETIMEDB_REPO_PATH}"/crates/bindings-csharp/BSATN.Runtime && dotnet pack ) +$ dotnet nuget locals all --clear +$ dotnet test +``` diff --git a/tools~/write-nuget-config.sh b/tools~/write-nuget-config.sh new file mode 100755 index 00000000..1655fc96 --- /dev/null +++ b/tools~/write-nuget-config.sh @@ -0,0 +1,35 @@ +set -ueo pipefail + +SPACETIMEDB_REPO_PATH="$1" + +cd "$(dirname "$(readlink -f "$0")")" +cd .. + +# 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. +# See https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file for more info on the config file, +# and https://tldp.org/LDP/abs/html/here-docs.html for more info on this bash feature. +cat >nuget.config < + + + + + + + + + + + + + + + + + +EOF + +echo "Wrote nuget.config contents:" +cat nuget.config