Skip to content

Commit

Permalink
feat: upgrade chapter 3 to .net 9 (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilbaczek authored Nov 30, 2024
1 parent 62c3fb3 commit 9a1d3cb
Show file tree
Hide file tree
Showing 28 changed files with 218 additions and 188 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/chapter-3-contracts-package-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:

env:
CHAPTER_DIR: 'Chapter-3-microservice-extraction/Fitnet.Contracts/Src'
NUGET_SOURCE_NAME: "evolutionaryArchitecture"

jobs:
build:
Expand All @@ -25,13 +26,14 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
- name: Add Evolutionary Architecture Nuget Source
uses: evolutionary-architecture/evolutionary-architecture-by-example/.github@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
owner: ${{ github.repository_owner }}
path: ${{ env.CHAPTER_DIR }}
nuget-source-name: ${{ env.NUGET_SOURCE_NAME }}
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand All @@ -50,13 +52,14 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
- name: Add Evolutionary Architecture Nuget Source
uses: evolutionary-architecture/evolutionary-architecture-by-example/.github@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
owner: ${{ github.repository_owner }}
path: ${{ env.CHAPTER_DIR }}
nuget-source-name: ${{ env.NUGET_SOURCE_NAME }}
- name: Pack Project
run: dotnet pack Fitnet.Contracts.IntegrationEvents/Fitnet.Contracts.IntegrationEvents.csproj -c Release
- name: Publish Packages
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/chapter-3-contracts-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ on:

env:
CHAPTER_DIR: "Chapter-3-microservice-extraction/Fitnet.Contracts/Src"

NUGET_SOURCE_NAME: "evolutionaryArchitecture"

jobs:
build:
defaults:
Expand All @@ -25,13 +26,14 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
- name: Add Evolutionary Architecture Nuget Source
uses: evolutionary-architecture/evolutionary-architecture-by-example/.github@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
owner: ${{ github.repository_owner }}
path: ${{ env.CHAPTER_DIR }}
nuget-source-name: ${{ env.NUGET_SOURCE_NAME }}
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand All @@ -49,13 +51,14 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
- name: Add Evolutionary Architecture Nuget Source
uses: evolutionary-architecture/evolutionary-architecture-by-example/.github@feature/nuget_config
uses: evolutionary-architecture/evolutionary-architecture-by-example/.github@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
owner: ${{ github.repository_owner }}
path: ${{ env.CHAPTER_DIR }}
nuget-source-name: ${{ env.NUGET_SOURCE_NAME }}
- name: Restore dependencies
run: dotnet restore
- name: Test
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/chapter-3-package-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:

env:
CHAPTER_DIR: 'Chapter-3-microservice-extraction/Fitnet.Common'
NUGET_SOURCE_NAME: "evolutionaryArchitecture"

jobs:
build:
Expand All @@ -35,6 +36,7 @@ jobs:
defaults:
run:
working-directory: ${{ env.CHAPTER_DIR }}

runs-on: ubuntu-latest
name: Test
needs: build
Expand Down Expand Up @@ -77,6 +79,7 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
owner: ${{ github.repository_owner }}
path: ${{ env.CHAPTER_DIR }}
nuget-source-name: ${{ env.NUGET_SOURCE_NAME }}

- name: Publish Packages
run: |
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/chapter-3-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:

env:
CHAPTER_DIR: "Chapter-3-microservice-extraction/Fitnet/Src"
NUGET_SOURCE_NAME: "evolutionaryArchitecture"

jobs:
build:
Expand All @@ -26,13 +27,14 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
- name: Add Evolutionary Architecture Nuget Source
uses: evolutionary-architecture/evolutionary-architecture-by-example/.github@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
owner: ${{ github.repository_owner }}
path: ${{ env.CHAPTER_DIR }}
nuget-source-name: ${{ env.NUGET_SOURCE_NAME }}
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand All @@ -50,13 +52,14 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
- name: Add Evolutionary Architecture Nuget Source
uses: evolutionary-architecture/evolutionary-architecture-by-example/.github@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
owner: ${{ github.repository_owner }}
path: ${{ env.CHAPTER_DIR }}
nuget-source-name: ${{ env.NUGET_SOURCE_NAME }}
- name: Restore dependencies
run: dotnet restore
- name: Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<AssemblyName>EvolutionaryArchitecture.$(MSBuildProjectName)</AssemblyName>
<RootNamespace>$(AssemblyName)</RootNamespace>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<AnalysisLevel>latest</AnalysisLevel>
<CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /src
COPY Directory.Build.props ./
COPY ["Fitnet.Contracts/Fitnet.Contracts.csproj", "Fitnet.Contracts/"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<PackageReference Include="Bogus" Version="35.5.1" />
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="xunit" Version="2.6.1" />
<PackageReference Include="xunit.analyzers" Version="1.4.0">
<PackageReference Include="Bogus" Version="35.6.1" />
<PackageReference Include="FluentAssertions" Version="6.12.2" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.analyzers" Version="1.17.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.categories" Version="2.0.8" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.8">
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,20 @@ namespace EvolutionaryArchitecture.Fitnet.Contracts.Api.UnitTests.Prepare.Reques

using EvolutionaryArchitecture.Fitnet.Contracts.Api.Prepare;

internal sealed class InvalidPrepareContractRequestTestCases : TheoryData<PrepareContractRequest>
internal sealed class InvalidPrepareContractRequestTestCases : TheoryData<string, int, int, DateTimeOffset, string>
{
private readonly Faker _faker = new();
private readonly DateTimeOffset _fakeNow = new Faker().Date.RecentOffset();

public InvalidPrepareContractRequestTestCases()
{
var validContractParameters = PrepareContractRequestParameters.GetValid();
AddRow(
new PrepareContractRequest(Guid.Empty, validContractParameters.MinAge, validContractParameters.MaxHeight,
_fakeNow), nameof(PrepareContractRequest.CustomerId));
AddRow(new PrepareContractRequest(Guid.NewGuid(), default, validContractParameters.MaxHeight, _fakeNow),
nameof(PrepareContractRequest.CustomerAge));
AddRow(
new PrepareContractRequest(Guid.NewGuid(), _faker.Random.Number(-100, -1),
validContractParameters.MaxHeight, _fakeNow), nameof(PrepareContractRequest.CustomerAge));
AddRow(new PrepareContractRequest(Guid.NewGuid(), validContractParameters.MinAge, default, _fakeNow),
nameof(PrepareContractRequest.CustomerHeight));
AddRow(
new PrepareContractRequest(Guid.NewGuid(), validContractParameters.MinAge, _faker.Random.Number(-100, -1),
_fakeNow), nameof(PrepareContractRequest.CustomerHeight));
AddRow(
new PrepareContractRequest(Guid.NewGuid(), validContractParameters.MinAge,
validContractParameters.MaxHeight, default), nameof(PrepareContractRequest.PreparedAt));
AddRow(
new PrepareContractRequest(Guid.NewGuid(), validContractParameters.MinAge,
validContractParameters.MaxHeight, default), nameof(PrepareContractRequest.PreparedAt));
Add(Guid.Empty.ToString(), validContractParameters.MinAge, validContractParameters.MaxHeight, _fakeNow, nameof(PrepareContractRequest.CustomerId));
Add(Guid.NewGuid().ToString(), default, validContractParameters.MaxHeight, _fakeNow, nameof(PrepareContractRequest.CustomerAge));
Add(Guid.NewGuid().ToString(), _faker.Random.Number(-100, -1), validContractParameters.MaxHeight, _fakeNow, nameof(PrepareContractRequest.CustomerAge));
Add(Guid.NewGuid().ToString(), validContractParameters.MinAge, default, _fakeNow, nameof(PrepareContractRequest.CustomerHeight));
Add(Guid.NewGuid().ToString(), validContractParameters.MinAge, _faker.Random.Number(-100, -1), _fakeNow, nameof(PrepareContractRequest.CustomerHeight));
Add(Guid.NewGuid().ToString(), validContractParameters.MinAge, validContractParameters.MaxHeight, default, nameof(PrepareContractRequest.PreparedAt));
Add(Guid.NewGuid().ToString(), validContractParameters.MinAge, validContractParameters.MaxHeight, default, nameof(PrepareContractRequest.PreparedAt));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ internal void Given_prepare_contract_request_validation_When_request_is_valid_Th
result.ShouldNotHaveAnyValidationErrors();
}

[Theory]
[ClassData(typeof(InvalidPrepareContractRequestTestCases))]
internal void Given_prepare_contract_request_validation_When_property_is_valid_Then_result_should_have_error(PrepareContractRequest request, string expectedInvalidPropertyName)
[Theory, ClassData(typeof(InvalidPrepareContractRequestTestCases))]
internal void Given_prepare_contract_request_validation_When_property_is_valid_Then_result_should_have_error(string customerId, int customerAge, int customerHeight, DateTimeOffset preparedAt, string expectedInvalidPropertyName)
{
// Arrange
var request = new PrepareContractRequest(Guid.Parse(customerId), customerAge, customerHeight, preparedAt);

// Act
var result = _validator.TestValidate(request);

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

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.6" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<PackageReference Include="evolutionaryarchitecture.fitnet.common.api" Version="3.1.1" />
<PackageReference Include="JetBrains.Annotations" Version="2023.3.0" />
<PackageReference Include="MassTransit.Abstractions" Version="8.2.2" />
<PackageReference Include="MediatR" Version="12.2.0" />
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0" />
<PackageReference Include="MassTransit.Abstractions" Version="8.3.2" />
<PackageReference Include="MediatR" Version="12.4.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Fitnet.Contracts.Core\Fitnet.Contracts.Core.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Bogus" Version="35.5.1" />
<PackageReference Include="Bogus" Version="35.6.1" />
<PackageReference Include="EvolutionaryArchitecture.Fitnet.Common.Core" Version="3.1.1" />
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="xunit" Version="2.6.6" />
<PackageReference Include="xunit.analyzers" Version="1.14.0">
<PackageReference Include="FluentAssertions" Version="6.12.2" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.analyzers" Version="1.17.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.categories" Version="2.0.8" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="MassTransit" Version="8.2.2" />
<PackageReference Include="MassTransit.RabbitMQ" Version="8.2.2" />
<PackageReference Include="MediatR" Version="12.2.0" />
<PackageReference Include="MassTransit" Version="8.3.2" />
<PackageReference Include="MassTransit.RabbitMQ" Version="8.3.2" />
<PackageReference Include="MediatR" Version="12.4.1" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.1" />
<PackageReference Include="System.Text.Encodings.Web" Version="9.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<Version>1.0.7</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BouncyCastle.Cryptography" Version="2.4.0" />
<PackageReference Include="EvolutionaryArchitecture.Fitnet.Common.Infrastructure" Version="3.1.1" />
<PackageReference Include="System.Text.Encodings.Web" Version="9.0.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
<ItemGroup>
<PackageReference Include="evolutionaryarchitecture.fitnet.common.api" Version="3.1.1" />
<PackageReference Include="evolutionaryarchitecture.fitnet.common.integrationteststoolbox" Version="3.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Text.Json" Version="9.0.0" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
</ItemGroup>

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

<ItemGroup>
<PackageReference Include="evolutionaryarchitecture.fitnet.common.api" Version="3.1.1" />
<PackageReference Include="JetBrains.Annotations" Version="2023.3.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<AssemblyName>EvolutionaryArchitecture.$(MSBuildProjectName)</AssemblyName>
<RootNamespace>$(AssemblyName)</RootNamespace>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<AnalysisLevel>latest</AnalysisLevel>
<CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand Down
4 changes: 2 additions & 2 deletions Chapter-3-microservice-extraction/Fitnet/Src/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /src
COPY Directory.Build.props ./
COPY ["Fitnet/Fitnet.csproj", "Fitnet/"]
Expand Down
Loading

0 comments on commit 9a1d3cb

Please sign in to comment.