From 5ec6ea7e85e81694647ce2803d98280b42fcbe2b Mon Sep 17 00:00:00 2001 From: Dwi Cahya Pramanda Date: Tue, 22 Oct 2024 14:39:31 +0700 Subject: [PATCH 1/3] Changed to local time format --- .../Models/HomeControllerBanner.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Homely.AspNetCore.Mvc.Helpers/Models/HomeControllerBanner.cs b/src/Homely.AspNetCore.Mvc.Helpers/Models/HomeControllerBanner.cs index a76479b..d63cb4f 100644 --- a/src/Homely.AspNetCore.Mvc.Helpers/Models/HomeControllerBanner.cs +++ b/src/Homely.AspNetCore.Mvc.Helpers/Models/HomeControllerBanner.cs @@ -6,18 +6,18 @@ namespace Homely.AspNetCore.Mvc.Helpers.Models /// public class HomeControllerBanner : IHomeControllerBanner { - private static readonly DateTime ApplicationStartedOn = DateTime.UtcNow; + private static readonly DateTime ApplicationStartedOn = DateTime.Now; public HomeControllerBanner(Assembly callingAssembly, string? banner = null) { var assemblyDate = callingAssembly.Location == null ? "-- unknown --" - : System.IO.File.GetLastWriteTime(callingAssembly.Location).ToString("U"); + : System.IO.File.GetLastWriteTime(callingAssembly.Location).ToString("F"); var assemblyInfo = $"Name: {callingAssembly.GetName().Name}{Environment.NewLine}" + $"Version: {callingAssembly.GetName().Version}{Environment.NewLine}" + $"Build Date : {assemblyDate}{Environment.NewLine}" + - $"Application Started: {ApplicationStartedOn:U}"; + $"Application Started: {ApplicationStartedOn:F}"; var serverDetails = $"Server name: {Environment.MachineName}"; From 9f74864bee4a6a0fb87596129d7df5cebe79c87a Mon Sep 17 00:00:00 2001 From: Dwi Cahya Pramanda Date: Tue, 22 Oct 2024 15:22:30 +0700 Subject: [PATCH 2/3] Bump github actions Migrate to NET 8 Bump NET Packages Fix existing UT errors --- .github/workflows/ci.yml | 14 +++++++------- .github/workflows/pull_request.yml | 12 ++++++------ .github/workflows/release.yml | 8 ++++---- global.json | 2 +- .../Homely.AspNetCore.Mvc.Helpers.csproj | 12 ++++++------ .../HomeControllerTests/ExceptionTestTests.cs | 2 +- .../HomeControllerTests/GetTests.cs | 10 ++++++++-- .../Homely.AspNetCore.Mvc.Helpers.Tests.csproj | 14 +++++++------- .../TestControllerTests/ConflictTests.cs | 4 ++-- .../TestControllerTests/DynamicErrorTests.cs | 2 +- .../TestControllerTests/ErrorTests.cs | 2 +- .../TestControllerTests/GetNotFoundTests.cs | 2 +- .../TestControllerTests/GetTests.cs | 2 +- .../TestControllerTests/ModelBindingTests.cs | 4 ++-- .../TestControllerTests/PostTests.cs | 2 +- .../Controllers/TestController.cs | 2 +- tests/TestWebApplication/TestWebApplication.csproj | 2 +- 17 files changed, 51 insertions(+), 45 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8572d89..89a5ae9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,13 +17,13 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Build version suffix run: echo "VERSION_SUFFIX=beta.${{ github.run_number }}" >> $GITHUB_ENV - name: Setup .NET - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v4 - run: dotnet restore --verbosity minimal @@ -34,7 +34,7 @@ jobs: - run: dotnet pack --configuration Release --no-build --output ./artifacts --version-suffix $VERSION_SUFFIX - name: Publish artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: path: ./artifacts/* @@ -46,7 +46,7 @@ jobs: --source https://nuget.pkg.github.com/${{ github.repository_owner }} - name: Remove old pre-release packages (keeping the GPR cleanish) - uses: actions/delete-package-versions@v2 + uses: actions/delete-package-versions@v4 with: package-name: 'Homely.AspNetCore.Mvc.Helpers' min-versions-to-keep: 10 @@ -57,10 +57,10 @@ jobs: steps: - name: Checkout repo - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup .NET - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v4 - run: dotnet restore --verbosity minimal @@ -69,7 +69,7 @@ jobs: - run: dotnet test --configuration Debug --verbosity minimal --no-build --collect:"XPlat Code Coverage" --results-directory "./.codecoverage" - name: Code coverage - uses: codecov/codecov-action@v2 + uses: codecov/codecov-action@v4 with: token: "${{ secrets.CODECOV_TOKEN }}" directory: "./.codecoverage" diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index e4745a0..a274fec 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -12,13 +12,13 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Build version suffix run: echo "VERSION_SUFFIX=alpha.${{ github.run_number }}" >> $GITHUB_ENV - name: Setup .NET - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v4 - run: dotnet restore --verbosity minimal @@ -29,7 +29,7 @@ jobs: - run: dotnet pack --configuration Release --no-build --output ./artifacts --version-suffix $VERSION_SUFFIX - name: Publish artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: path: ./artifacts/* @@ -38,10 +38,10 @@ jobs: steps: - name: Checkout repo - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup .NET - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v4 - run: dotnet restore --verbosity minimal @@ -50,7 +50,7 @@ jobs: - run: dotnet test --configuration Debug --verbosity minimal --no-build --collect:"XPlat Code Coverage" --results-directory "./.codecoverage" - name: Code coverage - uses: codecov/codecov-action@v2 + uses: codecov/codecov-action@v4 with: token: "${{ secrets.CODECOV_TOKEN }}" directory: "./.codecoverage" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f0c8c32..14aaa7d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,10 +23,10 @@ jobs: run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup .NET - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v4 - run: dotnet restore --verbosity minimal @@ -35,12 +35,12 @@ jobs: - run: dotnet pack --configuration Release --no-build --output ./artifacts /p:version=${{ env.RELEASE_VERSION }} - name: Publish artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: path: ./artifacts/* - name: Upload release assets - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: diff --git a/global.json b/global.json index 0babd83..bae2dc6 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "6.0.100", + "version": "8.0.400", "rollForward": "latestFeature" } } diff --git a/src/Homely.AspNetCore.Mvc.Helpers/Homely.AspNetCore.Mvc.Helpers.csproj b/src/Homely.AspNetCore.Mvc.Helpers/Homely.AspNetCore.Mvc.Helpers.csproj index 6ed8b33..cc9f27a 100644 --- a/src/Homely.AspNetCore.Mvc.Helpers/Homely.AspNetCore.Mvc.Helpers.csproj +++ b/src/Homely.AspNetCore.Mvc.Helpers/Homely.AspNetCore.Mvc.Helpers.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable true true @@ -22,14 +22,14 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/tests/Homely.AspNetCore.Mvc.Helpers.Tests/HomeControllerTests/ExceptionTestTests.cs b/tests/Homely.AspNetCore.Mvc.Helpers.Tests/HomeControllerTests/ExceptionTestTests.cs index c848566..4c20d37 100644 --- a/tests/Homely.AspNetCore.Mvc.Helpers.Tests/HomeControllerTests/ExceptionTestTests.cs +++ b/tests/Homely.AspNetCore.Mvc.Helpers.Tests/HomeControllerTests/ExceptionTestTests.cs @@ -24,7 +24,7 @@ public async Task GivenARequest_ExceptionTests_ReturnsAnHttp500() // Arrange. var expectedError = new ProblemDetails { - Type = "https://httpstatuses.com/500", + Type = "https://httpstatuses.io/500", Title = "Internal Server Error", Status = StatusCodes.Status500InternalServerError }; diff --git a/tests/Homely.AspNetCore.Mvc.Helpers.Tests/HomeControllerTests/GetTests.cs b/tests/Homely.AspNetCore.Mvc.Helpers.Tests/HomeControllerTests/GetTests.cs index e6dcccd..ecda17b 100644 --- a/tests/Homely.AspNetCore.Mvc.Helpers.Tests/HomeControllerTests/GetTests.cs +++ b/tests/Homely.AspNetCore.Mvc.Helpers.Tests/HomeControllerTests/GetTests.cs @@ -1,7 +1,8 @@ -using Homely.AspNetCore.Mvc.Helpers.Extensions; +using Homely.AspNetCore.Mvc.Helpers.Extensions; using Microsoft.Extensions.DependencyInjection; using Shouldly; using System; +using System.Reflection; using System.Threading.Tasks; using Xunit; @@ -21,11 +22,12 @@ public async Task GivenARequest_Get_ReturnsAnHttp200() { // Arrange. const string banner = "pew pew"; + var currentAssembly = Assembly.GetExecutingAssembly(); var client = _factory.WithWebHostBuilder(builder => { builder.ConfigureServices(services => { - services.AddControllers().AddAHomeController(services, banner); + services.AddControllers().AddAHomeController(services, banner, currentAssembly); }); }).CreateClient(); @@ -36,6 +38,10 @@ public async Task GivenARequest_Get_ReturnsAnHttp200() response.IsSuccessStatusCode.ShouldBeTrue(); var text = await response.Content.ReadAsStringAsync(); text.ShouldStartWith(banner); // Banner ASCII art/text. + + var buildDate = System.IO.File.GetLastWriteTime(currentAssembly.Location).ToString("F"); + + text.ShouldContain(buildDate); } } } diff --git a/tests/Homely.AspNetCore.Mvc.Helpers.Tests/Homely.AspNetCore.Mvc.Helpers.Tests.csproj b/tests/Homely.AspNetCore.Mvc.Helpers.Tests/Homely.AspNetCore.Mvc.Helpers.Tests.csproj index 59af6f5..322e51a 100644 --- a/tests/Homely.AspNetCore.Mvc.Helpers.Tests/Homely.AspNetCore.Mvc.Helpers.Tests.csproj +++ b/tests/Homely.AspNetCore.Mvc.Helpers.Tests/Homely.AspNetCore.Mvc.Helpers.Tests.csproj @@ -1,22 +1,22 @@ - net6.0 + net8.0 false enable - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/tests/Homely.AspNetCore.Mvc.Helpers.Tests/TestControllerTests/ConflictTests.cs b/tests/Homely.AspNetCore.Mvc.Helpers.Tests/TestControllerTests/ConflictTests.cs index a8e9e8e..7ef76c7 100644 --- a/tests/Homely.AspNetCore.Mvc.Helpers.Tests/TestControllerTests/ConflictTests.cs +++ b/tests/Homely.AspNetCore.Mvc.Helpers.Tests/TestControllerTests/ConflictTests.cs @@ -1,4 +1,4 @@ -using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Shouldly; using System; @@ -23,7 +23,7 @@ public async Task GivenAValidId_Get_ReturnsAnHtt409() // Arrange. var error = new ProblemDetails { - Type = "https://httpstatuses.com/409", + Type = "https://httpstatuses.io/409", Title = "Agent was already modified.", Status = StatusCodes.Status409Conflict, Detail = "agent was already modified after you retrieved the latest data. So you would then override the most recent copy. As such, you will need to refresh the page (to get the latest data) then modify that, if required.", diff --git a/tests/Homely.AspNetCore.Mvc.Helpers.Tests/TestControllerTests/DynamicErrorTests.cs b/tests/Homely.AspNetCore.Mvc.Helpers.Tests/TestControllerTests/DynamicErrorTests.cs index 07c4bf4..8c2e5fd 100644 --- a/tests/Homely.AspNetCore.Mvc.Helpers.Tests/TestControllerTests/DynamicErrorTests.cs +++ b/tests/Homely.AspNetCore.Mvc.Helpers.Tests/TestControllerTests/DynamicErrorTests.cs @@ -25,7 +25,7 @@ public async Task GivenTwoGetRequestsWhichManuallyThrowsAnError_ValidationError_ const string route = "/test/dynamicError"; var error = new ProblemDetails { - Type = "https://httpstatuses.com/500", + Type = "https://httpstatuses.io/500", Title = "Internal Server Error", Status = StatusCodes.Status500InternalServerError }; diff --git a/tests/Homely.AspNetCore.Mvc.Helpers.Tests/TestControllerTests/ErrorTests.cs b/tests/Homely.AspNetCore.Mvc.Helpers.Tests/TestControllerTests/ErrorTests.cs index 40a3b31..cf6fe3d 100644 --- a/tests/Homely.AspNetCore.Mvc.Helpers.Tests/TestControllerTests/ErrorTests.cs +++ b/tests/Homely.AspNetCore.Mvc.Helpers.Tests/TestControllerTests/ErrorTests.cs @@ -23,7 +23,7 @@ public async Task GivenAGetRequest_Error_ReturnsAnHttp500() // Arrange. var error = new ProblemDetails { - Type = "https://httpstatuses.com/500", + Type = "https://httpstatuses.io/500", Title = "Internal Server Error", Status = StatusCodes.Status500InternalServerError }; diff --git a/tests/Homely.AspNetCore.Mvc.Helpers.Tests/TestControllerTests/GetNotFoundTests.cs b/tests/Homely.AspNetCore.Mvc.Helpers.Tests/TestControllerTests/GetNotFoundTests.cs index 6ff26e5..45dadba 100644 --- a/tests/Homely.AspNetCore.Mvc.Helpers.Tests/TestControllerTests/GetNotFoundTests.cs +++ b/tests/Homely.AspNetCore.Mvc.Helpers.Tests/TestControllerTests/GetNotFoundTests.cs @@ -23,7 +23,7 @@ public async Task GivenABadRoute_Get_ReturnsAnHttp404() // Arrange. var error = new ProblemDetails { - Type = "https://httpstatuses.com/404", + Type = "https://httpstatuses.io/404", Title = "Not Found", Status = StatusCodes.Status404NotFound }; diff --git a/tests/Homely.AspNetCore.Mvc.Helpers.Tests/TestControllerTests/GetTests.cs b/tests/Homely.AspNetCore.Mvc.Helpers.Tests/TestControllerTests/GetTests.cs index 67ba5f0..9f25c3f 100644 --- a/tests/Homely.AspNetCore.Mvc.Helpers.Tests/TestControllerTests/GetTests.cs +++ b/tests/Homely.AspNetCore.Mvc.Helpers.Tests/TestControllerTests/GetTests.cs @@ -41,7 +41,7 @@ public async Task GivenAnInvalidId_Get_ReturnsAnHttp404() const int id = int.MaxValue; var error = new ProblemDetails { - Type = "https://tools.ietf.org/html/rfc7231#section-6.5.4", + Type = "https://tools.ietf.org/html/rfc9110#section-15.5.5", Title = "Not Found", Status = StatusCodes.Status404NotFound }; diff --git a/tests/Homely.AspNetCore.Mvc.Helpers.Tests/TestControllerTests/ModelBindingTests.cs b/tests/Homely.AspNetCore.Mvc.Helpers.Tests/TestControllerTests/ModelBindingTests.cs index 6e8ab4d..946c9cf 100644 --- a/tests/Homely.AspNetCore.Mvc.Helpers.Tests/TestControllerTests/ModelBindingTests.cs +++ b/tests/Homely.AspNetCore.Mvc.Helpers.Tests/TestControllerTests/ModelBindingTests.cs @@ -1,4 +1,4 @@ -using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Shouldly; using System; @@ -34,7 +34,7 @@ public async Task GivenABadModelBind_Get_ReturnsAnHttp400() // Arrange. var error = new ValidationProblemDetails { - Type = "https://tools.ietf.org/html/rfc7231#section-6.5.1", + Type = "https://tools.ietf.org/html/rfc9110#section-15.5.1", Title = "One or more validation errors occurred.", Status = StatusCodes.Status400BadRequest, Detail = "Please refer to the errors property for additional details.", diff --git a/tests/Homely.AspNetCore.Mvc.Helpers.Tests/TestControllerTests/PostTests.cs b/tests/Homely.AspNetCore.Mvc.Helpers.Tests/TestControllerTests/PostTests.cs index 2404a28..187b97b 100644 --- a/tests/Homely.AspNetCore.Mvc.Helpers.Tests/TestControllerTests/PostTests.cs +++ b/tests/Homely.AspNetCore.Mvc.Helpers.Tests/TestControllerTests/PostTests.cs @@ -68,7 +68,7 @@ public async Task GivenPostingAnInvalidModel_Post_ReturnsAnHttp400() var error = new ValidationProblemDetails { - Type = "https://tools.ietf.org/html/rfc7231#section-6.5.1", + Type = "https://tools.ietf.org/html/rfc9110#section-15.5.1", Title = "One or more validation errors occurred.", Status = StatusCodes.Status400BadRequest, Detail = "Please refer to the errors property for additional details.", diff --git a/tests/TestWebApplication/Controllers/TestController.cs b/tests/TestWebApplication/Controllers/TestController.cs index bc373a3..d5e2154 100644 --- a/tests/TestWebApplication/Controllers/TestController.cs +++ b/tests/TestWebApplication/Controllers/TestController.cs @@ -97,7 +97,7 @@ public IActionResult ConflictCheck() { var error = new ProblemDetails { - Type = "https://httpstatuses.com/409", + Type = "https://httpstatuses.io/409", Title = "Agent was already modified.", Status = StatusCodes.Status409Conflict, Instance = "/test/conflict", diff --git a/tests/TestWebApplication/TestWebApplication.csproj b/tests/TestWebApplication/TestWebApplication.csproj index 5aec84a..7516f48 100644 --- a/tests/TestWebApplication/TestWebApplication.csproj +++ b/tests/TestWebApplication/TestWebApplication.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 From c65b67cf04f212914016f2804b01f9c4b0261315 Mon Sep 17 00:00:00 2001 From: Dwi Cahya Pramanda Date: Tue, 22 Oct 2024 15:34:38 +0700 Subject: [PATCH 3/3] bump actions/delete-package-versions to v5 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 89a5ae9..e5505eb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,7 +46,7 @@ jobs: --source https://nuget.pkg.github.com/${{ github.repository_owner }} - name: Remove old pre-release packages (keeping the GPR cleanish) - uses: actions/delete-package-versions@v4 + uses: actions/delete-package-versions@v5 with: package-name: 'Homely.AspNetCore.Mvc.Helpers' min-versions-to-keep: 10