diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 345faeea0..4d88fe157 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -78,8 +78,18 @@ jobs: - name: Run Tests run: dotnet cake --target=Tests --test-filter=${{ startsWith(matrix.os, 'ubuntu') && 'FullyQualifiedName~Testcontainers' || 'DockerPlatform=Windows' }} + # The Test Reporter GH Action is not yet compatible with the recent + # actions/upload-artifact updates: https://github.com/dorny/test-reporter/issues/363. + - name: Upload Test And Coverage Results + uses: actions/upload-artifact@v3 + if: true + with: + name: ${{ matrix.os }}-v3 + path: test-results + - name: Upload Test And Coverage Results uses: actions/upload-artifact@v4 + if: true with: name: ${{ matrix.os }} path: test-results diff --git a/.github/workflows/test-report.yml b/.github/workflows/test-report.yml new file mode 100644 index 000000000..8a4b767c4 --- /dev/null +++ b/.github/workflows/test-report.yml @@ -0,0 +1,30 @@ +name: Test Report + +on: + workflow_run: + workflows: ['Continuous Integration & Delivery'] + types: + - completed + +jobs: + report: + strategy: + fail-fast: false + matrix: + os: [ ubuntu-22.04, windows-2022 ] + + runs-on: ${{ matrix.os }} + + permissions: + actions: read + checks: write + contents: read + + steps: + - name: Publish Test Report + uses: dorny/test-reporter@v1.8.0 + with: + artifact: ${{ matrix.os }}-v3 + name: ${{ matrix.os }} + path: '*.trx' + reporter: dotnet-trx diff --git a/build.cake b/build.cake index bf3673349..1d2e4aea2 100644 --- a/build.cake +++ b/build.cake @@ -80,7 +80,6 @@ Task("Tests") NoRestore = true, NoBuild = true, Collectors = new[] { "XPlat Code Coverage;Format=opencover" }, - Loggers = new[] { "trx" }, Filter = param.TestFilter, ResultsDirectory = param.Paths.Directories.TestResultsDirectoryPath, ArgumentCustomization = args => args diff --git a/src/Testcontainers.CosmosDb/CosmosDbBuilder.cs b/src/Testcontainers.CosmosDb/CosmosDbBuilder.cs index b25393ab4..d40116625 100644 --- a/src/Testcontainers.CosmosDb/CosmosDbBuilder.cs +++ b/src/Testcontainers.CosmosDb/CosmosDbBuilder.cs @@ -45,7 +45,7 @@ protected override CosmosDbBuilder Init() return base.Init() .WithImage(CosmosDbImage) .WithPortBinding(CosmosDbPort, true) - .WithWaitStrategy(Wait.ForUnixContainer().UntilMessageIsLogged("Started\\r?\\n")); + .WithWaitStrategy(Wait.ForUnixContainer().AddCustomWaitStrategy(new WaitUntil())); } /// @@ -65,4 +65,33 @@ protected override CosmosDbBuilder Merge(CosmosDbConfiguration oldValue, CosmosD { return new CosmosDbBuilder(new CosmosDbConfiguration(oldValue, newValue)); } + + /// + private sealed class WaitUntil : IWaitUntil + { + /// + public async Task UntilAsync(IContainer container) + { + // CosmosDB's preconfigured HTTP client will redirect the request to the container. + const string requestUri = "https://localhost/_explorer/emulator.pem"; + + var httpClient = ((CosmosDbContainer)container).HttpClient; + + try + { + using var httpResponse = await httpClient.GetAsync(requestUri) + .ConfigureAwait(false); + + return httpResponse.IsSuccessStatusCode; + } + catch (Exception) + { + return false; + } + finally + { + httpClient.Dispose(); + } + } + } } \ No newline at end of file diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props index 0fd5ad84a..d2f5aaa24 100644 --- a/tests/Directory.Build.props +++ b/tests/Directory.Build.props @@ -4,4 +4,7 @@ false + + trx%3BLogFileName=$(MSBuildProjectName).trx + \ No newline at end of file