Skip to content
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
26 changes: 0 additions & 26 deletions .github/workflows/nightlybuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,13 @@ on:
repository_dispatch:

jobs:
check:
runs-on: ubuntu-latest
name: Check latest commit
outputs:
commitcount: ${{ steps.commitswithintime.outputs.number-of-commits-within-time }}
steps:
- uses: actions/checkout@v2
#with:
#fetch-depth: 0

- name: Check for commits within time
#uses: AlexHolderDeveloper/CommitsWithinTime@v1.1.5
uses: TransactionProcessing/CommitsWithinTime@1.0.0
id: commitswithintime
with:
hours: 24

- name: Get the output from CommitsWithinTime
run: |
echo "The 'has-new-commits-within-time' value is ${{ steps.commitswithintime.outputs.has-new-commits-within-time }}"
echo "The 'number-of-commits-within-time' value is ${{ steps.commitswithintime.outputs.number-of-commits-within-time }}"
echo "The 'total-commits' value is ${{ steps.commitswithintime.outputs.total-commits }}"

build:
name: "Nightly Build"
env:
ASPNETCORE_ENVIRONMENT: "Production"

runs-on: ubuntu-latest

needs: check
if: ${{ needs.check.outputs.commitcount > 0 }}

steps:
- uses: actions/checkout@v2.3.4

Expand Down
34 changes: 32 additions & 2 deletions EstateReportingAPI.IntegrationTests/CustomWebApplicationFactory.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace EstateReportingAPI.IntegrationTests;
using Shared.Repositories;

namespace EstateReportingAPI.IntegrationTests;

using BusinessLogic;
using EstateManagement.Database.Contexts;
Expand Down Expand Up @@ -35,7 +37,7 @@ protected override void ConfigureWebHost(IWebHostBuilder builder)
var context = new EstateManagementSqlServerContext(DatabaseConnectionString);
Func<string, EstateManagementGenericContext> f = connectionString => context;

IDbContextFactory<EstateManagementGenericContext> factory = new DbContextFactory<EstateManagementGenericContext>(new ConfigurationReaderConnectionStringRepository(), f);
IDbContextFactory<EstateManagementGenericContext> factory = new DbContextFactory<EstateManagementGenericContext>(new TestConnectionStringConfigurationRepository(DatabaseConnectionString), f);

IReportingManager manager = new ReportingManager(factory);

Expand All @@ -52,6 +54,34 @@ protected override void ConfigureWebHost(IWebHostBuilder builder)
});

}

}

public class TestConnectionStringConfigurationRepository : IConnectionStringConfigurationRepository
{
private readonly string DbConnectionString;

public TestConnectionStringConfigurationRepository(String dbConnectionString)
{
DbConnectionString = dbConnectionString;
}
public Task DeleteConnectionStringConfiguration(string externalIdentifier, string connectionStringIdentifier,
CancellationToken cancellationToken)
{
throw new NotImplementedException();
}

public async Task<string> GetConnectionString(string externalIdentifier, string connectionStringIdentifier,
CancellationToken cancellationToken)
{
return DbConnectionString;
}

public Task CreateConnectionString(string externalIdentifier, string connectionStringIdentifier, string connectionString,
CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
}

public class TestAuthHandlerOptions : AuthenticationSchemeOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
<PackageReference Include="NLog" Version="5.2.8" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
<PackageReference Include="SecurityService.Client" Version="2024.5.1" />
<PackageReference Include="Lamar" Version="13.0.3" />
<PackageReference Include="Lamar.Microsoft.DependencyInjection" Version="13.0.3" />

</ItemGroup>

Expand Down
23 changes: 16 additions & 7 deletions EstateReportingAPI/Bootstrapper/MiddlewareRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,24 @@ namespace EstateReportingAPI.Bootstrapper{

[ExcludeFromCodeCoverage]
public class MiddlewareRegistry : ServiceRegistry{
public MiddlewareRegistry(){
public MiddlewareRegistry()
{

var connectionStringSection = Startup.Configuration.GetSection("ConnectionStrings");
if (connectionStringSection.Exists() == false)
{
this.AddHealthChecks();
}
else
{
this.AddHealthChecks().AddSqlServer(
connectionString: ConfigurationReader.GetConnectionString("HealthCheck"),
healthQuery: "SELECT 1;",
name: "Read Model Server",
failureStatus: HealthStatus.Degraded,
tags: new[] { "db", "sql", "sqlserver" });
}

this.AddHealthChecks()
.AddSqlServer(connectionString:ConfigurationReader.GetConnectionString("HealthCheck"),
healthQuery:"SELECT 1;",
name:"Read Model Server",
failureStatus:HealthStatus.Degraded,
tags:new[]{ "db", "sql", "sqlserver" });
this.AddSwaggerGen(c => {
c.SwaggerDoc("v1",
new OpenApiInfo{
Expand Down