Skip to content

Commit 99d147b

Browse files
64J0Copilot
andauthored
Add .NET 10 to the list of test TFMs and update CI (#702)
* Add .NET 10 to the list of TFMs - Update GitHub Actions configuration - Update tests due to .NET 10 breaking changes * Update tests/Giraffe.Tests/Helpers.fs Co-authored-by: Copilot <[email protected]> * Remove .NET {6, 7, 8}.x from CI workflows (build-and-test and publish) * Remove net10.0 from Giraffe.fsproj TFMs * Update CI: Install only .NET 10 * Add .NET {8, 9, 10} to the CI explicitly --------- Co-authored-by: Copilot <[email protected]>
1 parent dc89077 commit 99d147b

File tree

4 files changed

+33
-8
lines changed

4 files changed

+33
-8
lines changed

.github/workflows/build-and-test.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@ jobs:
3232
uses: actions/setup-dotnet@v5
3333
with:
3434
dotnet-version: |
35-
6.x
36-
7.x
3735
8.x
3836
9.x
37+
10.x
3938
- name: Restore
4039
run: dotnet restore
4140
- name: Build
@@ -51,7 +50,10 @@ jobs:
5150
- name: Setup .NET Core
5251
uses: actions/setup-dotnet@v5
5352
with:
54-
dotnet-version: 9.x
53+
dotnet-version: |
54+
8.x
55+
9.x
56+
10.x
5557
- name: Restore tools
5658
run: dotnet tool restore
5759
- name: Build solution

.github/workflows/publish.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,9 @@ jobs:
3434
uses: actions/setup-dotnet@v5
3535
with:
3636
dotnet-version: |
37-
6.x
38-
7.x
3937
8.x
4038
9.x
39+
10.x
4140
- name: Restore
4241
run: dotnet restore
4342
- name: Build
@@ -55,10 +54,9 @@ jobs:
5554
uses: actions/setup-dotnet@v5
5655
with:
5756
dotnet-version: |
58-
6.x
59-
7.x
6057
8.x
6158
9.x
59+
10.x
6260
- name: Create Release NuGet package
6361
run: |
6462
arrTag=(${GITHUB_REF//\// })

tests/Giraffe.Tests/Giraffe.Tests.fsproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
3+
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
44
<AssemblyName>Giraffe.Tests</AssemblyName>
55
</PropertyGroup>
66

@@ -46,6 +46,10 @@
4646
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="9.0.*" />
4747
</ItemGroup>
4848

49+
<ItemGroup Condition=" '$(TargetFramework)' == 'net10.0'">
50+
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="10.0.*" />
51+
</ItemGroup>
52+
4953
<ItemGroup>
5054
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
5155
<PackageReference Include="xunit" Version="2.9.*" />

tests/Giraffe.Tests/Helpers.fs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ open Microsoft.AspNetCore.Hosting
1414
open Microsoft.AspNetCore.TestHost
1515
open Microsoft.AspNetCore.Builder
1616
open Microsoft.Extensions.DependencyInjection
17+
open Microsoft.Extensions.Hosting
1718
open Xunit
1819
open NSubstitute
1920
open Giraffe
@@ -94,10 +95,22 @@ let createHost
9495
(configureServices: IServiceCollection -> unit)
9596
(args: 'Tuple)
9697
=
98+
#if NET10_0_OR_GREATER
99+
HostBuilder()
100+
.ConfigureWebHost(fun webHostBuilder ->
101+
webHostBuilder
102+
.UseTestServer()
103+
.UseContentRoot(Path.GetFullPath("TestFiles"))
104+
.Configure(Action<IApplicationBuilder>(configureApp args))
105+
.ConfigureServices(Action<IServiceCollection> configureServices)
106+
|> ignore
107+
)
108+
#else
97109
(WebHostBuilder())
98110
.UseContentRoot(Path.GetFullPath("TestFiles"))
99111
.Configure(Action<IApplicationBuilder>(configureApp args))
100112
.ConfigureServices(Action<IServiceCollection> configureServices)
113+
#endif
101114

102115
let mockJson (ctx: HttpContext) =
103116

@@ -131,7 +144,15 @@ let createRequest (method: HttpMethod) (path: string) =
131144

132145
let makeRequest configureApp configureServices args (request: HttpRequestMessage) =
133146
task {
147+
#if NET10_0_OR_GREATER
148+
// https://github.com/aspnet/Announcements/issues/526
149+
use host = createHost configureApp configureServices args |> _.Build()
150+
151+
let! _ = host.StartAsync()
152+
use server = host.GetTestServer()
153+
#else
134154
use server = new TestServer(createHost configureApp configureServices args)
155+
#endif
135156
use client = server.CreateClient()
136157
let! response = request |> client.SendAsync
137158
return response

0 commit comments

Comments
 (0)