Skip to content

Commit 99559ab

Browse files
authored
chore: Run each test project on a separate runner (#1295)
1 parent db02434 commit 99559ab

File tree

9 files changed

+101
-57
lines changed

9 files changed

+101
-57
lines changed

.cake-scripts/parameters.cake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ internal sealed class BuildParameters
1919
public string PullRequestId { get; private set; }
2020
public string Version { get; private set; }
2121
public string TestFilter { get; private set; }
22+
public string TestProject { get; private set; }
2223
public bool IsLocalBuild { get; private set; }
2324
public bool IsReleaseBuild { get; private set; }
2425
public bool IsPullRequest { get; private set; }
@@ -49,6 +50,7 @@ internal sealed class BuildParameters
4950
PullRequestId = buildInformation.PullRequestId,
5051
Version = buildInformation.Version,
5152
TestFilter = context.Argument<string>("test-filter", null),
53+
TestProject = context.Argument<string>("test-project", null),
5254
IsLocalBuild = buildInformation.IsLocalBuild,
5355
IsReleaseBuild = !buildInformation.IsLocalBuild && buildInformation.IsReleaseBuild,
5456
IsPullRequest = buildInformation.IsPullRequest,

.cake-scripts/paths.cake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ internal sealed class BuildPaths
99

1010
public static BuildPaths Instance(ICakeContext context, string version)
1111
{
12-
var baseDir = (DirectoryPath) context.Directory(".");
12+
var baseDir = (DirectoryPath)context.Directory(".");
1313

1414
var testResultsDir = baseDir.Combine("test-results");
1515
var testCoverageDir = baseDir.Combine("test-coverage");

.cake-scripts/version.cake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#addin nuget:?package=Cake.Git&version=3.0.0
1+
#addin nuget:?package=Cake.Git&version=4.0.0
22

33
internal sealed class BuildInformation
44
{

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"isRoot": true,
44
"tools": {
55
"cake.tool": {
6-
"version": "3.2.0",
6+
"version": "4.2.0",
77
"commands": [
88
"dotnet-cake"
99
]

.github/workflows/cicd.yml

Lines changed: 63 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,61 @@ env:
2525
TZ: CET # https://stackoverflow.com/q/53510011
2626

2727
jobs:
28-
build:
28+
ci:
2929
strategy:
30-
fail-fast: false
30+
max-parallel: 6
3131
matrix:
32-
os: [ ubuntu-22.04, windows-2022 ]
33-
34-
runs-on: ${{ matrix.os }}
32+
test-projects: [
33+
{ name: "Testcontainers", runs-on: "ubuntu-22.04" },
34+
{ name: "Testcontainers.Platform.Linux", runs-on: "ubuntu-22.04" },
35+
{ name: "Testcontainers.Platform.Windows", runs-on: "windows-2022" },
36+
{ name: "Testcontainers.Databases", runs-on: "ubuntu-22.04" },
37+
{ name: "Testcontainers.ResourceReaper", runs-on: "ubuntu-22.04" },
38+
{ name: "Testcontainers.ActiveMq", runs-on: "ubuntu-22.04" },
39+
{ name: "Testcontainers.ArangoDb", runs-on: "ubuntu-22.04" },
40+
{ name: "Testcontainers.Azurite", runs-on: "ubuntu-22.04" },
41+
{ name: "Testcontainers.BigQuery", runs-on: "ubuntu-22.04" },
42+
{ name: "Testcontainers.Bigtable", runs-on: "ubuntu-22.04" },
43+
{ name: "Testcontainers.ClickHouse", runs-on: "ubuntu-22.04" },
44+
{ name: "Testcontainers.CockroachDb", runs-on: "ubuntu-22.04" },
45+
{ name: "Testcontainers.Consul", runs-on: "ubuntu-22.04" },
46+
{ name: "Testcontainers.CosmosDb", runs-on: "ubuntu-22.04" },
47+
{ name: "Testcontainers.Couchbase", runs-on: "ubuntu-22.04" },
48+
{ name: "Testcontainers.CouchDb", runs-on: "ubuntu-22.04" },
49+
{ name: "Testcontainers.DynamoDb", runs-on: "ubuntu-22.04" },
50+
{ name: "Testcontainers.Elasticsearch", runs-on: "ubuntu-22.04" },
51+
{ name: "Testcontainers.EventStoreDb", runs-on: "ubuntu-22.04" },
52+
{ name: "Testcontainers.FakeGcsServer", runs-on: "ubuntu-22.04" },
53+
{ name: "Testcontainers.FirebirdSql", runs-on: "ubuntu-22.04" },
54+
{ name: "Testcontainers.Firestore", runs-on: "ubuntu-22.04" },
55+
{ name: "Testcontainers.InfluxDb", runs-on: "ubuntu-22.04" },
56+
{ name: "Testcontainers.JanusGraph", runs-on: "ubuntu-22.04" },
57+
{ name: "Testcontainers.K3s", runs-on: "ubuntu-22.04" },
58+
{ name: "Testcontainers.Kafka", runs-on: "ubuntu-22.04" },
59+
{ name: "Testcontainers.Keycloak", runs-on: "ubuntu-22.04" },
60+
{ name: "Testcontainers.Kusto", runs-on: "ubuntu-22.04" },
61+
{ name: "Testcontainers.LocalStack", runs-on: "ubuntu-22.04" },
62+
{ name: "Testcontainers.MariaDb", runs-on: "ubuntu-22.04" },
63+
{ name: "Testcontainers.Milvus", runs-on: "ubuntu-22.04" },
64+
{ name: "Testcontainers.Minio", runs-on: "ubuntu-22.04" },
65+
{ name: "Testcontainers.MongoDb", runs-on: "ubuntu-22.04" },
66+
{ name: "Testcontainers.MsSql", runs-on: "ubuntu-22.04" },
67+
{ name: "Testcontainers.MySql", runs-on: "ubuntu-22.04" },
68+
{ name: "Testcontainers.Nats", runs-on: "ubuntu-22.04" },
69+
{ name: "Testcontainers.Neo4j", runs-on: "ubuntu-22.04" },
70+
{ name: "Testcontainers.Oracle", runs-on: "ubuntu-22.04" },
71+
{ name: "Testcontainers.Papercut", runs-on: "ubuntu-22.04" },
72+
{ name: "Testcontainers.PostgreSql", runs-on: "ubuntu-22.04" },
73+
{ name: "Testcontainers.PubSub", runs-on: "ubuntu-22.04" },
74+
{ name: "Testcontainers.Pulsar", runs-on: "ubuntu-22.04" },
75+
{ name: "Testcontainers.RabbitMq", runs-on: "ubuntu-22.04" },
76+
{ name: "Testcontainers.RavenDb", runs-on: "ubuntu-22.04" },
77+
{ name: "Testcontainers.Redis", runs-on: "ubuntu-22.04" },
78+
{ name: "Testcontainers.Redpanda", runs-on: "ubuntu-22.04" },
79+
{ name: "Testcontainers.WebDriver", runs-on: "ubuntu-22.04" }
80+
]
81+
82+
runs-on: ${{ matrix.test-projects.runs-on }}
3583

3684
steps:
3785
- name: Checkout Repository
@@ -42,27 +90,9 @@ jobs:
4290
- name: Cache NuGet Packages
4391
uses: actions/cache@v4
4492
with:
45-
key: ${{ matrix.os }}-nuget-${{ hashFiles('Directory.Packages.props') }}
93+
key: ${{ matrix.test-projects.runs-on }}-nuget-${{ hashFiles('Directory.Packages.props') }}
4694
path: ~/.nuget/packages
4795

48-
# Our modules occupy too much disk space. The GitHub-hosted runners ran into the
49-
# error: "no space left on device." The pulled images are not cleaned up between
50-
# the test runs. One obvious approach is splitting the tests and running them on
51-
# multiple runners. However, we need to keep in mind that running too many
52-
# simultaneous builds has an impact on others as well. We observed that scheduled
53-
# Dependabot builds blocked others in the Testcontainers organization.
54-
- name: Free Disk Space
55-
uses: jlumbroso/[email protected]
56-
if: runner.os == 'Linux'
57-
with:
58-
tool-cache: true
59-
android: true
60-
dotnet: true
61-
haskell: true
62-
large-packages: true
63-
docker-images: true
64-
swap-storage: false
65-
6696
- name: Setup .NET
6797
uses: actions/setup-dotnet@v4
6898

@@ -76,28 +106,28 @@ jobs:
76106
run: dotnet cake --target=Build
77107

78108
- name: Run Tests
79-
run: dotnet cake --target=Tests --test-filter=${{ startsWith(matrix.os, 'ubuntu') && 'FullyQualifiedName~Testcontainers' || 'DockerPlatform=Windows' }}
109+
run: dotnet cake --target=Test --test-project=${{ matrix.test-projects.name }}
80110

81111
- name: Upload Test And Coverage Results
82112
uses: actions/upload-artifact@v4
83113
if: always()
84114
with:
85-
name: ${{ matrix.os }}
115+
name: ${{ matrix.test-projects.name }}
86116
path: test-results
87117

88-
publish:
118+
cd:
89119
if: ${{ contains(fromJson('["develop", "main"]'), github.ref_name) }}
90120

91-
needs: build
121+
needs: ci
92122

93123
environment: production
94124

95-
runs-on: ubuntu-22.04
96-
97125
permissions:
98126
contents: write
99127
pull-requests: read
100128

129+
runs-on: ubuntu-22.04
130+
101131
env:
102132
CODE_SIGNING_CERTIFICATE_BASE64: ${{ secrets.CODE_SIGNING_CERTIFICATE_BASE64 }}
103133
CODE_SIGNING_CERTIFICATE_PASSWORD: ${{ secrets.CODE_SIGNING_CERTIFICATE_PASSWORD }}
@@ -116,16 +146,10 @@ jobs:
116146
lfs: true
117147
fetch-depth: 0
118148

119-
- name: Download Test And Coverage Results (ubuntu-22.04)
120-
uses: actions/download-artifact@v4
121-
with:
122-
name: ubuntu-22.04
123-
path: test-results
124-
125-
- name: Download Test And Coverage Results (windows-2022)
149+
- name: Download Test And Coverage Results
126150
uses: actions/download-artifact@v4
127151
with:
128-
name: windows-2022
152+
pattern: Testcontainers*
129153
path: test-results
130154

131155
- name: Fix Absolute Code Coverage Paths
@@ -142,7 +166,7 @@ jobs:
142166
uses: actions/setup-java@v4
143167
with:
144168
distribution: temurin
145-
java-version: 17
169+
java-version: 21
146170

147171
- name: Setup .NET
148172
uses: actions/setup-dotnet@v4

.github/workflows/test-report.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,19 @@ on:
88

99
jobs:
1010
report:
11-
strategy:
12-
fail-fast: false
13-
matrix:
14-
os: [ ubuntu-22.04, windows-2022 ]
15-
16-
runs-on: ${{ matrix.os }}
17-
1811
permissions:
1912
actions: read
2013
checks: write
2114
contents: read
2215

16+
runs-on: ubuntu-22.04
17+
2318
steps:
2419
# https://github.com/dorny/test-reporter/issues/363#issuecomment-2381625959.
2520
- name: Publish Test Report
2621
uses: dorny/[email protected]
2722
with:
28-
artifact: ${{ matrix.os }}
29-
name: report (${{ matrix.os }})
23+
artifact: Testcontainers*
24+
name: Test Report
3025
path: '*.trx'
3126
reporter: dotnet-trx

build.cake

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#tool nuget:?package=dotnet-sonarscanner&version=9.0.0
1+
#tool nuget:?package=dotnet-sonarscanner&version=9.0.1
22

3-
#addin nuget:?package=Cake.Sonar&version=1.1.32
3+
#addin nuget:?package=Cake.Sonar&version=1.1.33
44

5-
#addin nuget:?package=Cake.Git&version=3.0.0
5+
#addin nuget:?package=Cake.Git&version=4.0.0
66

77
#load ".cake-scripts/parameters.cake"
88

@@ -71,6 +71,26 @@ Task("Build")
7171
});
7272
});
7373

74+
Task("Test")
75+
.Does(() =>
76+
{
77+
var testProject = param.Projects.OnlyTests
78+
.Select(testProject => testProject.Path.FullPath)
79+
.Single(testProject => testProject.EndsWith(param.TestProject + ".Tests.csproj"));
80+
81+
DotNetTest(testProject, new DotNetTestSettings
82+
{
83+
Configuration = param.Configuration,
84+
Verbosity = param.Verbosity,
85+
NoRestore = true,
86+
NoBuild = true,
87+
Collectors = new[] { "XPlat Code Coverage;Format=opencover" },
88+
ResultsDirectory = param.Paths.Directories.TestResultsDirectoryPath,
89+
ArgumentCustomization = args => args
90+
.AppendSwitchQuoted("--blame-hang-timeout", "5m")
91+
});
92+
});
93+
7494
Task("Tests")
7595
.Does(() =>
7696
{
@@ -111,7 +131,10 @@ Task("Sonar-Begin")
111131
PullRequestBranch = param.SourceBranch,
112132
PullRequestBase = param.TargetBranch,
113133
OpenCoverReportsPath = $"{MakeAbsolute(param.Paths.Directories.TestResultsDirectoryPath)}/**/*.opencover.xml",
114-
VsTestReportsPath = $"{MakeAbsolute(param.Paths.Directories.TestResultsDirectoryPath)}/**/*.trx"
134+
VsTestReportsPath = $"{MakeAbsolute(param.Paths.Directories.TestResultsDirectoryPath)}/**/*.trx",
135+
ArgumentCustomization = args => args
136+
.Append("/d:sonar.scanner.scanAll=\"false\"")
137+
.Append("/d:sonar.scanner.skipJreProvisioning=\"true\"")
115138
});
116139
});
117140

tests/Testcontainers.Platform.Linux.Tests/TarOutputMemoryStreamTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public sealed class HttpFixture : IAsyncLifetime
174174
private readonly IContainer _container = new ContainerBuilder()
175175
.WithImage(CommonImages.Alpine)
176176
.WithEntrypoint("/bin/sh", "-c")
177-
.WithCommand($"while true; do echo \"HTTP/1.1 200 OK\r\n\" | nc -l -p {HttpPort}; done")
177+
.WithCommand($"while true; do echo \"HTTP/1.1 200 OK\r\n\r\n\" | nc -l -p {HttpPort}; done")
178178
.WithPortBinding(HttpPort, true)
179179
.Build();
180180

tests/Testcontainers.Tests/Unit/Configurations/WaitUntilHttpRequestIsSucceededTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public sealed class WaitUntilHttpRequestIsSucceededTest : IAsyncLifetime
1919
private readonly IContainer _container = new ContainerBuilder()
2020
.WithImage(CommonImages.Alpine)
2121
.WithEntrypoint("/bin/sh", "-c")
22-
.WithCommand($"while true; do echo \"HTTP/1.1 200 OK\r\n\" | nc -l -p {HttpPort}; done")
22+
.WithCommand($"while true; do echo \"HTTP/1.1 200 OK\r\n\r\n\" | nc -l -p {HttpPort}; done")
2323
.WithPortBinding(HttpPort, true)
2424
.Build();
2525

0 commit comments

Comments
 (0)