Skip to content

Commit

Permalink
✨ support .NET 9 (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
Odonno authored Nov 28, 2024
1 parent 7c46daf commit c145a8b
Show file tree
Hide file tree
Showing 43 changed files with 403 additions and 218 deletions.
72 changes: 3 additions & 69 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,25 @@ on:

jobs:
action:
needs: [embedded-build]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Download embedded artifacts (Linux)
uses: actions/download-artifact@v4
with:
name: embedded-ubuntu-latest

- name: Download embedded artifacts (Windows)
uses: actions/download-artifact@v4
with:
name: embedded-windows-latest

- name: Download embedded artifacts (MacOS)
uses: actions/download-artifact@v4
with:
name: embedded-macos-latest

- name: Download SurrealDB
run: curl --proto '=https' --tlsv1.2 -sSf https://install.surrealdb.com | sh -s -- --version v1.5.5
run: curl --proto '=https' --tlsv1.2 -sSf https://install.surrealdb.com | sh -s

- name: Run SurrealDB root
run: surreal start --user root --pass root memory --allow-guests &

- name: Setup dotnet 8.0
- name: Setup dotnet 9.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: "8.0.x"

- name: Assign benchmark mode
run: ./prepare_embedded_benchmarks.sh -s
dotnet-version: "9.0.x"

- name: Execute Remote benchmarks
run: sudo dotnet run -c Release --project SurrealDb.Net.Benchmarks.Remote --filter '*'

- name: Execute Embedded benchmarks
run: sudo dotnet run -c Release --project SurrealDb.Net.Benchmarks.Embedded --filter '*'

- name: Revert benchmark mode
run: ./prepare_embedded_benchmarks.sh -e

- name: Download previous benchmark data
uses: actions/cache@v1
with:
Expand All @@ -66,44 +41,3 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
comment-on-alert: true
summary-always: true

embedded-build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
# expand matrix configuration to add "libpath" variable
- os: windows-latest
libpath: |
**/release/surreal_memory.dll
**/release/surreal_memory.pdb
- os: ubuntu-latest
libpath: |
**/release/libsurreal_memory.so
- os: macos-latest
libpath: |
**/release/libsurreal_memory.dylib
steps:
- name: Checkout
uses: actions/checkout@v3
with:
sparse-checkout: |
rust-embedded
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable

- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2

- name: Build libraries
working-directory: ./rust-embedded
run: cargo build --release

- name: Publish embedded artifacts
uses: actions/upload-artifact@v4
with:
name: embedded-${{ matrix.os }}
path: ${{ matrix.libpath }}
7 changes: 4 additions & 3 deletions .github/workflows/ci-aot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Setup dotnet 8.0
- name: Setup dotnet 9.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: "8.0.x"
dotnet-version: "9.0.x"

- name: Publish AOT test app, assert static analysis warning count, and run the app
shell: pwsh
run: .\build\test-aot-compatibility.ps1 net8.0
run: .\build\test-aot-compatibility.ps1 net9.0
continue-on-error: true # TODO : The SDK is not yet AoT compatible
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ jobs:
name: embedded
path: ./rust-embedded/target/debug

- name: Setup dotnet 8.0
- name: Setup dotnet 9.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: "8.0.x"
dotnet-version: "9.0.x"

- name: Install .NET tools
run: dotnet tool restore
Expand Down Expand Up @@ -69,10 +69,10 @@ jobs:
surreal start --user root --pass root memory --allow-guests &
fi
- name: Setup dotnet 8.0
- name: Setup dotnet 9.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: "8.0.x"
dotnet-version: "9.0.x"

- name: Install dependencies
run: dotnet restore
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ jobs:
pattern: embedded-*
merge-multiple: true

- name: Setup dotnet 8.0
- name: Setup dotnet 9.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: "8.0.x"
dotnet-version: "9.0.x"

- name: Create Package
run: dotnet pack /p:GenerateCompatibilitySuppressionFile=true --configuration Release --output ${{ env.NuGetDirectory }}
Expand All @@ -184,10 +184,10 @@ jobs:
runs-on: ubuntu-latest-4-cores

steps:
- name: Setup dotnet 8.0
- name: Setup dotnet 9.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: "8.0.x"
dotnet-version: "9.0.x"

- uses: actions/download-artifact@v4
with:
Expand All @@ -205,10 +205,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Setup dotnet 8.0
- name: Setup dotnet 9.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: "8.0.x"
dotnet-version: "9.0.x"

- uses: actions/download-artifact@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">false</IsAotCompatible>
<IsAotCompatible>false</IsAotCompatible>

<IsPackable>false</IsPackable>
<Version>0.6.0</Version>
Expand Down
7 changes: 4 additions & 3 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="BenchmarkDotNet" Version="0.13.10" />
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
<PackageVersion Include="Bogus" Version="35.5.1" />
<PackageVersion Include="ConcurrentHashSet" Version="1.3.0" />
<PackageVersion Include="coverlet.collector" Version="3.1.2" />
Expand All @@ -14,8 +14,7 @@
<PackageVersion Include="DotNet.ReproducibleBuilds" Version="1.1.1" />
<PackageVersion Include="FlakyTest.XUnit" Version="2.4.10" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="Meziantou.Xunit.ParallelTestFramework" Version="2.2.0" />
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="8.0.3" />
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="9.0.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="8.0.0" />
Expand All @@ -25,9 +24,11 @@
<PackageVersion Include="Microsoft.Spatial" Version="7.18.0" />
<PackageVersion Include="MudBlazor" Version="6.11.2" />
<PackageVersion Include="Pidgin" Version="3.2.3" />
<PackageVersion Include="Scalar.AspNetCore" Version="1.2.36" />
<PackageVersion Include="Semver" Version="2.3.0" />
<PackageVersion Include="Superpower" Version="3.0.0" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageVersion Include="Swashbuckle.AspNetCore.SwaggerUI" Version="7.0.0" />
<PackageVersion Include="System.Collections.Immutable" Version="8.0.0" />
<PackageVersion Include="System.Interactive.Async" Version="6.0.1" />
<PackageVersion Include="SystemTextJsonPatch" Version="4.0.0" />
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ Note that the support for .NET standard 2.1 will be maintained until further not
| .NET 6 | LTS | November 8, 2021 | November 12, 2024 |
| .NET 7 | STS | November 8, 2022 | May 14, 2024 |
| .NET 8 | Current LTS | November 14, 2023 | November 10, 2026 |
| .NET 9 | STS | November 12, 2024 | May 12, 2026 |

### Formatting

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

<IsPackable>true</IsPackable>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

<IsPackable>true</IsPackable>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

<IsPackable>true</IsPackable>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
49 changes: 32 additions & 17 deletions SurrealDb.Examples.MinimalApis/Program.cs
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
using System.Reflection;
using Microsoft.OpenApi.Models;
using Scalar.AspNetCore;
using SurrealDb.Examples.MinimalApis.Models;
using SurrealDb.Net;
using Swashbuckle.AspNetCore.SwaggerUI;

var builder = WebApplication.CreateBuilder(args);

var services = builder.Services;
var configuration = builder.Configuration;

services.AddEndpointsApiExplorer();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "MinimalApis Examples API", Version = "v1" });
services
.AddEndpointsApiExplorer()
.AddOpenApi(options =>
{
options.AddDocumentTransformer(
(document, _, _) =>
{
document.Info.Title = "MinimalApis Examples API";
document.Info.Version = "v1";

var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
c.IncludeXmlComments(xmlPath);
});
services.AddSurreal(configuration.GetConnectionString("SurrealDB")!);
return Task.CompletedTask;
}
);
});

// 💡 Be sure to have "NamingPolicy=CamelCase" in your connection string for PATCH methods to work as expected.
services.AddSurreal(configuration.GetConnectionString("SurrealDB")!);

var app = builder.Build();

if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}

app.UseHttpsRedirection();

app.MapGroup("/api")
Expand All @@ -38,6 +37,22 @@
)
.MapSurrealEndpoints<Todo>("/todo", new() { Tags = ["Todo"] });

if (app.Environment.IsDevelopment())
{
// 💡 Enable OpenAPI document generation (e.g. "/openapi/v1.json")
app.MapOpenApi();

// 💡 Display OpenAPI User Interfaces (Swagger UI, Scalar)
app.UseSwaggerUI(options =>
{
options.ConfigObject.Urls =
[
new UrlDescriptor { Name = "MinimalApis Examples API v1", Url = "/openapi/v1.json" }
];
});
app.MapScalarApiReference();
}

await InitializeDbAsync();

app.Run();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Bogus" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" />
<PackageReference Include="Swashbuckle.AspNetCore" />
<PackageReference Include="Scalar.AspNetCore" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<InvariantGlobalization>true</InvariantGlobalization>
<PublishAot>true</PublishAot>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>

Expand Down
Loading

0 comments on commit c145a8b

Please sign in to comment.