From 8566924cfe3f7855329323483d5a9b616bff3a08 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Fri, 20 Oct 2023 14:08:24 +0900 Subject: [PATCH 001/110] =?UTF-8?q?=E3=83=98=E3=83=AB=E3=82=B9=E3=83=81?= =?UTF-8?q?=E3=82=A7=E3=83=83=E3=82=AF=E7=94=A8API=E3=81=AE=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/HealthController.cs | 65 +++++++++++++++++++ .../src/Dressca.Web/DbHealthCheck.cs | 41 ++++++++++++ .../src/Dressca.Web/Program.cs | 4 ++ .../src/Dressca.Web/dressca-api.json | 47 +++++++++++++- 4 files changed, 154 insertions(+), 3 deletions(-) create mode 100644 samples/Dressca/dressca-backend/src/Dressca.Web/Controllers/HealthController.cs create mode 100644 samples/Dressca/dressca-backend/src/Dressca.Web/DbHealthCheck.cs diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/Controllers/HealthController.cs b/samples/Dressca/dressca-backend/src/Dressca.Web/Controllers/HealthController.cs new file mode 100644 index 000000000..910a4e6f8 --- /dev/null +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/Controllers/HealthController.cs @@ -0,0 +1,65 @@ +using System.Net; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Diagnostics.HealthChecks; + +namespace Dressca.Web.Controllers; + +/// +/// ヘルスチェック用のコントローラー。 +/// +[Route("api/health")] +[ApiController] +public class HealthController : ControllerBase +{ + private readonly HealthCheckService healthCheckService; + + /// + /// コンストラクター。 + /// + /// ヘルスチェックサービス。 + public HealthController(HealthCheckService healthCheckService) + { + this.healthCheckService = healthCheckService; + } + + /// + /// ヘルスチェックの結果を返します。 + /// + /// ヘルスチェックの結果。 + [HttpGet] + public async Task Get() + { + HealthReport report = await this.healthCheckService.CheckHealthAsync(); + + var result = new + { + status = report.Status.ToString(), + result = report.Entries + .Select(entry => new + { + name = entry.Key, + status = entry.Value.Status.ToString(), + description = entry.Value.Description?.ToString(), + data = entry.Value.Data, + exception = new + { + source = entry.Value.Exception?.Source, + message = entry.Value.Exception?.Message, + stackTrace = entry.Value.Exception?.StackTrace, + }, + }), + }; + return report.Status == HealthStatus.Healthy ? this.Ok(result) : this.StatusCode((int)HttpStatusCode.ServiceUnavailable, result); + } + + /// + /// ヘルスチェックの結果を返します。 + /// + /// ヘルスチェックの結果。 + [HttpHead] + public async Task Head() + { + HealthReport report = await this.healthCheckService.CheckHealthAsync(); + return report.Status == HealthStatus.Healthy ? this.Ok() : this.StatusCode((int)HttpStatusCode.ServiceUnavailable); + } +} diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/DbHealthCheck.cs b/samples/Dressca/dressca-backend/src/Dressca.Web/DbHealthCheck.cs new file mode 100644 index 000000000..cbf313bf8 --- /dev/null +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/DbHealthCheck.cs @@ -0,0 +1,41 @@ +using System.Data.Common; +using Microsoft.Data.SqlClient; +using Microsoft.Extensions.Diagnostics.HealthChecks; + +namespace Dressca.Web; + +/// +/// データベースのヘルスチェックを行うクラスです。 +/// +public class DbHealthCheck : IHealthCheck +{ + private string connectionString = @"Server=(localdb)\mssqllocaldb;Database=Dressca.Eshop;Integrated Security=True"; + + /// + /// データベースへの接続を確認します。 + /// + /// ヘルスチェックコンテキスト。 + /// キャンセルトークン。 + /// ヘルスチェックの結果。 + public async Task CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default) + { + using (var connection = new SqlConnection(this.connectionString)) + { + try + { + await connection.OpenAsync(cancellationToken); + + var command = connection.CreateCommand(); + command.CommandText = "SELECT 1"; + + await command.ExecuteNonQueryAsync(cancellationToken); + } + catch (DbException ex) + { + return new HealthCheckResult(status: context.Registration.FailureStatus, exception: ex); + } + } + + return HealthCheckResult.Healthy(); + } +} diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs b/samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs index 6b5dd0c0a..bdd47ee6d 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs @@ -2,6 +2,7 @@ using Dressca.ApplicationCore; using Dressca.EfInfrastructure; using Dressca.Store.Assets.StaticFiles; +using Dressca.Web; using Dressca.Web.Baskets; using Dressca.Web.Controllers; using Dressca.Web.Mapper; @@ -67,6 +68,9 @@ }); } +builder.Services.AddHealthChecks() + .AddCheck("DbHealthCheck"); + var app = builder.Build(); if (app.Environment.IsDevelopment()) diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/dressca-api.json b/samples/Dressca/dressca-backend/src/Dressca.Web/dressca-api.json index 21121f640..642090863 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web/dressca-api.json +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/dressca-api.json @@ -1,5 +1,5 @@ { - "x-generator": "NSwag v13.18.2.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v13.0.0.0))", + "x-generator": "NSwag v13.19.0.0 (NJsonSchema v10.9.0.0 (Newtonsoft.Json v13.0.0.0))", "openapi": "3.0.0", "info": { "title": "Dressca Web API", @@ -26,8 +26,7 @@ "required": true, "description": "アセットコード。", "schema": { - "type": "string", - "nullable": true + "type": "string" }, "x-position": 1 } @@ -332,6 +331,48 @@ } } }, + "/api/health": { + "get": { + "tags": [ + "Health" + ], + "summary": "ヘルスチェックの結果を返します。", + "operationId": "Health_Get", + "responses": { + "200": { + "description": "ヘルスチェックの結果。", + "content": { + "application/octet-stream": { + "schema": { + "type": "string", + "format": "binary" + } + } + } + } + } + }, + "head": { + "tags": [ + "Health" + ], + "summary": "ヘルスチェックの結果を返します。", + "operationId": "Health_Head", + "responses": { + "200": { + "description": "ヘルスチェックの結果。", + "content": { + "application/octet-stream": { + "schema": { + "type": "string", + "format": "binary" + } + } + } + } + } + } + }, "/api/orders/{orderId}": { "get": { "tags": [ From 6734fc853162a7d54cadad3a4249a2c4b683a7fc Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Thu, 26 Oct 2023 12:01:30 +0900 Subject: [PATCH 002/110] =?UTF-8?q?=E3=83=98=E3=83=AB=E3=82=B9=E3=83=81?= =?UTF-8?q?=E3=82=A7=E3=83=83=E3=82=AF=E6=A9=9F=E8=83=BD=E3=82=92=E6=AD=A3?= =?UTF-8?q?=E3=81=97=E3=81=84=E3=83=97=E3=83=AD=E3=82=B8=E3=82=A7=E3=82=AF?= =?UTF-8?q?=E3=83=88=E3=81=AB=E9=85=8D=E7=BD=AE=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Diagnostics/IDresscaHealthChecker.cs | 20 ++++++++ .../DresscaHealthChecker.cs | 30 ++++++++++++ .../EfInfrastructureServicesExtension.cs | 3 ++ .../src/Dressca.Web/DbHealthCheck.cs | 41 ----------------- .../HealthChecks/DatabaseHealthCheck.cs | 46 +++++++++++++++++++ .../src/Dressca.Web/Program.cs | 4 +- 6 files changed, 101 insertions(+), 43 deletions(-) create mode 100644 samples/Dressca/dressca-backend/src/Dressca.ApplicationCore/Diagnostics/IDresscaHealthChecker.cs create mode 100644 samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/DresscaHealthChecker.cs delete mode 100644 samples/Dressca/dressca-backend/src/Dressca.Web/DbHealthCheck.cs create mode 100644 samples/Dressca/dressca-backend/src/Dressca.Web/Diagnostics/HealthChecks/DatabaseHealthCheck.cs diff --git a/samples/Dressca/dressca-backend/src/Dressca.ApplicationCore/Diagnostics/IDresscaHealthChecker.cs b/samples/Dressca/dressca-backend/src/Dressca.ApplicationCore/Diagnostics/IDresscaHealthChecker.cs new file mode 100644 index 000000000..d89044f43 --- /dev/null +++ b/samples/Dressca/dressca-backend/src/Dressca.ApplicationCore/Diagnostics/IDresscaHealthChecker.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Dressca.ApplicationCore.Diagnostics; + +/// +/// データベースのヘルスチェックインターフェース。 +/// +public interface IDresscaHealthChecker +{ + /// + /// データベースの接続状態を確認します。 + /// + /// キャンセルトークン。 + /// データベースの接続状態。正常である場合 を返します。 + Task IsHealthyAsync(CancellationToken token); +} diff --git a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/DresscaHealthChecker.cs b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/DresscaHealthChecker.cs new file mode 100644 index 000000000..02cf4947c --- /dev/null +++ b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/DresscaHealthChecker.cs @@ -0,0 +1,30 @@ +using Dressca.ApplicationCore.Diagnostics; +using Microsoft.EntityFrameworkCore; + +namespace Dressca.EfInfrastructure; + +/// +/// Entity Framework Core を利用してデータベースのヘルスチェックを実装します。 +/// +internal class DresscaHealthChecker : IDresscaHealthChecker +{ + private readonly DresscaDbContext dbContext; + + /// + /// の新しいインスタンスを初期化します。 + /// + /// データアクセスに使用する オブジェクト。 + /// + /// です。 + /// + public DresscaHealthChecker(DresscaDbContext dbContext) + => this.dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext)); + + /// + public async Task IsHealthyAsync(CancellationToken token) + { + await this.dbContext.Database.ExecuteSqlRawAsync("SELECT 1", token); + + return true; + } +} diff --git a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/EfInfrastructureServicesExtension.cs b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/EfInfrastructureServicesExtension.cs index 1d885e665..5f57ae8f3 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/EfInfrastructureServicesExtension.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/EfInfrastructureServicesExtension.cs @@ -1,6 +1,7 @@ using Dressca.ApplicationCore.Assets; using Dressca.ApplicationCore.Baskets; using Dressca.ApplicationCore.Catalog; +using Dressca.ApplicationCore.Diagnostics; using Dressca.ApplicationCore.Ordering; using Dressca.EfInfrastructure.Resources; using Microsoft.EntityFrameworkCore; @@ -41,6 +42,7 @@ public static IServiceCollection AddDresscaEfInfrastructure(this IServiceCollect // Connection Strings var connectionString = configuration.GetConnectionString(ConnectionStringName); + if (string.IsNullOrWhiteSpace(connectionString)) { throw new ArgumentException( @@ -61,6 +63,7 @@ public static IServiceCollection AddDresscaEfInfrastructure(this IServiceCollect services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); return services; } diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/DbHealthCheck.cs b/samples/Dressca/dressca-backend/src/Dressca.Web/DbHealthCheck.cs deleted file mode 100644 index cbf313bf8..000000000 --- a/samples/Dressca/dressca-backend/src/Dressca.Web/DbHealthCheck.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System.Data.Common; -using Microsoft.Data.SqlClient; -using Microsoft.Extensions.Diagnostics.HealthChecks; - -namespace Dressca.Web; - -/// -/// データベースのヘルスチェックを行うクラスです。 -/// -public class DbHealthCheck : IHealthCheck -{ - private string connectionString = @"Server=(localdb)\mssqllocaldb;Database=Dressca.Eshop;Integrated Security=True"; - - /// - /// データベースへの接続を確認します。 - /// - /// ヘルスチェックコンテキスト。 - /// キャンセルトークン。 - /// ヘルスチェックの結果。 - public async Task CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default) - { - using (var connection = new SqlConnection(this.connectionString)) - { - try - { - await connection.OpenAsync(cancellationToken); - - var command = connection.CreateCommand(); - command.CommandText = "SELECT 1"; - - await command.ExecuteNonQueryAsync(cancellationToken); - } - catch (DbException ex) - { - return new HealthCheckResult(status: context.Registration.FailureStatus, exception: ex); - } - } - - return HealthCheckResult.Healthy(); - } -} diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/Diagnostics/HealthChecks/DatabaseHealthCheck.cs b/samples/Dressca/dressca-backend/src/Dressca.Web/Diagnostics/HealthChecks/DatabaseHealthCheck.cs new file mode 100644 index 000000000..c4a4f734b --- /dev/null +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/Diagnostics/HealthChecks/DatabaseHealthCheck.cs @@ -0,0 +1,46 @@ +using System.Data.Common; +using Dressca.ApplicationCore.Diagnostics; +using Dressca.EfInfrastructure; +using Microsoft.Data.SqlClient; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Diagnostics.HealthChecks; + +namespace Dressca.Web.Diagnostics.HealthChecks; + +/// +/// データベースのヘルスチェックを行うクラスです。 +/// +public class DatabaseHealthCheck : IHealthCheck +{ + private readonly IDresscaHealthChecker healthChecker; + + /// + /// クラスの新しいインスタンスを初期化します。 + /// + /// ヘルスチェッカー。 + /// + /// です。 + /// + public DatabaseHealthCheck(IDresscaHealthChecker healthChecker) + => this.healthChecker = healthChecker ?? throw new ArgumentNullException(nameof(healthChecker)); + + /// + /// データベースへの接続を確認します。 + /// + /// ヘルスチェックコンテキスト。 + /// キャンセルトークン。 + /// ヘルスチェックの結果。 + public async Task CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default) + { + try + { + await this.healthChecker.IsHealthyAsync(cancellationToken); + } + catch (DbException ex) + { + return new HealthCheckResult(status: context.Registration.FailureStatus, exception: ex); + } + + return HealthCheckResult.Healthy(); + } +} diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs b/samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs index bdd47ee6d..1b5690387 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs @@ -2,9 +2,9 @@ using Dressca.ApplicationCore; using Dressca.EfInfrastructure; using Dressca.Store.Assets.StaticFiles; -using Dressca.Web; using Dressca.Web.Baskets; using Dressca.Web.Controllers; +using Dressca.Web.Diagnostics.HealthChecks; using Dressca.Web.Mapper; using Dressca.Web.Resources; using Dressca.Web.Runtime; @@ -69,7 +69,7 @@ } builder.Services.AddHealthChecks() - .AddCheck("DbHealthCheck"); + .AddCheck("DbHealthCheck"); var app = builder.Build(); From cf7e9ec89621dcc6d7e8c7efc21021cd739f7cb7 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Fri, 27 Oct 2023 13:44:18 +0900 Subject: [PATCH 003/110] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AA=E3=83=95?= =?UTF-8?q?=E3=82=A1=E3=82=A4=E3=83=AB=E3=82=92=E5=89=8A=E9=99=A4=E3=81=97?= =?UTF-8?q?=E3=80=81IApiDescriptionProvider=E3=82=92=E5=AE=9F=E8=A3=85?= =?UTF-8?q?=E3=81=97=E3=81=9F=E3=82=AF=E3=83=A9=E3=82=B9=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dressca-backend/Directory.Packages.props | 1 + .../Diagnostics/IDresscaHealthChecker.cs | 20 ------ .../Dressca.EfInfrastructure.csproj | 1 + .../DresscaHealthChecker.cs | 30 --------- .../EfInfrastructureServicesExtension.cs | 6 +- .../Controllers/HealthController.cs | 65 ------------------ .../HealthChecks/DatabaseHealthCheck.cs | 46 ------------- .../HealthCheckDescriptionProvider.cs | 67 +++++++++++++++++++ .../src/Dressca.Web/Dressca.Web.csproj | 1 + .../src/Dressca.Web/Program.cs | 9 ++- .../src/Dressca.Web/dressca-api.json | 62 ++++++----------- 11 files changed, 100 insertions(+), 208 deletions(-) delete mode 100644 samples/Dressca/dressca-backend/src/Dressca.ApplicationCore/Diagnostics/IDresscaHealthChecker.cs delete mode 100644 samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/DresscaHealthChecker.cs delete mode 100644 samples/Dressca/dressca-backend/src/Dressca.Web/Controllers/HealthController.cs delete mode 100644 samples/Dressca/dressca-backend/src/Dressca.Web/Diagnostics/HealthChecks/DatabaseHealthCheck.cs create mode 100644 samples/Dressca/dressca-backend/src/Dressca.Web/Diagnostics/HealthChecks/HealthCheckDescriptionProvider.cs diff --git a/samples/Dressca/dressca-backend/Directory.Packages.props b/samples/Dressca/dressca-backend/Directory.Packages.props index 2f517d146..732691859 100644 --- a/samples/Dressca/dressca-backend/Directory.Packages.props +++ b/samples/Dressca/dressca-backend/Directory.Packages.props @@ -7,6 +7,7 @@ + diff --git a/samples/Dressca/dressca-backend/src/Dressca.ApplicationCore/Diagnostics/IDresscaHealthChecker.cs b/samples/Dressca/dressca-backend/src/Dressca.ApplicationCore/Diagnostics/IDresscaHealthChecker.cs deleted file mode 100644 index d89044f43..000000000 --- a/samples/Dressca/dressca-backend/src/Dressca.ApplicationCore/Diagnostics/IDresscaHealthChecker.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Dressca.ApplicationCore.Diagnostics; - -/// -/// データベースのヘルスチェックインターフェース。 -/// -public interface IDresscaHealthChecker -{ - /// - /// データベースの接続状態を確認します。 - /// - /// キャンセルトークン。 - /// データベースの接続状態。正常である場合 を返します。 - Task IsHealthyAsync(CancellationToken token); -} diff --git a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/Dressca.EfInfrastructure.csproj b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/Dressca.EfInfrastructure.csproj index 26246c804..f526e7c47 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/Dressca.EfInfrastructure.csproj +++ b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/Dressca.EfInfrastructure.csproj @@ -6,6 +6,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/DresscaHealthChecker.cs b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/DresscaHealthChecker.cs deleted file mode 100644 index 02cf4947c..000000000 --- a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/DresscaHealthChecker.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Dressca.ApplicationCore.Diagnostics; -using Microsoft.EntityFrameworkCore; - -namespace Dressca.EfInfrastructure; - -/// -/// Entity Framework Core を利用してデータベースのヘルスチェックを実装します。 -/// -internal class DresscaHealthChecker : IDresscaHealthChecker -{ - private readonly DresscaDbContext dbContext; - - /// - /// の新しいインスタンスを初期化します。 - /// - /// データアクセスに使用する オブジェクト。 - /// - /// です。 - /// - public DresscaHealthChecker(DresscaDbContext dbContext) - => this.dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext)); - - /// - public async Task IsHealthyAsync(CancellationToken token) - { - await this.dbContext.Database.ExecuteSqlRawAsync("SELECT 1", token); - - return true; - } -} diff --git a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/EfInfrastructureServicesExtension.cs b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/EfInfrastructureServicesExtension.cs index 5f57ae8f3..892dd0973 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/EfInfrastructureServicesExtension.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/EfInfrastructureServicesExtension.cs @@ -1,12 +1,13 @@ -using Dressca.ApplicationCore.Assets; +using System.Xml.Linq; +using Dressca.ApplicationCore.Assets; using Dressca.ApplicationCore.Baskets; using Dressca.ApplicationCore.Catalog; -using Dressca.ApplicationCore.Diagnostics; using Dressca.ApplicationCore.Ordering; using Dressca.EfInfrastructure.Resources; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Diagnostics.HealthChecks; namespace Dressca.EfInfrastructure; @@ -63,7 +64,6 @@ public static IServiceCollection AddDresscaEfInfrastructure(this IServiceCollect services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); return services; } diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/Controllers/HealthController.cs b/samples/Dressca/dressca-backend/src/Dressca.Web/Controllers/HealthController.cs deleted file mode 100644 index 910a4e6f8..000000000 --- a/samples/Dressca/dressca-backend/src/Dressca.Web/Controllers/HealthController.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System.Net; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Diagnostics.HealthChecks; - -namespace Dressca.Web.Controllers; - -/// -/// ヘルスチェック用のコントローラー。 -/// -[Route("api/health")] -[ApiController] -public class HealthController : ControllerBase -{ - private readonly HealthCheckService healthCheckService; - - /// - /// コンストラクター。 - /// - /// ヘルスチェックサービス。 - public HealthController(HealthCheckService healthCheckService) - { - this.healthCheckService = healthCheckService; - } - - /// - /// ヘルスチェックの結果を返します。 - /// - /// ヘルスチェックの結果。 - [HttpGet] - public async Task Get() - { - HealthReport report = await this.healthCheckService.CheckHealthAsync(); - - var result = new - { - status = report.Status.ToString(), - result = report.Entries - .Select(entry => new - { - name = entry.Key, - status = entry.Value.Status.ToString(), - description = entry.Value.Description?.ToString(), - data = entry.Value.Data, - exception = new - { - source = entry.Value.Exception?.Source, - message = entry.Value.Exception?.Message, - stackTrace = entry.Value.Exception?.StackTrace, - }, - }), - }; - return report.Status == HealthStatus.Healthy ? this.Ok(result) : this.StatusCode((int)HttpStatusCode.ServiceUnavailable, result); - } - - /// - /// ヘルスチェックの結果を返します。 - /// - /// ヘルスチェックの結果。 - [HttpHead] - public async Task Head() - { - HealthReport report = await this.healthCheckService.CheckHealthAsync(); - return report.Status == HealthStatus.Healthy ? this.Ok() : this.StatusCode((int)HttpStatusCode.ServiceUnavailable); - } -} diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/Diagnostics/HealthChecks/DatabaseHealthCheck.cs b/samples/Dressca/dressca-backend/src/Dressca.Web/Diagnostics/HealthChecks/DatabaseHealthCheck.cs deleted file mode 100644 index c4a4f734b..000000000 --- a/samples/Dressca/dressca-backend/src/Dressca.Web/Diagnostics/HealthChecks/DatabaseHealthCheck.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Data.Common; -using Dressca.ApplicationCore.Diagnostics; -using Dressca.EfInfrastructure; -using Microsoft.Data.SqlClient; -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Diagnostics.HealthChecks; - -namespace Dressca.Web.Diagnostics.HealthChecks; - -/// -/// データベースのヘルスチェックを行うクラスです。 -/// -public class DatabaseHealthCheck : IHealthCheck -{ - private readonly IDresscaHealthChecker healthChecker; - - /// - /// クラスの新しいインスタンスを初期化します。 - /// - /// ヘルスチェッカー。 - /// - /// です。 - /// - public DatabaseHealthCheck(IDresscaHealthChecker healthChecker) - => this.healthChecker = healthChecker ?? throw new ArgumentNullException(nameof(healthChecker)); - - /// - /// データベースへの接続を確認します。 - /// - /// ヘルスチェックコンテキスト。 - /// キャンセルトークン。 - /// ヘルスチェックの結果。 - public async Task CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default) - { - try - { - await this.healthChecker.IsHealthyAsync(cancellationToken); - } - catch (DbException ex) - { - return new HealthCheckResult(status: context.Registration.FailureStatus, exception: ex); - } - - return HealthCheckResult.Healthy(); - } -} diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/Diagnostics/HealthChecks/HealthCheckDescriptionProvider.cs b/samples/Dressca/dressca-backend/src/Dressca.Web/Diagnostics/HealthChecks/HealthCheckDescriptionProvider.cs new file mode 100644 index 000000000..1eeda50b1 --- /dev/null +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/Diagnostics/HealthChecks/HealthCheckDescriptionProvider.cs @@ -0,0 +1,67 @@ +using System.Reflection; +using Microsoft.AspNetCore.Mvc.Abstractions; +using Microsoft.AspNetCore.Mvc.ActionConstraints; +using Microsoft.AspNetCore.Mvc.ApiExplorer; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.AspNetCore.Mvc.Formatters; +using Microsoft.AspNetCore.Mvc.ModelBinding; + +namespace Dressca.Web.Diagnostics.HealthChecks; + +public class HealthCheckDescriptionProvider : IApiDescriptionProvider +{ + private readonly IModelMetadataProvider _modelMetadataProvider; + + public HealthCheckDescriptionProvider(IModelMetadataProvider modelMetadataProvider) + { + _modelMetadataProvider = modelMetadataProvider; + } + + public int Order => -1; + + public void OnProvidersExecuting(ApiDescriptionProviderContext context) + { } + + public void OnProvidersExecuted(ApiDescriptionProviderContext context) + { + var actionDescriptor = new ControllerActionDescriptor + { + ControllerName = "HealthChecks", + ActionName = "health", + Parameters = new List(), + EndpointMetadata = new List(), + ActionConstraints = new List(), + DisplayName = "Health check endpoint", + Properties = new Dictionary(), + BoundProperties = new List(), + FilterDescriptors = new List(), + ControllerTypeInfo = new TypeDelegator(typeof(string)) + }; + + var apiDescription = new ApiDescription + { + ActionDescriptor = actionDescriptor, + HttpMethod = HttpMethods.Get, + RelativePath = "health", + GroupName = "v1", + }; + + var apiResponseType = new ApiResponseType + { + ApiResponseFormats = new List + { + new ApiResponseFormat + { + MediaType = "text/plain", + Formatter = new StringOutputFormatter(), + }, + }, + Type = typeof(string), + StatusCode = StatusCodes.Status200OK, + }; + + apiDescription.SupportedResponseTypes.Add(apiResponseType); + context.Results.Add(apiDescription); + } +} diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/Dressca.Web.csproj b/samples/Dressca/dressca-backend/src/Dressca.Web/Dressca.Web.csproj index eda1e9417..5a2160dcc 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web/Dressca.Web.csproj +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/Dressca.Web.csproj @@ -14,6 +14,7 @@ + all diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs b/samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs index 1b5690387..2b5285827 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs @@ -9,6 +9,8 @@ using Dressca.Web.Resources; using Dressca.Web.Runtime; using Microsoft.AspNetCore.HttpLogging; +using Microsoft.AspNetCore.Mvc.ApiExplorer; +using Microsoft.Extensions.DependencyInjection.Extensions; var builder = WebApplication.CreateBuilder(args); @@ -68,8 +70,9 @@ }); } -builder.Services.AddHealthChecks() - .AddCheck("DbHealthCheck"); +builder.Services.TryAddEnumerable(ServiceDescriptor.Transient()); + +builder.Services.AddHealthChecks(); var app = builder.Build(); @@ -91,4 +94,6 @@ app.MapControllers(); +app.MapHealthChecks("/api/health"); + app.Run(); diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/dressca-api.json b/samples/Dressca/dressca-backend/src/Dressca.Web/dressca-api.json index 642090863..993752ef3 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web/dressca-api.json +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/dressca-api.json @@ -331,48 +331,6 @@ } } }, - "/api/health": { - "get": { - "tags": [ - "Health" - ], - "summary": "ヘルスチェックの結果を返します。", - "operationId": "Health_Get", - "responses": { - "200": { - "description": "ヘルスチェックの結果。", - "content": { - "application/octet-stream": { - "schema": { - "type": "string", - "format": "binary" - } - } - } - } - } - }, - "head": { - "tags": [ - "Health" - ], - "summary": "ヘルスチェックの結果を返します。", - "operationId": "Health_Head", - "responses": { - "200": { - "description": "ヘルスチェックの結果。", - "content": { - "application/octet-stream": { - "schema": { - "type": "string", - "format": "binary" - } - } - } - } - } - } - }, "/api/orders/{orderId}": { "get": { "tags": [ @@ -463,6 +421,26 @@ } } } + }, + "/health": { + "get": { + "tags": [ + "HealthChecks" + ], + "operationId": "HealthChecks_health", + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + } } }, "components": { From 0bf7b11d314b0aa7534325175d1669e3edce0d3b Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Fri, 27 Oct 2023 14:30:07 +0900 Subject: [PATCH 004/110] =?UTF-8?q?IHealthChecksBuilder=E3=81=AE=E6=8B=A1?= =?UTF-8?q?=E5=BC=B5=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HealthChecksBuilderExtensions.cs | 39 +++++++++++++++++++ .../src/Dressca.Web/Program.cs | 3 +- .../Dressca.Web/appsettings.Development.json | 1 + 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/HealthChecksBuilderExtensions.cs diff --git a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/HealthChecksBuilderExtensions.cs b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/HealthChecksBuilderExtensions.cs new file mode 100644 index 000000000..9719571dc --- /dev/null +++ b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/HealthChecksBuilderExtensions.cs @@ -0,0 +1,39 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Diagnostics.HealthChecks; + +namespace Dressca.EfInfrastructure; + +/// +/// の拡張メソッドを提供します。 +/// +public static class HealthChecksBuilderExtensions +{ + /// + /// のヘルスチェックを追加します。 + /// + /// 。 + /// ヘルスチェックの名称。 + /// ヘルスチェックが失敗した場合の 。 + /// ヘルスチェックのタグ。 + /// のヘルスチェックを実装した + public static IHealthChecksBuilder AddDresscaDbContextCheck(this IHealthChecksBuilder builder, string? name = null, HealthStatus? failureStatus = default, IEnumerable? tags = default) + { + return builder.AddDbContextCheck( + name, + failureStatus, + tags, + async (context, token) => + { + try + { + await context.Database.ExecuteSqlRawAsync("SELECT 1", token); + return true; + } + catch (Exception ex) + { + return false; + } + }); + } +} diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs b/samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs index 2b5285827..c6be65c75 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs @@ -72,7 +72,8 @@ builder.Services.TryAddEnumerable(ServiceDescriptor.Transient()); -builder.Services.AddHealthChecks(); +builder.Services.AddHealthChecks() + .AddDresscaDbContextCheck("DresscaDatabaseHealthCheck"); var app = builder.Build(); diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/appsettings.Development.json b/samples/Dressca/dressca-backend/src/Dressca.Web/appsettings.Development.json index 2770a6400..584b62cbb 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web/appsettings.Development.json +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/appsettings.Development.json @@ -4,6 +4,7 @@ "Default": "Information", "Microsoft.AspNetCore": "Warning", "Microsoft.AspNetCore.HttpLogging": "Information", + "Microsoft.Extensions.Diagnostics.HealthChecks": "Debug", "Dressca": "Debug" } }, From 90c6c28ac3329812a71810afb27119ad97e7e08b Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Fri, 27 Oct 2023 15:51:59 +0900 Subject: [PATCH 005/110] =?UTF-8?q?HealthCheckDescriptionProvider=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HealthCheckDescriptionProvider.cs | 39 ++++++++++++------- .../src/Dressca.Web/dressca-api.json | 4 +- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/Diagnostics/HealthChecks/HealthCheckDescriptionProvider.cs b/samples/Dressca/dressca-backend/src/Dressca.Web/Diagnostics/HealthChecks/HealthCheckDescriptionProvider.cs index 1eeda50b1..1e8d38f95 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web/Diagnostics/HealthChecks/HealthCheckDescriptionProvider.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/Diagnostics/HealthChecks/HealthCheckDescriptionProvider.cs @@ -1,4 +1,5 @@ using System.Reflection; +using Dressca.EfInfrastructure; using Microsoft.AspNetCore.Mvc.Abstractions; using Microsoft.AspNetCore.Mvc.ActionConstraints; using Microsoft.AspNetCore.Mvc.ApiExplorer; @@ -9,42 +10,54 @@ namespace Dressca.Web.Diagnostics.HealthChecks; +/// +/// ヘルスチェック用に を実装したクラス。 +/// public class HealthCheckDescriptionProvider : IApiDescriptionProvider { - private readonly IModelMetadataProvider _modelMetadataProvider; + private readonly IModelMetadataProvider modelMetadataProvider; + /// + /// の新しいインスタンスを初期化します。 + /// + /// モデルメタデータプロバイダー。 public HealthCheckDescriptionProvider(IModelMetadataProvider modelMetadataProvider) { - _modelMetadataProvider = modelMetadataProvider; + this.modelMetadataProvider = modelMetadataProvider; } + /// + /// を実装したクラスが処理される順番を表します。 + /// public int Order => -1; + /// + /// を生成あるいは変更します。 + /// + /// API 情報を保持するコンテキスト。 public void OnProvidersExecuting(ApiDescriptionProviderContext context) - { } + { + } + /// + /// の処理が終わった後に呼び出されます。 + /// + /// API 情報を保持するコンテキスト。 public void OnProvidersExecuted(ApiDescriptionProviderContext context) { var actionDescriptor = new ControllerActionDescriptor { ControllerName = "HealthChecks", - ActionName = "health", + ActionName = "api/health", Parameters = new List(), - EndpointMetadata = new List(), - ActionConstraints = new List(), - DisplayName = "Health check endpoint", - Properties = new Dictionary(), - BoundProperties = new List(), - FilterDescriptors = new List(), - ControllerTypeInfo = new TypeDelegator(typeof(string)) + ControllerTypeInfo = new TypeDelegator(typeof(string)), }; var apiDescription = new ApiDescription { ActionDescriptor = actionDescriptor, HttpMethod = HttpMethods.Get, - RelativePath = "health", - GroupName = "v1", + RelativePath = "api/health", }; var apiResponseType = new ApiResponseType diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/dressca-api.json b/samples/Dressca/dressca-backend/src/Dressca.Web/dressca-api.json index 993752ef3..c9e28ae27 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web/dressca-api.json +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/dressca-api.json @@ -422,12 +422,12 @@ } } }, - "/health": { + "/api/health": { "get": { "tags": [ "HealthChecks" ], - "operationId": "HealthChecks_health", + "operationId": "HealthChecks_api/health", "responses": { "200": { "description": "", From 5f9a3580751021a22a8a825b27dc53fdb2f1a110 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Mon, 30 Oct 2023 13:11:57 +0900 Subject: [PATCH 006/110] =?UTF-8?q?HealthChecksBuilderExtensions.AddDressc?= =?UTF-8?q?aDbContextCheck=E3=81=AB=E4=BE=8B=E5=A4=96=E6=99=82=E3=81=AE?= =?UTF-8?q?=E3=83=AD=E3=82=B0=E5=87=BA=E5=8A=9B=E5=87=A6=E7=90=86=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dressca.EfInfrastructure/HealthChecksBuilderExtensions.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/HealthChecksBuilderExtensions.cs b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/HealthChecksBuilderExtensions.cs index 9719571dc..7b606fda8 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/HealthChecksBuilderExtensions.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/HealthChecksBuilderExtensions.cs @@ -32,6 +32,7 @@ public static IHealthChecksBuilder AddDresscaDbContextCheck(this IHealthChecksBu } catch (Exception ex) { + Console.WriteLine(ex); return false; } }); From 60e21d7949e170a755143da09dd3af8e3278660b Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Tue, 31 Oct 2023 11:16:14 +0900 Subject: [PATCH 007/110] =?UTF-8?q?HealthChecksBuilderExtensions.AddDressc?= =?UTF-8?q?aDbContextCheck()=E3=81=AE=E3=83=AD=E3=82=B0=E5=87=BA=E5=8A=9B?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=82=92=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HealthChecksBuilderExtensions.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/HealthChecksBuilderExtensions.cs b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/HealthChecksBuilderExtensions.cs index 7b606fda8..4777e6bfb 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/HealthChecksBuilderExtensions.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/HealthChecksBuilderExtensions.cs @@ -1,6 +1,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Diagnostics.HealthChecks; +using Microsoft.Extensions.Logging; namespace Dressca.EfInfrastructure; @@ -16,8 +17,9 @@ public static class HealthChecksBuilderExtensions /// ヘルスチェックの名称。 /// ヘルスチェックが失敗した場合の 。 /// ヘルスチェックのタグ。 + /// ログレベル。 /// のヘルスチェックを実装した - public static IHealthChecksBuilder AddDresscaDbContextCheck(this IHealthChecksBuilder builder, string? name = null, HealthStatus? failureStatus = default, IEnumerable? tags = default) + public static IHealthChecksBuilder AddDresscaDbContextCheck(this IHealthChecksBuilder builder, string? name = null, HealthStatus? failureStatus = default, IEnumerable? tags = default, LogLevel? logLevel = LogLevel.Warning) { return builder.AddDbContextCheck( name, @@ -32,7 +34,14 @@ public static IHealthChecksBuilder AddDresscaDbContextCheck(this IHealthChecksBu } catch (Exception ex) { - Console.WriteLine(ex); + var loggerFactory = builder.Services.BuildServiceProvider().GetRequiredService(); + var logger = loggerFactory.CreateLogger(nameof(Dressca.EfInfrastructure)); + logger.Log( + logLevel: (LogLevel)logLevel, + eventId: 0, + state: "データベースのヘルスチェックが失敗しました。", + exception: ex, + formatter: (state, ex) => state.ToString()); return false; } }); From 35f105e7c0e0a27d5586728294fa035a4e42a67e Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Tue, 31 Oct 2023 11:21:22 +0900 Subject: [PATCH 008/110] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AA=E7=B7=A8?= =?UTF-8?q?=E9=9B=86=E5=86=85=E5=AE=B9=E3=82=92=E3=83=AD=E3=83=BC=E3=83=AB?= =?UTF-8?q?=E3=83=90=E3=83=83=E3=82=AF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EfInfrastructureServicesExtension.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/EfInfrastructureServicesExtension.cs b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/EfInfrastructureServicesExtension.cs index 892dd0973..1d885e665 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/EfInfrastructureServicesExtension.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/EfInfrastructureServicesExtension.cs @@ -1,5 +1,4 @@ -using System.Xml.Linq; -using Dressca.ApplicationCore.Assets; +using Dressca.ApplicationCore.Assets; using Dressca.ApplicationCore.Baskets; using Dressca.ApplicationCore.Catalog; using Dressca.ApplicationCore.Ordering; @@ -7,7 +6,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Diagnostics.HealthChecks; namespace Dressca.EfInfrastructure; @@ -43,7 +41,6 @@ public static IServiceCollection AddDresscaEfInfrastructure(this IServiceCollect // Connection Strings var connectionString = configuration.GetConnectionString(ConnectionStringName); - if (string.IsNullOrWhiteSpace(connectionString)) { throw new ArgumentException( From 67ef417bc5e31014c6b891651b89d65c07671165 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Tue, 31 Oct 2023 11:33:05 +0900 Subject: [PATCH 009/110] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AA=E5=87=A6?= =?UTF-8?q?=E7=90=86=E3=82=92=E5=89=8A=E9=99=A4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dressca.EfInfrastructure/HealthChecksBuilderExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/HealthChecksBuilderExtensions.cs b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/HealthChecksBuilderExtensions.cs index 4777e6bfb..4ac457a41 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/HealthChecksBuilderExtensions.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/HealthChecksBuilderExtensions.cs @@ -41,7 +41,7 @@ public static IHealthChecksBuilder AddDresscaDbContextCheck(this IHealthChecksBu eventId: 0, state: "データベースのヘルスチェックが失敗しました。", exception: ex, - formatter: (state, ex) => state.ToString()); + formatter: (state, ex) => state); return false; } }); From 57275d955694d29e9ce6ea05e4616c8078c10ea1 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Tue, 31 Oct 2023 15:39:04 +0900 Subject: [PATCH 010/110] =?UTF-8?q?HealthChecksBuilderExtensions=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HealthChecksBuilderExtensions.cs | 15 +++++++-------- .../Resources/Messages.Designer.cs | 9 +++++++++ .../Resources/Messages.resx | 3 +++ 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/HealthChecksBuilderExtensions.cs b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/HealthChecksBuilderExtensions.cs index 4ac457a41..e8b341e12 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/HealthChecksBuilderExtensions.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/HealthChecksBuilderExtensions.cs @@ -1,4 +1,5 @@ -using Microsoft.EntityFrameworkCore; +using Dressca.EfInfrastructure.Resources; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Diagnostics.HealthChecks; using Microsoft.Extensions.Logging; @@ -19,7 +20,7 @@ public static class HealthChecksBuilderExtensions /// ヘルスチェックのタグ。 /// ログレベル。 /// のヘルスチェックを実装した - public static IHealthChecksBuilder AddDresscaDbContextCheck(this IHealthChecksBuilder builder, string? name = null, HealthStatus? failureStatus = default, IEnumerable? tags = default, LogLevel? logLevel = LogLevel.Warning) + public static IHealthChecksBuilder AddDresscaDbContextCheck(this IHealthChecksBuilder builder, string? name = null, HealthStatus? failureStatus = default, IEnumerable? tags = default, LogLevel logLevel = LogLevel.Warning) { return builder.AddDbContextCheck( name, @@ -35,13 +36,11 @@ public static IHealthChecksBuilder AddDresscaDbContextCheck(this IHealthChecksBu catch (Exception ex) { var loggerFactory = builder.Services.BuildServiceProvider().GetRequiredService(); - var logger = loggerFactory.CreateLogger(nameof(Dressca.EfInfrastructure)); - logger.Log( - logLevel: (LogLevel)logLevel, - eventId: 0, - state: "データベースのヘルスチェックが失敗しました。", + var logger = loggerFactory.CreateLogger("Dressca.EfInfrastructure.HealthChecksBuilderExtensions"); + logger.Log( + logLevel: logLevel, exception: ex, - formatter: (state, ex) => state); + message: Messages.FailedDatabaseHealthCheck); return false; } }); diff --git a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/Resources/Messages.Designer.cs b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/Resources/Messages.Designer.cs index 11fda1dba..bde522199 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/Resources/Messages.Designer.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/Resources/Messages.Designer.cs @@ -60,6 +60,15 @@ internal Messages() { } } + /// + /// データベースのヘルスチェックが失敗しました。 に類似しているローカライズされた文字列を検索します。 + /// + internal static string FailedDatabaseHealthCheck { + get { + return ResourceManager.GetString("FailedDatabaseHealthCheck", resourceCulture); + } + } + /// /// {0} 接続文字列を構成から取得できません。 に類似しているローカライズされた文字列を検索します。 /// diff --git a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/Resources/Messages.resx b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/Resources/Messages.resx index 62600aec5..2665b4593 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/Resources/Messages.resx +++ b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/Resources/Messages.resx @@ -117,6 +117,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + データベースのヘルスチェックが失敗しました。 + {0} 接続文字列を構成から取得できません。 From ddee9870e998e0eda575378fcc12c57aaaadf3af Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Wed, 1 Nov 2023 13:07:04 +0900 Subject: [PATCH 011/110] =?UTF-8?q?=E3=83=98=E3=83=AB=E3=82=B9=E3=83=81?= =?UTF-8?q?=E3=82=A7=E3=83=83=E3=82=AFAPI=E3=81=AE=E7=B5=90=E5=90=88?= =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=92=E8=BF=BD=E5=8A=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dressca-backend/Directory.Packages.props | 1 + samples/Dressca/dressca-backend/Dressca.sln | 7 +++++ .../src/Dressca.Web/Program.cs | 5 ++++ .../DatabaseHealthCheckTest.cs | 28 +++++++++++++++++ .../Dressca.IntegrationTest.csproj | 30 +++++++++++++++++++ 5 files changed, 71 insertions(+) create mode 100644 samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs create mode 100644 samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj diff --git a/samples/Dressca/dressca-backend/Directory.Packages.props b/samples/Dressca/dressca-backend/Directory.Packages.props index 732691859..b2ea2d198 100644 --- a/samples/Dressca/dressca-backend/Directory.Packages.props +++ b/samples/Dressca/dressca-backend/Directory.Packages.props @@ -3,6 +3,7 @@ + diff --git a/samples/Dressca/dressca-backend/Dressca.sln b/samples/Dressca/dressca-backend/Dressca.sln index 5b8d1c4d7..f028dbb45 100644 --- a/samples/Dressca/dressca-backend/Dressca.sln +++ b/samples/Dressca/dressca-backend/Dressca.sln @@ -34,6 +34,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dressca.Web.Dto", "src\Dres EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dressca.Store.Assets.StaticFiles", "src\Dressca.Store.Assets.StaticFiles\Dressca.Store.Assets.StaticFiles.csproj", "{6E6D331E-4F04-4B1B-8BDD-96B9A40FDFD4}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dressca.IntegrationTest", "tests\Dressca.IntegrationTest\Dressca.IntegrationTest.csproj", "{02FD7ACA-26D9-4289-9402-CB33D3D30C31}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -72,6 +74,10 @@ Global {6E6D331E-4F04-4B1B-8BDD-96B9A40FDFD4}.Debug|Any CPU.Build.0 = Debug|Any CPU {6E6D331E-4F04-4B1B-8BDD-96B9A40FDFD4}.Release|Any CPU.ActiveCfg = Release|Any CPU {6E6D331E-4F04-4B1B-8BDD-96B9A40FDFD4}.Release|Any CPU.Build.0 = Release|Any CPU + {02FD7ACA-26D9-4289-9402-CB33D3D30C31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {02FD7ACA-26D9-4289-9402-CB33D3D30C31}.Debug|Any CPU.Build.0 = Debug|Any CPU + {02FD7ACA-26D9-4289-9402-CB33D3D30C31}.Release|Any CPU.ActiveCfg = Release|Any CPU + {02FD7ACA-26D9-4289-9402-CB33D3D30C31}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -85,6 +91,7 @@ Global {795D8320-6227-418A-B970-D2E851EA9AB6} = {16A54A4D-8AEA-42B3-B8CF-D8C7650BB3C6} {CAAA0815-902E-421D-A721-50DCCA839A62} = {16A54A4D-8AEA-42B3-B8CF-D8C7650BB3C6} {6E6D331E-4F04-4B1B-8BDD-96B9A40FDFD4} = {16A54A4D-8AEA-42B3-B8CF-D8C7650BB3C6} + {02FD7ACA-26D9-4289-9402-CB33D3D30C31} = {00E7327F-10DF-4937-AC61-FE2FCDCCA88B} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {8FD66EC1-E1D1-4664-9ACE-8026659FD708} diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs b/samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs index c6be65c75..35463bf9c 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs @@ -98,3 +98,8 @@ app.MapHealthChecks("/api/health"); app.Run(); + +/// +/// 結合テストプロジェクト用の部分クラス。 +/// +public partial class Program { } diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs new file mode 100644 index 000000000..5fa3a5972 --- /dev/null +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs @@ -0,0 +1,28 @@ +using Microsoft.AspNetCore.Mvc.Testing; +using Xunit; + +namespace Dressca.IntegrationTest; + +public class DatabaseHealthCheckTest : IClassFixture> +{ + private readonly WebApplicationFactory factory; + + public DatabaseHealthCheckTest(WebApplicationFactory factory) + { + this.factory = factory; + } + + [Fact] + public async Task DatabaseConnectionTest() + { + // Arrange + var client = this.factory.CreateClient(); + + // Act + var response = await client.GetAsync("api/health"); + + // Assert + response.EnsureSuccessStatusCode(); + Assert.Equal("Healthy", response.Content.ReadAsStringAsync().Result); + } +} diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj new file mode 100644 index 000000000..ff15a68ba --- /dev/null +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj @@ -0,0 +1,30 @@ + + + + net6.0 + enable + enable + + false + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + From 7c9a370f51d95ea13bf594279e28f5e5a5e21281 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Thu, 2 Nov 2023 16:57:45 +0900 Subject: [PATCH 012/110] =?UTF-8?q?=E7=B5=90=E5=90=88=E3=83=86=E3=82=B9?= =?UTF-8?q?=E3=83=88=E5=AE=9F=E8=A1=8C=E7=94=A8=E5=87=A6=E7=90=86=E3=82=92?= =?UTF-8?q?=E3=83=91=E3=82=A4=E3=83=97=E3=83=A9=E3=82=A4=E3=83=B3=E3=81=AB?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index b1079b2fd..0973553ca 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -58,6 +58,12 @@ jobs: echo '# Build Result :gear:' >> $GITHUB_STEP_SUMMARY cat build-result.txt | sed -n -e 's/^/> /p' >> $GITHUB_STEP_SUMMARY + - name: 結合テスト用にマイグレーション適用 + shell: bash + run: | + cd src\Dressca.EfInfrastructure + dotnet ef database update + - id: run-tests name: テストの実行 continue-on-error: true From 4820a7cfe43bc763c6d55f15fe5bdd51576147f1 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Thu, 2 Nov 2023 17:04:47 +0900 Subject: [PATCH 013/110] =?UTF-8?q?workingdirectory=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 0973553ca..b0d672e17 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -59,10 +59,10 @@ jobs: cat build-result.txt | sed -n -e 's/^/> /p' >> $GITHUB_STEP_SUMMARY - name: 結合テスト用にマイグレーション適用 + working-directory: samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure shell: bash run: | - cd src\Dressca.EfInfrastructure - dotnet ef database update + dotnet ef database update - id: run-tests name: テストの実行 From 054b9f750854cb59c1b03c66a7ed78b571ceb844 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Thu, 2 Nov 2023 17:10:07 +0900 Subject: [PATCH 014/110] =?UTF-8?q?EF=20Core=20=E3=83=84=E3=83=BC=E3=83=AB?= =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=82=B9=E3=83=88=E3=83=BC=E3=83=AB=E3=82=BF?= =?UTF-8?q?=E3=82=B9=E3=82=AF=E3=82=92=E8=BF=BD=E5=8A=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index b0d672e17..b53cb3c25 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -62,6 +62,7 @@ jobs: working-directory: samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure shell: bash run: | + dotnet tool install --global dotnet-ef dotnet ef database update - id: run-tests From 8ca6e1a903929655031556d28286be89595fc980 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Thu, 2 Nov 2023 17:44:07 +0900 Subject: [PATCH 015/110] =?UTF-8?q?SQL=20Server=E3=81=AE=E3=82=A4=E3=83=B3?= =?UTF-8?q?=E3=82=B9=E3=83=88=E3=83=BC=E3=83=AB=E3=82=BF=E3=82=B9=E3=82=AF?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index b53cb3c25..d84124a41 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -63,6 +63,13 @@ jobs: shell: bash run: | dotnet tool install --global dotnet-ef + sudo docker pull mcr.microsoft.com/mssql/server:2022-latest + sudo docker run -e "ACCEPT_EULA=Y" \ + -e "MSSQL_SA_PASSWORD=Passw0rd" \ + -p 1433:1433 --name sql1 \ + --hostname sql1 \ + -d \ + mcr.microsoft.com/mssql/server:2022-latest dotnet ef database update - id: run-tests From 178882ce4630cf3b06242d48570454e90b2f0956 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Thu, 2 Nov 2023 17:55:37 +0900 Subject: [PATCH 016/110] =?UTF-8?q?=E6=8E=A5=E7=B6=9A=E6=96=87=E5=AD=97?= =?UTF-8?q?=E5=88=97=E3=81=AE=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CustomWebApplicationFactory.cs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs new file mode 100644 index 000000000..6c1c00adb --- /dev/null +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs @@ -0,0 +1,36 @@ +using System.Data.Common; +using Dressca.EfInfrastructure; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc.Testing; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; + +namespace Dressca.IntegrationTest; +public class CustomWebApplicationFactory + : WebApplicationFactory where TProgram : class +{ + protected override void ConfigureWebHost(IWebHostBuilder builder) + { + builder.ConfigureServices(services => + { + var dbContextDescriptor = services.SingleOrDefault( + d => d.ServiceType == + typeof(DbContextOptions)); + + services.Remove(dbContextDescriptor); + + var dbConnectionDescriptor = services.SingleOrDefault( + d => d.ServiceType == + typeof(DbConnection)); + + services.Remove(dbConnectionDescriptor); + + services.AddDbContext( options => + { + options.UseSqlServer(@"Server=localhost,1433;Database=Dressca.Eshop;User=sa;Password=Passw0rd;"); + }); + }); + + builder.UseEnvironment("Development"); + } +} From da39ac431e2daf3c10367e29087f74d7f75a3a79 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Thu, 2 Nov 2023 18:02:31 +0900 Subject: [PATCH 017/110] =?UTF-8?q?=E7=B5=90=E5=90=88=E3=83=86=E3=82=B9?= =?UTF-8?q?=E3=83=88=E3=81=8B=E3=82=89Dressca.EfInfrastructure=E3=82=92?= =?UTF-8?q?=E5=8F=82=E7=85=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dressca.EfInfrastructure/Dressca.EfInfrastructure.csproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/Dressca.EfInfrastructure.csproj b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/Dressca.EfInfrastructure.csproj index f526e7c47..efa213865 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/Dressca.EfInfrastructure.csproj +++ b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/Dressca.EfInfrastructure.csproj @@ -32,4 +32,8 @@ + + + + From beb55233035ecebb4860b18c88ce03ae154a6dbe Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Thu, 2 Nov 2023 18:10:09 +0900 Subject: [PATCH 018/110] =?UTF-8?q?=E6=8E=A5=E7=B6=9A=E6=96=87=E5=AD=97?= =?UTF-8?q?=E5=88=97=E3=81=AE=E5=8B=95=E4=BD=9C=E7=A2=BA=E8=AA=8D=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/Dressca.Web/appsettings.Development.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/appsettings.Development.json b/samples/Dressca/dressca-backend/src/Dressca.Web/appsettings.Development.json index 584b62cbb..90420d046 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web/appsettings.Development.json +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/appsettings.Development.json @@ -9,6 +9,6 @@ } }, "ConnectionStrings": { - "DresscaDbContext": "Data Source=(localdb)\\mssqllocaldb;Database=Dressca.Eshop;Integrated Security=True" + "DresscaDbContext": "Server=localhost,1433;Database=Dressca.Eshop;User=sa;Password=Passw0rd;" } } From 3c640dfe137e787c4fddf50189ec3fdc3ca046ef Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Thu, 2 Nov 2023 18:17:59 +0900 Subject: [PATCH 019/110] =?UTF-8?q?=E6=8E=A5=E7=B6=9A=E6=96=87=E5=AD=97?= =?UTF-8?q?=E5=88=97=E3=81=AE=E5=8B=95=E4=BD=9C=E7=A2=BA=E8=AA=8D=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/Dressca.EfInfrastructure/DresscaDbContext.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/DresscaDbContext.cs b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/DresscaDbContext.cs index ad415f04b..687b28170 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/DresscaDbContext.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/DresscaDbContext.cs @@ -88,7 +88,8 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) ArgumentNullException.ThrowIfNull(optionsBuilder); if (!optionsBuilder.IsConfigured) { - optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Dressca.Eshop;Integrated Security=True"); + //optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Dressca.Eshop;Integrated Security=True"); + optionsBuilder.UseSqlServer(@"Server=localhost,1433;Database=Dressca.Eshop;User=sa;Password=Passw0rd;"); } } From 3c03f788b53d6b23a9ec7e5f62504baf7a4d87dd Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Thu, 2 Nov 2023 18:51:49 +0900 Subject: [PATCH 020/110] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E5=AE=9F?= =?UTF-8?q?=E8=A1=8C=E7=9B=B4=E5=89=8D=E3=81=AB=E3=83=87=E3=83=BC=E3=82=BF?= =?UTF-8?q?=E3=83=99=E3=83=BC=E3=82=B9=E3=81=AE=E5=AD=98=E5=9C=A8=E3=82=92?= =?UTF-8?q?=E7=A2=BA=E8=AA=8D=E3=81=99=E3=82=8B=E5=87=A6=E7=90=86=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 4 +--- .../Dressca.IntegrationTest/CustomWebApplicationFactory.cs | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index d84124a41..66de39763 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -58,11 +58,10 @@ jobs: echo '# Build Result :gear:' >> $GITHUB_STEP_SUMMARY cat build-result.txt | sed -n -e 's/^/> /p' >> $GITHUB_STEP_SUMMARY - - name: 結合テスト用にマイグレーション適用 + - name: 結合テスト用 SQL Server のセットアップ working-directory: samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure shell: bash run: | - dotnet tool install --global dotnet-ef sudo docker pull mcr.microsoft.com/mssql/server:2022-latest sudo docker run -e "ACCEPT_EULA=Y" \ -e "MSSQL_SA_PASSWORD=Passw0rd" \ @@ -70,7 +69,6 @@ jobs: --hostname sql1 \ -d \ mcr.microsoft.com/mssql/server:2022-latest - dotnet ef database update - id: run-tests name: テストの実行 diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs index 6c1c00adb..28c469f90 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; namespace Dressca.IntegrationTest; public class CustomWebApplicationFactory @@ -29,6 +30,9 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) { options.UseSqlServer(@"Server=localhost,1433;Database=Dressca.Eshop;User=sa;Password=Passw0rd;"); }); + + var dbContext = services.BuildServiceProvider().GetRequiredService(); + dbContext.Database.EnsureCreated(); }); builder.UseEnvironment("Development"); From dee00aeb3f905e050f8ff0e0400955698bdb2d97 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Thu, 2 Nov 2023 18:58:10 +0900 Subject: [PATCH 021/110] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E5=AE=9F?= =?UTF-8?q?=E8=A1=8C=E7=9B=B4=E5=89=8D=E3=81=AB=E3=83=87=E3=83=BC=E3=82=BF?= =?UTF-8?q?=E3=83=99=E3=83=BC=E3=82=B9=E3=81=AE=E5=AD=98=E5=9C=A8=E3=82=92?= =?UTF-8?q?=E7=A2=BA=E8=AA=8D=E3=81=99=E3=82=8B=E5=87=A6=E7=90=86=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/Dressca.EfInfrastructure/DresscaDbContext.cs | 3 +-- .../src/Dressca.Web/appsettings.Development.json | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/DresscaDbContext.cs b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/DresscaDbContext.cs index 687b28170..ad415f04b 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/DresscaDbContext.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/DresscaDbContext.cs @@ -88,8 +88,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) ArgumentNullException.ThrowIfNull(optionsBuilder); if (!optionsBuilder.IsConfigured) { - //optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Dressca.Eshop;Integrated Security=True"); - optionsBuilder.UseSqlServer(@"Server=localhost,1433;Database=Dressca.Eshop;User=sa;Password=Passw0rd;"); + optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Dressca.Eshop;Integrated Security=True"); } } diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/appsettings.Development.json b/samples/Dressca/dressca-backend/src/Dressca.Web/appsettings.Development.json index 90420d046..584b62cbb 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web/appsettings.Development.json +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/appsettings.Development.json @@ -9,6 +9,6 @@ } }, "ConnectionStrings": { - "DresscaDbContext": "Server=localhost,1433;Database=Dressca.Eshop;User=sa;Password=Passw0rd;" + "DresscaDbContext": "Data Source=(localdb)\\mssqllocaldb;Database=Dressca.Eshop;Integrated Security=True" } } From 072a31e2055a236579a5f8239c86f5b6da902a4c Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Thu, 2 Nov 2023 19:08:42 +0900 Subject: [PATCH 022/110] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E7=94=A8Web?= =?UTF-8?q?AP=E3=81=AB=E5=B7=AE=E3=81=97=E6=9B=BF=E3=81=88=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dressca.IntegrationTest/DatabaseHealthCheckTest.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs index 5fa3a5972..cbcddb4c1 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs @@ -3,11 +3,11 @@ namespace Dressca.IntegrationTest; -public class DatabaseHealthCheckTest : IClassFixture> +public class DatabaseHealthCheckTest : IClassFixture> { - private readonly WebApplicationFactory factory; + private readonly CustomWebApplicationFactory factory; - public DatabaseHealthCheckTest(WebApplicationFactory factory) + public DatabaseHealthCheckTest(CustomWebApplicationFactory factory) { this.factory = factory; } From fca4ec9eda2588f253ef972f04d170c8e4a8c804 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Thu, 2 Nov 2023 19:12:16 +0900 Subject: [PATCH 023/110] =?UTF-8?q?=E3=83=87=E3=83=BC=E3=82=BF=E3=83=99?= =?UTF-8?q?=E3=83=BC=E3=82=B9=E3=81=AE=E7=A2=BA=E8=AA=8D=E5=87=A6=E7=90=86?= =?UTF-8?q?=E3=82=92=E5=89=8A=E9=99=A4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dressca.IntegrationTest/CustomWebApplicationFactory.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs index 28c469f90..15f7edb68 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs @@ -30,9 +30,6 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) { options.UseSqlServer(@"Server=localhost,1433;Database=Dressca.Eshop;User=sa;Password=Passw0rd;"); }); - - var dbContext = services.BuildServiceProvider().GetRequiredService(); - dbContext.Database.EnsureCreated(); }); builder.UseEnvironment("Development"); From 2bcf8db4530e28e559f3dac5077f4c12948b1331 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Thu, 2 Nov 2023 19:16:04 +0900 Subject: [PATCH 024/110] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AA=E7=B7=A8?= =?UTF-8?q?=E9=9B=86=E5=86=85=E5=AE=B9=E3=82=92=E3=83=AD=E3=83=BC=E3=83=AB?= =?UTF-8?q?=E3=83=90=E3=83=83=E3=82=AF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dressca.IntegrationTest/CustomWebApplicationFactory.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs index 15f7edb68..28c469f90 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs @@ -30,6 +30,9 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) { options.UseSqlServer(@"Server=localhost,1433;Database=Dressca.Eshop;User=sa;Password=Passw0rd;"); }); + + var dbContext = services.BuildServiceProvider().GetRequiredService(); + dbContext.Database.EnsureCreated(); }); builder.UseEnvironment("Development"); From fff1ebaaceaa747dbe0186aecf5b77d0eb97c2c8 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Mon, 6 Nov 2023 10:20:26 +0900 Subject: [PATCH 025/110] =?UTF-8?q?=E7=B5=90=E5=90=88=E3=83=86=E3=82=B9?= =?UTF-8?q?=E3=83=88=E3=81=AEDB=E6=8E=A5=E7=B6=9A=E7=A2=BA=E8=AA=8D?= =?UTF-8?q?=E3=80=82(PostgreSQL)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 15 ++++++--------- .../dressca-backend/Directory.Packages.props | 1 + .../CustomWebApplicationFactory.cs | 6 +----- .../Dressca.IntegrationTest.csproj | 1 + 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 66de39763..32566e0c7 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -58,17 +58,14 @@ jobs: echo '# Build Result :gear:' >> $GITHUB_STEP_SUMMARY cat build-result.txt | sed -n -e 's/^/> /p' >> $GITHUB_STEP_SUMMARY - - name: 結合テスト用 SQL Server のセットアップ - working-directory: samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure + - name: 結合テスト用 PostgreSQL のセットアップ shell: bash run: | - sudo docker pull mcr.microsoft.com/mssql/server:2022-latest - sudo docker run -e "ACCEPT_EULA=Y" \ - -e "MSSQL_SA_PASSWORD=Passw0rd" \ - -p 1433:1433 --name sql1 \ - --hostname sql1 \ - -d \ - mcr.microsoft.com/mssql/server:2022-latest + sudo systemctl start postgresql.service + sudo su - postgres + psql + alter role postgres with password 'postgres'; + create database dressca_eshop; - id: run-tests name: テストの実行 diff --git a/samples/Dressca/dressca-backend/Directory.Packages.props b/samples/Dressca/dressca-backend/Directory.Packages.props index b2ea2d198..ce07bfe0a 100644 --- a/samples/Dressca/dressca-backend/Directory.Packages.props +++ b/samples/Dressca/dressca-backend/Directory.Packages.props @@ -13,6 +13,7 @@ + diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs index 28c469f90..5e496d91f 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs @@ -4,7 +4,6 @@ using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; namespace Dressca.IntegrationTest; public class CustomWebApplicationFactory @@ -28,11 +27,8 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) services.AddDbContext( options => { - options.UseSqlServer(@"Server=localhost,1433;Database=Dressca.Eshop;User=sa;Password=Passw0rd;"); + options.UseNpgsql("Host=localhost;Database=dressca_eshop;Username=postgres;Password=postgres"); }); - - var dbContext = services.BuildServiceProvider().GetRequiredService(); - dbContext.Database.EnsureCreated(); }); builder.UseEnvironment("Development"); diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj index ff15a68ba..c14a1dc33 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj @@ -12,6 +12,7 @@ + runtime; build; native; contentfiles; analyzers; buildtransitive From 94b38720d2dc869e7ee7654bd2eb3277710ed68c Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Mon, 6 Nov 2023 10:24:06 +0900 Subject: [PATCH 026/110] =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=83=87=E3=83=B3?= =?UTF-8?q?=E3=83=88=E3=82=92=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 32566e0c7..7e933b895 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -61,7 +61,7 @@ jobs: - name: 結合テスト用 PostgreSQL のセットアップ shell: bash run: | - sudo systemctl start postgresql.service + sudo systemctl start postgresql.service sudo su - postgres psql alter role postgres with password 'postgres'; From cfead2d48f867fb6f22562e1b2df4a690286c88b Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Mon, 6 Nov 2023 10:56:38 +0900 Subject: [PATCH 027/110] =?UTF-8?q?EF=20Core=E7=B5=8C=E7=94=B1=E3=81=A7DB?= =?UTF-8?q?=E3=81=AE=E5=AD=98=E5=9C=A8=E7=A2=BA=E8=AA=8D=E5=87=A6=E7=90=86?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 7 +------ .../Dressca.IntegrationTest/CustomWebApplicationFactory.cs | 3 +++ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 7e933b895..003a53536 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -60,12 +60,7 @@ jobs: - name: 結合テスト用 PostgreSQL のセットアップ shell: bash - run: | - sudo systemctl start postgresql.service - sudo su - postgres - psql - alter role postgres with password 'postgres'; - create database dressca_eshop; + run: sudo systemctl start postgresql.service - id: run-tests name: テストの実行 diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs index 5e496d91f..9a611f568 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs @@ -29,6 +29,9 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) { options.UseNpgsql("Host=localhost;Database=dressca_eshop;Username=postgres;Password=postgres"); }); + + var dbContext = services.BuildServiceProvider().GetRequiredService(); + dbContext.Database.EnsureCreated(); }); builder.UseEnvironment("Development"); From 1475480aec6879a95782c74a86f40c2cd5d95c71 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Mon, 6 Nov 2023 11:20:55 +0900 Subject: [PATCH 028/110] =?UTF-8?q?postgres=E3=81=AE=E3=83=AD=E3=82=B0?= =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC=E5=90=8D?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 003a53536..35e63645e 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -60,7 +60,11 @@ jobs: - name: 結合テスト用 PostgreSQL のセットアップ shell: bash - run: sudo systemctl start postgresql.service + run: | + sudo systemctl start postgresql.service + sudo su - postgres + psql -U postgres + alter role postgres with password 'postgres'; - id: run-tests name: テストの実行 From 97127008cd0e4393a9f6cbf2d211ac8c3de8654e Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Mon, 6 Nov 2023 12:07:27 +0900 Subject: [PATCH 029/110] =?UTF-8?q?PostgreSQL=E3=81=AE=E3=83=A6=E3=83=BC?= =?UTF-8?q?=E3=82=B6=E3=83=BC=E8=A8=AD=E5=AE=9A=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 35e63645e..1e630bfc7 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -62,9 +62,8 @@ jobs: shell: bash run: | sudo systemctl start postgresql.service - sudo su - postgres - psql -U postgres - alter role postgres with password 'postgres'; + sudo bash -c "echo \"local all all md5\" >> /etc/postgresql/14/main/pg_hba.conf" + sudo su postgres -c "psql postgres -c \"alter role postgres with login password 'postgres';\"" - id: run-tests name: テストの実行 From 9622a9de7a9449e0e1fef0a956610d4f4bccf287 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Mon, 6 Nov 2023 13:08:25 +0900 Subject: [PATCH 030/110] =?UTF-8?q?=E3=83=91=E3=82=A4=E3=83=97=E3=83=A9?= =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=81=AB=E3=83=87=E3=83=BC=E3=82=BF=E3=83=99?= =?UTF-8?q?=E3=83=BC=E3=82=B9=E4=BD=9C=E6=88=90=E5=87=A6=E7=90=86=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 1 + .../Dressca.IntegrationTest/CustomWebApplicationFactory.cs | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 1e630bfc7..827cd463a 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -64,6 +64,7 @@ jobs: sudo systemctl start postgresql.service sudo bash -c "echo \"local all all md5\" >> /etc/postgresql/14/main/pg_hba.conf" sudo su postgres -c "psql postgres -c \"alter role postgres with login password 'postgres';\"" + sudo su postgres -c "psql postgres -c 'create database dressca_eshop;'" - id: run-tests name: テストの実行 diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs index 9a611f568..5e496d91f 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs @@ -29,9 +29,6 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) { options.UseNpgsql("Host=localhost;Database=dressca_eshop;Username=postgres;Password=postgres"); }); - - var dbContext = services.BuildServiceProvider().GetRequiredService(); - dbContext.Database.EnsureCreated(); }); builder.UseEnvironment("Development"); From d15d0fdecf235262018635943f9da50a7bca8bc4 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Mon, 6 Nov 2023 13:39:27 +0900 Subject: [PATCH 031/110] =?UTF-8?q?=E7=B5=90=E5=90=88=E3=83=86=E3=82=B9?= =?UTF-8?q?=E3=83=88=E3=81=AEDB=E6=8E=A5=E7=B6=9A=E7=A2=BA=E8=AA=8D?= =?UTF-8?q?=E3=80=82(MySQL)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 10 +++++----- .../Dressca/dressca-backend/Directory.Packages.props | 1 + .../CustomWebApplicationFactory.cs | 2 +- .../Dressca.IntegrationTest.csproj | 1 + 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 827cd463a..f021f95e8 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -58,13 +58,13 @@ jobs: echo '# Build Result :gear:' >> $GITHUB_STEP_SUMMARY cat build-result.txt | sed -n -e 's/^/> /p' >> $GITHUB_STEP_SUMMARY - - name: 結合テスト用 PostgreSQL のセットアップ + - name: 結合テスト用 MySQL のセットアップ shell: bash run: | - sudo systemctl start postgresql.service - sudo bash -c "echo \"local all all md5\" >> /etc/postgresql/14/main/pg_hba.conf" - sudo su postgres -c "psql postgres -c \"alter role postgres with login password 'postgres';\"" - sudo su postgres -c "psql postgres -c 'create database dressca_eshop;'" + sudo systemctl start mysql.service + sudo mysql -u root -p + root + create database dressca_eshop; - id: run-tests name: テストの実行 diff --git a/samples/Dressca/dressca-backend/Directory.Packages.props b/samples/Dressca/dressca-backend/Directory.Packages.props index ce07bfe0a..822e59f3b 100644 --- a/samples/Dressca/dressca-backend/Directory.Packages.props +++ b/samples/Dressca/dressca-backend/Directory.Packages.props @@ -16,6 +16,7 @@ + diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs index 5e496d91f..ff32abbdf 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs @@ -27,7 +27,7 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) services.AddDbContext( options => { - options.UseNpgsql("Host=localhost;Database=dressca_eshop;Username=postgres;Password=postgres"); + options.UseMySql("server=localhost;user=root;password=root;database=dressca_eshop;",new MySqlServerVersion(new Version(8,0,34))); }); }); diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj index c14a1dc33..2910e4a43 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj @@ -13,6 +13,7 @@ + runtime; build; native; contentfiles; analyzers; buildtransitive From 3e4f2a330d48886de6520e3002aae510704f8912 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Mon, 6 Nov 2023 13:44:17 +0900 Subject: [PATCH 032/110] =?UTF-8?q?MySQL=E3=83=AD=E3=82=B0=E3=82=A4?= =?UTF-8?q?=E3=83=B3=E5=87=A6=E7=90=86=E3=81=AE=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index f021f95e8..f78985cb0 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -62,8 +62,7 @@ jobs: shell: bash run: | sudo systemctl start mysql.service - sudo mysql -u root -p - root + sudo mysql -u root -proot create database dressca_eshop; - id: run-tests From 89395a67a9f4d72717f4ca8c045fab0c99345e8e Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Mon, 6 Nov 2023 13:54:16 +0900 Subject: [PATCH 033/110] =?UTF-8?q?DB=E4=BD=9C=E6=88=90=E5=87=A6=E7=90=86?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index f78985cb0..3f6b3b246 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -62,8 +62,7 @@ jobs: shell: bash run: | sudo systemctl start mysql.service - sudo mysql -u root -proot - create database dressca_eshop; + sudo mysql -u root -proot -e "create database dressca_eshop;" - id: run-tests name: テストの実行 From 843c77fb2304015a17c80aecf923eb8b7386ebd1 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Mon, 6 Nov 2023 14:45:30 +0900 Subject: [PATCH 034/110] =?UTF-8?q?=E3=83=93=E3=83=AB=E3=83=89=E3=83=9E?= =?UTF-8?q?=E3=82=B7=E3=83=B3=E4=B8=8A=E3=81=AESQL=20Server=E3=82=92?= =?UTF-8?q?=E7=A2=BA=E8=AA=8D=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 5 ++--- .../Dressca.IntegrationTest/DatabaseHealthCheckTest.cs | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 3f6b3b246..71e9964d5 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -58,11 +58,10 @@ jobs: echo '# Build Result :gear:' >> $GITHUB_STEP_SUMMARY cat build-result.txt | sed -n -e 's/^/> /p' >> $GITHUB_STEP_SUMMARY - - name: 結合テスト用 MySQL のセットアップ + - name: 結合テスト用 SQL Server のセットアップ shell: bash run: | - sudo systemctl start mysql.service - sudo mysql -u root -proot -e "create database dressca_eshop;" + sqlcmd -S localhost -q "CREATE DATABASE Dressca.Eshop" - id: run-tests name: テストの実行 diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs index cbcddb4c1..5fa3a5972 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs @@ -3,11 +3,11 @@ namespace Dressca.IntegrationTest; -public class DatabaseHealthCheckTest : IClassFixture> +public class DatabaseHealthCheckTest : IClassFixture> { - private readonly CustomWebApplicationFactory factory; + private readonly WebApplicationFactory factory; - public DatabaseHealthCheckTest(CustomWebApplicationFactory factory) + public DatabaseHealthCheckTest(WebApplicationFactory factory) { this.factory = factory; } From 6629ac1c69da08794dd70b88acb8a1936686e552 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Mon, 6 Nov 2023 15:19:53 +0900 Subject: [PATCH 035/110] =?UTF-8?q?SQL=20Server=E5=8B=95=E4=BD=9C=E7=A2=BA?= =?UTF-8?q?=E8=AA=8D=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 71e9964d5..e25c7d9fa 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -61,7 +61,7 @@ jobs: - name: 結合テスト用 SQL Server のセットアップ shell: bash run: | - sqlcmd -S localhost -q "CREATE DATABASE Dressca.Eshop" + sudo systemctl start mssql-server - id: run-tests name: テストの実行 From baefafcb20c5b34cfce8ec344712cadfe63c4dfc Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Mon, 6 Nov 2023 17:13:02 +0900 Subject: [PATCH 036/110] =?UTF-8?q?Docker=E3=82=A4=E3=83=A1=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=82=92=E3=82=AD=E3=83=A3=E3=83=83=E3=82=B7=E3=83=A5?= =?UTF-8?q?=E3=81=99=E3=82=8B=E5=87=A6=E7=90=86=E3=82=92=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workflows/samples-dressca-backend.ci.yml | 46 +++++++++++++++++-- .../CustomWebApplicationFactory.cs | 2 +- .../DatabaseHealthCheckTest.cs | 6 +-- .../Dressca.IntegrationTest.csproj | 2 - 4 files changed, 47 insertions(+), 9 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index e25c7d9fa..502ecb2b0 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -13,6 +13,7 @@ on: env: WORKING_DIRECTORY: samples/Dressca/dressca-backend + PATH_CACHE: /tmp/docker-img defaults: run: @@ -58,10 +59,49 @@ jobs: echo '# Build Result :gear:' >> $GITHUB_STEP_SUMMARY cat build-result.txt | sed -n -e 's/^/> /p' >> $GITHUB_STEP_SUMMARY - - name: 結合テスト用 SQL Server のセットアップ - shell: bash + - name: キャッシュIDの作成 + id: imagetag + run: | + VARIANT=$(TZ=UTC-9 date '+%Y%m') + # イメージのタグを作成 + NAME_IMAGE=DockerImage + TAG="${NAME_IMAGE}:${VARIANT}" + # キャッシュする tar アーカイブ名とパスの設定 + NAME_TAR="${NAME_IMAGE}.${VARIANT}.tar" + PATH_TAR=${{ env.PATH_CACHE }}"/${NAME_TAR}" + # 変数を他の run でも使えるように output + echo "::set-output name=TAG::${TAG}" + echo "::set-output name=PATH_TAR::${PATH_TAR}" + + - name: キャッシュ有効化 + id: cache + uses: actions/cache@v3 + with: + path: ${{ env.PATH_CACHE }} + key: ${{ steps.imagetag.outputs.TAG }} + + - name: キャッシュがある場合にロード + if: steps.cache.outputs.cache-hit == 'true' + run: docker load --input ${{ steps.imagetag.outputs.PATH_TAR }} + + - name: キャッシュがない場合にイメージを保存 + if: steps.cache.outputs.cache-hit != 'true' + run: | + mkdir -p ${{ env.PATH_CACHE }} + sudo docker pull mcr.microsoft.com/mssql/server:2022-latest + sudo docker save mcr.microsoft.com/mssql/server:2022-latest > ${{ steps.imagetag.outputs.PATH_TAR }} ${{ steps.imagetag.outputs.TAG }} + + - name: 結合テスト用にSQL Serverをセットアップ run: | - sudo systemctl start mssql-server + sudo docker run -w ${{ steps.imagetag.outputs.TAG }} \ + -e "ACCEPT_EULA=Y" \ + -e "MSSQL_SA_PASSWORD=P@ssw0rd" \ + -p 1433:1433 --name sql1 \ + --hostname sql1 \ + -d \ + mcr.microsoft.com/mssql/server:2022-latest + sudo docker exec -it sql1 "bash" + /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P@ssw0rd" -q "CREATE DATABASE Dressca.Eshop;" - id: run-tests name: テストの実行 diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs index ff32abbdf..167c8af0e 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs @@ -27,7 +27,7 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) services.AddDbContext( options => { - options.UseMySql("server=localhost;user=root;password=root;database=dressca_eshop;",new MySqlServerVersion(new Version(8,0,34))); + options.UseSqlServer(@"Server=localhost,1433;Database=Dressca.Eshop;User=sa;Password=P@ssw0rd;"); }); }); diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs index 5fa3a5972..cbcddb4c1 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs @@ -3,11 +3,11 @@ namespace Dressca.IntegrationTest; -public class DatabaseHealthCheckTest : IClassFixture> +public class DatabaseHealthCheckTest : IClassFixture> { - private readonly WebApplicationFactory factory; + private readonly CustomWebApplicationFactory factory; - public DatabaseHealthCheckTest(WebApplicationFactory factory) + public DatabaseHealthCheckTest(CustomWebApplicationFactory factory) { this.factory = factory; } diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj index 2910e4a43..ff15a68ba 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj @@ -12,8 +12,6 @@ - - runtime; build; native; contentfiles; analyzers; buildtransitive From fe830c20adff707a741351740dc173a9eaf592e1 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Mon, 6 Nov 2023 17:31:08 +0900 Subject: [PATCH 037/110] =?UTF-8?q?Docker=E3=82=A4=E3=83=A1=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=81=AE=E3=82=AD=E3=83=A3=E3=83=83=E3=82=B7=E3=83=A5?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E5=85=88=E3=81=AE=E3=83=91=E3=82=B9=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 502ecb2b0..5babe4ae4 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -70,8 +70,8 @@ jobs: NAME_TAR="${NAME_IMAGE}.${VARIANT}.tar" PATH_TAR=${{ env.PATH_CACHE }}"/${NAME_TAR}" # 変数を他の run でも使えるように output - echo "::set-output name=TAG::${TAG}" - echo "::set-output name=PATH_TAR::${PATH_TAR}" + echo "TAG=${TAG}" >> "$GITHUB_OUTPUT" + echo "PATH_TAR=${PATH_TAR}" >> "$GITHUB_OUTPUT" - name: キャッシュ有効化 id: cache @@ -89,7 +89,7 @@ jobs: run: | mkdir -p ${{ env.PATH_CACHE }} sudo docker pull mcr.microsoft.com/mssql/server:2022-latest - sudo docker save mcr.microsoft.com/mssql/server:2022-latest > ${{ steps.imagetag.outputs.PATH_TAR }} ${{ steps.imagetag.outputs.TAG }} + sudo docker save mcr.microsoft.com/mssql/server:2022-latest > ${{ steps.imagetag.outputs.PATH_TAR }} - name: 結合テスト用にSQL Serverをセットアップ run: | From 909442538c981bf296c512eafe928414ef086749 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Mon, 6 Nov 2023 17:36:43 +0900 Subject: [PATCH 038/110] =?UTF-8?q?Docker=E3=82=A4=E3=83=A1=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=82=92=E3=83=AD=E3=83=BC=E3=83=89=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=83=91=E3=82=B9=E3=82=92=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 5babe4ae4..bbfb6bf49 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -93,7 +93,7 @@ jobs: - name: 結合テスト用にSQL Serverをセットアップ run: | - sudo docker run -w ${{ steps.imagetag.outputs.TAG }} \ + sudo docker run -w ${{ steps.imagetag.outputs.PATH_TAR }} \ -e "ACCEPT_EULA=Y" \ -e "MSSQL_SA_PASSWORD=P@ssw0rd" \ -p 1433:1433 --name sql1 \ From 79621d7391c92b13d2ca53b1d376b424e82e1d9f Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Mon, 6 Nov 2023 17:45:35 +0900 Subject: [PATCH 039/110] =?UTF-8?q?SQL=20Server=E3=81=AE=E3=82=BB=E3=83=83?= =?UTF-8?q?=E3=83=88=E3=82=A2=E3=83=83=E3=83=97=E3=82=BF=E3=82=B9=E3=82=AF?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index bbfb6bf49..b5f7bf222 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -93,7 +93,7 @@ jobs: - name: 結合テスト用にSQL Serverをセットアップ run: | - sudo docker run -w ${{ steps.imagetag.outputs.PATH_TAR }} \ + sudo docker run -t -w ${{ steps.imagetag.outputs.PATH_TAR }} \ -e "ACCEPT_EULA=Y" \ -e "MSSQL_SA_PASSWORD=P@ssw0rd" \ -p 1433:1433 --name sql1 \ From e9131760d2127a3aa2e365878c0d728ba596c794 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Mon, 6 Nov 2023 17:53:49 +0900 Subject: [PATCH 040/110] =?UTF-8?q?=E3=82=BB=E3=83=83=E3=83=88=E3=82=A2?= =?UTF-8?q?=E3=83=83=E3=83=97=E5=87=A6=E7=90=86=E3=82=92=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index b5f7bf222..5e58b2305 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -100,7 +100,7 @@ jobs: --hostname sql1 \ -d \ mcr.microsoft.com/mssql/server:2022-latest - sudo docker exec -it sql1 "bash" + sudo docker exec -it -t sql1 "bash" /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P@ssw0rd" -q "CREATE DATABASE Dressca.Eshop;" - id: run-tests From a81a929e774b53c2a926ba0a7cac16a79d3ac23e Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Mon, 6 Nov 2023 18:04:01 +0900 Subject: [PATCH 041/110] =?UTF-8?q?=E3=82=BB=E3=83=83=E3=83=88=E3=82=A2?= =?UTF-8?q?=E3=83=83=E3=83=97=E5=87=A6=E7=90=86=E3=82=92=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 5e58b2305..4e51e82ce 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -93,14 +93,14 @@ jobs: - name: 結合テスト用にSQL Serverをセットアップ run: | - sudo docker run -t -w ${{ steps.imagetag.outputs.PATH_TAR }} \ + sudo docker run -w ${{ steps.imagetag.outputs.PATH_TAR }} \ -e "ACCEPT_EULA=Y" \ -e "MSSQL_SA_PASSWORD=P@ssw0rd" \ -p 1433:1433 --name sql1 \ --hostname sql1 \ -d \ mcr.microsoft.com/mssql/server:2022-latest - sudo docker exec -it -t sql1 "bash" + sudo docker exec sql1 "bash" /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P@ssw0rd" -q "CREATE DATABASE Dressca.Eshop;" - id: run-tests From 9ba5b47c9067902dcf2e5ea83d51c0ddeecaf794 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Mon, 6 Nov 2023 18:11:30 +0900 Subject: [PATCH 042/110] =?UTF-8?q?=E3=82=B5=E3=83=BC=E3=83=90=E3=83=BC?= =?UTF-8?q?=E5=90=8D=E3=82=92=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 4e51e82ce..f4bfc3040 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -101,7 +101,7 @@ jobs: -d \ mcr.microsoft.com/mssql/server:2022-latest sudo docker exec sql1 "bash" - /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P@ssw0rd" -q "CREATE DATABASE Dressca.Eshop;" + /opt/mssql-tools/bin/sqlcmd -S sql1 -U SA -P "P@ssw0rd" -q "CREATE DATABASE Dressca.Eshop;" - id: run-tests name: テストの実行 From fa4cc56c87e3f8fd6335c677b7cb8e151e0d93ce Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Mon, 6 Nov 2023 18:14:19 +0900 Subject: [PATCH 043/110] =?UTF-8?q?=E3=83=AD=E3=82=B0=E3=82=A4=E3=83=B3?= =?UTF-8?q?=E3=83=91=E3=82=B9=E3=83=AF=E3=83=BC=E3=83=89=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index f4bfc3040..a6e7bdf30 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -101,7 +101,7 @@ jobs: -d \ mcr.microsoft.com/mssql/server:2022-latest sudo docker exec sql1 "bash" - /opt/mssql-tools/bin/sqlcmd -S sql1 -U SA -P "P@ssw0rd" -q "CREATE DATABASE Dressca.Eshop;" + /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P P@ssw0rd -q "CREATE DATABASE Dressca.Eshop;" - id: run-tests name: テストの実行 From f19af612b2c17c583981484fed1fb927e33fc6eb Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Tue, 7 Nov 2023 11:01:22 +0900 Subject: [PATCH 044/110] =?UTF-8?q?=E3=82=AD=E3=83=A3=E3=83=83=E3=82=B7?= =?UTF-8?q?=E3=83=A5=E3=81=AE=E4=BF=9D=E5=AD=98=E5=85=88=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index a6e7bdf30..77f01bb49 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -71,6 +71,7 @@ jobs: PATH_TAR=${{ env.PATH_CACHE }}"/${NAME_TAR}" # 変数を他の run でも使えるように output echo "TAG=${TAG}" >> "$GITHUB_OUTPUT" + echo "NAME_TAR=${NAME_TAR}" >> "$GITHUB_OUTPUT" echo "PATH_TAR=${PATH_TAR}" >> "$GITHUB_OUTPUT" - name: キャッシュ有効化 @@ -89,7 +90,7 @@ jobs: run: | mkdir -p ${{ env.PATH_CACHE }} sudo docker pull mcr.microsoft.com/mssql/server:2022-latest - sudo docker save mcr.microsoft.com/mssql/server:2022-latest > ${{ steps.imagetag.outputs.PATH_TAR }} + sudo docker save mcr.microsoft.com/mssql/server:2022-latest > ${{ steps.imagetag.outputs.NAME_TAR }} - name: 結合テスト用にSQL Serverをセットアップ run: | From ba5575f0e79339c096b6e2e013d9d9c170618bb3 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Tue, 7 Nov 2023 11:20:34 +0900 Subject: [PATCH 045/110] =?UTF-8?q?Docker=E3=82=A4=E3=83=A1=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=81=AE=E5=AE=9F=E8=A1=8C=E5=87=A6=E7=90=86=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 77f01bb49..84190b26c 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -90,11 +90,11 @@ jobs: run: | mkdir -p ${{ env.PATH_CACHE }} sudo docker pull mcr.microsoft.com/mssql/server:2022-latest - sudo docker save mcr.microsoft.com/mssql/server:2022-latest > ${{ steps.imagetag.outputs.NAME_TAR }} + sudo docker save mcr.microsoft.com/mssql/server:2022-latest -o ${{ steps.imagetag.outputs.PATH_TAR }} - name: 結合テスト用にSQL Serverをセットアップ run: | - sudo docker run -w ${{ steps.imagetag.outputs.PATH_TAR }} \ + sudo docker run mcr.microsoft.com/mssql/server:2022-latest \ -e "ACCEPT_EULA=Y" \ -e "MSSQL_SA_PASSWORD=P@ssw0rd" \ -p 1433:1433 --name sql1 \ From 0b08856ac805a255b4d48bc67a467e4f24ec918f Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Tue, 7 Nov 2023 11:41:13 +0900 Subject: [PATCH 046/110] =?UTF-8?q?=E3=82=B3=E3=83=9E=E3=83=B3=E3=83=89?= =?UTF-8?q?=E5=AE=9F=E8=A1=8C=E3=83=A6=E3=83=BC=E3=82=B6=E3=82=92=E6=8C=87?= =?UTF-8?q?=E5=AE=9A=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 84190b26c..bdc60d5a8 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -101,7 +101,7 @@ jobs: --hostname sql1 \ -d \ mcr.microsoft.com/mssql/server:2022-latest - sudo docker exec sql1 "bash" + sudo docker exec -it --user root sql1 "bash" /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P P@ssw0rd -q "CREATE DATABASE Dressca.Eshop;" - id: run-tests From 8f64ff2a5a7fb5ff3baecfc8adbd81ac3c47a60f Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Tue, 7 Nov 2023 11:55:31 +0900 Subject: [PATCH 047/110] =?UTF-8?q?=E3=82=B3=E3=83=9E=E3=83=B3=E3=83=89?= =?UTF-8?q?=E5=AE=9F=E8=A1=8C=E3=83=A6=E3=83=BC=E3=82=B6=E3=82=92=E6=8C=87?= =?UTF-8?q?=E5=AE=9A=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index bdc60d5a8..56007644c 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -94,7 +94,7 @@ jobs: - name: 結合テスト用にSQL Serverをセットアップ run: | - sudo docker run mcr.microsoft.com/mssql/server:2022-latest \ + sudo docker run --user root mcr.microsoft.com/mssql/server:2022-latest \ -e "ACCEPT_EULA=Y" \ -e "MSSQL_SA_PASSWORD=P@ssw0rd" \ -p 1433:1433 --name sql1 \ @@ -102,7 +102,7 @@ jobs: -d \ mcr.microsoft.com/mssql/server:2022-latest sudo docker exec -it --user root sql1 "bash" - /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P P@ssw0rd -q "CREATE DATABASE Dressca.Eshop;" + /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P@ssw0rd" -q "CREATE DATABASE Dressca.Eshop;" - id: run-tests name: テストの実行 From 497fb97cd502bb3f829b2b2f28c1829a273f801d Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Tue, 7 Nov 2023 13:00:03 +0900 Subject: [PATCH 048/110] =?UTF-8?q?sqlcmd=E3=81=AE=E3=82=AA=E3=83=97?= =?UTF-8?q?=E3=82=B7=E3=83=A7=E3=83=B3=E3=82=92=E8=BF=BD=E5=8A=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 56007644c..9ddb87a65 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -94,15 +94,15 @@ jobs: - name: 結合テスト用にSQL Serverをセットアップ run: | - sudo docker run --user root mcr.microsoft.com/mssql/server:2022-latest \ + sudo docker run mcr.microsoft.com/mssql/server:2022-latest \ -e "ACCEPT_EULA=Y" \ -e "MSSQL_SA_PASSWORD=P@ssw0rd" \ -p 1433:1433 --name sql1 \ --hostname sql1 \ -d \ mcr.microsoft.com/mssql/server:2022-latest - sudo docker exec -it --user root sql1 "bash" - /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P@ssw0rd" -q "CREATE DATABASE Dressca.Eshop;" + sudo docker exec -it sql1 "bash" + /opt/mssql-tools/bin/sqlcmd -No -S localhost -U SA -P "P@ssw0rd" -q "CREATE DATABASE Dressca.Eshop;" - id: run-tests name: テストの実行 From 7f2ca33b985c624d8cf95c8b07737fe4496db9a5 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Tue, 7 Nov 2023 13:20:14 +0900 Subject: [PATCH 049/110] =?UTF-8?q?Docker=E5=AE=9F=E8=A1=8C=E3=82=B3?= =?UTF-8?q?=E3=83=9E=E3=83=B3=E3=83=89=E3=82=92=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 9ddb87a65..9f8e78a47 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -97,12 +97,13 @@ jobs: sudo docker run mcr.microsoft.com/mssql/server:2022-latest \ -e "ACCEPT_EULA=Y" \ -e "MSSQL_SA_PASSWORD=P@ssw0rd" \ + -v sqlvolume:/var/opt/mssql \ -p 1433:1433 --name sql1 \ --hostname sql1 \ -d \ mcr.microsoft.com/mssql/server:2022-latest sudo docker exec -it sql1 "bash" - /opt/mssql-tools/bin/sqlcmd -No -S localhost -U SA -P "P@ssw0rd" -q "CREATE DATABASE Dressca.Eshop;" + /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P@ssw0rd" -q "CREATE DATABASE Dressca.Eshop;" - id: run-tests name: テストの実行 From c56373e40c3ed4eee01e0a0cf7b956f9e91aa8c5 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Tue, 7 Nov 2023 13:36:02 +0900 Subject: [PATCH 050/110] =?UTF-8?q?=E3=82=AD=E3=83=A3=E3=83=83=E3=82=B7?= =?UTF-8?q?=E3=83=A5=E3=81=97=E3=81=AA=E3=81=84=E5=A0=B4=E5=90=88=E3=81=AE?= =?UTF-8?q?=E5=8B=95=E4=BD=9C=E7=A2=BA=E8=AA=8D=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workflows/samples-dressca-backend.ci.yml | 69 +++++++++---------- 1 file changed, 34 insertions(+), 35 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 9f8e78a47..508f1de7f 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -59,45 +59,44 @@ jobs: echo '# Build Result :gear:' >> $GITHUB_STEP_SUMMARY cat build-result.txt | sed -n -e 's/^/> /p' >> $GITHUB_STEP_SUMMARY - - name: キャッシュIDの作成 - id: imagetag - run: | - VARIANT=$(TZ=UTC-9 date '+%Y%m') - # イメージのタグを作成 - NAME_IMAGE=DockerImage - TAG="${NAME_IMAGE}:${VARIANT}" - # キャッシュする tar アーカイブ名とパスの設定 - NAME_TAR="${NAME_IMAGE}.${VARIANT}.tar" - PATH_TAR=${{ env.PATH_CACHE }}"/${NAME_TAR}" - # 変数を他の run でも使えるように output - echo "TAG=${TAG}" >> "$GITHUB_OUTPUT" - echo "NAME_TAR=${NAME_TAR}" >> "$GITHUB_OUTPUT" - echo "PATH_TAR=${PATH_TAR}" >> "$GITHUB_OUTPUT" - - - name: キャッシュ有効化 - id: cache - uses: actions/cache@v3 - with: - path: ${{ env.PATH_CACHE }} - key: ${{ steps.imagetag.outputs.TAG }} - - - name: キャッシュがある場合にロード - if: steps.cache.outputs.cache-hit == 'true' - run: docker load --input ${{ steps.imagetag.outputs.PATH_TAR }} - - - name: キャッシュがない場合にイメージを保存 - if: steps.cache.outputs.cache-hit != 'true' - run: | - mkdir -p ${{ env.PATH_CACHE }} - sudo docker pull mcr.microsoft.com/mssql/server:2022-latest - sudo docker save mcr.microsoft.com/mssql/server:2022-latest -o ${{ steps.imagetag.outputs.PATH_TAR }} + #- name: キャッシュIDの作成 + # id: imagetag + # run: | + # VARIANT=$(TZ=UTC-9 date '+%Y%m') + # # イメージのタグを作成 + # NAME_IMAGE=DockerImage + # TAG="${NAME_IMAGE}:${VARIANT}" + # # キャッシュする tar アーカイブ名とパスの設定 + # NAME_TAR="${NAME_IMAGE}.${VARIANT}.tar" + # PATH_TAR=${{ env.PATH_CACHE }}"/${NAME_TAR}" + # # 変数を他の run でも使えるように output + # echo "TAG=${TAG}" >> "$GITHUB_OUTPUT" + # echo "NAME_TAR=${NAME_TAR}" >> "$GITHUB_OUTPUT" + # echo "PATH_TAR=${PATH_TAR}" >> "$GITHUB_OUTPUT" + + #- name: キャッシュ有効化 + # id: cache + # uses: actions/cache@v3 + # with: + # path: ${{ env.PATH_CACHE }} + # key: ${{ steps.imagetag.outputs.TAG }} + + #- name: キャッシュがある場合にロード + # if: steps.cache.outputs.cache-hit == 'true' + # run: docker load --input ${{ steps.imagetag.outputs.PATH_TAR }} + + #- name: キャッシュがない場合にイメージを保存 + # if: steps.cache.outputs.cache-hit != 'true' + # run: | + # mkdir -p ${{ env.PATH_CACHE }} + # sudo docker pull mcr.microsoft.com/mssql/server:2022-latest + # sudo docker save mcr.microsoft.com/mssql/server:2022-latest -o ${{ steps.imagetag.outputs.PATH_TAR }} - name: 結合テスト用にSQL Serverをセットアップ run: | - sudo docker run mcr.microsoft.com/mssql/server:2022-latest \ - -e "ACCEPT_EULA=Y" \ + sudo docker pull mcr.microsoft.com/mssql/server:2022-latest + sudo docker run -e "ACCEPT_EULA=Y" \ -e "MSSQL_SA_PASSWORD=P@ssw0rd" \ - -v sqlvolume:/var/opt/mssql \ -p 1433:1433 --name sql1 \ --hostname sql1 \ -d \ From ab9a32e8219d153a8256b763ef18da6501b930e7 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Tue, 7 Nov 2023 13:39:53 +0900 Subject: [PATCH 051/110] =?UTF-8?q?=E3=82=B3=E3=83=9E=E3=83=B3=E3=83=89?= =?UTF-8?q?=E3=81=AE=E3=82=AA=E3=83=97=E3=82=B7=E3=83=A7=E3=83=B3=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 508f1de7f..b35bae4a1 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -101,7 +101,7 @@ jobs: --hostname sql1 \ -d \ mcr.microsoft.com/mssql/server:2022-latest - sudo docker exec -it sql1 "bash" + sudo docker exec sql1 "bash" /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P@ssw0rd" -q "CREATE DATABASE Dressca.Eshop;" - id: run-tests From 5550490122348d2c96a02bbcbc8dba8f69e5b365 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Tue, 7 Nov 2023 13:46:50 +0900 Subject: [PATCH 052/110] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E7=94=A8?= =?UTF-8?q?=E3=83=87=E3=83=BC=E3=82=BF=E3=83=99=E3=83=BC=E3=82=B9=E5=90=8D?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 2 +- .../Dressca.IntegrationTest/CustomWebApplicationFactory.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index b35bae4a1..b0d34371e 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -102,7 +102,7 @@ jobs: -d \ mcr.microsoft.com/mssql/server:2022-latest sudo docker exec sql1 "bash" - /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P@ssw0rd" -q "CREATE DATABASE Dressca.Eshop;" + /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P@ssw0rd" -q "CREATE DATABASE Dressca_Eshop;" - id: run-tests name: テストの実行 diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs index 167c8af0e..2ab3aa4cf 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs @@ -27,7 +27,7 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) services.AddDbContext( options => { - options.UseSqlServer(@"Server=localhost,1433;Database=Dressca.Eshop;User=sa;Password=P@ssw0rd;"); + options.UseSqlServer(@"Server=localhost,1433;Database=Dressca_Eshop;User=sa;Password=P@ssw0rd;"); }); }); From c388ffa49f1da3bb36682ab0c858c5c3f53f3cb1 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Tue, 7 Nov 2023 13:55:42 +0900 Subject: [PATCH 053/110] =?UTF-8?q?Docker=E3=82=92=E3=82=AD=E3=83=A3?= =?UTF-8?q?=E3=83=83=E3=82=B7=E3=83=A5=E3=81=97=E3=80=81dbContext.Database?= =?UTF-8?q?.EnsureCreated()=E3=81=A7DB=E6=8E=A5=E7=B6=9A=E7=A2=BA=E8=AA=8D?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workflows/samples-dressca-backend.ci.yml | 67 +++++++++---------- .../CustomWebApplicationFactory.cs | 3 + 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index b0d34371e..7662db2f9 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -59,50 +59,47 @@ jobs: echo '# Build Result :gear:' >> $GITHUB_STEP_SUMMARY cat build-result.txt | sed -n -e 's/^/> /p' >> $GITHUB_STEP_SUMMARY - #- name: キャッシュIDの作成 - # id: imagetag - # run: | - # VARIANT=$(TZ=UTC-9 date '+%Y%m') - # # イメージのタグを作成 - # NAME_IMAGE=DockerImage - # TAG="${NAME_IMAGE}:${VARIANT}" - # # キャッシュする tar アーカイブ名とパスの設定 - # NAME_TAR="${NAME_IMAGE}.${VARIANT}.tar" - # PATH_TAR=${{ env.PATH_CACHE }}"/${NAME_TAR}" - # # 変数を他の run でも使えるように output - # echo "TAG=${TAG}" >> "$GITHUB_OUTPUT" - # echo "NAME_TAR=${NAME_TAR}" >> "$GITHUB_OUTPUT" - # echo "PATH_TAR=${PATH_TAR}" >> "$GITHUB_OUTPUT" - - #- name: キャッシュ有効化 - # id: cache - # uses: actions/cache@v3 - # with: - # path: ${{ env.PATH_CACHE }} - # key: ${{ steps.imagetag.outputs.TAG }} - - #- name: キャッシュがある場合にロード - # if: steps.cache.outputs.cache-hit == 'true' - # run: docker load --input ${{ steps.imagetag.outputs.PATH_TAR }} - - #- name: キャッシュがない場合にイメージを保存 - # if: steps.cache.outputs.cache-hit != 'true' - # run: | - # mkdir -p ${{ env.PATH_CACHE }} - # sudo docker pull mcr.microsoft.com/mssql/server:2022-latest - # sudo docker save mcr.microsoft.com/mssql/server:2022-latest -o ${{ steps.imagetag.outputs.PATH_TAR }} + - name: キャッシュIDの作成 + id: imagetag + run: | + VARIANT=$(TZ=UTC-9 date '+%Y%m') + # イメージのタグを作成 + NAME_IMAGE=DockerImage + TAG="${NAME_IMAGE}:${VARIANT}" + # キャッシュする tar アーカイブ名とパスの設定 + NAME_TAR="${NAME_IMAGE}.${VARIANT}.tar" + PATH_TAR=${{ env.PATH_CACHE }}"/${NAME_TAR}" + # 変数を他の run でも使えるように output + echo "TAG=${TAG}" >> "$GITHUB_OUTPUT" + echo "NAME_TAR=${NAME_TAR}" >> "$GITHUB_OUTPUT" + echo "PATH_TAR=${PATH_TAR}" >> "$GITHUB_OUTPUT" + + - name: キャッシュ有効化 + id: cache + uses: actions/cache@v3 + with: + path: ${{ env.PATH_CACHE }} + key: ${{ steps.imagetag.outputs.TAG }} - - name: 結合テスト用にSQL Serverをセットアップ + - name: キャッシュがある場合にロード + if: steps.cache.outputs.cache-hit == 'true' + run: docker load --input ${{ steps.imagetag.outputs.PATH_TAR }} + + - name: キャッシュがない場合にイメージを保存 + if: steps.cache.outputs.cache-hit != 'true' run: | + mkdir -p ${{ env.PATH_CACHE }} sudo docker pull mcr.microsoft.com/mssql/server:2022-latest + sudo docker save mcr.microsoft.com/mssql/server:2022-latest -o ${{ steps.imagetag.outputs.PATH_TAR }} + + - name: 結合テスト用にSQL Serverをセットアップ + run: | sudo docker run -e "ACCEPT_EULA=Y" \ -e "MSSQL_SA_PASSWORD=P@ssw0rd" \ -p 1433:1433 --name sql1 \ --hostname sql1 \ -d \ mcr.microsoft.com/mssql/server:2022-latest - sudo docker exec sql1 "bash" - /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P@ssw0rd" -q "CREATE DATABASE Dressca_Eshop;" - id: run-tests name: テストの実行 diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs index 2ab3aa4cf..8f57a1e4d 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs @@ -29,6 +29,9 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) { options.UseSqlServer(@"Server=localhost,1433;Database=Dressca_Eshop;User=sa;Password=P@ssw0rd;"); }); + + var dbContext = services.BuildServiceProvider().GetRequiredService(); + dbContext.Database.EnsureCreated(); }); builder.UseEnvironment("Development"); From e5349ea9162057308854e6dd8e3d5e41d53df796 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Tue, 7 Nov 2023 17:59:39 +0900 Subject: [PATCH 054/110] =?UTF-8?q?runsettings=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E3=81=AE=E5=8B=95=E4=BD=9C=E7=A2=BA=E8=AA=8D=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workflows/samples-dressca-backend.ci.yml | 67 ++++++++++--------- .../Dressca.EfInfrastructure.csproj | 4 -- .../CustomWebApplicationFactory.cs | 35 ++++++---- .../Dressca.IntegrationTest.csproj | 9 +++ .../appsettings.Development.json | 14 ++++ .../Dressca.IntegrationTest/appsettings.json | 13 ++++ .../citest.runsettings | 8 +++ .../localtest.runsettings | 8 +++ 8 files changed, 107 insertions(+), 51 deletions(-) create mode 100644 samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.Development.json create mode 100644 samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.json create mode 100644 samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/citest.runsettings create mode 100644 samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/localtest.runsettings diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 7662db2f9..e23f23d5f 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -59,41 +59,42 @@ jobs: echo '# Build Result :gear:' >> $GITHUB_STEP_SUMMARY cat build-result.txt | sed -n -e 's/^/> /p' >> $GITHUB_STEP_SUMMARY - - name: キャッシュIDの作成 - id: imagetag - run: | - VARIANT=$(TZ=UTC-9 date '+%Y%m') - # イメージのタグを作成 - NAME_IMAGE=DockerImage - TAG="${NAME_IMAGE}:${VARIANT}" - # キャッシュする tar アーカイブ名とパスの設定 - NAME_TAR="${NAME_IMAGE}.${VARIANT}.tar" - PATH_TAR=${{ env.PATH_CACHE }}"/${NAME_TAR}" - # 変数を他の run でも使えるように output - echo "TAG=${TAG}" >> "$GITHUB_OUTPUT" - echo "NAME_TAR=${NAME_TAR}" >> "$GITHUB_OUTPUT" - echo "PATH_TAR=${PATH_TAR}" >> "$GITHUB_OUTPUT" - - - name: キャッシュ有効化 - id: cache - uses: actions/cache@v3 - with: - path: ${{ env.PATH_CACHE }} - key: ${{ steps.imagetag.outputs.TAG }} - - - name: キャッシュがある場合にロード - if: steps.cache.outputs.cache-hit == 'true' - run: docker load --input ${{ steps.imagetag.outputs.PATH_TAR }} - - - name: キャッシュがない場合にイメージを保存 - if: steps.cache.outputs.cache-hit != 'true' - run: | - mkdir -p ${{ env.PATH_CACHE }} - sudo docker pull mcr.microsoft.com/mssql/server:2022-latest - sudo docker save mcr.microsoft.com/mssql/server:2022-latest -o ${{ steps.imagetag.outputs.PATH_TAR }} + #- name: キャッシュIDの作成 + # id: imagetag + # run: | + # VARIANT=$(TZ=UTC-9 date '+%Y%m') + # # イメージのタグを作成 + # NAME_IMAGE=DockerImage + # TAG="${NAME_IMAGE}:${VARIANT}" + # # キャッシュする tar アーカイブ名とパスの設定 + # NAME_TAR="${NAME_IMAGE}.${VARIANT}.tar" + # PATH_TAR=${{ env.PATH_CACHE }}"/${NAME_TAR}" + # # 変数を他の run でも使えるように output + # echo "TAG=${TAG}" >> "$GITHUB_OUTPUT" + # echo "NAME_TAR=${NAME_TAR}" >> "$GITHUB_OUTPUT" + # echo "PATH_TAR=${PATH_TAR}" >> "$GITHUB_OUTPUT" + + #- name: キャッシュ有効化 + # id: cache + # uses: actions/cache@v3 + # with: + # path: ${{ env.PATH_CACHE }} + # key: ${{ steps.imagetag.outputs.TAG }} + + #- name: キャッシュがある場合にロード + # if: steps.cache.outputs.cache-hit == 'true' + # run: docker load --input ${{ steps.imagetag.outputs.PATH_TAR }} + + #- name: キャッシュがない場合にイメージを保存 + # if: steps.cache.outputs.cache-hit != 'true' + # run: | + # mkdir -p ${{ env.PATH_CACHE }} + # sudo docker pull mcr.microsoft.com/mssql/server:2022-latest + # sudo docker save mcr.microsoft.com/mssql/server:2022-latest -o ${{ steps.imagetag.outputs.PATH_TAR }} - name: 結合テスト用にSQL Serverをセットアップ run: | + sudo docker pull mcr.microsoft.com/mssql/server:2022-latest sudo docker run -e "ACCEPT_EULA=Y" \ -e "MSSQL_SA_PASSWORD=P@ssw0rd" \ -p 1433:1433 --name sql1 \ @@ -104,7 +105,7 @@ jobs: - id: run-tests name: テストの実行 continue-on-error: true - run: dotnet test --no-build --logger trx --verbosity normal --configuration ${{ env.BUILD_CONFIGURATION }} --collect "XPlat Code Coverage" + run: dotnet test --settings:./citest.runsettings --no-build --logger trx --verbosity normal --configuration ${{ env.BUILD_CONFIGURATION }} --collect "XPlat Code Coverage" - id: create-test-result-report name: テスト結果ページの作成 diff --git a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/Dressca.EfInfrastructure.csproj b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/Dressca.EfInfrastructure.csproj index efa213865..f526e7c47 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/Dressca.EfInfrastructure.csproj +++ b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/Dressca.EfInfrastructure.csproj @@ -32,8 +32,4 @@ - - - - diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs index 8f57a1e4d..720e8ea64 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs @@ -1,8 +1,10 @@ using System.Data.Common; using Dressca.EfInfrastructure; +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; namespace Dressca.IntegrationTest; @@ -13,27 +15,32 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) { builder.ConfigureServices(services => { - var dbContextDescriptor = services.SingleOrDefault( - d => d.ServiceType == - typeof(DbContextOptions)); + //var dbContextDescriptor = services.SingleOrDefault( + // d => d.ServiceType == + // typeof(DbContextOptions)); - services.Remove(dbContextDescriptor); + //services.Remove(dbContextDescriptor); - var dbConnectionDescriptor = services.SingleOrDefault( - d => d.ServiceType == - typeof(DbConnection)); + //var dbConnectionDescriptor = services.SingleOrDefault( + // d => d.ServiceType == + // typeof(DbConnection)); - services.Remove(dbConnectionDescriptor); + //services.Remove(dbConnectionDescriptor); - services.AddDbContext( options => - { - options.UseSqlServer(@"Server=localhost,1433;Database=Dressca_Eshop;User=sa;Password=P@ssw0rd;"); - }); + var fileDirectory = Environment.GetEnvironmentVariable("appSettingsFileDirectory"); + var config = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile(fileDirectory, optional: true, reloadOnChange: true) + .Build(); - var dbContext = services.BuildServiceProvider().GetRequiredService(); - dbContext.Database.EnsureCreated(); + + services.AddDresscaEfInfrastructure(config); + + //var dbContext = services.BuildServiceProvider().GetRequiredService(); + //dbContext.Database.EnsureCreated(); }); builder.UseEnvironment("Development"); + } } diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj index ff15a68ba..2d0ca2dca 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj @@ -27,4 +27,13 @@ + + + Always + + + Always + + + diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.Development.json b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.Development.json new file mode 100644 index 000000000..584b62cbb --- /dev/null +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.Development.json @@ -0,0 +1,14 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning", + "Microsoft.AspNetCore.HttpLogging": "Information", + "Microsoft.Extensions.Diagnostics.HealthChecks": "Debug", + "Dressca": "Debug" + } + }, + "ConnectionStrings": { + "DresscaDbContext": "Data Source=(localdb)\\mssqllocaldb;Database=Dressca.Eshop;Integrated Security=True" + } +} diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.json b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.json new file mode 100644 index 000000000..841cb9d21 --- /dev/null +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.json @@ -0,0 +1,13 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning", + "Dressca": "Information" + } + }, + "ConnectionStrings": { + "DresscaDbContext": "Server=localhost,1433;Database=Dressca_Eshop;User=sa;Password=P@ssw0rd;" + }, + "AllowedHosts": "*" +} diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/citest.runsettings b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/citest.runsettings new file mode 100644 index 000000000..edf49af4d --- /dev/null +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/citest.runsettings @@ -0,0 +1,8 @@ + + + + + appSettings.json + + + diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/localtest.runsettings b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/localtest.runsettings new file mode 100644 index 000000000..5c77569fb --- /dev/null +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/localtest.runsettings @@ -0,0 +1,8 @@ + + + + + appSettings.Development.json + + + From 5ce3a1306572da7eb39a0817524ded1e1e94b937 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Tue, 7 Nov 2023 18:05:17 +0900 Subject: [PATCH 055/110] =?UTF-8?q?runsettings=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E3=81=AE=E3=83=91=E3=82=B9=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index e23f23d5f..4123a13a2 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -105,7 +105,7 @@ jobs: - id: run-tests name: テストの実行 continue-on-error: true - run: dotnet test --settings:./citest.runsettings --no-build --logger trx --verbosity normal --configuration ${{ env.BUILD_CONFIGURATION }} --collect "XPlat Code Coverage" + run: dotnet test --settings:./Dressca.IntegrationTest/citest.runsettings --no-build --logger trx --verbosity normal --configuration ${{ env.BUILD_CONFIGURATION }} --collect "XPlat Code Coverage" - id: create-test-result-report name: テスト結果ページの作成 From 1c3812622f61d6346b91f63dc01b3fb50265039d Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Tue, 7 Nov 2023 18:09:01 +0900 Subject: [PATCH 056/110] =?UTF-8?q?runsettings=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E3=81=AE=E3=83=91=E3=82=B9=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 4123a13a2..d21b9cffc 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -105,7 +105,7 @@ jobs: - id: run-tests name: テストの実行 continue-on-error: true - run: dotnet test --settings:./Dressca.IntegrationTest/citest.runsettings --no-build --logger trx --verbosity normal --configuration ${{ env.BUILD_CONFIGURATION }} --collect "XPlat Code Coverage" + run: dotnet test --settings:./tests/Dressca.IntegrationTest/citest.runsettings --no-build --logger trx --verbosity normal --configuration ${{ env.BUILD_CONFIGURATION }} --collect "XPlat Code Coverage" - id: create-test-result-report name: テスト結果ページの作成 From 8ebcc14437e8f21246cffbf54c4bcde7a01648ad Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Tue, 7 Nov 2023 18:16:32 +0900 Subject: [PATCH 057/110] =?UTF-8?q?appsettings=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E3=81=AE=E3=83=87=E3=82=A3=E3=83=AC=E3=82=AF=E3=83=88?= =?UTF-8?q?=E3=83=AA=E3=82=92=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tests/Dressca.IntegrationTest/citest.runsettings | 2 +- .../tests/Dressca.IntegrationTest/localtest.runsettings | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/citest.runsettings b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/citest.runsettings index edf49af4d..090571e09 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/citest.runsettings +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/citest.runsettings @@ -2,7 +2,7 @@ - appSettings.json + ./appsettings.json diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/localtest.runsettings b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/localtest.runsettings index 5c77569fb..5f6265547 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/localtest.runsettings +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/localtest.runsettings @@ -2,7 +2,7 @@ - appSettings.Development.json + ./appsettings.Development.json From 5f798f46c8d93274253717afa785ee4195cf5e26 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Wed, 8 Nov 2023 09:06:23 +0900 Subject: [PATCH 058/110] =?UTF-8?q?=E3=83=91=E3=82=A4=E3=83=97=E3=83=A9?= =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=81=AB=E3=83=87=E3=83=BC=E3=82=BF=E3=83=99?= =?UTF-8?q?=E3=83=BC=E3=82=B9=E4=BD=9C=E6=88=90=E3=82=AF=E3=82=A8=E3=83=AA?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index d21b9cffc..f4edf27dd 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -101,6 +101,7 @@ jobs: --hostname sql1 \ -d \ mcr.microsoft.com/mssql/server:2022-latest + sudo docker exec -it sql1 /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P@ssw0rd" -Q "CREATE DATABASE Dressca.Eshop;" - id: run-tests name: テストの実行 From a8b263dba80479f912312a132cb64d137aa17d21 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Wed, 8 Nov 2023 09:09:32 +0900 Subject: [PATCH 059/110] =?UTF-8?q?=E3=83=91=E3=82=A4=E3=83=97=E3=83=A9?= =?UTF-8?q?=E3=82=A4=E3=83=B3=E4=B8=8A=E3=81=AE=E3=83=87=E3=83=BC=E3=82=BF?= =?UTF-8?q?=E3=83=99=E3=83=BC=E3=82=B9=E4=BD=9C=E6=88=90=E3=82=AF=E3=82=A8?= =?UTF-8?q?=E3=83=AA=E3=82=92=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index f4edf27dd..e03154592 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -101,7 +101,7 @@ jobs: --hostname sql1 \ -d \ mcr.microsoft.com/mssql/server:2022-latest - sudo docker exec -it sql1 /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P@ssw0rd" -Q "CREATE DATABASE Dressca.Eshop;" + sudo docker exec sql1 /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P@ssw0rd" -Q "CREATE DATABASE Dressca.Eshop;" - id: run-tests name: テストの実行 From 2071d8c2122e820a6fd94e0e8c9f307266444ab8 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Wed, 8 Nov 2023 09:13:16 +0900 Subject: [PATCH 060/110] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E7=94=A8?= =?UTF-8?q?=E3=83=87=E3=83=BC=E3=82=BF=E3=83=99=E3=83=BC=E3=82=B9=E5=90=8D?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index e03154592..7f236bdd7 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -101,7 +101,7 @@ jobs: --hostname sql1 \ -d \ mcr.microsoft.com/mssql/server:2022-latest - sudo docker exec sql1 /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P@ssw0rd" -Q "CREATE DATABASE Dressca.Eshop;" + sudo docker exec sql1 /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P@ssw0rd" -Q "CREATE DATABASE Dressca_Eshop;" - id: run-tests name: テストの実行 From 7228f7a35e7db695df34621c0274aee0315d7bdf Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Wed, 8 Nov 2023 09:29:57 +0900 Subject: [PATCH 061/110] =?UTF-8?q?runsettings=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E3=81=AE=E5=87=BA=E5=8A=9B=E8=A8=AD=E5=AE=9A=E3=82=92?= =?UTF-8?q?=E5=A4=89=E6=9B=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dressca.IntegrationTest/Dressca.IntegrationTest.csproj | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj index 2d0ca2dca..4c7d84198 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj @@ -34,6 +34,12 @@ Always + + Always + + + Always + From fe8442e6413961855198cb20f5d2e859aac0d6dc Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Wed, 8 Nov 2023 09:37:00 +0900 Subject: [PATCH 062/110] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E5=AE=9F?= =?UTF-8?q?=E8=A1=8C=E6=99=82=E3=81=AE--nobuild=E3=82=AA=E3=83=97=E3=82=B7?= =?UTF-8?q?=E3=83=A7=E3=83=B3=E3=82=92=E5=89=8A=E9=99=A4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 7f236bdd7..3f588fbcf 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -106,7 +106,7 @@ jobs: - id: run-tests name: テストの実行 continue-on-error: true - run: dotnet test --settings:./tests/Dressca.IntegrationTest/citest.runsettings --no-build --logger trx --verbosity normal --configuration ${{ env.BUILD_CONFIGURATION }} --collect "XPlat Code Coverage" + run: dotnet test --settings:./tests/Dressca.IntegrationTest/citest.runsettings --logger trx --verbosity normal --configuration ${{ env.BUILD_CONFIGURATION }} --collect "XPlat Code Coverage" - id: create-test-result-report name: テスト結果ページの作成 From 0d96b9883297876a621a4c9e9bad7ba5e101f079 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Wed, 8 Nov 2023 09:59:45 +0900 Subject: [PATCH 063/110] =?UTF-8?q?=E3=83=AD=E3=83=BC=E3=82=AB=E3=83=AB?= =?UTF-8?q?=E3=81=A7runsettings=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E3=82=92=E8=87=AA=E5=8B=95=E6=A4=9C=E5=87=BA=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E8=A8=AD=E5=AE=9A=E5=A4=89=E6=9B=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 2 +- .../Dressca.IntegrationTest/Dressca.IntegrationTest.csproj | 2 +- .../{appsettings.json => appsettings.citest.json} | 0 .../tests/Dressca.IntegrationTest/citest.runsettings | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/{appsettings.json => appsettings.citest.json} (100%) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 3f588fbcf..7f236bdd7 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -106,7 +106,7 @@ jobs: - id: run-tests name: テストの実行 continue-on-error: true - run: dotnet test --settings:./tests/Dressca.IntegrationTest/citest.runsettings --logger trx --verbosity normal --configuration ${{ env.BUILD_CONFIGURATION }} --collect "XPlat Code Coverage" + run: dotnet test --settings:./tests/Dressca.IntegrationTest/citest.runsettings --no-build --logger trx --verbosity normal --configuration ${{ env.BUILD_CONFIGURATION }} --collect "XPlat Code Coverage" - id: create-test-result-report name: テスト結果ページの作成 diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj index 4c7d84198..80429c05b 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj @@ -31,7 +31,7 @@ Always - + Always diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.json b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.citest.json similarity index 100% rename from samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.json rename to samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.citest.json diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/citest.runsettings b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/citest.runsettings index 090571e09..4b8c96261 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/citest.runsettings +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/citest.runsettings @@ -2,7 +2,7 @@ - ./appsettings.json + ./appsettings.citest.json From 61e92cf0f8aa6ada84571360f46a91c5d35e4b5d Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Wed, 8 Nov 2023 17:48:43 +0900 Subject: [PATCH 064/110] =?UTF-8?q?DresscaDbContext=E3=81=AE=E3=82=B5?= =?UTF-8?q?=E3=83=BC=E3=83=93=E3=82=B9=E7=99=BB=E9=8C=B2=E5=89=8A=E9=99=A4?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=82=92EfInfrastructure=E3=81=AB=E7=A7=BB?= =?UTF-8?q?=E5=8B=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EfInfrastructureServicesExtension.cs | 2 ++ .../CustomWebApplicationFactory.cs | 17 ----------------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/EfInfrastructureServicesExtension.cs b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/EfInfrastructureServicesExtension.cs index 1d885e665..90668d407 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/EfInfrastructureServicesExtension.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/EfInfrastructureServicesExtension.cs @@ -6,6 +6,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; namespace Dressca.EfInfrastructure; @@ -49,6 +50,7 @@ public static IServiceCollection AddDresscaEfInfrastructure(this IServiceCollect } // DbContext + services.RemoveAll>(); services.AddDbContext(option => { option.UseSqlServer(connectionString); diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs index 720e8ea64..11fefc189 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs @@ -15,32 +15,15 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) { builder.ConfigureServices(services => { - //var dbContextDescriptor = services.SingleOrDefault( - // d => d.ServiceType == - // typeof(DbContextOptions)); - - //services.Remove(dbContextDescriptor); - - //var dbConnectionDescriptor = services.SingleOrDefault( - // d => d.ServiceType == - // typeof(DbConnection)); - - //services.Remove(dbConnectionDescriptor); - var fileDirectory = Environment.GetEnvironmentVariable("appSettingsFileDirectory"); var config = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile(fileDirectory, optional: true, reloadOnChange: true) .Build(); - services.AddDresscaEfInfrastructure(config); - - //var dbContext = services.BuildServiceProvider().GetRequiredService(); - //dbContext.Database.EnsureCreated(); }); builder.UseEnvironment("Development"); - } } From 6da09305f2b786beef3ee6d021c574d7413df1c5 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Thu, 9 Nov 2023 09:59:46 +0900 Subject: [PATCH 065/110] =?UTF-8?q?Docker=E3=82=A4=E3=83=A1=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=81=AE=E3=82=AD=E3=83=A3=E3=83=83=E3=82=B7=E3=83=A5?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=82=92=E8=BF=BD=E5=8A=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workflows/samples-dressca-backend.ci.yml | 64 +++++++++---------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 7f236bdd7..c5cd0ba52 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -59,42 +59,40 @@ jobs: echo '# Build Result :gear:' >> $GITHUB_STEP_SUMMARY cat build-result.txt | sed -n -e 's/^/> /p' >> $GITHUB_STEP_SUMMARY - #- name: キャッシュIDの作成 - # id: imagetag - # run: | - # VARIANT=$(TZ=UTC-9 date '+%Y%m') - # # イメージのタグを作成 - # NAME_IMAGE=DockerImage - # TAG="${NAME_IMAGE}:${VARIANT}" - # # キャッシュする tar アーカイブ名とパスの設定 - # NAME_TAR="${NAME_IMAGE}.${VARIANT}.tar" - # PATH_TAR=${{ env.PATH_CACHE }}"/${NAME_TAR}" - # # 変数を他の run でも使えるように output - # echo "TAG=${TAG}" >> "$GITHUB_OUTPUT" - # echo "NAME_TAR=${NAME_TAR}" >> "$GITHUB_OUTPUT" - # echo "PATH_TAR=${PATH_TAR}" >> "$GITHUB_OUTPUT" - - #- name: キャッシュ有効化 - # id: cache - # uses: actions/cache@v3 - # with: - # path: ${{ env.PATH_CACHE }} - # key: ${{ steps.imagetag.outputs.TAG }} - - #- name: キャッシュがある場合にロード - # if: steps.cache.outputs.cache-hit == 'true' - # run: docker load --input ${{ steps.imagetag.outputs.PATH_TAR }} - - #- name: キャッシュがない場合にイメージを保存 - # if: steps.cache.outputs.cache-hit != 'true' - # run: | - # mkdir -p ${{ env.PATH_CACHE }} - # sudo docker pull mcr.microsoft.com/mssql/server:2022-latest - # sudo docker save mcr.microsoft.com/mssql/server:2022-latest -o ${{ steps.imagetag.outputs.PATH_TAR }} + - name: キャッシュIDの作成 + id: imagetag + run: | + VARIANT=$(TZ=UTC-9 date '+%Y%m') + # イメージのタグを作成 + NAME_IMAGE=SQLServerDockerImage + # キャッシュする tar アーカイブ名とパスの設定 + NAME_TAR="${NAME_IMAGE}.${VARIANT}.tar" + PATH_TAR=${{ env.PATH_CACHE }}"/${NAME_TAR}" + # 変数を他の run でも使えるように output + echo "NAME_TAR=${NAME_TAR}" >> "$GITHUB_OUTPUT" + echo "PATH_TAR=${PATH_TAR}" >> "$GITHUB_OUTPUT" + + - name: キャッシュ有効化 + id: cache + uses: actions/cache@v3 + with: + path: ${{ env.PATH_CACHE }} + key: ${{ steps.imagetag.outputs.NAME }} - - name: 結合テスト用にSQL Serverをセットアップ + - name: キャッシュがある場合にロード + if: steps.cache.outputs.cache-hit == 'true' + run: docker load --input ${{ steps.imagetag.outputs.PATH_TAR }} + + - name: キャッシュがない場合にイメージを保存 + if: steps.cache.outputs.cache-hit != 'true' run: | + mkdir -p ${{ env.PATH_CACHE }} sudo docker pull mcr.microsoft.com/mssql/server:2022-latest + sudo docker save mcr.microsoft.com/mssql/server:2022-latest -o ${{ steps.imagetag.outputs.PATH_TAR }} + + - name: 結合テスト用にSQL Serverをセットアップ + run: | + #sudo docker pull mcr.microsoft.com/mssql/server:2022-latest sudo docker run -e "ACCEPT_EULA=Y" \ -e "MSSQL_SA_PASSWORD=P@ssw0rd" \ -p 1433:1433 --name sql1 \ From 5d2eba526c9840c7b45dfdc2caf0b553847573a9 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Thu, 9 Nov 2023 10:30:36 +0900 Subject: [PATCH 066/110] =?UTF-8?q?=E3=82=AD=E3=83=A3=E3=83=83=E3=82=B7?= =?UTF-8?q?=E3=83=A5=E3=81=AE=E3=82=AD=E3=83=BC=E3=82=92=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index c5cd0ba52..cfd50a48d 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -77,7 +77,7 @@ jobs: uses: actions/cache@v3 with: path: ${{ env.PATH_CACHE }} - key: ${{ steps.imagetag.outputs.NAME }} + key: ${{ steps.imagetag.outputs.NAME_TAR }} - name: キャッシュがある場合にロード if: steps.cache.outputs.cache-hit == 'true' From acf7933e61592a0d814fc5e5ab5d019988c0bc04 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Thu, 9 Nov 2023 10:50:49 +0900 Subject: [PATCH 067/110] =?UTF-8?q?=E3=82=AF=E3=82=A8=E3=83=AA=E9=83=A8?= =?UTF-8?q?=E5=88=86=E3=82=92=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88=E3=82=A2?= =?UTF-8?q?=E3=82=A6=E3=83=88=E3=81=97=E3=81=A6=E5=8B=95=E4=BD=9C=E7=A2=BA?= =?UTF-8?q?=E8=AA=8D=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index cfd50a48d..dac07e50b 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -99,7 +99,7 @@ jobs: --hostname sql1 \ -d \ mcr.microsoft.com/mssql/server:2022-latest - sudo docker exec sql1 /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P@ssw0rd" -Q "CREATE DATABASE Dressca_Eshop;" + #sudo docker exec sql1 /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P@ssw0rd" -Q "CREATE DATABASE Dressca_Eshop;" - id: run-tests name: テストの実行 From 01d2ebf15bb6e588a04a2e1a60581ebe67f52907 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Thu, 9 Nov 2023 11:13:07 +0900 Subject: [PATCH 068/110] =?UTF-8?q?=E3=82=AF=E3=82=A8=E3=83=AA=E3=81=AE?= =?UTF-8?q?=E3=82=B5=E3=83=BC=E3=83=90=E3=83=BC=E5=90=8D=E3=82=92=E5=A4=89?= =?UTF-8?q?=E6=9B=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index dac07e50b..f539d67d1 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -99,7 +99,7 @@ jobs: --hostname sql1 \ -d \ mcr.microsoft.com/mssql/server:2022-latest - #sudo docker exec sql1 /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P@ssw0rd" -Q "CREATE DATABASE Dressca_Eshop;" + sudo docker exec sql1 /opt/mssql-tools/bin/sqlcmd -S 127.0.0.1,1433 -U SA -P "P@ssw0rd" -Q "CREATE DATABASE Dressca_Eshop;" - id: run-tests name: テストの実行 From 508fb40ee98f9de136bbc4eff8f4119b00c85fa0 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Thu, 9 Nov 2023 11:42:18 +0900 Subject: [PATCH 069/110] =?UTF-8?q?=E3=82=AD=E3=83=A3=E3=83=83=E3=82=B7?= =?UTF-8?q?=E3=83=A5=E4=BF=9D=E5=AD=98=E3=81=AE=E5=87=A6=E7=90=86=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index f539d67d1..51ac61d75 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -83,13 +83,21 @@ jobs: if: steps.cache.outputs.cache-hit == 'true' run: docker load --input ${{ steps.imagetag.outputs.PATH_TAR }} - - name: キャッシュがない場合にイメージを保存 + - name: キャッシュがない場合にイメージをプル if: steps.cache.outputs.cache-hit != 'true' run: | mkdir -p ${{ env.PATH_CACHE }} sudo docker pull mcr.microsoft.com/mssql/server:2022-latest sudo docker save mcr.microsoft.com/mssql/server:2022-latest -o ${{ steps.imagetag.outputs.PATH_TAR }} + - name: キャッシュの保存 + if: steps.cache.outputs.cache-hit != 'true' + id: cache + uses: actions/cache/save@v3 + with: + path: ${{ env.PATH_CACHE }} + key: ${{ steps.imagetag.outputs.NAME_TAR }} + - name: 結合テスト用にSQL Serverをセットアップ run: | #sudo docker pull mcr.microsoft.com/mssql/server:2022-latest @@ -99,7 +107,7 @@ jobs: --hostname sql1 \ -d \ mcr.microsoft.com/mssql/server:2022-latest - sudo docker exec sql1 /opt/mssql-tools/bin/sqlcmd -S 127.0.0.1,1433 -U SA -P "P@ssw0rd" -Q "CREATE DATABASE Dressca_Eshop;" + sudo docker exec sql1 /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P@ssw0rd" -Q "CREATE DATABASE Dressca_Eshop;" - id: run-tests name: テストの実行 From efb5e78d5601c8d632e4bd18670d2b83ca4a9ff1 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Thu, 9 Nov 2023 13:30:07 +0900 Subject: [PATCH 070/110] =?UTF-8?q?=E3=83=87=E3=83=BC=E3=82=BF=E3=83=99?= =?UTF-8?q?=E3=83=BC=E3=82=B9=E4=BD=9C=E6=88=90=E3=82=AF=E3=82=A8=E3=83=AA?= =?UTF-8?q?=E3=82=92=E5=AE=9F=E8=A1=8C=E3=81=97=E3=81=A6=E3=81=8B=E3=82=89?= =?UTF-8?q?=E3=82=AD=E3=83=A3=E3=83=83=E3=82=B7=E3=83=A5=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workflows/samples-dressca-backend.ci.yml | 28 +++++++------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 51ac61d75..7600e220f 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -63,7 +63,6 @@ jobs: id: imagetag run: | VARIANT=$(TZ=UTC-9 date '+%Y%m') - # イメージのタグを作成 NAME_IMAGE=SQLServerDockerImage # キャッシュする tar アーカイブ名とパスの設定 NAME_TAR="${NAME_IMAGE}.${VARIANT}.tar" @@ -79,28 +78,15 @@ jobs: path: ${{ env.PATH_CACHE }} key: ${{ steps.imagetag.outputs.NAME_TAR }} - - name: キャッシュがある場合にロード - if: steps.cache.outputs.cache-hit == 'true' - run: docker load --input ${{ steps.imagetag.outputs.PATH_TAR }} + #- name: キャッシュがある場合にロード + # if: steps.cache.outputs.cache-hit == 'true' + # run: docker load --input ${{ steps.imagetag.outputs.PATH_TAR }} - - name: キャッシュがない場合にイメージをプル + - name: キャッシュがない場合にイメージをプルして保存 if: steps.cache.outputs.cache-hit != 'true' run: | mkdir -p ${{ env.PATH_CACHE }} sudo docker pull mcr.microsoft.com/mssql/server:2022-latest - sudo docker save mcr.microsoft.com/mssql/server:2022-latest -o ${{ steps.imagetag.outputs.PATH_TAR }} - - - name: キャッシュの保存 - if: steps.cache.outputs.cache-hit != 'true' - id: cache - uses: actions/cache/save@v3 - with: - path: ${{ env.PATH_CACHE }} - key: ${{ steps.imagetag.outputs.NAME_TAR }} - - - name: 結合テスト用にSQL Serverをセットアップ - run: | - #sudo docker pull mcr.microsoft.com/mssql/server:2022-latest sudo docker run -e "ACCEPT_EULA=Y" \ -e "MSSQL_SA_PASSWORD=P@ssw0rd" \ -p 1433:1433 --name sql1 \ @@ -108,6 +94,12 @@ jobs: -d \ mcr.microsoft.com/mssql/server:2022-latest sudo docker exec sql1 /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P@ssw0rd" -Q "CREATE DATABASE Dressca_Eshop;" + sudo docker save mcr.microsoft.com/mssql/server:2022-latest -o ${{ steps.imagetag.outputs.PATH_TAR }} + + - name: 結合テスト用にSQL Serverをセットアップ + run: | + sudo docker load --input ${{ steps.imagetag.outputs.PATH_TAR }} + sudo docker run - id: run-tests name: テストの実行 From d41349978a38908c8dddf4997a50c62f6c4bcc11 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Thu, 9 Nov 2023 13:40:51 +0900 Subject: [PATCH 071/110] =?UTF-8?q?=E3=82=B3=E3=83=9E=E3=83=B3=E3=83=89?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 7600e220f..34eaad0c5 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -99,7 +99,7 @@ jobs: - name: 結合テスト用にSQL Serverをセットアップ run: | sudo docker load --input ${{ steps.imagetag.outputs.PATH_TAR }} - sudo docker run + sudo docker run mcr.microsoft.com/mssql/server:2022-latest - id: run-tests name: テストの実行 From 5c8bccab62be8e81bedcaffd59863ec5d0c226c0 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Thu, 9 Nov 2023 13:46:09 +0900 Subject: [PATCH 072/110] =?UTF-8?q?SQL=20Server=E3=82=BB=E3=83=83=E3=83=88?= =?UTF-8?q?=E3=82=A2=E3=83=83=E3=83=97=E5=87=A6=E7=90=86=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 34eaad0c5..d29bb4705 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -99,7 +99,12 @@ jobs: - name: 結合テスト用にSQL Serverをセットアップ run: | sudo docker load --input ${{ steps.imagetag.outputs.PATH_TAR }} - sudo docker run mcr.microsoft.com/mssql/server:2022-latest + sudo docker run mcr.microsoft.com/mssql/server:2022-latest -e "ACCEPT_EULA=Y" \ + -e "MSSQL_SA_PASSWORD=P@ssw0rd" \ + -p 1433:1433 --name sql1 \ + --hostname sql1 \ + -d \ + mcr.microsoft.com/mssql/server:2022-latest - id: run-tests name: テストの実行 From 0c8a0d621743b41447081326ee03f8ca14254122 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Thu, 9 Nov 2023 13:50:31 +0900 Subject: [PATCH 073/110] =?UTF-8?q?SQL=20Server=E3=81=AE=E3=82=BB=E3=83=83?= =?UTF-8?q?=E3=83=88=E3=82=A2=E3=83=83=E3=83=97=E5=87=A6=E7=90=86=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index d29bb4705..aa4368633 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -99,7 +99,7 @@ jobs: - name: 結合テスト用にSQL Serverをセットアップ run: | sudo docker load --input ${{ steps.imagetag.outputs.PATH_TAR }} - sudo docker run mcr.microsoft.com/mssql/server:2022-latest -e "ACCEPT_EULA=Y" \ + sudo docker run -e "ACCEPT_EULA=Y" \ -e "MSSQL_SA_PASSWORD=P@ssw0rd" \ -p 1433:1433 --name sql1 \ --hostname sql1 \ From 902d0ae4b8468484bc6a828992213411a6a654c0 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Thu, 9 Nov 2023 18:17:32 +0900 Subject: [PATCH 074/110] =?UTF-8?q?=E7=92=B0=E5=A2=83=E5=A4=89=E6=95=B0?= =?UTF-8?q?=E3=81=8C=E6=9C=89=E5=8A=B9=E3=81=8B=E7=A2=BA=E8=AA=8D=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workflows/samples-dressca-backend.ci.yml | 36 ++----------------- .../EfInfrastructureServicesExtension.cs | 1 + .../CustomWebApplicationFactory.cs | 22 +++++++----- .../Dressca.IntegrationTest.csproj | 2 +- ...ttings.citest.json => appsettings.CI.json} | 0 .../citest.runsettings | 2 +- .../localtest.runsettings | 2 +- 7 files changed, 21 insertions(+), 44 deletions(-) rename samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/{appsettings.citest.json => appsettings.CI.json} (100%) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index aa4368633..04763c8e0 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -14,6 +14,7 @@ on: env: WORKING_DIRECTORY: samples/Dressca/dressca-backend PATH_CACHE: /tmp/docker-img + ASPNETCORE_ENVIRONMENT: CI defaults: run: @@ -59,30 +60,7 @@ jobs: echo '# Build Result :gear:' >> $GITHUB_STEP_SUMMARY cat build-result.txt | sed -n -e 's/^/> /p' >> $GITHUB_STEP_SUMMARY - - name: キャッシュIDの作成 - id: imagetag - run: | - VARIANT=$(TZ=UTC-9 date '+%Y%m') - NAME_IMAGE=SQLServerDockerImage - # キャッシュする tar アーカイブ名とパスの設定 - NAME_TAR="${NAME_IMAGE}.${VARIANT}.tar" - PATH_TAR=${{ env.PATH_CACHE }}"/${NAME_TAR}" - # 変数を他の run でも使えるように output - echo "NAME_TAR=${NAME_TAR}" >> "$GITHUB_OUTPUT" - echo "PATH_TAR=${PATH_TAR}" >> "$GITHUB_OUTPUT" - - - name: キャッシュ有効化 - id: cache - uses: actions/cache@v3 - with: - path: ${{ env.PATH_CACHE }} - key: ${{ steps.imagetag.outputs.NAME_TAR }} - - #- name: キャッシュがある場合にロード - # if: steps.cache.outputs.cache-hit == 'true' - # run: docker load --input ${{ steps.imagetag.outputs.PATH_TAR }} - - - name: キャッシュがない場合にイメージをプルして保存 + - name: 結合テスト用にSQL ServerのDockerイメージをプル if: steps.cache.outputs.cache-hit != 'true' run: | mkdir -p ${{ env.PATH_CACHE }} @@ -94,22 +72,14 @@ jobs: -d \ mcr.microsoft.com/mssql/server:2022-latest sudo docker exec sql1 /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P@ssw0rd" -Q "CREATE DATABASE Dressca_Eshop;" - sudo docker save mcr.microsoft.com/mssql/server:2022-latest -o ${{ steps.imagetag.outputs.PATH_TAR }} - name: 結合テスト用にSQL Serverをセットアップ run: | - sudo docker load --input ${{ steps.imagetag.outputs.PATH_TAR }} - sudo docker run -e "ACCEPT_EULA=Y" \ - -e "MSSQL_SA_PASSWORD=P@ssw0rd" \ - -p 1433:1433 --name sql1 \ - --hostname sql1 \ - -d \ - mcr.microsoft.com/mssql/server:2022-latest - id: run-tests name: テストの実行 continue-on-error: true - run: dotnet test --settings:./tests/Dressca.IntegrationTest/citest.runsettings --no-build --logger trx --verbosity normal --configuration ${{ env.BUILD_CONFIGURATION }} --collect "XPlat Code Coverage" + run: dotnet test --no-build --logger trx --verbosity normal --configuration ${{ env.BUILD_CONFIGURATION }} --collect "XPlat Code Coverage" - id: create-test-result-report name: テスト結果ページの作成 diff --git a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/EfInfrastructureServicesExtension.cs b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/EfInfrastructureServicesExtension.cs index 90668d407..f8d388ad1 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/EfInfrastructureServicesExtension.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure/EfInfrastructureServicesExtension.cs @@ -50,6 +50,7 @@ public static IServiceCollection AddDresscaEfInfrastructure(this IServiceCollect } // DbContext + // 結合テスト実行時に設定を差し替えるため、サービス登録をいったん削除してから登録 services.RemoveAll>(); services.AddDbContext(option => { diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs index 11fefc189..7dfb23e1a 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs @@ -1,11 +1,7 @@ -using System.Data.Common; -using Dressca.EfInfrastructure; -using Microsoft.AspNetCore.Builder; +using Dressca.EfInfrastructure; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc.Testing; -using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; namespace Dressca.IntegrationTest; public class CustomWebApplicationFactory @@ -13,17 +9,27 @@ public class CustomWebApplicationFactory { protected override void ConfigureWebHost(IWebHostBuilder builder) { + var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Development"; + + //var webhostenv = builder.GetSetting("environment"); + //builder.UseEnvironment("Development"); + builder.ConfigureServices(services => { - var fileDirectory = Environment.GetEnvironmentVariable("appSettingsFileDirectory"); + //var filePath = Environment.GetEnvironmentVariable("appSettingsFilePath"); + //var config = new ConfigurationBuilder() + // .SetBasePath(Directory.GetCurrentDirectory()) + // .AddJsonFile(filePath, optional: true, reloadOnChange: true) + // .Build(); + var config = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile(fileDirectory, optional: true, reloadOnChange: true) + .AddJsonFile($"appsettings.{env}.json", optional: true, reloadOnChange: true) + .AddEnvironmentVariables() .Build(); services.AddDresscaEfInfrastructure(config); }); - builder.UseEnvironment("Development"); } } diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj index 80429c05b..850a26f9b 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj @@ -31,7 +31,7 @@ Always - + Always diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.citest.json b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.CI.json similarity index 100% rename from samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.citest.json rename to samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.CI.json diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/citest.runsettings b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/citest.runsettings index 4b8c96261..05c242cee 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/citest.runsettings +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/citest.runsettings @@ -2,7 +2,7 @@ - ./appsettings.citest.json + ./appsettings.citest.json diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/localtest.runsettings b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/localtest.runsettings index 5f6265547..ac58e7a9b 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/localtest.runsettings +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/localtest.runsettings @@ -2,7 +2,7 @@ - ./appsettings.Development.json + ./appsettings.Development.json From 194397e3060e05e40e872b59e364cdba6f9568ed Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Thu, 9 Nov 2023 18:24:39 +0900 Subject: [PATCH 075/110] =?UTF-8?q?=E5=8B=95=E4=BD=9C=E7=A2=BA=E8=AA=8D?= =?UTF-8?q?=E7=94=A8=E3=81=AB=E4=B8=8D=E8=A6=81=E3=81=AA=E8=A8=98=E8=BC=89?= =?UTF-8?q?=E3=82=92=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88=E3=82=A2=E3=82=A6?= =?UTF-8?q?=E3=83=88=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workflows/samples-dressca-backend.ci.yml | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 04763c8e0..8865956bd 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -13,7 +13,6 @@ on: env: WORKING_DIRECTORY: samples/Dressca/dressca-backend - PATH_CACHE: /tmp/docker-img ASPNETCORE_ENVIRONMENT: CI defaults: @@ -60,21 +59,19 @@ jobs: echo '# Build Result :gear:' >> $GITHUB_STEP_SUMMARY cat build-result.txt | sed -n -e 's/^/> /p' >> $GITHUB_STEP_SUMMARY - - name: 結合テスト用にSQL ServerのDockerイメージをプル - if: steps.cache.outputs.cache-hit != 'true' - run: | - mkdir -p ${{ env.PATH_CACHE }} - sudo docker pull mcr.microsoft.com/mssql/server:2022-latest - sudo docker run -e "ACCEPT_EULA=Y" \ - -e "MSSQL_SA_PASSWORD=P@ssw0rd" \ - -p 1433:1433 --name sql1 \ - --hostname sql1 \ - -d \ - mcr.microsoft.com/mssql/server:2022-latest - sudo docker exec sql1 /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P@ssw0rd" -Q "CREATE DATABASE Dressca_Eshop;" - - - name: 結合テスト用にSQL Serverをセットアップ - run: | + #- name: 結合テスト用にSQL ServerのDockerイメージをプル + # run: | + # sudo docker pull mcr.microsoft.com/mssql/server:2022-latest + # sudo docker run -e "ACCEPT_EULA=Y" \ + # -e "MSSQL_SA_PASSWORD=P@ssw0rd" \ + # -p 1433:1433 --name sql1 \ + # --hostname sql1 \ + # -d \ + # mcr.microsoft.com/mssql/server:2022-latest + # sudo docker exec sql1 /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P@ssw0rd" -Q "CREATE DATABASE Dressca_Eshop;" + + #- name: 結合テスト用にSQL Serverをセットアップ + # run: | - id: run-tests name: テストの実行 From 684c19af4b962dd34c73c233c6491773c92e10b3 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Thu, 9 Nov 2023 18:33:38 +0900 Subject: [PATCH 076/110] =?UTF-8?q?=E7=92=B0=E5=A2=83=E5=A4=89=E6=95=B0?= =?UTF-8?q?=E3=81=AE=E8=A8=AD=E5=AE=9A=E4=BD=8D=E7=BD=AE=E3=82=92=E5=A4=89?= =?UTF-8?q?=E6=9B=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 8865956bd..b22cd659f 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -13,7 +13,6 @@ on: env: WORKING_DIRECTORY: samples/Dressca/dressca-backend - ASPNETCORE_ENVIRONMENT: CI defaults: run: @@ -76,6 +75,8 @@ jobs: - id: run-tests name: テストの実行 continue-on-error: true + env: + ASPNETCORE_ENVIRONMENT: CI run: dotnet test --no-build --logger trx --verbosity normal --configuration ${{ env.BUILD_CONFIGURATION }} --collect "XPlat Code Coverage" - id: create-test-result-report From fd7d0547179ebcc664ea355d0202d91d8ca11cc2 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Thu, 9 Nov 2023 18:44:27 +0900 Subject: [PATCH 077/110] =?UTF-8?q?=E9=81=A9=E5=BD=93=E3=81=AA=E7=92=B0?= =?UTF-8?q?=E5=A2=83=E5=A4=89=E6=95=B0=E5=90=8D=E3=81=A7=E5=8B=95=E4=BD=9C?= =?UTF-8?q?=E7=A2=BA=E8=AA=8D=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 2 +- .../Dressca.IntegrationTest/CustomWebApplicationFactory.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index b22cd659f..68130aa84 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -76,7 +76,7 @@ jobs: name: テストの実行 continue-on-error: true env: - ASPNETCORE_ENVIRONMENT: CI + TEST_ENVIRONMENT: CI run: dotnet test --no-build --logger trx --verbosity normal --configuration ${{ env.BUILD_CONFIGURATION }} --collect "XPlat Code Coverage" - id: create-test-result-report diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs index 7dfb23e1a..f38860110 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs @@ -9,7 +9,7 @@ public class CustomWebApplicationFactory { protected override void ConfigureWebHost(IWebHostBuilder builder) { - var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Development"; + var env = Environment.GetEnvironmentVariable("TEST_ENVIRONMENT") ?? "Development"; //var webhostenv = builder.GetSetting("environment"); //builder.UseEnvironment("Development"); From ac4014db097235339585f26032c1d2c89321048e Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Thu, 9 Nov 2023 18:59:16 +0900 Subject: [PATCH 078/110] =?UTF-8?q?bash=E3=81=A7=E7=92=B0=E5=A2=83?= =?UTF-8?q?=E5=A4=89=E6=95=B0=E3=82=92=E8=A8=AD=E5=AE=9A=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 68130aa84..e311e3e52 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -75,9 +75,9 @@ jobs: - id: run-tests name: テストの実行 continue-on-error: true - env: - TEST_ENVIRONMENT: CI - run: dotnet test --no-build --logger trx --verbosity normal --configuration ${{ env.BUILD_CONFIGURATION }} --collect "XPlat Code Coverage" + run: | + set TEST_ENVIRONMENT=CI + dotnet test --no-build --logger trx --verbosity normal --configuration ${{ env.BUILD_CONFIGURATION }} --collect "XPlat Code Coverage" - id: create-test-result-report name: テスト結果ページの作成 From 2766fef7d6b56f1e2f146ab1ee7a53398753c533 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Thu, 9 Nov 2023 19:02:45 +0900 Subject: [PATCH 079/110] =?UTF-8?q?=E3=82=B3=E3=83=9E=E3=83=B3=E3=83=89?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index e311e3e52..fc151dc3c 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -76,7 +76,7 @@ jobs: name: テストの実行 continue-on-error: true run: | - set TEST_ENVIRONMENT=CI + export TEST_ENVIRONMENT=CI dotnet test --no-build --logger trx --verbosity normal --configuration ${{ env.BUILD_CONFIGURATION }} --collect "XPlat Code Coverage" - id: create-test-result-report From 80969218c7e61d3513e5b9639e77e141e3568878 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Fri, 10 Nov 2023 09:05:06 +0900 Subject: [PATCH 080/110] =?UTF-8?q?=E3=83=9E=E3=82=A4=E3=82=B0=E3=83=AC?= =?UTF-8?q?=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3=E9=81=A9=E7=94=A8=E3=81=AE?= =?UTF-8?q?=E3=82=BF=E3=82=B9=E3=82=AF=E3=82=92=E8=BF=BD=E5=8A=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workflows/samples-dressca-backend.ci.yml | 29 ++++++++++--------- .../CustomWebApplicationFactory.cs | 9 ------ .../Dressca.IntegrationTest.csproj | 6 ---- .../citest.runsettings | 8 ----- .../localtest.runsettings | 8 ----- 5 files changed, 16 insertions(+), 44 deletions(-) delete mode 100644 samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/citest.runsettings delete mode 100644 samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/localtest.runsettings diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index fc151dc3c..1b818a6bf 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -58,19 +58,22 @@ jobs: echo '# Build Result :gear:' >> $GITHUB_STEP_SUMMARY cat build-result.txt | sed -n -e 's/^/> /p' >> $GITHUB_STEP_SUMMARY - #- name: 結合テスト用にSQL ServerのDockerイメージをプル - # run: | - # sudo docker pull mcr.microsoft.com/mssql/server:2022-latest - # sudo docker run -e "ACCEPT_EULA=Y" \ - # -e "MSSQL_SA_PASSWORD=P@ssw0rd" \ - # -p 1433:1433 --name sql1 \ - # --hostname sql1 \ - # -d \ - # mcr.microsoft.com/mssql/server:2022-latest - # sudo docker exec sql1 /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P@ssw0rd" -Q "CREATE DATABASE Dressca_Eshop;" - - #- name: 結合テスト用にSQL Serverをセットアップ - # run: | + - name: 結合テスト用にSQL ServerのDockerイメージをプル + run: | + sudo docker pull mcr.microsoft.com/mssql/server:2022-latest + sudo docker run -e "ACCEPT_EULA=Y" \ + -e "MSSQL_SA_PASSWORD=P@ssw0rd" \ + -p 1433:1433 --name sql1 \ + --hostname sql1 \ + -d mcr.microsoft.com/mssql/server:2022-latest + #sudo docker exec sql1 /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P@ssw0rd" -Q "CREATE DATABASE Dressca_Eshop;" + + - name: 結合テスト用にマイグレーション適用 + working-directory: samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure + shell: bash + run: | + dotnet tool install --global dotnet-ef + dotnet ef database update --connection "Server=localhost,1433;Database=Dressca_Eshop;User=sa;Password=P@ssw0rd;" - id: run-tests name: テストの実行 diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs index f38860110..a39014219 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs @@ -11,17 +11,8 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) { var env = Environment.GetEnvironmentVariable("TEST_ENVIRONMENT") ?? "Development"; - //var webhostenv = builder.GetSetting("environment"); - //builder.UseEnvironment("Development"); - builder.ConfigureServices(services => { - //var filePath = Environment.GetEnvironmentVariable("appSettingsFilePath"); - //var config = new ConfigurationBuilder() - // .SetBasePath(Directory.GetCurrentDirectory()) - // .AddJsonFile(filePath, optional: true, reloadOnChange: true) - // .Build(); - var config = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile($"appsettings.{env}.json", optional: true, reloadOnChange: true) diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj index 850a26f9b..07db9b9f7 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj @@ -34,12 +34,6 @@ Always - - Always - - - Always - diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/citest.runsettings b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/citest.runsettings deleted file mode 100644 index 05c242cee..000000000 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/citest.runsettings +++ /dev/null @@ -1,8 +0,0 @@ - - - - - ./appsettings.citest.json - - - diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/localtest.runsettings b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/localtest.runsettings deleted file mode 100644 index ac58e7a9b..000000000 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/localtest.runsettings +++ /dev/null @@ -1,8 +0,0 @@ - - - - - ./appsettings.Development.json - - - From 302e9b9f3c67af71326e3fcf623617df28778c34 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Fri, 10 Nov 2023 09:45:58 +0900 Subject: [PATCH 081/110] =?UTF-8?q?=E6=8E=A5=E7=B6=9A=E6=96=87=E5=AD=97?= =?UTF-8?q?=E5=88=97=E3=82=92appsettings=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E3=81=8B=E3=82=89=E5=8F=96=E5=BE=97=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 1b818a6bf..8d4be9648 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -69,11 +69,14 @@ jobs: #sudo docker exec sql1 /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P@ssw0rd" -Q "CREATE DATABASE Dressca_Eshop;" - name: 結合テスト用にマイグレーション適用 - working-directory: samples/Dressca/dressca-backend/src/Dressca.EfInfrastructure + working-directory: ${{ env.WORKING_DIRECTORY }}/src/Dressca.EfInfrastructure shell: bash + env: + APPSETTINGS_FILEPATH: ${{ env.WORKING_DIRECTORY }}/tests/Dressca.IntegrationTest/appsettings.CI.json run: | dotnet tool install --global dotnet-ef - dotnet ef database update --connection "Server=localhost,1433;Database=Dressca_Eshop;User=sa;Password=P@ssw0rd;" + connectionString=$(cat ${{env.APPSETTINGS_FILEPATH}} | jq '.ConnectionStrings[].DresscaDbContext') + dotnet ef database update --connection $connectionString - id: run-tests name: テストの実行 From 22e44595695b0ab333cf259091b8d6d84ccb7bbe Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Fri, 10 Nov 2023 09:55:43 +0900 Subject: [PATCH 082/110] =?UTF-8?q?appsettings=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E3=81=AE=E3=83=93=E3=83=AB=E3=83=89=E3=82=A2=E3=82=AF?= =?UTF-8?q?=E3=82=B7=E3=83=A7=E3=83=B3=E3=82=92=E5=A4=89=E6=9B=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dressca.IntegrationTest.csproj | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj index 07db9b9f7..25672284a 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj @@ -8,6 +8,20 @@ false + + + + + + + + Always + + + Always + + + @@ -27,13 +41,4 @@ - - - Always - - - Always - - - From b4b3897ee4f6b5dd3103d7e3a13c96a0d833f24f Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Fri, 10 Nov 2023 10:02:47 +0900 Subject: [PATCH 083/110] =?UTF-8?q?appsettings=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E3=81=AE=E3=83=91=E3=82=B9=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 8d4be9648..9002b004c 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -72,7 +72,7 @@ jobs: working-directory: ${{ env.WORKING_DIRECTORY }}/src/Dressca.EfInfrastructure shell: bash env: - APPSETTINGS_FILEPATH: ${{ env.WORKING_DIRECTORY }}/tests/Dressca.IntegrationTest/appsettings.CI.json + APPSETTINGS_FILEPATH: ../../tests/Dressca.IntegrationTest/appsettings.CI.json run: | dotnet tool install --global dotnet-ef connectionString=$(cat ${{env.APPSETTINGS_FILEPATH}} | jq '.ConnectionStrings[].DresscaDbContext') From 33eaf8e909075ab0093d680a20e3abfdfe003cf2 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Fri, 10 Nov 2023 10:09:36 +0900 Subject: [PATCH 084/110] =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E3=83=91=E3=82=B9=E3=82=92=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 9002b004c..1204a636f 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -75,7 +75,7 @@ jobs: APPSETTINGS_FILEPATH: ../../tests/Dressca.IntegrationTest/appsettings.CI.json run: | dotnet tool install --global dotnet-ef - connectionString=$(cat ${{env.APPSETTINGS_FILEPATH}} | jq '.ConnectionStrings[].DresscaDbContext') + connectionString=$(cat ${{env.APPSETTINGS_FILEPATH}} | jq '.ConnectionStrings.DresscaDbContext') dotnet ef database update --connection $connectionString - id: run-tests From a68eadb5fa272eb500372bcc56578912b45f6870 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Fri, 10 Nov 2023 10:19:14 +0900 Subject: [PATCH 085/110] =?UTF-8?q?=E6=8E=A5=E7=B6=9A=E6=96=87=E5=AD=97?= =?UTF-8?q?=E5=88=97=E3=82=92=E5=8F=96=E5=BE=97=E3=81=99=E3=82=8B=E5=87=A6?= =?UTF-8?q?=E7=90=86=E3=82=92=E5=88=A5=E3=82=BF=E3=82=B9=E3=82=AF=E3=81=AB?= =?UTF-8?q?=E5=88=86=E9=9B=A2=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workflows/samples-dressca-backend.ci.yml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 1204a636f..4a054794c 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -27,6 +27,7 @@ jobs: DOTNET_CLI_TELEMETRY_OPTOUT: true BUILD_CONFIGURATION: Debug BUILD_SUMMARY_FILE: BuildSummary.md + TEST_ENVIRONMENT: CI permissions: checks: write contents: read @@ -66,23 +67,27 @@ jobs: -p 1433:1433 --name sql1 \ --hostname sql1 \ -d mcr.microsoft.com/mssql/server:2022-latest - #sudo docker exec sql1 /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P@ssw0rd" -Q "CREATE DATABASE Dressca_Eshop;" + + - name: 結合テスト用データベース接続文字列を取得 + id: get-connection-string + env: + APPSETTINGS_FILEPATH: ${{ env.WORKING_DIRECTORY }}/tests/Dressca.IntegrationTest/appsettings.${{ env.TEST_ENVIRONMENT }}.json + run: | + connectionString=$(cat ${{env.APPSETTINGS_FILEPATH}} | jq '.ConnectionStrings.DresscaDbContext') + echo "CONNECTION_STRING=${connectionString}" >> "$GITHUB_OUTPUT" - name: 結合テスト用にマイグレーション適用 working-directory: ${{ env.WORKING_DIRECTORY }}/src/Dressca.EfInfrastructure shell: bash - env: - APPSETTINGS_FILEPATH: ../../tests/Dressca.IntegrationTest/appsettings.CI.json run: | dotnet tool install --global dotnet-ef - connectionString=$(cat ${{env.APPSETTINGS_FILEPATH}} | jq '.ConnectionStrings.DresscaDbContext') - dotnet ef database update --connection $connectionString + dotnet ef database update --connection ${{ steps.get-connection-string.outputs.CONNECTION_STRING }} - id: run-tests name: テストの実行 continue-on-error: true run: | - export TEST_ENVIRONMENT=CI + export TEST_ENVIRONMENT=${{ env.TEST_ENVIRONMENT }} dotnet test --no-build --logger trx --verbosity normal --configuration ${{ env.BUILD_CONFIGURATION }} --collect "XPlat Code Coverage" - id: create-test-result-report From 779cdae14de9903c2901d9f68f38ae64ff05a3b0 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Fri, 10 Nov 2023 10:23:20 +0900 Subject: [PATCH 086/110] =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E3=83=91=E3=82=B9=E3=82=92=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 4a054794c..39342245b 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -71,7 +71,7 @@ jobs: - name: 結合テスト用データベース接続文字列を取得 id: get-connection-string env: - APPSETTINGS_FILEPATH: ${{ env.WORKING_DIRECTORY }}/tests/Dressca.IntegrationTest/appsettings.${{ env.TEST_ENVIRONMENT }}.json + APPSETTINGS_FILEPATH: tests/Dressca.IntegrationTest/appsettings.${{ env.TEST_ENVIRONMENT }}.json run: | connectionString=$(cat ${{env.APPSETTINGS_FILEPATH}} | jq '.ConnectionStrings.DresscaDbContext') echo "CONNECTION_STRING=${connectionString}" >> "$GITHUB_OUTPUT" From c44aed96eb54aa18f3a9f0ce46e4b5abc9f181db Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Fri, 10 Nov 2023 10:32:28 +0900 Subject: [PATCH 087/110] =?UTF-8?q?=E7=92=B0=E5=A2=83=E5=A4=89=E6=95=B0?= =?UTF-8?q?=E5=90=8D=E3=82=92ASPNETCORE=5FENVIRONMENT=E3=81=AB=E5=A4=89?= =?UTF-8?q?=E6=9B=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 6 +++--- .../Dressca.IntegrationTest/CustomWebApplicationFactory.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 39342245b..d5c3b9bfc 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -27,7 +27,7 @@ jobs: DOTNET_CLI_TELEMETRY_OPTOUT: true BUILD_CONFIGURATION: Debug BUILD_SUMMARY_FILE: BuildSummary.md - TEST_ENVIRONMENT: CI + ASPNETCORE_ENVIRONMENT: CI permissions: checks: write contents: read @@ -71,7 +71,7 @@ jobs: - name: 結合テスト用データベース接続文字列を取得 id: get-connection-string env: - APPSETTINGS_FILEPATH: tests/Dressca.IntegrationTest/appsettings.${{ env.TEST_ENVIRONMENT }}.json + APPSETTINGS_FILEPATH: tests/Dressca.IntegrationTest/appsettings.${{ env.ASPNETCORE_ENVIRONMENT }}.json run: | connectionString=$(cat ${{env.APPSETTINGS_FILEPATH}} | jq '.ConnectionStrings.DresscaDbContext') echo "CONNECTION_STRING=${connectionString}" >> "$GITHUB_OUTPUT" @@ -87,7 +87,7 @@ jobs: name: テストの実行 continue-on-error: true run: | - export TEST_ENVIRONMENT=${{ env.TEST_ENVIRONMENT }} + export ASPNETCORE_ENVIRONMENT=${{ env.ASPNETCORE_ENVIRONMENT }} dotnet test --no-build --logger trx --verbosity normal --configuration ${{ env.BUILD_CONFIGURATION }} --collect "XPlat Code Coverage" - id: create-test-result-report diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs index a39014219..3a2b9a05e 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs @@ -9,7 +9,7 @@ public class CustomWebApplicationFactory { protected override void ConfigureWebHost(IWebHostBuilder builder) { - var env = Environment.GetEnvironmentVariable("TEST_ENVIRONMENT") ?? "Development"; + var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Development"; builder.ConfigureServices(services => { From 27d58fc2178309ddffb4675fbc564e2e891babd8 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Fri, 10 Nov 2023 10:49:58 +0900 Subject: [PATCH 088/110] =?UTF-8?q?=E7=92=B0=E5=A2=83=E5=A4=89=E6=95=B0?= =?UTF-8?q?=E5=90=8D=E3=82=92=E4=BF=AE=E6=AD=A3=E3=81=97=E3=80=81=E4=B8=8D?= =?UTF-8?q?=E8=A6=81=E3=81=AA=E5=87=A6=E7=90=86=E3=82=92=E5=89=8A=E9=99=A4?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 12 ++++++------ .../CustomWebApplicationFactory.cs | 3 +-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index d5c3b9bfc..5b29d4525 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -27,7 +27,7 @@ jobs: DOTNET_CLI_TELEMETRY_OPTOUT: true BUILD_CONFIGURATION: Debug BUILD_SUMMARY_FILE: BuildSummary.md - ASPNETCORE_ENVIRONMENT: CI + TEST_ENVIRONMENT: CI permissions: checks: write contents: read @@ -59,7 +59,7 @@ jobs: echo '# Build Result :gear:' >> $GITHUB_STEP_SUMMARY cat build-result.txt | sed -n -e 's/^/> /p' >> $GITHUB_STEP_SUMMARY - - name: 結合テスト用にSQL ServerのDockerイメージをプル + - name: SQL ServerのDockerイメージをプル(結合テスト用) run: | sudo docker pull mcr.microsoft.com/mssql/server:2022-latest sudo docker run -e "ACCEPT_EULA=Y" \ @@ -68,15 +68,15 @@ jobs: --hostname sql1 \ -d mcr.microsoft.com/mssql/server:2022-latest - - name: 結合テスト用データベース接続文字列を取得 + - name: データベース接続文字列を取得(結合テスト用) id: get-connection-string env: - APPSETTINGS_FILEPATH: tests/Dressca.IntegrationTest/appsettings.${{ env.ASPNETCORE_ENVIRONMENT }}.json + APPSETTINGS_FILEPATH: tests/Dressca.IntegrationTest/appsettings.${{ env.TEST_ENVIRONMENT }}.json run: | connectionString=$(cat ${{env.APPSETTINGS_FILEPATH}} | jq '.ConnectionStrings.DresscaDbContext') echo "CONNECTION_STRING=${connectionString}" >> "$GITHUB_OUTPUT" - - name: 結合テスト用にマイグレーション適用 + - name: マイグレーション適用(結合テスト用) working-directory: ${{ env.WORKING_DIRECTORY }}/src/Dressca.EfInfrastructure shell: bash run: | @@ -87,7 +87,7 @@ jobs: name: テストの実行 continue-on-error: true run: | - export ASPNETCORE_ENVIRONMENT=${{ env.ASPNETCORE_ENVIRONMENT }} + export TEST_ENVIRONMENT=${{ env.TEST_ENVIRONMENT }} dotnet test --no-build --logger trx --verbosity normal --configuration ${{ env.BUILD_CONFIGURATION }} --collect "XPlat Code Coverage" - id: create-test-result-report diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs index 3a2b9a05e..0f733f3f7 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs @@ -9,14 +9,13 @@ public class CustomWebApplicationFactory { protected override void ConfigureWebHost(IWebHostBuilder builder) { - var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Development"; + var env = Environment.GetEnvironmentVariable("TEST_ENVIRONMENT") ?? "Development"; builder.ConfigureServices(services => { var config = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile($"appsettings.{env}.json", optional: true, reloadOnChange: true) - .AddEnvironmentVariables() .Build(); services.AddDresscaEfInfrastructure(config); From bd66727a5e7f995e5d11daf009b3093a722c27f6 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Fri, 10 Nov 2023 12:00:53 +0900 Subject: [PATCH 089/110] =?UTF-8?q?=E7=B5=90=E5=90=88=E3=83=86=E3=82=B9?= =?UTF-8?q?=E3=83=88=E3=81=A7=E5=88=A9=E7=94=A8=E3=81=99=E3=82=8Bappsettin?= =?UTF-8?q?gs=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=81=AE=E5=90=8D?= =?UTF-8?q?=E5=89=8D=E3=82=92=E5=A4=89=E6=9B=B4=E3=80=82=20=E3=83=93?= =?UTF-8?q?=E3=83=AB=E3=83=89=E3=83=9E=E3=82=B7=E3=83=B3=E3=81=A7=E8=A8=AD?= =?UTF-8?q?=E5=AE=9A=E3=81=99=E3=82=8B=E7=92=B0=E5=A2=83=E5=A4=89=E6=95=B0?= =?UTF-8?q?=E5=90=8D=E3=82=92ASPNETCORE=5FENVIRONMENT=E3=81=AB=E5=A4=89?= =?UTF-8?q?=E6=9B=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 4 ++-- .../CustomWebApplicationFactory.cs | 2 +- .../Dressca.IntegrationTest.csproj | 6 +++--- .../Dressca.IntegrationTest/appsettings.CI.json | 13 ------------- .../appsettings.Development.json | 9 ++++----- .../appsettings.DevelopmentLocal.json | 14 ++++++++++++++ 6 files changed, 24 insertions(+), 24 deletions(-) delete mode 100644 samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.CI.json create mode 100644 samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.DevelopmentLocal.json diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 5b29d4525..2cc3248fa 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -27,7 +27,7 @@ jobs: DOTNET_CLI_TELEMETRY_OPTOUT: true BUILD_CONFIGURATION: Debug BUILD_SUMMARY_FILE: BuildSummary.md - TEST_ENVIRONMENT: CI + TEST_ENVIRONMENT: Development permissions: checks: write contents: read @@ -87,7 +87,7 @@ jobs: name: テストの実行 continue-on-error: true run: | - export TEST_ENVIRONMENT=${{ env.TEST_ENVIRONMENT }} + export ASPNETCORE_ENVIRONMENT=${{ env.TEST_ENVIRONMENT }} dotnet test --no-build --logger trx --verbosity normal --configuration ${{ env.BUILD_CONFIGURATION }} --collect "XPlat Code Coverage" - id: create-test-result-report diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs index 0f733f3f7..c038fcc68 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs @@ -9,7 +9,7 @@ public class CustomWebApplicationFactory { protected override void ConfigureWebHost(IWebHostBuilder builder) { - var env = Environment.GetEnvironmentVariable("TEST_ENVIRONMENT") ?? "Development"; + var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development" ? "Development" : "DevelopmentLocal"; builder.ConfigureServices(services => { diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj index 25672284a..2ccbf7c1c 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj @@ -9,15 +9,15 @@ - + - + Always - + Always diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.CI.json b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.CI.json deleted file mode 100644 index 841cb9d21..000000000 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.CI.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning", - "Dressca": "Information" - } - }, - "ConnectionStrings": { - "DresscaDbContext": "Server=localhost,1433;Database=Dressca_Eshop;User=sa;Password=P@ssw0rd;" - }, - "AllowedHosts": "*" -} diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.Development.json b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.Development.json index 584b62cbb..841cb9d21 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.Development.json +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.Development.json @@ -3,12 +3,11 @@ "LogLevel": { "Default": "Information", "Microsoft.AspNetCore": "Warning", - "Microsoft.AspNetCore.HttpLogging": "Information", - "Microsoft.Extensions.Diagnostics.HealthChecks": "Debug", - "Dressca": "Debug" + "Dressca": "Information" } }, "ConnectionStrings": { - "DresscaDbContext": "Data Source=(localdb)\\mssqllocaldb;Database=Dressca.Eshop;Integrated Security=True" - } + "DresscaDbContext": "Server=localhost,1433;Database=Dressca_Eshop;User=sa;Password=P@ssw0rd;" + }, + "AllowedHosts": "*" } diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.DevelopmentLocal.json b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.DevelopmentLocal.json new file mode 100644 index 000000000..584b62cbb --- /dev/null +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.DevelopmentLocal.json @@ -0,0 +1,14 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning", + "Microsoft.AspNetCore.HttpLogging": "Information", + "Microsoft.Extensions.Diagnostics.HealthChecks": "Debug", + "Dressca": "Debug" + } + }, + "ConnectionStrings": { + "DresscaDbContext": "Data Source=(localdb)\\mssqllocaldb;Database=Dressca.Eshop;Integrated Security=True" + } +} From 737fe389f16e1812f8f64a9045d5b6f6e19f68e5 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Fri, 10 Nov 2023 14:52:26 +0900 Subject: [PATCH 090/110] =?UTF-8?q?=E3=83=AD=E3=83=BC=E3=82=AB=E3=83=AB?= =?UTF-8?q?=E3=81=A7=E3=81=AE=E3=83=86=E3=82=B9=E3=83=88=E7=92=B0=E5=A2=83?= =?UTF-8?q?=E3=81=AEappsettings=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E3=82=92=E5=89=8A=E9=99=A4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/Dressca.Web/dressca-api.json | 2 +- .../CustomWebApplicationFactory.cs | 20 ++++++++++--------- .../Dressca.IntegrationTest.csproj | 4 ---- .../appsettings.DevelopmentLocal.json | 14 ------------- 4 files changed, 12 insertions(+), 28 deletions(-) delete mode 100644 samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.DevelopmentLocal.json diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/dressca-api.json b/samples/Dressca/dressca-backend/src/Dressca.Web/dressca-api.json index c9e28ae27..f8d64c98f 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web/dressca-api.json +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/dressca-api.json @@ -1,5 +1,5 @@ { - "x-generator": "NSwag v13.19.0.0 (NJsonSchema v10.9.0.0 (Newtonsoft.Json v13.0.0.0))", + "x-generator": "NSwag v13.20.0.0 (NJsonSchema v10.9.0.0 (Newtonsoft.Json v13.0.0.0))", "openapi": "3.0.0", "info": { "title": "Dressca Web API", diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs index c038fcc68..f9327fc30 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs @@ -9,17 +9,19 @@ public class CustomWebApplicationFactory { protected override void ConfigureWebHost(IWebHostBuilder builder) { - var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development" ? "Development" : "DevelopmentLocal"; + var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); - builder.ConfigureServices(services => + if (env == "Development") { - var config = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile($"appsettings.{env}.json", optional: true, reloadOnChange: true) - .Build(); - - services.AddDresscaEfInfrastructure(config); - }); + builder.ConfigureServices(services => + { + var config = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile($"appsettings.{env}.json", optional: true, reloadOnChange: true) + .Build(); + services.AddDresscaEfInfrastructure(config); + }); + } } } diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj index 2ccbf7c1c..32ae13075 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj @@ -10,16 +10,12 @@ - Always - - Always - diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.DevelopmentLocal.json b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.DevelopmentLocal.json deleted file mode 100644 index 584b62cbb..000000000 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.DevelopmentLocal.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning", - "Microsoft.AspNetCore.HttpLogging": "Information", - "Microsoft.Extensions.Diagnostics.HealthChecks": "Debug", - "Dressca": "Debug" - } - }, - "ConnectionStrings": { - "DresscaDbContext": "Data Source=(localdb)\\mssqllocaldb;Database=Dressca.Eshop;Integrated Security=True" - } -} From 278a894a31e8360c31de0cb50976aa0d52070563 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Fri, 10 Nov 2023 15:09:59 +0900 Subject: [PATCH 091/110] =?UTF-8?q?=E5=8F=82=E7=85=A7=E3=81=99=E3=82=8B?= =?UTF-8?q?=E7=92=B0=E5=A2=83=E5=A4=89=E6=95=B0=E3=82=92=E5=A4=89=E6=9B=B4?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CustomWebApplicationFactory.cs | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs index f9327fc30..0ba218525 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs @@ -9,11 +9,10 @@ public class CustomWebApplicationFactory { protected override void ConfigureWebHost(IWebHostBuilder builder) { - var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); - - if (env == "Development") + builder.ConfigureServices((context, services) => { - builder.ConfigureServices(services => + var env = context.HostingEnvironment.EnvironmentName; + if (env != "Development") { var config = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) @@ -21,7 +20,24 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) .Build(); services.AddDresscaEfInfrastructure(config); - }); - } + } + }); + + //builder.UseEnvironment("Development"); + + //var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); + + //if (env == "Development") + //{ + // builder.ConfigureServices(services => + // { + // var config = new ConfigurationBuilder() + // .SetBasePath(Directory.GetCurrentDirectory()) + // .AddJsonFile($"appsettings.{env}.json", optional: true, reloadOnChange: true) + // .Build(); + + // services.AddDresscaEfInfrastructure(config); + // }); + //} } } From 61515de06c11c42e5fbf174a876e7287d79e6ee4 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Fri, 10 Nov 2023 15:20:49 +0900 Subject: [PATCH 092/110] =?UTF-8?q?=E3=83=93=E3=83=AB=E3=83=89=E3=83=9E?= =?UTF-8?q?=E3=82=B7=E3=83=B3=E4=B8=8A=E3=81=A7=E8=A8=AD=E5=AE=9A=E3=81=99?= =?UTF-8?q?=E3=82=8B=E7=92=B0=E5=A2=83=E5=A4=89=E6=95=B0=E5=90=8D=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 2 +- .../Dressca.IntegrationTest/CustomWebApplicationFactory.cs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 2cc3248fa..58b0cdbc9 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -87,7 +87,7 @@ jobs: name: テストの実行 continue-on-error: true run: | - export ASPNETCORE_ENVIRONMENT=${{ env.TEST_ENVIRONMENT }} + export DOTNET_ENVIRONMENT=${{ env.TEST_ENVIRONMENT }} dotnet test --no-build --logger trx --verbosity normal --configuration ${{ env.BUILD_CONFIGURATION }} --collect "XPlat Code Coverage" - id: create-test-result-report diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs index 0ba218525..afc726d25 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs @@ -11,8 +11,9 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) { builder.ConfigureServices((context, services) => { + // CIのビルドマシン上で実行する場合はappsettingsを読み込む var env = context.HostingEnvironment.EnvironmentName; - if (env != "Development") + if (env == "Development") { var config = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) From ef6d8af2e72487a839898ba8da8ad073b370d75a Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Fri, 10 Nov 2023 15:25:40 +0900 Subject: [PATCH 093/110] =?UTF-8?q?appsettings=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E5=90=8D=E3=82=92=E5=A4=89=E6=9B=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 2 +- .../Dressca.IntegrationTest/CustomWebApplicationFactory.cs | 2 +- .../Dressca.IntegrationTest/Dressca.IntegrationTest.csproj | 4 ++-- ...ings.Development.json => appsettings.IntegrationTest.json} | 0 4 files changed, 4 insertions(+), 4 deletions(-) rename samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/{appsettings.Development.json => appsettings.IntegrationTest.json} (100%) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 58b0cdbc9..3163cc055 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -27,7 +27,7 @@ jobs: DOTNET_CLI_TELEMETRY_OPTOUT: true BUILD_CONFIGURATION: Debug BUILD_SUMMARY_FILE: BuildSummary.md - TEST_ENVIRONMENT: Development + TEST_ENVIRONMENT: IntegrationTest permissions: checks: write contents: read diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs index afc726d25..db97e3ebc 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs @@ -13,7 +13,7 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) { // CIのビルドマシン上で実行する場合はappsettingsを読み込む var env = context.HostingEnvironment.EnvironmentName; - if (env == "Development") + if (env != "Development") { var config = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj index 32ae13075..8eb794555 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj @@ -9,11 +9,11 @@ - + - + Always diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.Development.json b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.IntegrationTest.json similarity index 100% rename from samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.Development.json rename to samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/appsettings.IntegrationTest.json From e7c3026c816ed847b9d306110d8192206307ebdc Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Fri, 10 Nov 2023 15:42:34 +0900 Subject: [PATCH 094/110] =?UTF-8?q?=E6=A7=8B=E6=88=90=E3=83=95=E3=82=A1?= =?UTF-8?q?=E3=82=A4=E3=83=AB=E8=BF=BD=E5=8A=A0=E3=81=AE=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dressca.IntegrationTest/CustomWebApplicationFactory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs index db97e3ebc..8feefa91d 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs @@ -13,7 +13,7 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) { // CIのビルドマシン上で実行する場合はappsettingsを読み込む var env = context.HostingEnvironment.EnvironmentName; - if (env != "Development") + if (env == "IntegrationTest") { var config = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) From 46c1f0983f36a58c30d7e726b63a2d1ba70cc9a5 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Fri, 10 Nov 2023 15:49:49 +0900 Subject: [PATCH 095/110] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E5=AE=9F?= =?UTF-8?q?=E8=A1=8C=E3=82=B3=E3=83=9E=E3=83=B3=E3=83=89=E3=81=AE=E5=BC=95?= =?UTF-8?q?=E6=95=B0=E3=82=92=E8=BF=BD=E5=8A=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 3163cc055..44fef810a 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -87,8 +87,8 @@ jobs: name: テストの実行 continue-on-error: true run: | - export DOTNET_ENVIRONMENT=${{ env.TEST_ENVIRONMENT }} - dotnet test --no-build --logger trx --verbosity normal --configuration ${{ env.BUILD_CONFIGURATION }} --collect "XPlat Code Coverage" + #export DOTNET_ENVIRONMENT=${{ env.TEST_ENVIRONMENT }} + dotnet test --environment IntegrationTest --no-build --logger trx --verbosity normal --configuration ${{ env.BUILD_CONFIGURATION }} --collect "XPlat Code Coverage" - id: create-test-result-report name: テスト結果ページの作成 From 62a3d495e8e706c96f989fee8158240ac0803a4b Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Fri, 10 Nov 2023 16:03:28 +0900 Subject: [PATCH 096/110] =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E3=81=AE=E7=A2=BA?= =?UTF-8?q?=E8=AA=8D=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 2 +- .../Dressca.IntegrationTest/CustomWebApplicationFactory.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 44fef810a..e1ec2ad39 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -88,7 +88,7 @@ jobs: continue-on-error: true run: | #export DOTNET_ENVIRONMENT=${{ env.TEST_ENVIRONMENT }} - dotnet test --environment IntegrationTest --no-build --logger trx --verbosity normal --configuration ${{ env.BUILD_CONFIGURATION }} --collect "XPlat Code Coverage" + dotnet test --no-build --logger trx --verbosity normal --configuration ${{ env.BUILD_CONFIGURATION }} --collect "XPlat Code Coverage" - id: create-test-result-report name: テスト結果ページの作成 diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs index 8feefa91d..afc726d25 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs @@ -13,7 +13,7 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) { // CIのビルドマシン上で実行する場合はappsettingsを読み込む var env = context.HostingEnvironment.EnvironmentName; - if (env == "IntegrationTest") + if (env == "Development") { var config = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) From 04590e39887b6560fef73b3476dcf785cebcac22 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Fri, 10 Nov 2023 16:08:12 +0900 Subject: [PATCH 097/110] =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E3=81=AE=E5=8B=95?= =?UTF-8?q?=E4=BD=9C=E7=A2=BA=E8=AA=8D=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dressca.IntegrationTest/CustomWebApplicationFactory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs index afc726d25..7cc85369c 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs @@ -17,7 +17,7 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) { var config = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile($"appsettings.{env}.json", optional: true, reloadOnChange: true) + .AddJsonFile($"appsettings.IntegrationTest.json", optional: true, reloadOnChange: true) .Build(); services.AddDresscaEfInfrastructure(config); From 59b9b7b3786d831fd322ffbe2d52c887c27ef01b Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Fri, 10 Nov 2023 16:26:40 +0900 Subject: [PATCH 098/110] =?UTF-8?q?=E7=92=B0=E5=A2=83=E5=A4=89=E6=95=B0?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workflows/samples-dressca-backend.ci.yml | 2 +- .../CustomWebApplicationFactory.cs | 31 +++++-------------- 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index e1ec2ad39..1658d0fd1 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -87,7 +87,7 @@ jobs: name: テストの実行 continue-on-error: true run: | - #export DOTNET_ENVIRONMENT=${{ env.TEST_ENVIRONMENT }} + export ASPNETCORE_ENVIRONMENT=${{ env.TEST_ENVIRONMENT }} dotnet test --no-build --logger trx --verbosity normal --configuration ${{ env.BUILD_CONFIGURATION }} --collect "XPlat Code Coverage" - id: create-test-result-report diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs index 7cc85369c..bf000288d 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs @@ -9,36 +9,19 @@ public class CustomWebApplicationFactory { protected override void ConfigureWebHost(IWebHostBuilder builder) { - builder.ConfigureServices((context, services) => + var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Development"; + + if (env != "Development") { - // CIのビルドマシン上で実行する場合はappsettingsを読み込む - var env = context.HostingEnvironment.EnvironmentName; - if (env == "Development") + builder.ConfigureServices(services => { var config = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile($"appsettings.IntegrationTest.json", optional: true, reloadOnChange: true) + .AddJsonFile($"appsettings.{env}.json", optional: true, reloadOnChange: true) .Build(); services.AddDresscaEfInfrastructure(config); - } - }); - - //builder.UseEnvironment("Development"); - - //var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); - - //if (env == "Development") - //{ - // builder.ConfigureServices(services => - // { - // var config = new ConfigurationBuilder() - // .SetBasePath(Directory.GetCurrentDirectory()) - // .AddJsonFile($"appsettings.{env}.json", optional: true, reloadOnChange: true) - // .Build(); - - // services.AddDresscaEfInfrastructure(config); - // }); - //} + }); + } } } From 7df240f46a6f71375c3e07bcc571dae30d4d8794 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Fri, 10 Nov 2023 16:36:13 +0900 Subject: [PATCH 099/110] =?UTF-8?q?=E7=92=B0=E5=A2=83=E5=A4=89=E6=95=B0?= =?UTF-8?q?=E5=90=8D=E7=AD=89=E3=82=92=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 2 +- .../Dressca.IntegrationTest/CustomWebApplicationFactory.cs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 1658d0fd1..35f8751f5 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -87,7 +87,7 @@ jobs: name: テストの実行 continue-on-error: true run: | - export ASPNETCORE_ENVIRONMENT=${{ env.TEST_ENVIRONMENT }} + export TEST_ENVIRONMENT=${{ env.TEST_ENVIRONMENT }} dotnet test --no-build --logger trx --verbosity normal --configuration ${{ env.BUILD_CONFIGURATION }} --collect "XPlat Code Coverage" - id: create-test-result-report diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs index bf000288d..9ad08e277 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; namespace Dressca.IntegrationTest; public class CustomWebApplicationFactory @@ -9,9 +10,9 @@ public class CustomWebApplicationFactory { protected override void ConfigureWebHost(IWebHostBuilder builder) { - var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Development"; + var env = Environment.GetEnvironmentVariable("TEST_ENVIRONMENT") ?? Environments.Development; - if (env != "Development") + if (env != Environments.Development) { builder.ConfigureServices(services => { From 970ed78e35bada58a06bbbdba6c1d78b7dab64c7 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Fri, 10 Nov 2023 16:49:58 +0900 Subject: [PATCH 100/110] =?UTF-8?q?=E5=90=8D=E5=89=8D=E7=A9=BA=E9=96=93?= =?UTF-8?q?=E3=81=AE=E8=AA=BF=E6=95=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HealthChecks/HealthCheckDescriptionProvider.cs | 5 +---- samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) rename samples/Dressca/dressca-backend/src/Dressca.Web/{Diagnostics => }/HealthChecks/HealthCheckDescriptionProvider.cs (94%) diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/Diagnostics/HealthChecks/HealthCheckDescriptionProvider.cs b/samples/Dressca/dressca-backend/src/Dressca.Web/HealthChecks/HealthCheckDescriptionProvider.cs similarity index 94% rename from samples/Dressca/dressca-backend/src/Dressca.Web/Diagnostics/HealthChecks/HealthCheckDescriptionProvider.cs rename to samples/Dressca/dressca-backend/src/Dressca.Web/HealthChecks/HealthCheckDescriptionProvider.cs index 1e8d38f95..02dc33614 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web/Diagnostics/HealthChecks/HealthCheckDescriptionProvider.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/HealthChecks/HealthCheckDescriptionProvider.cs @@ -1,14 +1,11 @@ using System.Reflection; -using Dressca.EfInfrastructure; using Microsoft.AspNetCore.Mvc.Abstractions; -using Microsoft.AspNetCore.Mvc.ActionConstraints; using Microsoft.AspNetCore.Mvc.ApiExplorer; using Microsoft.AspNetCore.Mvc.Controllers; -using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Mvc.Formatters; using Microsoft.AspNetCore.Mvc.ModelBinding; -namespace Dressca.Web.Diagnostics.HealthChecks; +namespace Dressca.Web.HealthChecks; /// /// ヘルスチェック用に を実装したクラス。 diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs b/samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs index 35463bf9c..b7de9b921 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs @@ -4,7 +4,7 @@ using Dressca.Store.Assets.StaticFiles; using Dressca.Web.Baskets; using Dressca.Web.Controllers; -using Dressca.Web.Diagnostics.HealthChecks; +using Dressca.Web.HealthChecks; using Dressca.Web.Mapper; using Dressca.Web.Resources; using Dressca.Web.Runtime; From ac9c61d0833d4322aafea5c54dae44c13ab74861 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Fri, 10 Nov 2023 17:31:50 +0900 Subject: [PATCH 101/110] =?UTF-8?q?HealthCheckDescriptor=E3=81=ABGET/HEAD?= =?UTF-8?q?=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E3=81=9D=E3=82=8C=E3=81=9E?= =?UTF-8?q?=E3=82=8C=E3=81=AE=E8=AA=AC=E6=98=8E=E3=82=92=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HealthCheckDescriptionProvider.cs | 43 ++++++++++++++++--- .../src/Dressca.Web/Program.cs | 2 +- .../src/Dressca.Web/dressca-api.json | 40 ++++++++++++++++- 3 files changed, 77 insertions(+), 8 deletions(-) diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/HealthChecks/HealthCheckDescriptionProvider.cs b/samples/Dressca/dressca-backend/src/Dressca.Web/HealthChecks/HealthCheckDescriptionProvider.cs index 02dc33614..851473625 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web/HealthChecks/HealthCheckDescriptionProvider.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/HealthChecks/HealthCheckDescriptionProvider.cs @@ -12,6 +12,11 @@ namespace Dressca.Web.HealthChecks; /// public class HealthCheckDescriptionProvider : IApiDescriptionProvider { + /// + /// ヘルスチェックAPIの相対パス。 + /// + public static readonly string HealthCheckRelativePath = "api/health"; + private readonly IModelMetadataProvider modelMetadataProvider; /// @@ -45,19 +50,26 @@ public void OnProvidersExecuted(ApiDescriptionProviderContext context) var actionDescriptor = new ControllerActionDescriptor { ControllerName = "HealthChecks", - ActionName = "api/health", + ActionName = HealthCheckRelativePath, Parameters = new List(), ControllerTypeInfo = new TypeDelegator(typeof(string)), }; - var apiDescription = new ApiDescription + var getApiDescription = new ApiDescription { ActionDescriptor = actionDescriptor, HttpMethod = HttpMethods.Get, - RelativePath = "api/health", + RelativePath = HealthCheckRelativePath, + }; + + var headApiDescription = new ApiDescription + { + ActionDescriptor = actionDescriptor, + HttpMethod = HttpMethods.Head, + RelativePath = HealthCheckRelativePath, }; - var apiResponseType = new ApiResponseType + var normalApiResponseType = new ApiResponseType { ApiResponseFormats = new List { @@ -71,7 +83,26 @@ public void OnProvidersExecuted(ApiDescriptionProviderContext context) StatusCode = StatusCodes.Status200OK, }; - apiDescription.SupportedResponseTypes.Add(apiResponseType); - context.Results.Add(apiDescription); + var errorApiResponseType = new ApiResponseType + { + ApiResponseFormats = new List + { + new ApiResponseFormat + { + MediaType = "text/plain", + Formatter = new StringOutputFormatter(), + }, + }, + Type = typeof(string), + StatusCode = StatusCodes.Status503ServiceUnavailable, + }; + + getApiDescription.SupportedResponseTypes.Add(normalApiResponseType); + getApiDescription.SupportedResponseTypes.Add(errorApiResponseType); + headApiDescription.SupportedResponseTypes.Add(normalApiResponseType); + headApiDescription.SupportedResponseTypes.Add(errorApiResponseType); + + context.Results.Add(getApiDescription); + context.Results.Add(headApiDescription); } } diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs b/samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs index b7de9b921..851de1ee6 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs @@ -95,7 +95,7 @@ app.MapControllers(); -app.MapHealthChecks("/api/health"); +app.MapHealthChecks(HealthCheckDescriptionProvider.HealthCheckRelativePath); app.Run(); diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/dressca-api.json b/samples/Dressca/dressca-backend/src/Dressca.Web/dressca-api.json index f8d64c98f..ee1d4fc94 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web/dressca-api.json +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/dressca-api.json @@ -427,7 +427,7 @@ "tags": [ "HealthChecks" ], - "operationId": "HealthChecks_api/health", + "operationId": "HealthChecks_api/healthGET", "responses": { "200": { "description": "", @@ -438,6 +438,44 @@ } } } + }, + "503": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + }, + "head": { + "tags": [ + "HealthChecks" + ], + "operationId": "HealthChecks_api/healthHEAD", + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + }, + "503": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } } } } From 36699916c9af19fe620f3e3443fc0680d155f20d Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Fri, 10 Nov 2023 17:41:40 +0900 Subject: [PATCH 102/110] =?UTF-8?q?appSettings=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E3=82=92=E6=A7=8B=E6=88=90=E3=81=AB=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=E3=81=99=E3=82=8B=E9=9A=9B=E3=81=AE=E6=9D=A1=E4=BB=B6=E5=BC=8F?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dressca.IntegrationTest/CustomWebApplicationFactory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs index 9ad08e277..95eb6b36d 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs @@ -12,7 +12,7 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) { var env = Environment.GetEnvironmentVariable("TEST_ENVIRONMENT") ?? Environments.Development; - if (env != Environments.Development) + if (!env.Equals(Environments.Development, StringComparison.OrdinalIgnoreCase)) { builder.ConfigureServices(services => { From f67af85e44a31f8caadf54efca3f36b914a06c29 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Fri, 10 Nov 2023 17:45:00 +0900 Subject: [PATCH 103/110] =?UTF-8?q?EF=20Core=20=E3=83=84=E3=83=BC=E3=83=AB?= =?UTF-8?q?=E3=81=AE=E3=82=A4=E3=83=B3=E3=82=B9=E3=83=88=E3=83=BC=E3=83=AB?= =?UTF-8?q?=E3=82=92=E5=88=A5=E3=82=BF=E3=82=B9=E3=82=AF=E3=81=AB=E5=88=86?= =?UTF-8?q?=E9=9B=A2=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 35f8751f5..3f47bf7bf 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -76,12 +76,14 @@ jobs: connectionString=$(cat ${{env.APPSETTINGS_FILEPATH}} | jq '.ConnectionStrings.DresscaDbContext') echo "CONNECTION_STRING=${connectionString}" >> "$GITHUB_OUTPUT" + - name: EF Core ツールのインストール(結合テスト用) + shell: bash + run: dotnet tool install --global dotnet-ef + - name: マイグレーション適用(結合テスト用) working-directory: ${{ env.WORKING_DIRECTORY }}/src/Dressca.EfInfrastructure shell: bash - run: | - dotnet tool install --global dotnet-ef - dotnet ef database update --connection ${{ steps.get-connection-string.outputs.CONNECTION_STRING }} + run: dotnet ef database update --connection ${{ steps.get-connection-string.outputs.CONNECTION_STRING }} - id: run-tests name: テストの実行 From ab4e663f99fd22a678a3f1ae899e447832290300 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Fri, 10 Nov 2023 17:49:39 +0900 Subject: [PATCH 104/110] =?UTF-8?q?SQL=20Server=E3=81=AE=E3=82=BB=E3=83=83?= =?UTF-8?q?=E3=83=88=E3=82=A2=E3=83=83=E3=83=97=E5=87=A6=E7=90=86=E3=82=92?= =?UTF-8?q?=E5=88=86=E5=89=B2=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/samples-dressca-backend.ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/samples-dressca-backend.ci.yml b/.github/workflows/samples-dressca-backend.ci.yml index 3f47bf7bf..2a9ce1701 100644 --- a/.github/workflows/samples-dressca-backend.ci.yml +++ b/.github/workflows/samples-dressca-backend.ci.yml @@ -60,8 +60,10 @@ jobs: cat build-result.txt | sed -n -e 's/^/> /p' >> $GITHUB_STEP_SUMMARY - name: SQL ServerのDockerイメージをプル(結合テスト用) + run: sudo docker pull mcr.microsoft.com/mssql/server:2022-latest + + - name: SQL Serverのコンテナを起動(結合テスト用) run: | - sudo docker pull mcr.microsoft.com/mssql/server:2022-latest sudo docker run -e "ACCEPT_EULA=Y" \ -e "MSSQL_SA_PASSWORD=P@ssw0rd" \ -p 1433:1433 --name sql1 \ From 563841a7d2938c09f64ed9abd9c3a83cb944a61a Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Fri, 10 Nov 2023 18:01:03 +0900 Subject: [PATCH 105/110] =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=83=87=E3=83=B3?= =?UTF-8?q?=E3=83=88=E7=AD=89=E3=81=AE=E8=AD=A6=E5=91=8A=E3=81=AB=E5=AF=BE?= =?UTF-8?q?=E5=BF=9C=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs | 4 +++- .../Dressca.IntegrationTest/DatabaseHealthCheckTest.cs | 6 +++--- .../ApplicationCore/Catalog/CatalogDomainServiceTest.cs | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs b/samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs index 851de1ee6..14bf4e7e7 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/Program.cs @@ -102,4 +102,6 @@ /// /// 結合テストプロジェクト用の部分クラス。 /// -public partial class Program { } +public partial class Program +{ +} diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs index cbcddb4c1..396ac37f8 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs @@ -1,5 +1,4 @@ -using Microsoft.AspNetCore.Mvc.Testing; -using Xunit; +using Xunit; namespace Dressca.IntegrationTest; @@ -23,6 +22,7 @@ public async Task DatabaseConnectionTest() // Assert response.EnsureSuccessStatusCode(); - Assert.Equal("Healthy", response.Content.ReadAsStringAsync().Result); + var healthCheckResult = await response.Content.ReadAsStringAsync(); + Assert.Equal("Healthy", healthCheckResult); } } diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogDomainServiceTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogDomainServiceTest.cs index 460b11252..69426705d 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogDomainServiceTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogDomainServiceTest.cs @@ -4,6 +4,7 @@ using Xunit.Abstractions; namespace Dressca.UnitTests.ApplicationCore.Catalog; + public class CatalogDomainServiceTest { private readonly XunitLoggerFactory loggerFactory; From 28ce9179072488010798e3657acf8f56a6c90240 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Fri, 10 Nov 2023 18:14:30 +0900 Subject: [PATCH 106/110] =?UTF-8?q?HEAD/GET=E3=83=A1=E3=82=BD=E3=83=83?= =?UTF-8?q?=E3=83=89=E3=81=9D=E3=82=8C=E3=81=9E=E3=82=8C=E3=81=AEApiRespon?= =?UTF-8?q?seType=E3=82=92=E5=AE=9A=E7=BE=A9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HealthCheckDescriptionProvider.cs | 22 ++++++++++++++----- .../src/Dressca.Web/dressca-api.json | 18 ++------------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/HealthChecks/HealthCheckDescriptionProvider.cs b/samples/Dressca/dressca-backend/src/Dressca.Web/HealthChecks/HealthCheckDescriptionProvider.cs index 851473625..9188b4fe2 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web/HealthChecks/HealthCheckDescriptionProvider.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/HealthChecks/HealthCheckDescriptionProvider.cs @@ -69,7 +69,7 @@ public void OnProvidersExecuted(ApiDescriptionProviderContext context) RelativePath = HealthCheckRelativePath, }; - var normalApiResponseType = new ApiResponseType + var normalGetApiResponseType = new ApiResponseType { ApiResponseFormats = new List { @@ -83,7 +83,7 @@ public void OnProvidersExecuted(ApiDescriptionProviderContext context) StatusCode = StatusCodes.Status200OK, }; - var errorApiResponseType = new ApiResponseType + var errorGetApiResponseType = new ApiResponseType { ApiResponseFormats = new List { @@ -97,10 +97,20 @@ public void OnProvidersExecuted(ApiDescriptionProviderContext context) StatusCode = StatusCodes.Status503ServiceUnavailable, }; - getApiDescription.SupportedResponseTypes.Add(normalApiResponseType); - getApiDescription.SupportedResponseTypes.Add(errorApiResponseType); - headApiDescription.SupportedResponseTypes.Add(normalApiResponseType); - headApiDescription.SupportedResponseTypes.Add(errorApiResponseType); + var normalHeadApiResponseType = new ApiResponseType + { + StatusCode = StatusCodes.Status200OK, + }; + + var errorHeadApiResponseType = new ApiResponseType + { + StatusCode = StatusCodes.Status503ServiceUnavailable, + }; + + getApiDescription.SupportedResponseTypes.Add(normalGetApiResponseType); + getApiDescription.SupportedResponseTypes.Add(errorGetApiResponseType); + headApiDescription.SupportedResponseTypes.Add(normalHeadApiResponseType); + headApiDescription.SupportedResponseTypes.Add(errorHeadApiResponseType); context.Results.Add(getApiDescription); context.Results.Add(headApiDescription); diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/dressca-api.json b/samples/Dressca/dressca-backend/src/Dressca.Web/dressca-api.json index ee1d4fc94..eb4776238 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web/dressca-api.json +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/dressca-api.json @@ -458,24 +458,10 @@ "operationId": "HealthChecks_api/healthHEAD", "responses": { "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "string" - } - } - } + "description": "" }, "503": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "string" - } - } - } + "description": "" } } } From 7e925f4ce95e05c4605f40507c7d86dd31a0dc51 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Mon, 13 Nov 2023 11:56:35 +0900 Subject: [PATCH 107/110] =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dressca.Web/HealthChecks/HealthCheckDescriptionProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/HealthChecks/HealthCheckDescriptionProvider.cs b/samples/Dressca/dressca-backend/src/Dressca.Web/HealthChecks/HealthCheckDescriptionProvider.cs index 9188b4fe2..ef20e6d2d 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web/HealthChecks/HealthCheckDescriptionProvider.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/HealthChecks/HealthCheckDescriptionProvider.cs @@ -13,7 +13,7 @@ namespace Dressca.Web.HealthChecks; public class HealthCheckDescriptionProvider : IApiDescriptionProvider { /// - /// ヘルスチェックAPIの相対パス。 + /// ヘルスチェックAPIの相対パス "api/health" 。 /// public static readonly string HealthCheckRelativePath = "api/health"; From b9abba1553d258ceaeff014b05a54b832229a038 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Mon, 13 Nov 2023 11:58:02 +0900 Subject: [PATCH 108/110] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E7=94=A8Web?= =?UTF-8?q?ApplicationFactory=E3=82=AF=E3=83=A9=E3=82=B9=E3=81=AE=E5=90=8D?= =?UTF-8?q?=E5=89=8D=E3=82=92=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dressca.IntegrationTest/DatabaseHealthCheckTest.cs | 6 +++--- ...onFactory.cs => IntegrationTestWebApplicationFactory.cs} | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) rename samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/{CustomWebApplicationFactory.cs => IntegrationTestWebApplicationFactory.cs} (94%) diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs index 396ac37f8..53ba2a1c6 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs @@ -2,11 +2,11 @@ namespace Dressca.IntegrationTest; -public class DatabaseHealthCheckTest : IClassFixture> +public class DatabaseHealthCheckTest : IClassFixture> { - private readonly CustomWebApplicationFactory factory; + private readonly IntegrationTestWebApplicationFactory factory; - public DatabaseHealthCheckTest(CustomWebApplicationFactory factory) + public DatabaseHealthCheckTest(IntegrationTestWebApplicationFactory factory) { this.factory = factory; } diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/IntegrationTestWebApplicationFactory.cs similarity index 94% rename from samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs rename to samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/IntegrationTestWebApplicationFactory.cs index 95eb6b36d..5e2edd989 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/CustomWebApplicationFactory.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/IntegrationTestWebApplicationFactory.cs @@ -5,7 +5,7 @@ using Microsoft.Extensions.Hosting; namespace Dressca.IntegrationTest; -public class CustomWebApplicationFactory +public class IntegrationTestWebApplicationFactory : WebApplicationFactory where TProgram : class { protected override void ConfigureWebHost(IWebHostBuilder builder) From 81fd4ca08d11b8610bdee6e17b7cc3b7e8dc23a8 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Mon, 13 Nov 2023 12:00:15 +0900 Subject: [PATCH 109/110] =?UTF-8?q?StyleCop.Analyzers=20=E3=81=AE=E3=83=91?= =?UTF-8?q?=E3=83=83=E3=82=B1=E3=83=BC=E3=82=B8=E3=82=92=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dressca.IntegrationTest/Dressca.IntegrationTest.csproj | 4 ++++ .../IntegrationTestWebApplicationFactory.cs | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj index 8eb794555..45b9b4655 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj @@ -22,6 +22,10 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/IntegrationTestWebApplicationFactory.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/IntegrationTestWebApplicationFactory.cs index 5e2edd989..842a11e20 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/IntegrationTestWebApplicationFactory.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/IntegrationTestWebApplicationFactory.cs @@ -5,8 +5,10 @@ using Microsoft.Extensions.Hosting; namespace Dressca.IntegrationTest; + public class IntegrationTestWebApplicationFactory - : WebApplicationFactory where TProgram : class + : WebApplicationFactory + where TProgram : class { protected override void ConfigureWebHost(IWebHostBuilder builder) { From 5908e7b8fb8da2bc83132872085deabffe14edc0 Mon Sep 17 00:00:00 2001 From: Fumika Koyama Date: Tue, 14 Nov 2023 14:25:38 +0900 Subject: [PATCH 110/110] =?UTF-8?q?Dressca.IntegrationTest.csproj=E3=81=8B?= =?UTF-8?q?=E3=82=89=E4=B8=8D=E8=A6=81=E3=81=AA=E8=A8=AD=E5=AE=9A=E3=82=92?= =?UTF-8?q?=E5=89=8A=E9=99=A4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dressca.IntegrationTest.csproj | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj index 45b9b4655..e00b11c45 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/Dressca.IntegrationTest.csproj @@ -1,20 +1,12 @@  - net6.0 - enable - enable - false - - - - - Always + PreserveNewest