Skip to content

Commit

Permalink
Add support for .NET 9 (#179)
Browse files Browse the repository at this point in the history
* Add support for .NET 9

* Fix TUnit example

* Deal with CVE warnings

---------

Co-authored-by: JT <Hawxy@users.noreply.github.com>
  • Loading branch information
Hawxy and Hawxy authored Nov 26, 2024
1 parent c05b83e commit 300913a
Show file tree
Hide file tree
Showing 15 changed files with 103 additions and 95 deletions.
10 changes: 3 additions & 7 deletions .github/workflows/Build_&_Test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,9 @@ jobs:
name: ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
uses: actions/cache@v3
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
path: |
.nuke/temp
~/.nuget/packages
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
dotnet-version: '9'
- name: 'Run: Test'
run: ./build.cmd Test
11 changes: 4 additions & 7 deletions .github/workflows/Manual_Nuget_Push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@ jobs:
name: ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
uses: actions/cache@v3
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
path: |
.nuke/temp
~/.nuget/packages
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
dotnet-version: '9'

- name: 'Run: NugetPush'
run: ./build.cmd NugetPush
env:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install .NET Core 8.0.x
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

- name: Install Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20

- name: Setup Pages
uses: actions/configure-pages@v3
uses: actions/configure-pages@v5

- name: Install dependencies
run: npm ci
Expand All @@ -37,7 +37,7 @@ jobs:
touch docs/.vitepress/dist/.nojekyll
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
uses: actions/upload-pages-artifact@v3
with:
path: docs/.vitepress/dist

Expand All @@ -51,4 +51,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
uses: actions/deploy-pages@v4
122 changes: 65 additions & 57 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,48 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"$ref": "#/definitions/build",
"title": "Build Schema",
"definitions": {
"build": {
"type": "object",
"Host": {
"type": "string",
"enum": [
"AppVeyor",
"AzurePipelines",
"Bamboo",
"Bitbucket",
"Bitrise",
"GitHubActions",
"GitLab",
"Jenkins",
"Rider",
"SpaceAutomation",
"TeamCity",
"Terminal",
"TravisCI",
"VisualStudio",
"VSCode"
]
},
"ExecutableTarget": {
"type": "string",
"enum": [
"Clean",
"Compile",
"NugetPack",
"NugetPush",
"Restore",
"Test"
]
},
"Verbosity": {
"type": "string",
"description": "",
"enum": [
"Verbose",
"Normal",
"Minimal",
"Quiet"
]
},
"NukeBuild": {
"properties": {
"Continue": {
"type": "boolean",
Expand All @@ -15,35 +53,13 @@
"description": "Shows the help text for this build assembly"
},
"Host": {
"type": "string",
"description": "Host for execution. Default is 'automatic'",
"enum": [
"AppVeyor",
"AzurePipelines",
"Bamboo",
"Bitbucket",
"Bitrise",
"GitHubActions",
"GitLab",
"Jenkins",
"Rider",
"SpaceAutomation",
"TeamCity",
"Terminal",
"TravisCI",
"VisualStudio",
"VSCode"
]
"$ref": "#/definitions/Host"
},
"NoLogo": {
"type": "boolean",
"description": "Disables displaying the NUKE logo"
},
"NugetApiKey": {
"type": "string",
"description": "Nuget Api Key",
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
},
"Partition": {
"type": "string",
"description": "Partition to use on CI"
Expand All @@ -67,47 +83,39 @@
"type": "array",
"description": "List of targets to be skipped. Empty list skips all dependencies",
"items": {
"type": "string",
"enum": [
"Clean",
"Compile",
"NugetPack",
"NugetPush",
"Restore",
"Test"
]
"$ref": "#/definitions/ExecutableTarget"
}
},
"Solution": {
"type": "string",
"description": "Path to a solution file that is automatically loaded"
},
"Target": {
"type": "array",
"description": "List of targets to be invoked. Default is '{default_target}'",
"items": {
"type": "string",
"enum": [
"Clean",
"Compile",
"NugetPack",
"NugetPush",
"Restore",
"Test"
]
"$ref": "#/definitions/ExecutableTarget"
}
},
"Verbosity": {
"type": "string",
"description": "Logging verbosity during build execution. Default is 'Normal'",
"enum": [
"Minimal",
"Normal",
"Quiet",
"Verbose"
]
"$ref": "#/definitions/Verbosity"
}
}
}
},
"allOf": [
{
"properties": {
"NugetApiKey": {
"type": "string",
"description": "Nuget Api Key",
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
},
"Solution": {
"type": "string",
"description": "Path to a solution file that is automatically loaded"
}
}
},
{
"$ref": "#/definitions/NukeBuild"
}
}
]
}
2 changes: 1 addition & 1 deletion build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nuke.Common" Version="8.1.0" />
<PackageReference Include="Nuke.Common" Version="9.0.1" />
</ItemGroup>

</Project>
14 changes: 8 additions & 6 deletions build/build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@
[GitHubActions(
"Build & Test",
GitHubActionsImage.UbuntuLatest,
OnPushBranches = new []{ "master" },
OnPullRequestBranches = new []{ "master" },
InvokedTargets = new[] { nameof(Test) })]
OnPushBranches = ["master"],
OnPullRequestBranches = ["master"],
InvokedTargets = [nameof(Test)],
AutoGenerate = false)]
[GitHubActions(
"Manual Nuget Push",
GitHubActionsImage.UbuntuLatest,
On = new[] { GitHubActionsTrigger.WorkflowDispatch },
InvokedTargets = new[] { nameof(NugetPush) },
ImportSecrets = new[] { nameof(NugetApiKey) })]
On = [GitHubActionsTrigger.WorkflowDispatch],
InvokedTargets = [nameof(NugetPush)],
ImportSecrets = [nameof(NugetApiKey)],
AutoGenerate = false)]
class Build : NukeBuild
{
/// Support plugins are available for:
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/tunit.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public sealed class AlbaBootstrap : IAsyncInitializer, IAsyncDisposable
<sup><a href='https://github.com/JasperFx/alba/blob/master/src/TUnitSamples/Program.cs#L6-L21' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_tunit_application' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Then inject the instance by added `[ClassDataSource<AlbaBootstrap>(Shared = SharedType.Globally)]` to your test class. We recommend creating a base class to allow easier access of the host and any other dependencies.
Then inject the instance by added `[ClassDataSource<AlbaBootstrap>(Shared = SharedType.PerAssembly)]` to your test class. We recommend creating a base class to allow easier access of the host and any other dependencies.

<!-- snippet: sample_TUnit_scenario_test -->
<a id='snippet-sample_tunit_scenario_test'></a>
Expand All @@ -35,7 +35,7 @@ public abstract class AlbaTestBase(AlbaBootstrap albaBootstrap)
protected IAlbaHost Host => albaBootstrap.Host;
}

[ClassDataSource<AlbaBootstrap>(Shared = SharedType.Globally)]
[ClassDataSource<AlbaBootstrap>(Shared = SharedType.PerAssembly)]
public class MyTestClass(AlbaBootstrap albaBootstrap) : AlbaTestBase(albaBootstrap)
{
[Test]
Expand Down
2 changes: 1 addition & 1 deletion src/Alba.Testing/Alba.Testing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="NSubstitute" Version="5.1.0" />
<PackageReference Include="Shouldly" Version="4.2.1" />
<PackageReference Include="xunit" Version="2.9.2" />
Expand Down
9 changes: 7 additions & 2 deletions src/Alba/Alba.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<PropertyGroup>
<Description>Supercharged integration testing for ASP.NET Core HTTP endpoints</Description>
<Version>8.0.0</Version>
<TargetFramework>net8.0</TargetFramework>
<Version>8.1.0</Version>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<PackageProjectUrl>http://jasperfx.github.io/alba/</PackageProjectUrl>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
Expand Down Expand Up @@ -32,4 +32,9 @@
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.7" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.0" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/IdentityServer.New/IdentityServer.New.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Duende.IdentityServer" Version="7.0.7" />
<PackageReference Include="Duende.IdentityServer" Version="7.0.8" />
<PackageReference Include="IdentityModel" Version="6.2.0" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.2" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/NUnitSamples/NUnitSamples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/TUnitSamples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public abstract class AlbaTestBase(AlbaBootstrap albaBootstrap)
protected IAlbaHost Host => albaBootstrap.Host;
}

[ClassDataSource<AlbaBootstrap>(Shared = SharedType.Globally)]
[ClassDataSource<AlbaBootstrap>(Shared = SharedType.PerAssembly)]
public class MyTestClass(AlbaBootstrap albaBootstrap) : AlbaTestBase(albaBootstrap)
{
[Test]
Expand Down
2 changes: 1 addition & 1 deletion src/TUnitSamples/TUnitSamples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


<ItemGroup>
<PackageReference Include="TUnit" Version="0.1.897" />
<PackageReference Include="TUnit" Version="0.4.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/WebApiNet6/WebApiNet6.csproj
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>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/WebAppSecuredWithJwt/WebAppSecuredWithJwt.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.7" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.1.0" />
</ItemGroup>

</Project>

0 comments on commit 300913a

Please sign in to comment.