-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d2b0de
commit fe365d8
Showing
61 changed files
with
2,921 additions
and
411 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,134 @@ | ||
|
||
resources: | ||
repositories: | ||
- repository: MockRegister | ||
type: git | ||
name: sb-mock-register | ||
ref: develop | ||
|
||
trigger: | ||
- develop | ||
- main | ||
- releases/* | ||
|
||
pool: | ||
vmImage: ubuntu-latest | ||
|
||
steps: | ||
- checkout: MockRegister | ||
- checkout: self | ||
|
||
# Build mock-register | ||
- task: Docker@2 | ||
displayName: Build mock-register image | ||
inputs: | ||
command: build | ||
Dockerfile: $(Build.SourcesDirectory)/sb-mock-register/Source/Dockerfile.for-testing | ||
buildContext: $(Build.SourcesDirectory)/sb-mock-register/Source | ||
repository: mock-register | ||
tags: latest | ||
|
||
# Run integration tests | ||
- task: DockerCompose@0 | ||
displayName: Integration Tests - Up | ||
condition: always() | ||
inputs: | ||
action: Run a Docker Compose command | ||
dockerComposeFile: $(Build.SourcesDirectory)/sb-mock-data-holder/Source/docker-compose.GetDataRecipients.IntegrationTests.yml | ||
dockerComposeCommand: up --abort-on-container-exit --exit-code-from getdatarecipients-integration-tests | ||
|
||
# Remove integration tests | ||
- task: DockerCompose@0 | ||
displayName: Integration Tests - Down | ||
condition: always() | ||
inputs: | ||
action: Run a Docker Compose command | ||
dockerComposeFile: $(Build.SourcesDirectory)/sb-mock-data-holder/Source/docker-compose.GetDataRecipients.IntegrationTests.yml | ||
dockerComposeCommand: down | ||
|
||
# Publish mock-register logs | ||
- publish: $(Build.SourcesDirectory)/sb-mock-data-holder/Source/_temp/mock-register/tmp | ||
displayName: Publish MockRegister logs | ||
condition: always() | ||
artifact: Mock-Register - Logs | ||
|
||
# Publish mock-data-holder logs | ||
- publish: $(Build.SourcesDirectory)/sb-mock-data-holder/Source/_temp/mock-data-holder/tmp | ||
displayName: Publish MockDataHolder logs | ||
condition: always() | ||
artifact: Mock-Data-Holder - Logs | ||
|
||
# Login to ACR | ||
- task: Docker@2 | ||
displayName: Login to ACR | ||
condition: always() | ||
inputs: | ||
command: login | ||
containerRegistry: <<yourContainerRegistryName>> | ||
|
||
# Run trx formatter to output .MD and .CSV | ||
- script: | | ||
docker run \ | ||
-v=$(Build.SourcesDirectory)/sb-mock-data-holder/Source/_temp/getdatarecipients-integration-tests/testresults/results.trx:/app/results.trx:ro \ | ||
-v=$(Build.SourcesDirectory)/sb-mock-data-holder/Source/_temp/getdatarecipients-integration-tests/testresults/formatted/:/app/out/:rw \ | ||
<<yourContainerRegistryName>>.azurecr.io/trx-formatter -i results.trx -t "MDH-GetDataRecipients" --outputprefix "MDH-GetDataRecipients" -o out/ | ||
displayName: 'Run trx-formatter' | ||
condition: always() | ||
# Publish getdatarecipients integration tests results | ||
- publish: $(Build.SourcesDirectory)/sb-mock-data-holder/Source/_temp/getdatarecipients-integration-tests/testresults | ||
displayName: Publish integration tests | ||
condition: always() | ||
artifact: GetDataRecipients - Integration tests | ||
|
||
- task: PublishTestResults@2 | ||
displayName: 'Surface Integration Test TRX results to devops' | ||
condition: succeededOrFailed() | ||
inputs: | ||
testResultsFormat: 'VSTest' # Options: JUnit, NUnit, VSTest, xUnit, cTest | ||
testResultsFiles: '**/results.trx' | ||
searchFolder: $(Build.SourcesDirectory)/sb-mock-data-holder/Source/_temp/getdatarecipients-integration-tests/testresults | ||
#mergeTestResults: false # Optional | ||
#failTaskOnFailedTests: false # Optional | ||
testRunTitle: 'getdatarecipients-integration-tests' # Optional | ||
#buildPlatform: # Optional | ||
#buildConfiguration: # Optional | ||
publishRunAttachments: true # Optional | ||
|
||
# Tests have passed, so now build/publish the azure function | ||
|
||
- task: UseDotNet@2 | ||
displayName: 'Install .NET 6 SDK' | ||
inputs: | ||
packageType: 'sdk' | ||
version: '6.0.x' | ||
performMultiLevelLookup: true | ||
|
||
- script: | | ||
cd $(Build.SourcesDirectory)/sb-mock-data-holder/Source/CDR.GetDataRecipients | ||
dotnet restore | ||
dotnet build --configuration Release | ||
displayName: 'Build CDR.GetDataRecipients' | ||
- task: DotNetCoreCLI@2 | ||
inputs: | ||
command: publish | ||
arguments: '--configuration Release --output publish_output' | ||
projects: '$(Build.SourcesDirectory)/sb-mock-data-holder/Source/CDR.GetDataRecipients/CDR.GetDataRecipients.csproj' | ||
publishWebProjects: false | ||
modifyOutputPath: false | ||
zipAfterPublish: false | ||
displayName: 'DotNet publish CDR.GetDataRecipients' | ||
|
||
- task: ArchiveFiles@2 | ||
displayName: 'Archive CDR.GetDataRecipients' | ||
inputs: | ||
rootFolderOrFile: '$(System.DefaultWorkingDirectory)/publish_output' | ||
includeRootFolder: false | ||
archiveFile: '$(System.DefaultWorkingDirectory)/CDR.GetDataRecipients.zip' | ||
|
||
- task: PublishBuildArtifacts@1 | ||
displayName: 'Publish CDR.GetDataRecipients' | ||
inputs: | ||
PathToPublish: '$(System.DefaultWorkingDirectory)/CDR.GetDataRecipients.zip' | ||
artifactName: 'functions' |
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
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
20 changes: 20 additions & 0 deletions
20
Source/CDR.DataHolder.API.Logger/CDR.DataHolder.API.Logger.csproj
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 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<Version>1.1.0</Version> | ||
<FileVersion>1.1.0</FileVersion> | ||
<AssemblyVersion>1.1.0</AssemblyVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.9" /> | ||
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="2.2.0" /> | ||
<PackageReference Include="Serilog.AspNetCore" Version="4.1.0" /> | ||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.3.0" /> | ||
<PackageReference Include="Serilog.Sinks.MSSqlServer" Version="5.7.1" /> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace CDR.DataHolder.API.Logger | ||
{ | ||
using Serilog; | ||
|
||
public interface IRequestResponseLogger | ||
{ | ||
ILogger Log { get; } | ||
} | ||
} |
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,13 @@ | ||
namespace CDR.DataHolder.API.Logger | ||
{ | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
public static class LoggerExtensions | ||
{ | ||
public static IServiceCollection AddRequestResponseLogging(this IServiceCollection services) | ||
{ | ||
services.AddSingleton<IRequestResponseLogger, RequestResponseLogger>(); | ||
return services; | ||
} | ||
} | ||
} |
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 @@ | ||
namespace CDR.DataHolder.API.Logger | ||
{ | ||
using System.Diagnostics; | ||
using Microsoft.Extensions.Configuration; | ||
using Serilog; | ||
using Serilog.Core; | ||
|
||
public class RequestResponseLogger : IRequestResponseLogger, IDisposable | ||
{ | ||
private readonly Logger _logger; | ||
private readonly IConfiguration _configuration; | ||
|
||
public ILogger Log { get { return _logger; } } | ||
|
||
public RequestResponseLogger(IConfiguration configuration) | ||
{ | ||
|
||
_configuration = configuration; | ||
|
||
_logger = new LoggerConfiguration() | ||
.ReadFrom.Configuration(configuration, sectionName: "SerilogRequestResponseLogger") | ||
.Enrich.WithProperty("RequestMethod", "") | ||
.Enrich.WithProperty("RequestBody", "") | ||
.Enrich.WithProperty("RequestHeaders", "") | ||
.Enrich.WithProperty("RequestPath", "") | ||
.Enrich.WithProperty("RequestQueryString", "") | ||
.Enrich.WithProperty("StatusCode", "") | ||
.Enrich.WithProperty("ElapsedTime", "") | ||
.Enrich.WithProperty("ResponseHeaders", "") | ||
.Enrich.WithProperty("ResponseBody", "") | ||
.Enrich.WithProperty("RequestHost", "") | ||
.Enrich.WithProperty("RequestIpAddress", "") | ||
.Enrich.WithProperty("ClientId", "") | ||
.Enrich.WithProperty("SoftwareId", "") | ||
.Enrich.WithProperty("FapiInteractionId", "") | ||
.CreateLogger(); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
Dispose(true); | ||
GC.SuppressFinalize(this); | ||
} | ||
|
||
protected virtual void Dispose(bool disposing) | ||
{ | ||
if (disposing) | ||
{ | ||
Serilog.Log.CloseAndFlush(); | ||
} | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.