Improved CI/CD Pipelines - #19
Conversation
| branches: [ "main" ] | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} |
There was a problem hiding this comment.
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.
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: read |
There was a problem hiding this comment.
Safeguard against... shenanigans.
| - 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 |
There was a problem hiding this comment.
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".
| uses: NuGet/login@v1 | ||
| id: login | ||
| with: | ||
| user: ${{ secrets.NUGET_USER }} |
There was a problem hiding this comment.
Not exactly a secret since it's really just my NuGet username 😄. But apparently that's how it is done.
| @@ -1,4 +1,4 @@ | |||
| using Microsoft.AspNetCore.Hosting; | |||
There was a problem hiding this comment.
Many files have a BOM which always annoys the living F out of me. An UTF-8 BOM makes no F-ing sense.
| namespace Ninject.Web.AspNetCore.Test.Fakes | ||
| { | ||
| public class FakeActivationCacheAccessor : IActivationCache, IActivationCacheAccessor | ||
| public sealed class FakeActivationCacheAccessor : IActivationCache, IActivationCacheAccessor |
There was a problem hiding this comment.
This avoids the warning for calling GC.whatever... in the Dispose method which is one of the analyzer checks.
| } | ||
|
|
||
| private IKernel CreateKernel() | ||
| private AspNetCoreKernel CreateKernel() |
There was a problem hiding this comment.
Another analyzer warning.
| public sealed class ActivationCacheTests : IDisposable | ||
| { | ||
| private readonly WeakTableActivationCache testee; | ||
| private readonly WeakTableActivationCache _testee; |
There was a problem hiding this comment.
This did not get disposed properly. Analyzer warnings can be useful 😝.
| { | ||
| throw new ArgumentNullException(nameof(serviceCollection)); | ||
| } | ||
| ArgumentNullException.ThrowIfNull(serviceCollection); |
There was a problem hiding this comment.
Also recommended by an analyzer warning.
|
Thanks for these updates, looks good :-) |
Well... It's a LOT of changes, but mostly they are automated formatting fixes and dealing with build warnings from inconsistencies in the code, so it's not as bad as it looks.
Migration to SLNX Format
I've been working with *.slnx style solutions for a while now and they are simply... better. Readable. I updated the solution and I have no regrets.
Improved Build Pipeline and Semi-Automated Release
I extended and renamed the GitHub build pipeline with some security constraints and other improvements. Then I introduced a new
publish.ymlworkflow that uses the brand new NuGet Trusted Publishing mechanism to automatically publish packages. I've been testing this on some of my other projects and I am much more comfortable actually automating this since it significantly reduces the risk of leaking long-living API keys. It also makes it much easier for any of the project maintainers to actually create a release since all you have to do is... push a tag - at least if I configured the repository Ruleset correctly. Seedoc\release-process.md.Running Analyzers on Build
I enabled running code analyzers throughout the project with the
src/Directory.Build.propswhich of course generated dozens of warnings because of small inconsistencies in the code. I disabled some of the warnings on purpose and simply dealt with the rest by fixing the code.These are the warnings that I disabled:
Consistent Formatting and Check in CI/CD
We've had a bit of a formatting mess in this project from the very beginning and since I was already working on the build process, I decided to finally do something about this. I updated the
.editorconfigwith some (according to me) sane rules and randotnet format src/Ninject.Web.AspNetCore.slnxto apply these consistent formatting rules. These rules are now also checked in the CI/CD pipelines and the build will fail if there are violations.