|
8 | 8 | jobs: |
9 | 9 | build: |
10 | 10 | 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 | + |
11 | 34 | strategy: |
| 35 | + fail-fast: false |
12 | 36 | 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 | + |
17 | 76 | steps: |
18 | | - - uses: actions/checkout@v4 |
| 77 | + - uses: actions/checkout@v6 |
19 | 78 | with: |
20 | 79 | fetch-depth: 0 |
| 80 | + |
21 | 81 | - name: Setup .NET Core |
22 | | - uses: actions/setup-dotnet@v4 |
| 82 | + uses: actions/setup-dotnet@v5 |
23 | 83 | with: |
24 | | - dotnet-version: 10.x |
| 84 | + dotnet-version: ${{ matrix.dotnet.sdk }} |
| 85 | + |
25 | 86 | - 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 }} |
0 commit comments