-
Notifications
You must be signed in to change notification settings - Fork 2
Improved CI/CD Pipelines #19
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
Changes from all commits
94126ff
78e1bac
a519a46
af0f40c
115d31a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| name: .NET Build | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ "**" ] | ||
| pull_request: | ||
| branches: [ "main" ] | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Safeguard against... shenanigans. |
||
|
|
||
| env: | ||
| SOLUTION_FILE: src/Ninject.Web.AspNetCore.slnx | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| name: Build and Test | ||
| steps: | ||
| # Checkout the repository | ||
| - name: Checkout code | ||
| uses: actions/checkout@v5 | ||
|
|
||
| # Setup .NET Core SDK | ||
| - name: Setup .NET | ||
| uses: actions/setup-dotnet@v5 | ||
| with: | ||
| dotnet-version: 10.0.x | ||
|
|
||
| - name: Restore dependencies | ||
| run: dotnet restore $SOLUTION_FILE | ||
|
|
||
| - name: Verify formatting | ||
| run: dotnet format $SOLUTION_FILE --verify-no-changes | ||
|
|
||
| - name: Build | ||
| run: dotnet build --no-restore $SOLUTION_FILE | ||
|
|
||
| - name: Test | ||
| run: dotnet test --no-build $SOLUTION_FILE | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| name: NuGet Package Release | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - 'v*.*.*' | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: false | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| env: | ||
| SOLUTION_FILE: src/Ninject.Web.AspNetCore.slnx | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| id-token: write # required so the job can request a GitHub OIDC token for NuGet Trusted Publishing | ||
|
|
||
| steps: | ||
| # Checkout the repository | ||
| - name: Checkout code | ||
| uses: actions/checkout@v5 | ||
|
|
||
| # Setup .NET Core SDK | ||
| - name: Setup .NET Core | ||
| uses: actions/setup-dotnet@v5 | ||
| with: | ||
| dotnet-version: 10.0.x | ||
|
|
||
| - name: Restore dependencies | ||
| run: dotnet restore $SOLUTION_FILE | ||
|
|
||
| - name: Verify formatting | ||
| run: dotnet format $SOLUTION_FILE --verify-no-changes | ||
|
|
||
| - name: Build | ||
| run: dotnet build --no-restore $SOLUTION_FILE | ||
|
|
||
| - name: Test | ||
| run: dotnet test --no-build $SOLUTION_FILE | ||
|
|
||
| # Derive the package version from the pushed tag, e.g. refs/tags/v10.0.1 -> 10.0.1 | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this also works for SemVer pre-release versions like "v10.2.0-beta.1" where the derived version will be "10.2.0-beta.1". |
||
| - name: Extract version from tag | ||
| id: version | ||
| run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Pack Ninject.Web.AspNetCore | ||
| run: dotnet pack $SOLUTION_FILE -c Release --include-symbols -p:SymbolPackageFormat=snupkg -p:Version=${{ steps.version.outputs.version }} --output ./artifacts | ||
|
|
||
| # Exchange the GitHub OIDC token for a short-lived (1 hour) NuGet API key | ||
| - name: NuGet login (OIDC -> temp API key) | ||
| uses: NuGet/login@v1 | ||
| id: login | ||
| with: | ||
| user: ${{ secrets.NUGET_USER }} | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not exactly a secret since it's really just my NuGet username 😄. But apparently that's how it is done. |
||
|
|
||
| # Push the packages to NuGet | ||
| - name: Push to NuGet | ||
| run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ steps.login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,15 @@ | ||
| # Release Process | ||
| Build and package the project with the _Release_ configuration. | ||
| Releases are built, packed and published automatically by the [`NuGet Package Release`](../.github/publish.yml) GitHub Actions workflow. | ||
|
|
||
| To ship a release, push a tag matching `v*.*.*` (e.g. `v10.0.1`): | ||
| ``` | ||
| $version = "5.1.x" | ||
| dotnet build .\src\Ninject.Web.AspNetCore.sln -c Release -p:Version="$version" | ||
| dotnet pack .\src\Ninject.Web.AspNetCore.sln -c Release --include-symbols -p:SymbolPackageFormat=snupkg -p:Version="$version" | ||
| git tag v10.0.1 | ||
| git push origin v10.0.1 | ||
| ``` | ||
|
|
||
| Publish all three packages with the `publish.ps1` script, replacing the API key and versions as needed. | ||
| ``` | ||
| .\doc\publish.ps1 -apiKey "NuGet APIKey" -version "$version" | ||
| ``` | ||
| The workflow then: | ||
| 1. Restores, builds and tests the solution. | ||
| 2. Derives the package version from the tag name (stripping the leading `v`, e.g. `v10.0.1` -> `10.0.1`) and packs all three packages with that version via `-p:Version`. | ||
| 3. Exchanges the workflow's GitHub OIDC token for a short-lived NuGet API key ([NuGet Trusted Publishing](https://learn.microsoft.com/en-us/nuget/nuget-org/trusted-publishing)) and pushes the packages to nuget.org. | ||
|
|
||
| With the NuGet API key stored in the Windows credential manager, we can do | ||
| ``` | ||
| .\doc\publish.ps1 -apiKey $((Read-CredentialsStore -Target "NuGet:Ninject.Web.AspNetCore:APIKey").GetNetworkCredential().Password) -version "$version" | ||
| ``` | ||
| No manual build, pack or publish steps are required. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <Project> | ||
|
|
||
| <PropertyGroup> | ||
| <EnableNETAnalyzers>true</EnableNETAnalyzers> | ||
| <AnalysisLevel>latest</AnalysisLevel> | ||
| <AnalysisMode>Recommended</AnalysisMode> | ||
| <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild> | ||
| <NoWarn>CA1805,CA1822</NoWarn> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,41 +1,41 @@ | ||
| using System; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using Ninject.Planning.Bindings.Resolvers; | ||
| using Xunit; | ||
| namespace Ninject.Web.AspNetCore.ComplianceTest; | ||
| /// <summary> | ||
| /// See https://github.com/dotnet/runtime/tree/main/src/libraries/Microsoft.Extensions.DependencyInjection.Specification.Tests/src - the dotnet/runtime | ||
| /// project which contains the dependency injection library code also contains a set of "compliance tests" that can be run against a potential alternative | ||
| /// implementation to check if it is compliant. This class is running the dedicated specification tests for KEYED services. | ||
| /// </summary> | ||
| public class KeyedDependencyInjectionComplianceTests : Microsoft.Extensions.DependencyInjection.Specification.KeyedDependencyInjectionSpecificationTests | ||
| { | ||
| protected override IServiceProvider CreateServiceProvider(IServiceCollection serviceCollection) | ||
| { | ||
| var kernel = new AspNetCoreKernel(); | ||
| // remove autobinding as CreateServiceWithKeyedParameter e.g. tests that no autobinding happens. | ||
| kernel.Components.Remove<IMissingBindingResolver, SelfBindingResolver>(); | ||
| var factory = new NinjectServiceProviderFactory(kernel); | ||
| return factory.CreateBuilder(serviceCollection).Build(); | ||
| } | ||
| #pragma warning disable xUnit1024, xUnit1026 | ||
| [Theory(Skip = "Wrong implementation of the test, should use Assert.Equal and not Assert.Same")] | ||
| [InlineData(true)] | ||
| [InlineData(false)] | ||
| public new void ResolveWithAnyKeyQuery_Constructor(bool anyKeyQueryBeforeSingletonQueries) | ||
| { | ||
| } | ||
| [Theory(Skip = "Wrong implementation, should use Assert.Equal and not Assert.Same")] | ||
| [InlineData(true)] | ||
| [InlineData(false)] | ||
| public new void ResolveWithAnyKeyQuery_Constructor_Duplicates(bool anyKeyQueryBeforeSingletonQueries) | ||
| { | ||
| } | ||
| #pragma warning restore xUnit1024, xUnit1026 | ||
| } | ||
| using System; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using Ninject.Planning.Bindings.Resolvers; | ||
| using Xunit; | ||
|
|
||
| namespace Ninject.Web.AspNetCore.ComplianceTest; | ||
|
|
||
| /// <summary> | ||
| /// See https://github.com/dotnet/runtime/tree/main/src/libraries/Microsoft.Extensions.DependencyInjection.Specification.Tests/src - the dotnet/runtime | ||
| /// project which contains the dependency injection library code also contains a set of "compliance tests" that can be run against a potential alternative | ||
| /// implementation to check if it is compliant. This class is running the dedicated specification tests for KEYED services. | ||
| /// </summary> | ||
| public class KeyedDependencyInjectionComplianceTests : Microsoft.Extensions.DependencyInjection.Specification.KeyedDependencyInjectionSpecificationTests | ||
| { | ||
| protected override IServiceProvider CreateServiceProvider(IServiceCollection collection) | ||
| { | ||
| var kernel = new AspNetCoreKernel(); | ||
| // remove autobinding as CreateServiceWithKeyedParameter e.g. tests that no autobinding happens. | ||
| kernel.Components.Remove<IMissingBindingResolver, SelfBindingResolver>(); | ||
| var factory = new NinjectServiceProviderFactory(kernel); | ||
|
|
||
| return factory.CreateBuilder(collection).Build(); | ||
| } | ||
|
|
||
| #pragma warning disable xUnit1024, xUnit1026 | ||
|
|
||
| [Theory(Skip = "Wrong implementation of the test, should use Assert.Equal and not Assert.Same")] | ||
| [InlineData(true)] | ||
| [InlineData(false)] | ||
| public new void ResolveWithAnyKeyQuery_Constructor(bool anyKeyQueryBeforeSingletonQueries) | ||
| { | ||
| } | ||
|
|
||
| [Theory(Skip = "Wrong implementation, should use Assert.Equal and not Assert.Same")] | ||
| [InlineData(true)] | ||
| [InlineData(false)] | ||
| public new void ResolveWithAnyKeyQuery_Constructor_Duplicates(bool anyKeyQueryBeforeSingletonQueries) | ||
| { | ||
| } | ||
| #pragma warning restore xUnit1024, xUnit1026 | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| using Microsoft.AspNetCore.Hosting; | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Many files have a BOM which always annoys the living F out of me. An UTF-8 BOM makes no F-ing sense. |
||
| using Microsoft.AspNetCore.Hosting; | ||
| using Microsoft.AspNetCore.Server.HttpSys; | ||
| using System; | ||
| using System.Runtime.Versioning; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| using Ninject.Activation.Caching; | ||
| using Ninject.Activation.Caching; | ||
| using Ninject.Web.AspNetCore.Components; | ||
| using System; | ||
| using System.Collections.Generic; | ||
|
|
@@ -7,7 +7,7 @@ | |
|
|
||
| namespace Ninject.Web.AspNetCore.Test.Fakes | ||
| { | ||
| public class FakeActivationCacheAccessor : IActivationCache, IActivationCacheAccessor | ||
| public sealed class FakeActivationCacheAccessor : IActivationCache, IActivationCacheAccessor | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This avoids the warning for calling |
||
| { | ||
| private readonly ConditionalWeakTable<object, ActivationEntry> _trackedInstances = new ConditionalWeakTable<object, ActivationEntry>(); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| namespace Ninject.Web.AspNetCore.Test.Fakes | ||
| { | ||
| #if NET8_0_OR_GREATER | ||
| #if NET8_0_OR_GREATER | ||
| public interface IKeyedWeaponStorage | ||
| { | ||
| IWeapon Weapon { get; } | ||
| } | ||
| #endif | ||
| } | ||
| #endif | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means that if I push changes to a branch while a build is already running, then the current build will be aborted and a new one started.