Skip to content

Commit f23258e

Browse files
committed
Add Native AOT adapter smoke validation
1 parent 227f023 commit f23258e

3 files changed

Lines changed: 52 additions & 0 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ jobs:
6464
- name: Test (full solution)
6565
run: dotnet test --solution ManagedCode.CodexSharpSDK.slnx --configuration Release --no-build -- --treenode-filter "/*/*/*/*[RequiresCodexAuth!=true]"
6666

67+
- name: Install Native AOT prerequisites
68+
run: sudo apt-get update && sudo apt-get install -y clang zlib1g-dev libssl-dev libbrotli-dev
69+
70+
- name: Publish and run Native AOT smoke
71+
run: |
72+
dotnet publish AotSmoke/ManagedCode.CodexSharpSDK.AotSmoke.csproj --configuration Release --runtime linux-x64 --output ./AotSmoke/artifacts
73+
./AotSmoke/artifacts/ManagedCode.CodexSharpSDK.AotSmoke
74+
6775
- name: Codex CLI smoke tests
6876
run: dotnet test --project CodexSharpSDK.Tests/CodexSharpSDK.Tests.csproj --configuration Release --no-build -- --treenode-filter "/*/*/*/CodexCli_Smoke_*"
6977

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<TargetFramework>net10.0</TargetFramework>
5+
<PublishAot>true</PublishAot>
6+
<Nullable>enable</Nullable>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
9+
</PropertyGroup>
10+
<ItemGroup>
11+
<ProjectReference Include="../CodexSharpSDK/CodexSharpSDK.csproj" />
12+
<ProjectReference Include="../CodexSharpSDK.Extensions.AI/CodexSharpSDK.Extensions.AI.csproj" />
13+
</ItemGroup>
14+
</Project>

‎AotSmoke/Program.cs‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
namespace AotSmoke;
2+
3+
using System.Text.Json.Serialization;
4+
using ManagedCode.CodexSharpSDK.Client;
5+
using ManagedCode.CodexSharpSDK.Extensions.AI;
6+
using ManagedCode.CodexSharpSDK.Models;
7+
using Microsoft.Extensions.AI;
8+
using CodexRunResult = ManagedCode.CodexSharpSDK.Models.RunResult<Payload>;
9+
10+
internal static class Program
11+
{
12+
public static void Main()
13+
{
14+
var schema = StructuredOutputSchema.Map<Payload>(properties: [(payload => payload.Value, StructuredOutputSchema.PlainText())]);
15+
using var client = new CodexChatClient();
16+
Func<CodexThread, Task<CodexRunResult>> typedRun = thread => thread.RunAsync<Payload>("AOT smoke", schema, AotJsonContext.Default.Payload);
17+
Func<IChatClient, IEnumerable<ChatMessage>, ChatOptions?, CancellationToken, Task<ChatResponse>> response =
18+
(chatClient, messages, options, token) => chatClient.GetResponseAsync(messages, options, token);
19+
Func<IChatClient, IEnumerable<ChatMessage>, ChatOptions?, CancellationToken, IAsyncEnumerable<ChatResponseUpdate>> stream =
20+
(chatClient, messages, options, token) => chatClient.GetStreamingResponseAsync(messages, options, token);
21+
GC.KeepAlive(typedRun);
22+
GC.KeepAlive(response);
23+
GC.KeepAlive(stream);
24+
Console.WriteLine(AotJsonContext.Default.Payload.Type.Name);
25+
}
26+
}
27+
28+
internal sealed class Payload { public string? Value { get; set; } }
29+
[JsonSerializable(typeof(Payload))]
30+
internal sealed partial class AotJsonContext : JsonSerializerContext;

0 commit comments

Comments
 (0)