From 2a10aff4970265cc66883219cd8040df0cc77d18 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Mon, 9 Sep 2024 12:50:33 -0700 Subject: [PATCH 1/4] redo PR --- .github/workflows/dotnet.yml | 25 +++---------------------- tests~/README.md | 20 ++++++++++++++++++++ tools~/write-nuget-config.sh | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 22 deletions(-) create mode 100644 tests~/README.md create mode 100644 tools~/write-nuget-config.sh diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 69d6b8b1..a30d7d9d 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. + ./scripts/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 100644 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 From 062e524f7f772b25f068b27653d4577d0e7466ac Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Mon, 9 Sep 2024 12:53:39 -0700 Subject: [PATCH 2/4] fix --- .github/workflows/dotnet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index a30d7d9d..328eb5f7 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -37,7 +37,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. - ./scripts/write-nuget-config.sh ../SpacetimeDB + ./tools/write-nuget-config.sh ../SpacetimeDB - name: Restore dependencies working-directory: spacetimedb-csharp-sdk From 1afa3ad9335536552d24e6a2504e43f295f2ae49 Mon Sep 17 00:00:00 2001 From: Ingvar Stepanyan Date: Thu, 3 Oct 2024 12:58:39 +0100 Subject: [PATCH 3/4] Fix path --- .github/workflows/dotnet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 328eb5f7..643a1628 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -37,7 +37,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. - ./tools/write-nuget-config.sh ../SpacetimeDB + ./tools~/write-nuget-config.sh ../SpacetimeDB - name: Restore dependencies working-directory: spacetimedb-csharp-sdk From 4b67ab213a6a9d5652a8fdf22fbda1ff81ff05b0 Mon Sep 17 00:00:00 2001 From: Ingvar Stepanyan Date: Thu, 3 Oct 2024 13:00:14 +0100 Subject: [PATCH 4/4] Mark script as executable --- tools~/write-nuget-config.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 tools~/write-nuget-config.sh diff --git a/tools~/write-nuget-config.sh b/tools~/write-nuget-config.sh old mode 100644 new mode 100755