From 5ea08f27129fa8b66a9a8e81fc2564045e3c2dcc Mon Sep 17 00:00:00 2001 From: John Sedlak Date: Wed, 17 Jun 2026 14:41:26 -0400 Subject: [PATCH] Bump Orleans to 10.2.x and adopt NuGet Trusted Publishing (#4) Raise the Microsoft.Orleans.Journaling floor from 10.0.1-alpha.1 to 10.2.0-alpha.1 and align the rest of the Orleans family (Sdk, Reminders, Streaming) on 10.2.0 so Strata consumers compile against the same version they run on. Bump the Microsoft.Extensions.* packages to the 10.0.5 floor the new Journaling requires. The journaling storage/hosting API was redesigned between these alphas (StateMachineStorage -> JournalStorage), so migrate the test fixture: AddStateMachineStorage/IStateMachineStorageProvider/VolatileStateMachine- StorageProvider become AddJournalStorage/IJournalStorageProvider/Volatile- JournalStorageProvider, plus a now-required journal format via UseJsonJournalFormat. The JSON format needs polymorphism declared for the abstract BaseAccountEvent to round-trip persisted events. Also switch the publish workflow to NuGet Trusted Publishing (OIDC via NuGet/login@v1, no long-lived API key), fix the SDK to 10.0.x for the net10.0 targets, and drive the package version through dotnet pack. Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/nuget-publish.yml | 40 ++++++++++++------- .../JournalingTests/JournalingTestFixture.cs | 37 +++++++++++++++-- .../Strata.Journaling.Tests.csproj | 4 +- src/Strata/Strata.csproj | 14 +++---- 4 files changed, 69 insertions(+), 26 deletions(-) diff --git a/.github/workflows/nuget-publish.yml b/.github/workflows/nuget-publish.yml index ed2e7fb..16896a1 100644 --- a/.github/workflows/nuget-publish.yml +++ b/.github/workflows/nuget-publish.yml @@ -10,9 +10,13 @@ jobs: build: runs-on: ubuntu-latest + permissions: + contents: read + id-token: write # Required for NuGet Trusted Publishing (OIDC token issuance) + steps: - name: Checkout Code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Get next version uses: reecetech/version-increment@2023.9.3 @@ -21,18 +25,10 @@ jobs: scheme: semver increment: patch - - name: Update versions - uses: jacobtomlinson/gha-find-replace@v3 - with: - include: "*.csproj" - find: "1.0.0-beta" - replace: "${{ steps.version.outputs.version }}" - regex: false - - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: 9.0.x + dotnet-version: 10.0.x - name: Install dependencies run: dotnet restore @@ -40,8 +36,24 @@ jobs: - name: Build run: dotnet build --configuration Release --no-restore - - name: Publish Strata - uses: brandedoutcast/publish-nuget@v2.5.2 + - name: Pack Strata + run: >- + dotnet pack src/Strata/Strata.csproj + --configuration Release + -p:Version=${{ steps.version.outputs.version }} + --output ${{ runner.temp }}/packages + + # Exchange the GitHub OIDC token for a short-lived nuget.org API key. + # Requires a Trusted Publishing policy on nuget.org for this repo + workflow. + - name: NuGet login (OIDC -> temp API key) + uses: NuGet/login@v1 + id: login with: - PROJECT_FILE_PATH: src/Strata/Strata.csproj - NUGET_KEY: ${{secrets.NUGET_API_KEY}} + user: jsedlak # nuget.org username (profile name); swap for ${{ secrets.NUGET_USER }} if preferred + + - name: Publish Strata + run: >- + dotnet nuget push ${{ runner.temp }}/packages/*.nupkg + --api-key ${{ steps.login.outputs.NUGET_API_KEY }} + --source https://api.nuget.org/v3/index.json + --skip-duplicate diff --git a/src/Strata.Journaling.Tests/JournalingTests/JournalingTestFixture.cs b/src/Strata.Journaling.Tests/JournalingTests/JournalingTestFixture.cs index 57d6721..d897cfd 100644 --- a/src/Strata.Journaling.Tests/JournalingTests/JournalingTestFixture.cs +++ b/src/Strata.Journaling.Tests/JournalingTests/JournalingTestFixture.cs @@ -1,9 +1,13 @@ using System.Collections.Concurrent; +using System.Text.Json.Serialization; +using System.Text.Json.Serialization.Metadata; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Orleans.Configuration; using Orleans.Journaling; +using Orleans.Journaling.Json; using Orleans.TestingHost; +using Strata.Journaling.Tests.JournalingTests.Events; using Xunit; namespace Strata.Journaling.Tests; @@ -19,7 +23,7 @@ public class JournalingTestFixture : IAsyncLifetime public JournalingTestFixture() { var builder = new InProcessTestClusterBuilder(); - var storageProvider = new VolatileStateMachineStorageProvider(); + var storageProvider = new VolatileJournalStorageProvider(); static void ConfigureConsoleLogging(ILoggingBuilder logging) { @@ -36,8 +40,9 @@ static void ConfigureConsoleLogging(ILoggingBuilder logging) siloBuilder.AddMemoryGrainStorageAsDefault(); siloBuilder.UseInMemoryReminderService(); siloBuilder.ConfigureLogging(ConfigureConsoleLogging); - siloBuilder.AddStateMachineStorage(); - siloBuilder.Services.AddSingleton(storageProvider); + siloBuilder.AddJournalStorage(); + siloBuilder.Services.AddSingleton(storageProvider); + siloBuilder.UseJsonJournalFormat(CreateJournalTypeResolver()); // configure a really low idle collection age to test the outbox timer siloBuilder.Services.Configure(options => @@ -54,6 +59,32 @@ protected virtual void ConfigureTestCluster(InProcessTestClusterBuilder builder) { } + /// + /// The JSON journal format serializes events with System.Text.Json, which (unlike the Orleans + /// serializer) needs polymorphism declared explicitly to round-trip events stored under their + /// abstract base type. Without this, replaying a persisted throws + /// NotSupportedException because the concrete type information is lost. + /// + private static IJsonTypeInfoResolver CreateJournalTypeResolver() + { + var resolver = new DefaultJsonTypeInfoResolver(); + resolver.Modifiers.Add(static typeInfo => + { + if (typeInfo.Type == typeof(BaseAccountEvent)) + { + typeInfo.PolymorphismOptions = new JsonPolymorphismOptions + { + TypeDiscriminatorPropertyName = "$type", + DerivedTypes = + { + new JsonDerivedType(typeof(BalanceAdjustedEvent), nameof(BalanceAdjustedEvent)), + }, + }; + } + }); + return resolver; + } + public virtual async Task InitializeAsync() { await Cluster.DeployAsync(); diff --git a/src/Strata.Journaling.Tests/Strata.Journaling.Tests.csproj b/src/Strata.Journaling.Tests/Strata.Journaling.Tests.csproj index 5ba8572..7d942b4 100644 --- a/src/Strata.Journaling.Tests/Strata.Journaling.Tests.csproj +++ b/src/Strata.Journaling.Tests/Strata.Journaling.Tests.csproj @@ -13,8 +13,8 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all diff --git a/src/Strata/Strata.csproj b/src/Strata/Strata.csproj index 176f704..9670134 100644 --- a/src/Strata/Strata.csproj +++ b/src/Strata/Strata.csproj @@ -19,14 +19,14 @@ - - - - - + + + + + - - + +