Skip to content
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

Update Homely.AspNetCore.Mvc.Helpers to show local datetime instead of UTC #92

Merged
merged 3 commits into from
Oct 22, 2024
Merged
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
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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/*

Expand All @@ -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@v5
with:
package-name: 'Homely.AspNetCore.Mvc.Helpers'
min-versions-to-keep: 10
Expand All @@ -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

Expand All @@ -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"
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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/*

Expand All @@ -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

Expand All @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0.100",
"version": "8.0.400",
"rollForward": "latestFeature"
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
Expand All @@ -22,14 +22,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Hellang.Middleware.ProblemDetails" Version="6.3.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<PackageReference Include="Hellang.Middleware.ProblemDetails" Version="6.5.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.1" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.9.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ namespace Homely.AspNetCore.Mvc.Helpers.Models
/// <inheritdoc/>
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}";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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();

Expand All @@ -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);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.1.0">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.10" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="Shouldly" Version="4.0.3" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PackageReference Include="Shouldly" Version="4.2.1" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Shouldly;
using System;
Expand All @@ -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.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Shouldly;
using System;
Expand Down Expand Up @@ -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.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
2 changes: 1 addition & 1 deletion tests/TestWebApplication/Controllers/TestController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion tests/TestWebApplication/TestWebApplication.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading