Skip to content

Commit af238fd

Browse files
feat: Split HTTP handlers into sub-projects (testcontainers#44)
Co-authored-by: Andre Hofmeister <9199345+HofmeisterAn@users.noreply.github.com>
1 parent 5b41b33 commit af238fd

50 files changed

Lines changed: 1125 additions & 195 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 128 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,139 @@ on:
88
jobs:
99
build:
1010
runs-on: ubuntu-24.04
11+
services:
12+
# Docker without TLS (plain TCP) !DEPRECATED! with next docker release
13+
docker-without-tls:
14+
image: docker:29.1.1-dind
15+
env:
16+
DOCKER_TLS_CERTDIR: ""
17+
ports:
18+
- 2375:2375
19+
options: >-
20+
--privileged
21+
22+
# Docker with TLS (secure TCP)
23+
docker-with-tls:
24+
image: docker:29.1.1-dind
25+
env:
26+
DOCKER_TLS_CERTDIR: /certs
27+
ports:
28+
- 2376:2376
29+
options: >-
30+
--privileged
31+
volumes:
32+
- /home/runner/certs:/certs
33+
1134
strategy:
35+
fail-fast: false
1236
matrix:
13-
framework:
14-
- net8.0
15-
- net9.0
16-
- net10.0
37+
dotnet:
38+
- sdk: 8.x
39+
tfm: net8.0
40+
- sdk: 9.x
41+
tfm: net9.0
42+
- sdk: 10.x
43+
tfm: net10.0
44+
docker:
45+
- name: unix
46+
docker_host: unix:///var/run/docker.sock
47+
tls_verify: ""
48+
cert_path: ""
49+
native_http: 0
50+
needs_dind: false
51+
- name: tcp-2375
52+
docker_host: tcp://localhost:2375
53+
tls_verify: ""
54+
cert_path: ""
55+
native_http: 0
56+
needs_dind: true
57+
- name: tcp-2376-tls
58+
docker_host: tcp://localhost:2376
59+
tls_verify: 1
60+
cert_path: /home/runner/certs/client
61+
native_http: 0
62+
needs_dind: true
63+
- name: tcp-2375-native
64+
docker_host: tcp://localhost:2375
65+
tls_verify: ""
66+
cert_path: ""
67+
native_http: 1
68+
needs_dind: true
69+
- name: tcp-2376-tls-native
70+
docker_host: tcp://localhost:2376
71+
tls_verify: 1
72+
cert_path: /home/runner/certs/client
73+
native_http: 1
74+
needs_dind: true
75+
1776
steps:
18-
- uses: actions/checkout@v4
77+
- uses: actions/checkout@v6
1978
with:
2079
fetch-depth: 0
80+
2181
- name: Setup .NET Core
22-
uses: actions/setup-dotnet@v4
82+
uses: actions/setup-dotnet@v5
2383
with:
24-
dotnet-version: 10.x
84+
dotnet-version: ${{ matrix.dotnet.sdk }}
85+
2586
- name: Build
26-
run: dotnet build -c Release --framework ${{ matrix.framework }}
27-
- name: Test
28-
run: dotnet test -c Release --framework ${{ matrix.framework }} --no-build --logger console
87+
run: >-
88+
dotnet build
89+
--configuration Release
90+
--framework ${{ matrix.dotnet.tfm }}
91+
92+
- name: Create client PKCS#12 bundle
93+
if: ${{ matrix.docker.tls_verify == 1 }}
94+
run: |
95+
sudo chown -R $USER:$USER $HOME/certs
96+
openssl pkcs12 -export \
97+
-out "$HOME/certs/client/client.pfx" \
98+
-inkey "$HOME/certs/client/key.pem" \
99+
-in "$HOME/certs/client/cert.pem" \
100+
-certfile "$HOME/certs/client/ca.pem" \
101+
-passout pass:
102+
103+
- name: Wait for Docker to be healthy (2375)
104+
if: ${{ matrix.docker.needs_dind && matrix.docker.docker_host == 'tcp://localhost:2375' }}
105+
run: |
106+
for i in {1..10}; do
107+
if docker --host=tcp://localhost:2375 version; then
108+
echo "Docker is ready on port 2375"
109+
exit 0
110+
fi
111+
echo "Waiting for Docker on port 2375..."
112+
sleep 3
113+
done
114+
echo "Docker on port 2375 did not become ready in time."
115+
exit 1
116+
117+
- name: Wait for Docker to be healthy (2376)
118+
if: ${{ matrix.docker.needs_dind && matrix.docker.docker_host == 'tcp://localhost:2376' }}
119+
run: |
120+
for i in {1..10}; do
121+
if docker --host=tcp://localhost:2376 --tlsverify \
122+
--tlscacert="$HOME/certs/client/ca.pem" \
123+
--tlscert="$HOME/certs/client/cert.pem" \
124+
--tlskey="$HOME/certs/client/key.pem" version; then
125+
echo "Docker is ready on port 2376"
126+
exit 0
127+
fi
128+
echo "Waiting for Docker on port 2376..."
129+
sleep 3
130+
done
131+
echo "Docker on port 2376 did not become ready in time."
132+
exit 1
133+
134+
- name: Test (${{ matrix.docker.name }})
135+
run: >-
136+
dotnet test
137+
--configuration Release
138+
--framework ${{ matrix.dotnet.tfm }}
139+
--no-restore
140+
--no-build
141+
--logger console
142+
env:
143+
DOCKER_HOST: ${{ matrix.docker.docker_host }}
144+
DOCKER_TLS_VERIFY: ${{ matrix.docker.tls_verify }}
145+
DOCKER_CERT_PATH: ${{ matrix.docker.cert_path }}
146+
DOCKER_DOTNET_NATIVE_HTTP_ENABLED: ${{ matrix.docker.native_http }}

.github/workflows/publish.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ jobs:
1212
build:
1313
runs-on: ubuntu-24.04
1414
steps:
15-
- uses: actions/checkout@v4
15+
- uses: actions/checkout@v6
1616
with:
1717
fetch-depth: 0
1818
- name: Setup .NET Core
19-
uses: actions/setup-dotnet@v4
19+
uses: actions/setup-dotnet@v5
2020
with:
2121
dotnet-version: 10.x
2222
- name: Install NBGV tool
@@ -28,7 +28,7 @@ jobs:
2828
- name: Push packages to NuGet.org
2929
run: dotnet nuget push ./packages/Docker.DotNet.*.nupkg --skip-duplicate -k ${{ secrets.NUGET_KEY }} -s https://api.nuget.org/v3/index.json
3030
- name: Create Release
31-
uses: actions/github-script@v7
31+
uses: actions/github-script@v8
3232
with:
3333
script: |
3434
github.rest.repos.createRelease({

Directory.Packages.props

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project>
2+
<PropertyGroup>
3+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
4+
</PropertyGroup>
5+
<ItemGroup>
6+
<GlobalPackageReference Include="Nerdbank.GitVersioning" Version="3.5.119" />
7+
</ItemGroup>
8+
<ItemGroup>
9+
<PackageVersion Include="System.IO.Pipelines" Version="8.0.0" />
10+
<PackageVersion Include="System.Net.Http.Json" Version="8.0.1" />
11+
<PackageVersion Include="System.Text.Json" Version="8.0.5" />
12+
<PackageVersion Include="BouncyCastle.Cryptography" Version="2.5.1" />
13+
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.3" />
14+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
15+
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
16+
<PackageVersion Include="xunit" Version="2.9.2" />
17+
</ItemGroup>
18+
</Project>

0 commit comments

Comments
 (0)