Skip to content

Commit 7009f34

Browse files
committed
fix: reset database using Respawn 🗑️
1 parent 87cda69 commit 7009f34

File tree

12 files changed

+44
-17
lines changed

12 files changed

+44
-17
lines changed

.github/instructions/accessibility.instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
description: 'Guidance for creating more accessible code'
3-
applyTo: '**'
3+
applyTo: '**/*.ts, **/*.html'
44
---
55

66
# Instructions for accessibility

.github/instructions/angular.instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
description: 'Angular project coding and best practices instructions'
3-
applyTo: '**/*.ts'
3+
applyTo: '**/*.ts, **/*.html'
44
---
55

66
# Angular Instructions

.github/instructions/dotnet.instructions.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ Each module follows DDD structure:
8383
- Register services in module-specific extension methods
8484
- Use `IOptions<T>` for configuration binding
8585

86+
## Logging
87+
88+
- Use structured logging with LoggerMessage delegates (CA1848)
89+
8690
## Testing Guidelines
8791

8892
### Unit Tests with TUnit

.github/prompts/review-and-refactor.prompt.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: 'Review and refactor code in your project according to defined inst
55

66
## Role
77

8-
You're a senior expert software engineer with extensive experience in maintaining projects over a long time and ensuring clean code and best practices.
8+
You're a senior expert software engineer with extensive experience in maintaining projects over a long time and ensuring clean code and best practices.
99

1010
## Task
1111

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ jobs:
124124
PLAYWRIGHT_USERNAME: ${{ secrets.PLAYWRIGHT_USERNAME }}
125125
PLAYWRIGHT_PASSWORD: ${{ secrets.PLAYWRIGHT_PASSWORD }}
126126
APPLICATION_URL: ${{ secrets.APPLICATION_URL }}
127+
DATABASE_URL: ${{ secrets.DATABASE_URL }}
127128

128129
- name: Upload E2E Results Artifact
129130
uses: actions/upload-artifact@v5

Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<PackageVersion Include="Microsoft.Testing.Extensions.CodeCoverage" Version="18.1.0" />
3333
<PackageVersion Include="Microsoft.Testing.Extensions.TrxReport" Version="2.0.2" />
3434
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="10.0.0" />
35+
<PackageVersion Include="Respawn" Version="7.0.0" />
3536
<PackageVersion Include="Testcontainers.PostgreSql" Version="4.9.0" />
3637
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.14.0" />
3738
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.14.0" />

Sandbox.AppHost/Program.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
var keycloak = builder.AddKeycloak("keycloak", adminUsername: keycloakAdminUsername, adminPassword: keycloakAdminPassword)
1212
.WithDataVolume()
13-
.WithEnvironment("KC_HEALTH_ENABLED", "true")
14-
.WithEnvironment("KC_METRICS_ENABLED", "true")
13+
.WithOtlpExporter()
1514
.WithRealmImport("../config/keycloak/realms");
1615
openIDConnectSettingsClientSecret.WithParentRelationship(keycloak);
1716
keycloakAdminUsername.WithParentRelationship(keycloak);
@@ -108,9 +107,10 @@
108107
.WithEnvironment("TEMPO_URL", $"{tempo.GetEndpoint("otlp")}");
109108

110109
var postgres = builder.AddPostgres("postgres")
111-
.WithDataVolume()
112-
.WithPgAdmin()
113-
.WithPgWeb();
110+
.WithDataVolume();
111+
postgres
112+
.WithPgAdmin(c => c.WithParentRelationship(postgres))
113+
.WithPgWeb(c => c.WithParentRelationship(postgres));
114114

115115
var database = postgres.AddDatabase("sandbox-db");
116116

@@ -126,6 +126,12 @@
126126
IconName = "DatabaseLightning",
127127
ConfirmationMessage = "Are you sure you want to reset the database?",
128128
});
129+
130+
migrations.WithHttpCommand(path: "/reseed-db", displayName: "Reseed Database", commandOptions: new HttpCommandOptions
131+
{
132+
IconName = "DatabaseLightning",
133+
ConfirmationMessage = "Are you sure you want to reseed the database?",
134+
});
129135
}
130136

131137
var apiService = builder.AddProject<Projects.Sandbox_ApiService>("apiservice")
@@ -161,7 +167,7 @@
161167
.WaitFor(angularApplication)
162168
.WaitFor(openTelemetryCollector)
163169
.WaitFor(keycloak)
164-
.WithUrlForEndpoint("http", url =>
170+
.WithUrlForEndpoint("https", url =>
165171
{
166172
url.DisplayText = "Open application";
167173
})

Sandbox.EndToEndTests/.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
APPLICATION_URL=http://localhost:5165
2-
DATABASE_URL=http://localhost:5341
1+
APPLICATION_URL=https://gateway-sandbox.dev.localhost:7263
2+
DATABASE_URL=https://migrations-sandbox.dev.localhost:7479
33

44
# Authentication credentials
55
PLAYWRIGHT_USERNAME=your-username@example.com

Sandbox.EndToEndTests/global-setup.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { getConfig } from './utils/env';
22

3+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
4+
35
async function globalSetup() {
46
const config = getConfig();
57
const databaseUrl = config.databaseUrl;
@@ -9,16 +11,13 @@ async function globalSetup() {
911
return;
1012
}
1113

12-
const resetUrl = `${databaseUrl}/reset-db`;
14+
const reseedUrl = `${databaseUrl}/reseed-db`;
1315

14-
console.log(`Resetting database via ${resetUrl}...`);
16+
console.log(`Resetting database via ${reseedUrl}...`);
1517

1618
try {
17-
const response = await fetch(resetUrl, {
19+
const response = await fetch(reseedUrl, {
1820
method: 'POST',
19-
headers: {
20-
'Content-Type': 'application/json',
21-
},
2221
});
2322

2423
if (!response.ok) {

Sandbox.EndToEndTests/playwright.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,6 @@ export default defineConfig({
6161
url: config.applicationUrl,
6262
reuseExistingServer: !process.env.CI,
6363
timeout: 60000 * 5,
64+
ignoreHTTPSErrors: true,
6465
},
6566
});

0 commit comments

Comments
 (0)