Skip to content

Commit

Permalink
Update all packages to dotnet 9 (#16)
Browse files Browse the repository at this point in the history
* Update all packages to dotnet 9

* Stop tests on failure

* Install dotnet 9 in playwright container

* remove redundant files

* cleanup build folder on self hosted agent

* clean

* Update to dotnet 9

* Update data protection keys to use Microsoft.AspNetCore.DataProtection 9.0

* Try without container prefixes

* Reenable generation

* Remove ci step

* Remove github actions test logger which fails with

Could not find a test logger with AssemblyQualifiedName, URI or FriendlyName 'GitHubActions'.

* Remove github actions test logger

* Switch to BeginAsyncLifetimeScope

* Tidy

---------

Co-authored-by: peter.kneale <[email protected]>
  • Loading branch information
PeterKneale and peterkneale-compareclub authored Dec 24, 2024
1 parent 7ef4037 commit 689eeec
Show file tree
Hide file tree
Showing 72 changed files with 236 additions and 290 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
pull_request:
runs-on: self-hosted
steps:

- uses: actions/checkout@v4
with:
show-progress: 'false'
Expand Down
1 change: 1 addition & 0 deletions MicroSaas.sln
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{644DFC0E-D660-4C21-A3B0-40B264F88C8F}"
ProjectSection(SolutionItems) = preProject
.github\workflows\release.yml = .github\workflows\release.yml
.github\workflows\pull_request.yml = .github\workflows\pull_request.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "common", "common", "{882D2D96-59E4-408F-AF68-9E83F4B454E1}"
Expand Down
17 changes: 9 additions & 8 deletions MicroSaas.sln.DotSettings.user
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AConcurrencyDetector_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003Fpeter_002Ekneale_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F9c8f16a6f2a832e3e14957cfc4ac2c6fe5a78bacb9e21524267e621242e_003FConcurrencyDetector_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASingleQueryingEnumerable_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003Fpeter_002Ekneale_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F413341ec7da6e42cb630e52ba9208edacb2e7267da1d9296f51628fcd35e81d9_003FSingleQueryingEnumerable_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue">&lt;AssemblyExplorer&gt;&#xD;
&lt;Assembly Path="C:\dev\projects\MicroSaas\tests\Micro.Modules.IntegrationTests\bin\Debug\net8.0\Micro.Translations.Application.dll" /&gt;&#xD;
&lt;Assembly Path="C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.4\System.Private.CoreLib.dll" /&gt;&#xD;
Expand All @@ -12,14 +14,11 @@
<s:String x:Key="/Default/Environment/UnitTesting/CreateUnitTestDialog/TestProjectMapping/=7F5702D7_002D1808_002D443D_002DBD92_002DFFD5FADE5158/@EntryIndexedValue">D83D5413-12DA-49BE-89CA-3A55041DA1E1</s:String>
<s:String x:Key="/Default/Environment/UnitTesting/CreateUnitTestDialog/TestProjectMapping/=F6117A4E_002D3072_002D452A_002D9E25_002D526D6C6EF596/@EntryIndexedValue">1E66C0C9-DAA3-4E55-86C7-F6197E900D57</s:String>
<s:String x:Key="/Default/Environment/UnitTesting/CreateUnitTestDialog/TestTemplateMapping/=xUnit/@EntryIndexedValue">33ff99d8-b1ad-4ed5-a4fd-376b97c2c841</s:String>
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=b013dc63_002Df2d3_002D4169_002D8d0d_002D8d36b596ca6c/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="Session" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;&#xD;
&lt;Or&gt;&#xD;
&lt;And&gt;&#xD;
&lt;ProjectFolder&gt;303110BA-112C-4CF4-AE69-7376AA933F87/d:UseCases&lt;/ProjectFolder&gt;&#xD;
&lt;Project Location="C:\dev\projects\MicroSaas\tests\Micro.Web.AcceptanceTests" Presentation="&amp;lt;web&amp;gt;\&amp;lt;Micro.Web.AcceptanceTests&amp;gt;" /&gt;&#xD;
&lt;/And&gt;&#xD;
&lt;Project Location="C:\dev\projects\MicroSaas\tests\Micro.Modules.SystemTests" Presentation="&amp;lt;tests&amp;gt;\&amp;lt;Micro.Modules.SystemTests&amp;gt;" /&gt;&#xD;
&lt;/Or&gt;&#xD;

<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=22012913_002D896a_002D41cd_002Db49f_002Dc20e070aa276/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="Many_can_be_created_at_once" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;&#xD;
&lt;TestAncestor&gt;&#xD;
&lt;TestId&gt;xUnit::74F19403-CCCC-4B1C-9810-58E139698770::net9.0::Micro.Tenants.IntegrationTests.UseCases.Organisations.ParallelisationTest.Many_can_be_created_at_once&lt;/TestId&gt;&#xD;
&lt;/TestAncestor&gt;&#xD;
&lt;/SessionState&gt;</s:String>


Expand Down Expand Up @@ -55,6 +54,8 @@








Expand Down
2 changes: 0 additions & 2 deletions docker-compose-acceptance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ services:
- DOTNET_CLI_TELEMETRY_OPTOUT=true
- DOTNET_NUGET_SIGNATURE_VERIFICATION=false
- WEB_HOST=web
- GITHUB_ACTIONS=${GITHUB_ACTIONS:-FALSE}
entrypoint:
- dotnet
- test
- Micro.Web.AcceptanceTests.dll
- --no-restore
- --configuration=Release
- --verbosity=quiet
- --logger=GitHubActions
depends_on:
- web

Expand Down
4 changes: 0 additions & 4 deletions docker-compose-integration-tests.sh

This file was deleted.

2 changes: 0 additions & 2 deletions docker-compose-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ services:
- DOTNET_NUGET_SIGNATURE_VERIFICATION=false
- Logging:LogLevel:Default=Warning
- DB_HOST=db
- GITHUB_ACTIONS=${GITHUB_ACTIONS:-FALSE}
entrypoint:
- dotnet
- test
Expand All @@ -24,7 +23,6 @@ services:
- --configuration=Release
- --verbosity=quiet
- --filter=Type=Integration
- --logger=GitHubActions
depends_on:
- db

Expand Down
2 changes: 0 additions & 2 deletions docker-compose-system-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ services:
- DOTNET_NUGET_SIGNATURE_VERIFICATION=false
- Logging:LogLevel:Default=Warning
- DB_HOST=db
- GITHUB_ACTIONS=${GITHUB_ACTIONS:-FALSE}
entrypoint:
- dotnet
- test
Expand All @@ -24,7 +23,6 @@ services:
- --configuration=Release
- --verbosity=quiet
- --filter=Type=System
- --logger=GitHubActions
depends_on:
- db

Expand Down
4 changes: 0 additions & 4 deletions docker-compose-unit-tests.sh

This file was deleted.

4 changes: 1 addition & 3 deletions docker-compose-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ services:
- DOTNET_CLI_TELEMETRY_OPTOUT=true
- DOTNET_NUGET_SIGNATURE_VERIFICATION=false
- Logging:LogLevel:Default=Warning
- GITHUB_ACTIONS=${GITHUB_ACTIONS:-FALSE}
entrypoint:
- dotnet
- test
- --no-restore
- --collect:"XPlat Code Coverage"
- --configuration=Release
- --verbosity=quiet
- --filter=Type=Unit
- --logger=GitHubActions
- --filter=Type=Unit
1 change: 1 addition & 0 deletions run-docker-compose-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ set -e
docker compose -f docker-compose.yml build
docker compose -f docker-compose-unit-tests.yml build
docker compose -f docker-compose-integration-tests.yml build
docker compose -f docker-compose-system-tests.yml build
docker compose -f docker-compose-acceptance-tests.yml build
6 changes: 5 additions & 1 deletion run-docker-compose-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ run_tests() {
docker compose --progress quiet -f "${compose_file}" up \
--force-recreate \
--remove-orphans \
--no-log-prefix \
--abort-on-container-exit \
--exit-code-from "${test_type}-tests"

if [ $? -ne 0 ]; then
echo "::error file=${compose_file},line=1,col=1::${test_type^} tests failed"
exit 1
fi
}

echo "::notice ::Running tests..."
Expand Down
9 changes: 4 additions & 5 deletions src/Micro.Cli/Accessor.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using Micro.Common.Application;

namespace Micro.Cli
namespace Micro.Cli;

public class Accessor : IExecutionContextAccessor
{
public class Accessor : IExecutionContextAccessor
{
public IExecutionContext ExecutionContext { get; set; } = null!;
}
public IExecutionContext ExecutionContext { get; init; } = null!;
}
8 changes: 4 additions & 4 deletions src/Micro.Cli/Micro.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<Content Include="..\.dockerignore">
<Link>.dockerignore</Link>
</Content>
<None Remove="appsettings.json"/>
<None Remove="appsettings.json" />
<Content Include="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand All @@ -25,9 +25,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0"/>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0"/>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.0" />
</ItemGroup>

</Project>
8 changes: 2 additions & 6 deletions src/Micro.Common/Application/ProcessInboxCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

namespace Micro.Common.Application;

public class ProcessInboxCommand : IRequest
{
}
public class ProcessInboxCommand : IRequest;

public class ProcessInboxCommandValidator : AbstractValidator<ProcessInboxCommand>
{
}
public class ProcessInboxCommandValidator : AbstractValidator<ProcessInboxCommand>;
8 changes: 2 additions & 6 deletions src/Micro.Common/Application/ProcessOutboxCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

namespace Micro.Common.Application;

public class ProcessOutboxCommand : IRequest
{
}
public class ProcessOutboxCommand : IRequest;

public class ProcessOutboxCommandValidator : AbstractValidator<ProcessOutboxCommand>
{
}
public class ProcessOutboxCommandValidator : AbstractValidator<ProcessOutboxCommand>;
8 changes: 2 additions & 6 deletions src/Micro.Common/Application/ProcessQueueCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

namespace Micro.Common.Application;

public class ProcessQueueCommand : IRequest
{
}
public class ProcessQueueCommand : IRequest;

public class ProcessQueueCommandValidator : AbstractValidator<ProcessQueueCommand>
{
}
public class ProcessQueueCommandValidator : AbstractValidator<ProcessQueueCommand>;
12 changes: 7 additions & 5 deletions src/Micro.Common/BaseModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,32 @@ namespace Micro.Common;

public class BaseModule
{
private readonly Func<IServiceScope> _scopeFactory;
private readonly Func<AsyncServiceScope> _scopeFactory;

protected BaseModule(Func<IServiceScope> scopeFactory)
protected BaseModule(Func<AsyncServiceScope> scopeFactory)
{
_scopeFactory = scopeFactory;
}

public async Task SendCommand(IRequest command)
{
using var scope = _scopeFactory.Invoke();
await using var scope = _scopeFactory.Invoke();
var logger = scope.ServiceProvider.GetRequiredService<ILogger<BaseModule>>();
logger.LogDebug("Sending command {Command}", command);
var dispatcher = scope.ServiceProvider.GetRequiredService<IMediator>();
await dispatcher.Send(command);
}

public async Task<TResult> SendQuery<TResult>(IRequest<TResult> query)
{
using var scope = _scopeFactory.Invoke();
await using var scope = _scopeFactory.Invoke();
var dispatcher = scope.ServiceProvider.GetRequiredService<IMediator>();
return await dispatcher.Send(query);
}

public async Task PublishNotification(INotification notification)
{
using var scope = _scopeFactory.Invoke();
await using var scope = _scopeFactory.Invoke();
var dispatcher = scope.ServiceProvider.GetRequiredService<IMediator>();
await dispatcher.Publish(notification);
}
Expand Down
28 changes: 14 additions & 14 deletions src/Micro.Common/Micro.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@

<ItemGroup>
<PackageReference Include="Dapper" Version="2.1.35" />
<PackageReference Include="FluentValidation" Version="11.9.2" />
<PackageReference Include="FluentMigrator" Version="5.2.0" />
<PackageReference Include="FluentMigrator.Runner" Version="5.2.0" />
<PackageReference Include="FluentMigrator.Runner.Postgres" Version="5.2.0" />
<PackageReference Include="MediatR" Version="12.3.0" />
<PackageReference Include="FluentValidation" Version="11.11.0" />
<PackageReference Include="FluentMigrator" Version="6.2.0" />
<PackageReference Include="FluentMigrator.Runner" Version="6.2.0" />
<PackageReference Include="FluentMigrator.Runner.Postgres" Version="6.2.0" />
<PackageReference Include="MediatR" Version="12.4.1" />
<PackageReference Include="MediatR.Contracts" Version="2.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.6">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.6" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Npgsql" Version="8.0.3" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" />
<PackageReference Include="Polly" Version="8.4.0" />
<PackageReference Include="Quartz" Version="3.9.0" />
<PackageReference Include="Npgsql" Version="9.0.2" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.2" />
<PackageReference Include="Polly" Version="8.5.0" />
<PackageReference Include="Quartz" Version="3.13.1" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/Micro.Proxy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
USER $APP_UID
WORKDIR /app
EXPOSE 8080
EXPOSE 8081

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["src/Micro.Proxy/Micro.Proxy.csproj", "src/Micro.Proxy/"]
Expand Down
4 changes: 2 additions & 2 deletions src/Micro.Proxy/Micro.Proxy.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Yarp.ReverseProxy" Version="2.1.0" />
<PackageReference Include="Yarp.ReverseProxy" Version="2.2.0" />
</ItemGroup>
<ItemGroup>
<Content Include="..\..\.dockerignore">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ public static class DeleteOrganisation
{
public record Command : IRequest;

public class Validator : AbstractValidator<Command>
{
}
public class Validator : AbstractValidator<Command>;

public class Handler(IExecutionContext context, IOrganisationRepository organisations) : IRequestHandler<Command>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ public record Query : IRequest<Result>;

public record Result(Guid Id, string Name);

public class Validator : AbstractValidator<Query>
{
}
public class Validator : AbstractValidator<Query>;

public class Handler(IExecutionContext context, IOrganisationRepository organisations) : IRequestHandler<Query, Result>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ public record Query : IRequest<Result>;

public record Result(Guid Id, string Name);

public class Validator : AbstractValidator<Query>
{
}
public class Validator : AbstractValidator<Query>;

public class Handler(IExecutionContext context, IOrganisationRepository organisations) : IRequestHandler<Query, Result>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public override void Up()
.WithColumn(RoleColumn).AsString(RoleMaxLength)
.WithColumn(CreatedAt).AsDateTimeOffset()
.WithColumn(UpdatedAt).AsDateTimeOffset().Nullable();
;

Create.Table(UsersTable)
.WithColumn(IdColumn).AsGuid().PrimaryKey()
Expand All @@ -32,7 +31,6 @@ public override void Up()
.WithColumn(NameColumn).AsString(NameMaxLength)
.WithColumn(CreatedAt).AsDateTimeOffset()
.WithColumn(UpdatedAt).AsDateTimeOffset().Nullable();
;

Create.ForeignKey($"fk_{MembershipsTable}_{OrganisationsTable}")
.FromTable(MembershipsTable).ForeignColumn(OrganisationIdColumn)
Expand Down
Loading

0 comments on commit 689eeec

Please sign in to comment.