GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — C# module unit testing (#6501) · euxarist/SpacetimeDB@b304fd5

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .github/workflows
    • ci.yml
    • csharp-testing.yml
    • release.yml
  • Cargo.lock
  • Cargo.toml
  • codex-plugin/plugins/spacetimedb/skills/csharp-server
    • SKILL.md
  • crates
    • bindings-csharp
      • Codegen.Tests
        • Tests.cs
        • fixtures
          • diag/snapshots
            • ExtraCompilationErrors.net10.verified.txt
            • Module#FFI.verified.cs
            • Module.net10#FFI.verified.cs
            • Module.net10#Reducers.InAnotherNamespace.TestDuplicateReducerName.verified.cs
            • Module.net10#Reducers.OnReducerWithReservedPrefix.verified.cs
            • Module.net10#Reducers.TestDuplicateReducerKind1.verified.cs
            • Module.net10#Reducers.TestDuplicateReducerKind2.verified.cs
            • Module.net10#Reducers.TestDuplicateReducerName.verified.cs
            • Module.net10#Reducers.TestReducerReturnType.verified.cs
            • Module.net10#Reducers.TestReducerWithoutContext.verified.cs
            • Module.net10#Reducers.__ReducerWithReservedPrefix.verified.cs
            • Module.net10#TestScheduleIssues.DummyScheduledReducer.verified.cs
          • explicitnames/snapshots
            • Module#FFI.verified.cs
            • Module.net10#FFI.verified.cs
            • Module.net10#Reducers.DemoProcedure.verified.cs
            • Module.net10#Reducers.DemoReducer.verified.cs
            • Module.net10.wasm#DemoTable.verified.cs
            • Module.net10.wasm#FFI.verified.cs
            • Module.net10.wasm#Reducers.DemoProcedure.verified.cs
            • Module.net10.wasm#Reducers.DemoReducer.verified.cs
          • server/snapshots
            • Module#FFI.verified.cs
            • Module.net10#FFI.verified.cs
            • Module.net10#MultiTableRow.InsertMultiData.verified.cs
            • Module.net10#Reducers.InsertData.verified.cs
            • Module.net10#Reducers.ScheduleImmediate.verified.cs
            • Module.net10#Test.NestingNamespaces.AndClasses.InsertData2.verified.cs
            • Module.net10#Timers.Init.verified.cs
            • Module.net10#Timers.SendScheduledMessage.verified.cs
            • Module.net10.wasm#BTreeMultiColumn.verified.cs
            • Module.net10.wasm#BTreeViews.verified.cs
            • Module.net10.wasm#FFI.verified.cs
            • Module.net10.wasm#MultiTableRow.InsertMultiData.verified.cs
            • Module.net10.wasm#MultiTableRow.verified.cs
            • Module.net10.wasm#PrivateTable.verified.cs
            • Module.net10.wasm#PublicTable.verified.cs
            • Module.net10.wasm#Reducers.InsertData.verified.cs
            • Module.net10.wasm#Reducers.ScheduleImmediate.verified.cs
            • Module.net10.wasm#RegressionMultipleUniqueIndexesHadSameName.verified.cs
            • Module.net10.wasm#Test.NestingNamespaces.AndClasses.InsertData2.verified.cs
            • Module.net10.wasm#Timers.Init.verified.cs
            • Module.net10.wasm#Timers.SendMessageTimer.verified.cs
            • Module.net10.wasm#Timers.SendScheduledMessage.verified.cs
      • Codegen
        • Diag.cs
        • Environment.cs
        • Module.cs
        • TestModule.cs
      • Runtime
        • AuthCtx.cs
        • CompatibilitySuppressions.xml
        • DatabaseEnvironment.cs
        • HandlerContext.cs
        • Http.cs
        • Internal
          • DatabaseAccess.cs
          • FFI.cs
          • FramedRows.cs
          • IIndex.cs
          • IModuleContext.cs
          • IReducer.cs
          • ITable.cs
          • IView.cs
          • Module.cs
          • ModuleBuilder.cs
          • NamespaceBinding.cs
          • NamespaceRegistry.cs
          • Procedure.cs
          • TableAccessor.cs
          • TransactionCallback.cs
        • Log.cs
        • LogStopwatch.cs
        • ModuleContexts.cs
        • ProcedureContext.cs
        • Runtime.csproj
        • TransactionalContextState.cs
        • buildTransitive/net10.0
          • SpacetimeDB.Runtime.props
        • build
          • SpacetimeDB.Runtime.targets
      • SpacetimeSharpSATS.sln
      • Testing.Tests
        • AcceptanceTests.cs
        • ContextSelectionTests.cs
        • EnvironmentTests.cs
        • HostlessTests.cs
        • HttpTests.cs
        • InteropTests.cs
        • ModuleTestContextTests.cs
        • Module
          • AcceptanceModule.cs
          • ChatModule.cs
          • Module.csproj
          • Module.cs
          • SelectionChild
            • Module.cs
            • SelectionChild.csproj
          • SelectionLeaf
            • Module.cs
            • SelectionLeaf.csproj
          • SelectionMounts.cs
        • MountedTableTests.cs
        • ProcedureHookTests.cs
        • ProcedureTests.cs
        • QueryTests.cs
        • RangeIndexTests.cs
        • ReducerTests.cs
        • TableMutationTests.cs
        • TestAuthTests.cs
        • TestSchema.cs
        • Testing.Tests.csproj
        • UniqueIndexTests.cs
      • Testing
        • DEVELOP.md
        • DatabaseBackend.cs
        • ModuleTestContext.cs
        • Native.cs
        • NativeDatastore.cs
        • NativeTransaction.cs
        • ProcedureContextBuilder.cs
        • README.md
        • TestAuth.cs
        • TestClock.cs
        • TestRng.cs
        • Testing.csproj
    • cli/src/subcommands
      • init.rs
    • smoketests/tests/standalone
      • csharp_module.rs
    • test-datastore-ffi
      • Cargo.toml
      • src
        • lib.rs
        • transaction.rs
        • transaction
          • tests.rs
    • test-datastore/src
      • lib.rs
  • docs/docs/00250-how-to
    • 00900-unit-testing.md
  • skills/csharp-server
    • SKILL.md
  • templates/chat-console-cs
    • .template.json
    • README.md
    • client.csproj
    • tests
      • Module.Tests.csproj
      • ModuleTests.cs
  • tools
    • ci
      • commands
        • csharp-testing-packages
          • Cargo.toml
          • src
            • main.rs
        • test-csharp-build/src
          • main.rs
        • test/src
          • main.rs
      • src
        • main.rs
    • regen/src
      • csharp.rs
    • release/src/targets
      • csharp.rs

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.github/workflows/ci.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/ci.yml
+21-1Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1252,6 +1252,14 @@ jobs:
12521252
12531253
- *show-sccache-stats
12541254

1255+
csharp_testing_packages:
1256+
needs: [merge_queue_noop, lints]
1257+
if: ${{ needs.merge_queue_noop.outputs.skip_tests != 'true' }}
1258+
uses: ./.github/workflows/csharp-testing.yml
1259+
with:
1260+
# The merge queue and master still cover every platform before and after landing.
1261+
all-platforms: ${{ github.event_name != 'pull_request' }}
1262+
12551263
test:
12561264
needs:
12571265
[
@@ -1260,6 +1268,7 @@ jobs:
12601268
rust_tests,
12611269
rust_serial_tests,
12621270
csharp_tests,
1271+
csharp_testing_packages,
12631272
cpp_compile_tests,
12641273
sdk_tests_native,
12651274
sdk_tests_browser,
@@ -1277,6 +1286,7 @@ jobs:
12771286
RUST_BUILD_RESULT: ${{ needs.rust_test_build.result }}
12781287
RUST_SERIAL_RESULT: ${{ needs.rust_serial_tests.result }}
12791288
CSHARP_RESULT: ${{ needs.csharp_tests.result }}
1289+
CSHARP_TESTING_PACKAGES_RESULT: ${{ needs.csharp_testing_packages.result }}
12801290
CPP_RESULT: ${{ needs.cpp_compile_tests.result }}
12811291
SDK_NATIVE_RESULT: ${{ needs.sdk_tests_native.result }}
12821292
SDK_BROWSER_RESULT: ${{ needs.sdk_tests_browser.result }}
@@ -1285,6 +1295,7 @@ jobs:
12851295
test "${RUST_RESULT}" = success
12861296
test "${RUST_SERIAL_RESULT}" = success
12871297
test "${CSHARP_RESULT}" = success
1298+
test "${CSHARP_TESTING_PACKAGES_RESULT}" = success
12881299
test "${CPP_RESULT}" = success
12891300
test "${SDK_NATIVE_RESULT}" = success
12901301
test "${SDK_BROWSER_RESULT}" = success
@@ -2120,7 +2131,7 @@ jobs:
21202131
- *show-sccache-stats
21212132

21222133
csharp-testsuite:
2123-
needs: [merge_queue_noop, lints, upload-build-artifacts-linux]
2134+
needs: [merge_queue_noop, lints, upload-build-artifacts-linux, csharp_testing_packages]
21242135
if: ${{ needs.merge_queue_noop.outputs.skip_tests != 'true' }}
21252136
# The C# SDK build and tests saturated the small runner's CPU, so keep this on the main runner.
21262137
runs-on: spacetimedb-linux
@@ -2196,7 +2207,16 @@ jobs:
21962207
- name: Run C# SDK harness tests
21972208
run: cargo test -p sdk-csharp-test-harness --test sdk_csharp
21982209

2210+
- name: Download complete C# testing packages
2211+
uses: actions/download-artifact@v4
2212+
with:
2213+
name: spacetimedb-testing-packages
2214+
path: ${{ runner.temp }}/testing-packages
2215+
21992216
- name: Check C# managed and WASM build pipeline
2217+
env:
2218+
CSHARP_PACKAGE_FEED: ${{ runner.temp }}/testing-packages
2219+
CSHARP_PACKAGE_VERSION: ${{ needs.csharp_testing_packages.outputs.package-version }}
22002220
run: cargo ci test-csharp-build
22012221

22022222
- name: Check quickstart-chat bindings are up to date
Collapse file

‎.github/workflows/csharp-testing.yml‎

Copy file name to clipboard
+141Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
name: C# Testing Packages
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
use-release-tag:
7+
type: boolean
8+
default: false
9+
release-tag:
10+
type: string
11+
default: ""
12+
# Pull requests build and test linux-x64 only. Everything that lands or ships covers all platforms.
13+
all-platforms:
14+
type: boolean
15+
default: true
16+
outputs:
17+
package-version:
18+
value: ${{ jobs.prepare.outputs.package-version }}
19+
source-sha:
20+
value: ${{ jobs.prepare.outputs.sha }}
21+
22+
permissions:
23+
contents: read
24+
25+
jobs:
26+
prepare:
27+
runs-on: ubuntu-22.04
28+
outputs:
29+
sha: ${{ steps.prepare.outputs.sha }}
30+
package-version: ${{ steps.prepare.outputs.package-version }}
31+
platforms: ${{ steps.prepare.outputs.platforms }}
32+
steps:
33+
- uses: actions/checkout@v4
34+
with:
35+
persist-credentials: false
36+
fetch-depth: ${{ inputs.use-release-tag && '0' || '1' }}
37+
- uses: dsherret/rust-toolchain-file@v1
38+
- id: prepare
39+
env:
40+
RELEASE_TAG: ${{ inputs.release-tag }}
41+
GH_TOKEN: ${{ github.token }}
42+
run: >-
43+
cargo ci other-workflows csharp-testing-packages prepare
44+
--use-release-tag ${{ inputs.use-release-tag }} --all-platforms ${{ inputs.all-platforms }}
45+
46+
csharp_testing_native:
47+
needs: prepare
48+
name: C# testing native bridge (${{ matrix.rid }})
49+
runs-on: ${{ matrix.runner }}
50+
timeout-minutes: 45
51+
strategy:
52+
fail-fast: false
53+
matrix: ${{ fromJSON(needs.prepare.outputs.platforms) }}
54+
env:
55+
RUST_BACKTRACE: full
56+
CARGO_INCREMENTAL: 0
57+
steps:
58+
- uses: actions/checkout@v4
59+
with:
60+
ref: ${{ needs.prepare.outputs.sha }}
61+
persist-credentials: false
62+
- uses: dsherret/rust-toolchain-file@v1
63+
- uses: Swatinem/rust-cache@v2
64+
with:
65+
key: csharp-testing-${{ matrix.rid }}
66+
# Only CI pushes to master populate the cache, so pull requests don't evict each other's entries
67+
# and release runs never write the cache every branch reads.
68+
save-if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
69+
- uses: actions/setup-dotnet@v4
70+
with:
71+
global-json-file: global.json
72+
73+
- name: Build, inspect and test native bridge
74+
run: cargo ci other-workflows csharp-testing-packages native --rid ${{ matrix.rid }}
75+
76+
- name: Upload tested native bridge
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: spacetimedb-testing-native-${{ matrix.rid }}
80+
path: native/
81+
if-no-files-found: error
82+
retention-days: 14
83+
84+
csharp_testing_pack:
85+
needs: [prepare, csharp_testing_native]
86+
name: Assemble C# testing packages
87+
runs-on: ubuntu-22.04
88+
timeout-minutes: 20
89+
steps:
90+
- uses: actions/checkout@v4
91+
with:
92+
ref: ${{ needs.prepare.outputs.sha }}
93+
persist-credentials: false
94+
- uses: dsherret/rust-toolchain-file@v1
95+
- uses: actions/setup-dotnet@v4
96+
with:
97+
global-json-file: global.json
98+
- uses: actions/download-artifact@v4
99+
with:
100+
pattern: spacetimedb-testing-native-*
101+
merge-multiple: true
102+
path: native
103+
104+
- name: Pack and check complete package set
105+
run: >-
106+
cargo ci other-workflows csharp-testing-packages pack
107+
--version ${{ needs.prepare.outputs.package-version }} --all-platforms ${{ inputs.all-platforms }}
108+
109+
- uses: actions/upload-artifact@v4
110+
with:
111+
name: spacetimedb-testing-packages
112+
path: feed/*.nupkg
113+
if-no-files-found: error
114+
retention-days: 14
115+
116+
csharp_testing_packages:
117+
needs: [prepare, csharp_testing_pack]
118+
name: C# testing package acceptance (${{ matrix.rid }})
119+
runs-on: ${{ matrix.runner }}
120+
timeout-minutes: 20
121+
strategy:
122+
fail-fast: false
123+
matrix: ${{ fromJSON(needs.prepare.outputs.platforms) }}
124+
steps:
125+
- uses: actions/checkout@v4
126+
with:
127+
ref: ${{ needs.prepare.outputs.sha }}
128+
persist-credentials: false
129+
- uses: dsherret/rust-toolchain-file@v1
130+
- uses: actions/setup-dotnet@v4
131+
with:
132+
global-json-file: global.json
133+
- uses: actions/download-artifact@v4
134+
with:
135+
name: spacetimedb-testing-packages
136+
path: feed
137+
138+
- name: Check C# testing NuGet packages
139+
run: >-
140+
cargo ci other-workflows csharp-testing-packages accept
141+
--version ${{ needs.prepare.outputs.package-version }} --rid ${{ matrix.rid }}
Collapse file

‎.github/workflows/release.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/release.yml
+22-3Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,16 @@ jobs:
148148
if: ${{ !inputs.dry_run }}
149149
run: cargo-release release crates ${{ github.event.inputs.release_tag }}
150150

151-
release-csharp:
151+
validate-csharp-packages:
152152
needs: build-cargo-release
153+
if: ${{ inputs.release_csharp }}
154+
uses: ./.github/workflows/csharp-testing.yml
155+
with:
156+
use-release-tag: ${{ !inputs.dry_run }}
157+
release-tag: ${{ inputs.release_tag }}
158+
159+
release-csharp:
160+
needs: [build-cargo-release, validate-csharp-packages]
153161
runs-on: spacetimedb-linux
154162
if: ${{ inputs.release_csharp }}
155163
env:
@@ -158,10 +166,15 @@ jobs:
158166
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
159167

160168
steps:
169+
# The runner context isn't available in job-level env, so set the feed path here.
170+
- name: Set validated package feed path
171+
run: echo "CSHARP_PACKAGE_FEED=$RUNNER_TEMP/validated-csharp-packages" >> "$GITHUB_ENV"
172+
161173
- name: Checkout release source
162174
uses: actions/checkout@v4
163175
with:
164-
ref: ${{ inputs.dry_run && github.sha || github.event.inputs.release_tag }}
176+
ref: ${{ needs.validate-csharp-packages.outputs.source-sha }}
177+
persist-credentials: false
165178
submodules: recursive
166179

167180
- name: Set up Rust
@@ -183,7 +196,7 @@ jobs:
183196
- name: Set up .NET
184197
uses: actions/setup-dotnet@v4
185198
with:
186-
global-json-path: global.json
199+
global-json-file: global.json
187200

188201
- name: Install NuGet
189202
shell: bash
@@ -219,6 +232,12 @@ jobs:
219232
echo "Git URL rewrite config:"
220233
git config --global --get-regexp url
221234
235+
- name: Download validated C# packages
236+
uses: actions/download-artifact@v4
237+
with:
238+
name: spacetimedb-testing-packages
239+
path: ${{ env.CSHARP_PACKAGE_FEED }}
240+
222241
- name: Run C# SDK release (dry-run)
223242
if: ${{ inputs.dry_run }}
224243
run: cargo-release release csharp ${{ github.event.inputs.release_tag }} --dry-run
Collapse file

‎Cargo.lock‎

Copy file name to clipboardExpand all lines: Cargo.lock
+22Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎Cargo.toml‎

Copy file name to clipboardExpand all lines: Cargo.toml
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ members = [
4444
"crates/subscription",
4545
"crates/table",
4646
"crates/test-datastore",
47+
"crates/test-datastore-ffi",
4748
"crates/testing",
4849
"crates/update",
4950
"modules/benchmarks",
@@ -103,6 +104,7 @@ members = [
103104
"tools/ci/commands/check-release-deps",
104105
"tools/ci/commands/llm-benchmark-summary",
105106
"tools/ci/commands/cache-warm",
107+
"tools/ci/commands/csharp-testing-packages",
106108
"tools/ci/common",
107109
"tools/keynote-bench-harness",
108110
"tools/license-check",
Collapse file

‎codex-plugin/plugins/spacetimedb/skills/csharp-server/SKILL.md‎

Copy file name to clipboardExpand all lines: codex-plugin/plugins/spacetimedb/skills/csharp-server/SKILL.md
+10Lines changed: 10 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ metadata:
1515

1616
## Build Configuration (.NET 10)
1717

18+
Module unit tests use a sibling .NET 10 test project with an ordinary module
19+
`ProjectReference` and the separate `SpacetimeDB.Testing` NuGet package, at exactly
20+
the module's Runtime version. Run with `dotnet test`; no server or Rust compiler
21+
is required. Keep Testing out of module dependencies and test sources outside
22+
the module directory. Use `using var test = ModuleTestContext.Create(typeof(Module).Assembly)`
23+
and `test.WithReducerTx(TestAuth.Internal(), ctx => Module.Reducer(ctx))`.
24+
Callbacks are synchronous; one fixture supports one execution flow, while separate
25+
fixtures may run in parallel. The chat-console-cs template includes tests for
26+
.NET 10 only. See `/how-to/unit-testing` for setup and release availability.
27+
1828
New .NET 10 modules build as managed libraries by default. Use the CLI for WASM
1929
builds, or select the runtime identifier explicitly when invoking dotnet:
2030

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.