Skip to content

V3.0.2/package maintenance #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 38 additions & 53 deletions .github/workflows/pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:
jobs:
build:
name: 🛠️ Build
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
strategy:
matrix:
configuration: [Debug, Release]
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:

pack:
name: 📦 Pack
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
strategy:
matrix:
configuration: [Debug, Release]
Expand All @@ -80,10 +80,16 @@ jobs:
uploadPackedArtifact: true
version: ${{ needs.build.outputs.version }}

sonarcloud:
name: 🔬 Code Quality Analysis
test:
name: 🧪 Test
needs: [build]
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, windows-2022]
configuration: [Debug, Release]
runs-on: ${{ matrix.os }}
timeout-minutes: 15
steps:
- name: Checkout
uses: codebeltnet/git-checkout@v1
Expand All @@ -93,64 +99,43 @@ jobs:
with:
includePreview: true

- name: Install .NET Tool - Sonar Scanner
uses: codebeltnet/dotnet-tool-install-sonarscanner@v1

- name: Restore Dependencies
uses: codebeltnet/dotnet-restore@v2

- name: Run SonarCloud Analysis
uses: codebeltnet/sonarcloud-scan@v1
with:
token: ${{ secrets.SONAR_TOKEN }}
organization: geekle
projectKey: bootstrapper
version: ${{ needs.build.outputs.version }}
- name: Install .NET Tool - Report Generator
uses: codebeltnet/dotnet-tool-install-reportgenerator@v1

- name: Build
uses: codebeltnet/dotnet-build@v2
- name: Test with ${{ matrix.configuration }} build
uses: codebeltnet/dotnet-test@v3
with:
configuration: ${{ matrix.configuration }}
buildSwitches: -p:SkipSignAssembly=true
uploadBuildArtifact: false

- name: Finalize SonarCloud Analysis
uses: codebeltnet/sonarcloud-scan-finalize@v1
with:
token: ${{ secrets.SONAR_TOKEN }}
sonarcloud:
name: call-sonarcloud
needs: [build,test]
uses: codebeltnet/jobs-sonarcloud/.github/workflows/default.yml@v1
with:
organization: geekle
projectKey: bootstrapper
version: ${{ needs.build.outputs.version }}
secrets: inherit

codecov:
name: call-codecov
needs: [build,test]
uses: codebeltnet/jobs-codecov/.github/workflows/default.yml@v1
with:
repository: codebeltnet/bootstrapper
secrets: inherit

codeql:
name: 🛡️ Security Analysis
needs: [build]
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: codebeltnet/git-checkout@v1

- name: Install .NET
uses: codebeltnet/install-dotnet@v1
with:
includePreview: true

- name: Restore Dependencies
uses: codebeltnet/dotnet-restore@v2

- name: Prepare CodeQL SAST Analysis
uses: codebeltnet/codeql-scan@v1

- name: Build
uses: codebeltnet/dotnet-build@v2
with:
buildSwitches: -p:SkipSignAssembly=true
uploadBuildArtifact: false

- name: Finalize CodeQL SAST Analysis
uses: codebeltnet/codeql-scan-finalize@v1
name: call-codeql
needs: [build,test]
uses: codebeltnet/jobs-codeql/.github/workflows/default.yml@v1

deploy:
if: github.event_name != 'pull_request'
name: 🚀 Deploy v${{ needs.build.outputs.version }}
runs-on: ubuntu-22.04
needs: [build,pack,sonarcloud,codeql]
runs-on: ubuntu-24.04
needs: [build, pack, test, sonarcloud, codecov, codeql]
environment: Production
steps:
- uses: codebeltnet/nuget-push@v1
Expand Down
16 changes: 16 additions & 0 deletions Codebelt.Bootstrapper.sln
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Codebelt.Bootstrapper.Minim
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Codebelt.Bootstrapper.MinimalWorker.App", "app\Codebelt.Bootstrapper.MinimalWorker.App\Codebelt.Bootstrapper.MinimalWorker.App.csproj", "{E87D127B-4CD1-4009-962E-EEF70A522C13}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Codebelt.Bootstrapper.Tests", "test\Codebelt.Bootstrapper.Tests\Codebelt.Bootstrapper.Tests.csproj", "{CC656409-7479-4553-8E9B-0854801E1590}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Codebelt.Bootstrapper.FunctionalTests", "test\Codebelt.Bootstrapper.FunctionalTests\Codebelt.Bootstrapper.FunctionalTests.csproj", "{8970491F-E0BD-489D-AA7E-617A67C2E39F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -109,6 +115,14 @@ Global
{E87D127B-4CD1-4009-962E-EEF70A522C13}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E87D127B-4CD1-4009-962E-EEF70A522C13}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E87D127B-4CD1-4009-962E-EEF70A522C13}.Release|Any CPU.Build.0 = Release|Any CPU
{CC656409-7479-4553-8E9B-0854801E1590}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CC656409-7479-4553-8E9B-0854801E1590}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CC656409-7479-4553-8E9B-0854801E1590}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CC656409-7479-4553-8E9B-0854801E1590}.Release|Any CPU.Build.0 = Release|Any CPU
{8970491F-E0BD-489D-AA7E-617A67C2E39F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8970491F-E0BD-489D-AA7E-617A67C2E39F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8970491F-E0BD-489D-AA7E-617A67C2E39F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8970491F-E0BD-489D-AA7E-617A67C2E39F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -130,6 +144,8 @@ Global
{3C43A01F-51E7-4166-91D5-E2088E68F4E5} = {28409021-5670-4008-9061-DBAAA0FC4DA6}
{497AD6CD-1E7E-4B4D-ACE5-CDD005A14F96} = {28409021-5670-4008-9061-DBAAA0FC4DA6}
{E87D127B-4CD1-4009-962E-EEF70A522C13} = {28409021-5670-4008-9061-DBAAA0FC4DA6}
{CC656409-7479-4553-8E9B-0854801E1590} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
{8970491F-E0BD-489D-AA7E-617A67C2E39F} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {72FB037E-3629-4CDB-812E-D577A3D4FD26}
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,6 @@
</ItemGroup>

<ItemGroup Condition="'$(IsTestProject)' == 'true'">
<PackageReference Include="Codebelt.Extensions.Xunit" />
<PackageReference Include="Codebelt.Extensions.Xunit.App" />
</ItemGroup>
</Project>
24 changes: 12 additions & 12 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Codebelt.Extensions.Swashbuckle.AspNetCore" Version="9.0.1" />
<PackageVersion Include="Codebelt.Extensions.Xunit" Version="9.0.1" />
<PackageVersion Include="Cuemon.Core" Version="9.0.1" />
<PackageVersion Include="Cuemon.Extensions.Hosting" Version="9.0.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageVersion Include="Codebelt.Extensions.Xunit.App" Version="9.1.3" />
<PackageVersion Include="Cuemon.Core" Version="9.0.3" />
<PackageVersion Include="Cuemon.Extensions.Hosting" Version="9.0.3" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageVersion Include="MinVer" Version="6.0.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
<PackageVersion Include="coverlet.msbuild" Version="6.0.4" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.1" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.2" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('net9'))">
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="9.0.1" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="9.0.1" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="9.0.1" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.1" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="9.0.1" />
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="9.0.3" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="9.0.3" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="9.0.3" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.3" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="9.0.3" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('net8'))">
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="8.0.12" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="8.0.12" />
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="8.0.14" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="8.0.14" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace Codebelt.Bootstrapper.Assets
{
public class TestBackgroundService : BackgroundService
{
private readonly ILogger<TestBackgroundService> _logger;

public TestBackgroundService(ILogger<TestBackgroundService> logger)
{
_logger = logger;
}

public TimeSpan Elapsed { get; private set; } = TimeSpan.Zero;

protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
var sw = Stopwatch.StartNew();
await this.WaitForApplicationStartedAnnouncementAsync(stoppingToken).ConfigureAwait(false);
sw.Stop();
Elapsed = sw.Elapsed;
_logger.LogInformation("TestBackgroundService started after {Elapsed}", Elapsed);
}
}
}
35 changes: 35 additions & 0 deletions test/Codebelt.Bootstrapper.FunctionalTests/Assets/TestFixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System.Collections.Generic;
using Codebelt.Extensions.Xunit.Hosting;
using Codebelt.Extensions.Xunit;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;

namespace Codebelt.Bootstrapper.Assets
{
public class TestHostFixture : HostFixture
{
public override void ConfigureHost(Test hostTest)
{
var hb = Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder()
.ConfigureAppConfiguration((context, config) =>
{
ConfigureCallback(config.Build(), context.HostingEnvironment);
})
.ConfigureServices((context, services) =>
{
Configuration = context.Configuration;
HostingEnvironment = context.HostingEnvironment;
ConfigureServicesCallback(services);
})
.ConfigureHostConfiguration(builder =>
{
builder.AddInMemoryCollection(new Dictionary<string, string>
{
{ HostDefaults.ApplicationKey, hostTest.CallerType.Assembly.GetName().Name }
});
});
ConfigureHostCallback(hb);
Host = hb.Build();
}
}
}
17 changes: 17 additions & 0 deletions test/Codebelt.Bootstrapper.FunctionalTests/Assets/TestStartup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace Codebelt.Bootstrapper.Assets
{
public class TestStartup : StartupRoot
{
public TestStartup(IConfiguration configuration, IHostEnvironment environment) : base(configuration, environment)
{
}

public override void ConfigureServices(IServiceCollection services)
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System;
using System.Threading;
using Codebelt.Bootstrapper.Assets;
using Codebelt.Extensions.Xunit;
using Codebelt.Extensions.Xunit.Hosting;
using Microsoft.Extensions.Hosting;
using Xunit;
using Xunit.Abstractions;

namespace Codebelt.Bootstrapper
{
public class BootstrapperLifetimeTest : Test
{
private bool _started = false;
private bool _stopping = false;
private bool _stopped = false;

public BootstrapperLifetimeTest(ITestOutputHelper output) : base(output)
{
BootstrapperLifetime.OnApplicationStartedCallback = () => { _started = true; };
BootstrapperLifetime.OnApplicationStoppingCallback = () => { _stopping = true; };
BootstrapperLifetime.OnApplicationStoppedCallback = () => { _stopped = true; };
}

[Fact]
public void OnApplicationStartedCallback_ShouldBeInvokedWhenStartingHost()
{
using var test = GenericHostTestFactory.Create(services =>
{
services.AddXunitTestLoggingOutputHelperAccessor();
services.AddXunitTestLogging(TestOutput);
}, hb =>
{
hb.UseBootstrapperLifetime();
hb.UseBootstrapperStartup<TestStartup>();
}, new TestHostFixture());

test.Host.Start();

Assert.True(_started);
}

[Fact]
public void OnApplicationStoppingCallback_OnApplicationStoppedCallback_ShouldBeInvokedWhenStoppingHost()
{
using var test = GenericHostTestFactory.Create(services =>
{
services.AddXunitTestLoggingOutputHelperAccessor();
services.AddXunitTestLogging(TestOutput);
}, hb =>
{
hb.UseBootstrapperLifetime();
hb.UseBootstrapperStartup<TestStartup>();
}, new TestHostFixture());

test.Host.Start();
test.Host.StopAsync().GetAwaiter().GetResult();

Assert.True(_stopping && _stopped);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<RootNamespace>Codebelt.Bootstrapper</RootNamespace>
</PropertyGroup>

<!-- Added due to BootstrapperLifetime static callbacks -->
<ItemGroup>
<AssemblyAttribute Include="Xunit.CollectionBehaviorAttribute">
<_Parameter1>DisableTestParallelization = true</_Parameter1>
<_Parameter1_IsLiteral>true</_Parameter1_IsLiteral>
</AssemblyAttribute>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Codebelt.Bootstrapper\Codebelt.Bootstrapper.csproj" />
</ItemGroup>

</Project>
Loading
Loading