-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Combined commit message for updates up to 0162cdb
- Loading branch information
Showing
643 changed files
with
13,150 additions
and
22,569 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Dockerized CI with Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build-and-test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up .NET | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: 8.0 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Install Docker Compose | ||
run: | | ||
DOCKER_COMPOSE_VERSION=2.20.2 | ||
curl -L "https://github.com/docker/compose/releases/download/v${DOCKER_COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | ||
chmod +x /usr/local/bin/docker-compose | ||
docker-compose version | ||
- name: Start Docker Services | ||
run: | | ||
docker compose -f compose.yaml up --build -d | ||
shell: bash | ||
|
||
- name: Restore .NET Dependencies | ||
run: dotnet restore | ||
shell: bash | ||
|
||
- name: Build .NET Solution | ||
run: dotnet build --no-restore --configuration Debug | ||
shell: bash | ||
|
||
- name: Run Tests | ||
run: dotnet test --no-build --configuration Debug --verbosity normal | ||
shell: bash | ||
|
||
- name: Cleanup Docker Services | ||
if: always() | ||
run: docker compose -f compose.yaml down --volumes | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Binaries | ||
*.dll | ||
*.exe | ||
*.pdb | ||
|
||
# Build directories | ||
/bin | ||
/obj | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="5.0.17" /> | ||
</ItemGroup> | ||
|
||
</Project> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers> | ||
<PublishSingleFile>true</PublishSingleFile> | ||
<SelfContained>true</SelfContained> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="5.0.17" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.10" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.2" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Contract.Logger; | ||
|
||
public interface IOperationLogger | ||
{ | ||
Task LogOperation(LogOperationAttribute attribute, string methodName, object?[] parameters); | ||
Task LogOperationError(LogOperationAttribute attribute, string methodName, Exception ex); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Contract.Logger; | ||
|
||
[AttributeUsage(AttributeTargets.Method)] | ||
public class LogOperationAttribute : Attribute | ||
{ | ||
public string Component { get; } | ||
public string Category { get; } | ||
public LogLevel Level { get; } | ||
public bool LogParameters { get; set; } = true; | ||
public bool LogResponse { get; set; } = true; | ||
|
||
public LogOperationAttribute(string component, string category, LogLevel level = LogLevel.Information) | ||
{ | ||
Component = component; | ||
Category = category; | ||
Level = level; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Contract.Logger; | ||
|
||
public static class LoggerExtensions | ||
{ | ||
public static void AddOperationLogging(this IServiceCollection services, string environment) | ||
{ | ||
services.AddScoped<IOperationLogger>(sp => new OperationLogger( | ||
sp.GetRequiredService<ILoggerFactory>().CreateLogger<OperationLogger>(), | ||
environment)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Contract.Logger; | ||
|
||
public class OperationLogger : IOperationLogger | ||
{ | ||
private readonly ILogger _logger; | ||
private readonly string _environment; | ||
|
||
public OperationLogger(ILogger logger, string environment) | ||
{ | ||
_logger = logger; | ||
_environment = environment; | ||
} | ||
|
||
public async Task LogOperation(LogOperationAttribute attribute, string methodName, params object?[] parameters) | ||
{ | ||
if (attribute.LogParameters && parameters is { Length: > 0 }) | ||
{ | ||
var paramString = string.Join(", ", parameters.Select(p => p?.ToString() ?? "null")); | ||
_logger.Log(attribute.Level, | ||
"[{Environment}][{Component}][{Category}] {Method} started - Parameters: {Parameters}", | ||
_environment, attribute.Component, attribute.Category, methodName, paramString); | ||
} | ||
else | ||
{ | ||
_logger.Log(attribute.Level, | ||
"[{Environment}][{Component}][{Category}] {Method} started", | ||
_environment, attribute.Component, attribute.Category, methodName); | ||
} | ||
|
||
await Task.CompletedTask; | ||
} | ||
|
||
public async Task LogOperationComplete(LogOperationAttribute attribute, string methodName, object? result = null) | ||
{ | ||
if (result != null && attribute.LogResponse) | ||
{ | ||
_logger.Log(attribute.Level, | ||
"[{Environment}][{Component}][{Category}] {Method} completed - Result: {Result}", | ||
_environment, attribute.Component, attribute.Category, methodName, result); | ||
} | ||
else | ||
{ | ||
_logger.Log(attribute.Level, | ||
"[{Environment}][{Component}][{Category}] {Method} completed", | ||
_environment, attribute.Component, attribute.Category, methodName); | ||
} | ||
|
||
await Task.CompletedTask; | ||
} | ||
|
||
public async Task LogOperationError(LogOperationAttribute attribute, string methodName, Exception ex) | ||
{ | ||
_logger.LogError(ex, | ||
"[{Environment}][{Component}][{Category}] {Method} failed - {Error}", | ||
_environment, attribute.Component, attribute.Category, methodName, ex.Message); | ||
|
||
await Task.CompletedTask; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.