forked from dotnet/Docker.DotNet
-
-
Notifications
You must be signed in to change notification settings - Fork 15
142 lines (131 loc) · 4.31 KB
/
ci.yml
File metadata and controls
142 lines (131 loc) · 4.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: CI
on:
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-24.04
services:
# Docker without TLS (plain TCP) !DEPRECATED! with next docker release
docker-without-tls:
image: docker:29.1.1-dind
env:
DOCKER_TLS_CERTDIR: ""
ports:
- 2375:2375
options: >-
--privileged
# Docker with TLS (secure TCP)
docker-with-tls:
image: docker:29.1.1-dind
env:
DOCKER_TLS_CERTDIR: /certs
ports:
- 2376:2376
options: >-
--privileged
volumes:
- /home/runner/certs:/certs
strategy:
fail-fast: false
matrix:
dotnet:
- sdk: 8.x
tfm: net8.0
- sdk: 9.x
tfm: net9.0
- sdk: 10.x
tfm: net10.0
docker:
- name: unix
docker_host: unix:///var/run/docker.sock
tls_verify: ""
cert_path: ""
native_http: 0
needs_dind: false
- name: tcp-2375
docker_host: tcp://localhost:2375
tls_verify: ""
cert_path: ""
native_http: 0
needs_dind: true
- name: tcp-2376-tls
docker_host: tcp://localhost:2376
tls_verify: 1
cert_path: /home/runner/certs/client
native_http: 0
needs_dind: true
- name: tcp-2375-native
docker_host: tcp://localhost:2375
tls_verify: ""
cert_path: ""
native_http: 1
needs_dind: true
- name: tcp-2376-tls-native
docker_host: tcp://localhost:2376
tls_verify: 1
cert_path: /home/runner/certs/client
native_http: 1
needs_dind: true
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup .NET Core
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ matrix.dotnet.sdk }}
- name: Build
run: >-
dotnet build
--configuration Release
--framework ${{ matrix.dotnet.tfm }}
- name: Create client PKCS#12 bundle
if: ${{ matrix.docker.tls_verify == 1 }}
run: |
sudo chown -R $USER:$USER $HOME/certs
openssl pkcs12 -export \
-out "$HOME/certs/client/client.pfx" \
-inkey "$HOME/certs/client/key.pem" \
-in "$HOME/certs/client/cert.pem" \
-certfile "$HOME/certs/client/ca.pem" \
-passout pass:
- name: Wait for Docker to be healthy (2375)
if: ${{ matrix.docker.needs_dind && matrix.docker.docker_host == 'tcp://localhost:2375' }}
run: |
for i in {1..10}; do
if docker --host=tcp://localhost:2375 version; then
echo "Docker is ready on port 2375"
exit 0
fi
echo "Waiting for Docker on port 2375..."
sleep 3
done
echo "Docker on port 2375 did not become ready in time."
exit 1
- name: Wait for Docker to be healthy (2376)
if: ${{ matrix.docker.needs_dind && matrix.docker.docker_host == 'tcp://localhost:2376' }}
run: |
for i in {1..10}; do
if docker --host=tcp://localhost:2376 --tlsverify \
--tlscacert="$HOME/certs/client/ca.pem" \
--tlscert="$HOME/certs/client/cert.pem" \
--tlskey="$HOME/certs/client/key.pem" version; then
echo "Docker is ready on port 2376"
exit 0
fi
echo "Waiting for Docker on port 2376..."
sleep 3
done
echo "Docker on port 2376 did not become ready in time."
exit 1
- name: Test (${{ matrix.docker.name }})
run: |
./test/Docker.DotNet.Tests/bin/Release/${{ matrix.dotnet.tfm }}/linux-x64/publish/Docker.DotNet.Tests
./test/Docker.DotNet.TestsV2/bin/Release/${{ matrix.dotnet.tfm }}/linux-x64/publish/Docker.DotNet.TestsV2
env:
DOCKER_HOST: ${{ matrix.docker.docker_host }}
DOCKER_TLS_VERIFY: ${{ matrix.docker.tls_verify }}
DOCKER_CERT_PATH: ${{ matrix.docker.cert_path }}
DOCKER_DOTNET_NATIVE_HTTP_ENABLED: ${{ matrix.docker.native_http }}