github.com/adityamillind98/moby@v23.0.0-rc.4+incompatible/.github/workflows/.windows.yml (about) 1 # reusable workflow 2 name: .windows 3 4 # TODO: hide reusable workflow from the UI. Tracked in https://github.com/community/community/discussions/12025 5 6 on: 7 workflow_call: 8 inputs: 9 os: 10 required: true 11 type: string 12 send_coverage: 13 required: false 14 type: boolean 15 default: false 16 17 env: 18 GO_VERSION: 1.19.5 19 GOTESTLIST_VERSION: v0.2.0 20 TESTSTAT_VERSION: v0.1.3 21 WINDOWS_BASE_IMAGE: mcr.microsoft.com/windows/servercore 22 WINDOWS_BASE_TAG_2019: ltsc2019 23 WINDOWS_BASE_TAG_2022: ltsc2022 24 TEST_IMAGE_NAME: moby:test 25 TEST_CTN_NAME: moby 26 DOCKER_BUILDKIT: 0 27 ITG_CLI_MATRIX_SIZE: 6 28 29 jobs: 30 build: 31 runs-on: ${{ inputs.os }} 32 env: 33 GOPATH: ${{ github.workspace }}\go 34 GOBIN: ${{ github.workspace }}\go\bin 35 BIN_OUT: ${{ github.workspace }}\out 36 defaults: 37 run: 38 working-directory: ${{ env.GOPATH }}/src/github.com/docker/docker 39 steps: 40 - 41 name: Checkout 42 uses: actions/checkout@v3 43 with: 44 path: ${{ env.GOPATH }}/src/github.com/docker/docker 45 - 46 name: Env 47 run: | 48 Get-ChildItem Env: | Out-String 49 - 50 name: Init 51 run: | 52 New-Item -ItemType "directory" -Path "${{ github.workspace }}\go-build" 53 New-Item -ItemType "directory" -Path "${{ github.workspace }}\go\pkg\mod" 54 If ("${{ inputs.os }}" -eq "windows-2019") { 55 echo "WINDOWS_BASE_IMAGE_TAG=${{ env.WINDOWS_BASE_TAG_2019 }}" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append 56 } ElseIf ("${{ inputs.os }}" -eq "windows-2022") { 57 echo "WINDOWS_BASE_IMAGE_TAG=${{ env.WINDOWS_BASE_TAG_2022 }}" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append 58 } 59 - 60 name: Cache 61 uses: actions/cache@v3 62 with: 63 path: | 64 ~\AppData\Local\go-build 65 ~\go\pkg\mod 66 ${{ github.workspace }}\go-build 67 ${{ env.GOPATH }}\pkg\mod 68 key: ${{ inputs.os }}-${{ github.job }}-${{ hashFiles('**/vendor.sum') }} 69 restore-keys: | 70 ${{ inputs.os }}-${{ github.job }}- 71 - 72 name: Docker info 73 run: | 74 docker info 75 - 76 name: Build base image 77 run: | 78 docker pull ${{ env.WINDOWS_BASE_IMAGE }}:${{ env.WINDOWS_BASE_IMAGE_TAG }} 79 docker tag ${{ env.WINDOWS_BASE_IMAGE }}:${{ env.WINDOWS_BASE_IMAGE_TAG }} microsoft/windowsservercore 80 docker build --build-arg GO_VERSION -t ${{ env.TEST_IMAGE_NAME }} -f Dockerfile.windows . 81 - 82 name: Build binaries 83 run: | 84 & docker run --name ${{ env.TEST_CTN_NAME }} -e "DOCKER_GITCOMMIT=${{ github.sha }}" ` 85 -v "${{ github.workspace }}\go-build:C:\Users\ContainerAdministrator\AppData\Local\go-build" ` 86 -v "${{ github.workspace }}\go\pkg\mod:C:\gopath\pkg\mod" ` 87 ${{ env.TEST_IMAGE_NAME }} hack\make.ps1 -Daemon -Client 88 - 89 name: Copy artifacts 90 run: | 91 New-Item -ItemType "directory" -Path "${{ env.BIN_OUT }}" 92 docker cp "${{ env.TEST_CTN_NAME }}`:c`:\gopath\src\github.com\docker\docker\bundles\docker.exe" ${{ env.BIN_OUT }}\ 93 docker cp "${{ env.TEST_CTN_NAME }}`:c`:\gopath\src\github.com\docker\docker\bundles\dockerd.exe" ${{ env.BIN_OUT }}\ 94 docker cp "${{ env.TEST_CTN_NAME }}`:c`:\gopath\bin\gotestsum.exe" ${{ env.BIN_OUT }}\ 95 docker cp "${{ env.TEST_CTN_NAME }}`:c`:\containerd\bin\containerd.exe" ${{ env.BIN_OUT }}\ 96 docker cp "${{ env.TEST_CTN_NAME }}`:c`:\containerd\bin\containerd-shim-runhcs-v1.exe" ${{ env.BIN_OUT }}\ 97 - 98 name: Upload artifacts 99 uses: actions/upload-artifact@v3 100 with: 101 name: build-${{ inputs.os }} 102 path: ${{ env.BIN_OUT }}/* 103 if-no-files-found: error 104 retention-days: 2 105 106 unit-test: 107 runs-on: ${{ inputs.os }} 108 timeout-minutes: 120 109 env: 110 GOPATH: ${{ github.workspace }}\go 111 GOBIN: ${{ github.workspace }}\go\bin 112 defaults: 113 run: 114 working-directory: ${{ env.GOPATH }}/src/github.com/docker/docker 115 steps: 116 - 117 name: Checkout 118 uses: actions/checkout@v3 119 with: 120 path: ${{ env.GOPATH }}/src/github.com/docker/docker 121 - 122 name: Env 123 run: | 124 Get-ChildItem Env: | Out-String 125 - 126 name: Init 127 run: | 128 New-Item -ItemType "directory" -Path "${{ github.workspace }}\go-build" 129 New-Item -ItemType "directory" -Path "${{ github.workspace }}\go\pkg\mod" 130 New-Item -ItemType "directory" -Path "bundles" 131 If ("${{ inputs.os }}" -eq "windows-2019") { 132 echo "WINDOWS_BASE_IMAGE_TAG=${{ env.WINDOWS_BASE_TAG_2019 }}" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append 133 } ElseIf ("${{ inputs.os }}" -eq "windows-2022") { 134 echo "WINDOWS_BASE_IMAGE_TAG=${{ env.WINDOWS_BASE_TAG_2022 }}" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append 135 } 136 - 137 name: Cache 138 uses: actions/cache@v3 139 with: 140 path: | 141 ~\AppData\Local\go-build 142 ~\go\pkg\mod 143 ${{ github.workspace }}\go-build 144 ${{ env.GOPATH }}\pkg\mod 145 key: ${{ inputs.os }}-${{ github.job }}-${{ hashFiles('**/vendor.sum') }} 146 restore-keys: | 147 ${{ inputs.os }}-${{ github.job }}- 148 - 149 name: Docker info 150 run: | 151 docker info 152 - 153 name: Build base image 154 run: | 155 docker pull ${{ env.WINDOWS_BASE_IMAGE }}:${{ env.WINDOWS_BASE_IMAGE_TAG }} 156 docker tag ${{ env.WINDOWS_BASE_IMAGE }}:${{ env.WINDOWS_BASE_IMAGE_TAG }} microsoft/windowsservercore 157 docker build --build-arg GO_VERSION -t ${{ env.TEST_IMAGE_NAME }} -f Dockerfile.windows . 158 - 159 name: Test 160 run: | 161 & docker run --name ${{ env.TEST_CTN_NAME }} -e "DOCKER_GITCOMMIT=${{ github.sha }}" ` 162 -v "${{ github.workspace }}\go-build:C:\Users\ContainerAdministrator\AppData\Local\go-build" ` 163 -v "${{ github.workspace }}\go\pkg\mod:C:\gopath\pkg\mod" ` 164 -v "${{ env.GOPATH }}\src\github.com\docker\docker\bundles:C:\gopath\src\github.com\docker\docker\bundles" ` 165 ${{ env.TEST_IMAGE_NAME }} hack\make.ps1 -TestUnit 166 - 167 name: Send to Codecov 168 if: inputs.send_coverage 169 uses: codecov/codecov-action@v3 170 with: 171 working-directory: ${{ env.GOPATH }}\src\github.com\docker\docker 172 directory: bundles 173 env_vars: RUNNER_OS 174 flags: unit 175 - 176 name: Upload reports 177 if: always() 178 uses: actions/upload-artifact@v3 179 with: 180 name: ${{ inputs.os }}-unit-reports 181 path: ${{ env.GOPATH }}\src\github.com\docker\docker\bundles\* 182 183 unit-test-report: 184 runs-on: ubuntu-latest 185 if: always() 186 needs: 187 - unit-test 188 steps: 189 - 190 name: Set up Go 191 uses: actions/setup-go@v3 192 with: 193 go-version: ${{ env.GO_VERSION }} 194 - 195 name: Download artifacts 196 uses: actions/download-artifact@v3 197 with: 198 name: ${{ inputs.os }}-unit-reports 199 path: /tmp/artifacts 200 - 201 name: Install teststat 202 run: | 203 go install github.com/vearutop/teststat@${{ env.TESTSTAT_VERSION }} 204 - 205 name: Create summary 206 run: | 207 teststat -markdown $(find /tmp/artifacts -type f -name '*.json' -print0 | xargs -0) >> $GITHUB_STEP_SUMMARY 208 209 integration-test-prepare: 210 runs-on: ubuntu-latest 211 outputs: 212 matrix: ${{ steps.tests.outputs.matrix }} 213 steps: 214 - 215 name: Checkout 216 uses: actions/checkout@v3 217 - 218 name: Set up Go 219 uses: actions/setup-go@v3 220 with: 221 go-version: ${{ env.GO_VERSION }} 222 - 223 name: Install gotestlist 224 run: 225 go install github.com/crazy-max/gotestlist/cmd/gotestlist@${{ env.GOTESTLIST_VERSION }} 226 - 227 name: Create matrix 228 id: tests 229 working-directory: ./integration-cli 230 run: | 231 # Distribute integration-cli tests for the matrix in integration-test job. 232 # Also prepend ./... to the matrix. This is a special case to run "Test integration" step exclusively. 233 matrix="$(gotestlist -d ${{ env.ITG_CLI_MATRIX_SIZE }} ./...)" 234 matrix="$(echo "$matrix" | jq -c '. |= ["./..."] + .')" 235 echo "matrix=$matrix" >> $GITHUB_OUTPUT 236 - 237 name: Show matrix 238 run: | 239 echo ${{ steps.tests.outputs.matrix }} 240 241 integration-test: 242 runs-on: ${{ inputs.os }} 243 timeout-minutes: 120 244 needs: 245 - build 246 - integration-test-prepare 247 strategy: 248 fail-fast: false 249 matrix: 250 runtime: 251 - builtin 252 - containerd 253 test: ${{ fromJson(needs.integration-test-prepare.outputs.matrix) }} 254 env: 255 GOPATH: ${{ github.workspace }}\go 256 GOBIN: ${{ github.workspace }}\go\bin 257 BIN_OUT: ${{ github.workspace }}\out 258 defaults: 259 run: 260 working-directory: ${{ env.GOPATH }}/src/github.com/docker/docker 261 steps: 262 - 263 name: Checkout 264 uses: actions/checkout@v3 265 with: 266 path: ${{ env.GOPATH }}/src/github.com/docker/docker 267 - 268 name: Env 269 run: | 270 Get-ChildItem Env: | Out-String 271 - 272 name: Download artifacts 273 uses: actions/download-artifact@v3 274 with: 275 name: build-${{ inputs.os }} 276 path: ${{ env.BIN_OUT }} 277 - 278 name: Init 279 run: | 280 New-Item -ItemType "directory" -Path "bundles" 281 If ("${{ inputs.os }}" -eq "windows-2019") { 282 echo "WINDOWS_BASE_IMAGE_TAG=${{ env.WINDOWS_BASE_TAG_2019 }}" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append 283 } ElseIf ("${{ inputs.os }}" -eq "windows-2022") { 284 echo "WINDOWS_BASE_IMAGE_TAG=${{ env.WINDOWS_BASE_TAG_2022 }}" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append 285 } 286 Write-Output "${{ env.BIN_OUT }}" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append 287 - 288 # removes docker service that is currently installed on the runner. we 289 # could use Uninstall-Package but not yet available on Windows runners. 290 # more info: https://github.com/actions/virtual-environments/blob/d3a5bad25f3b4326c5666bab0011ac7f1beec95e/images/win/scripts/Installers/Install-Docker.ps1#L11 291 name: Removing current daemon 292 run: | 293 if (Get-Service docker -ErrorAction SilentlyContinue) { 294 $dockerVersion = (docker version -f "{{.Server.Version}}") 295 Write-Host "Current installed Docker version: $dockerVersion" 296 # remove service 297 Stop-Service -Force -Name docker 298 Remove-Service -Name docker 299 # removes event log entry. we could use "Remove-EventLog -LogName -Source docker" 300 # but this cmd is not available atm 301 $ErrorActionPreference = "SilentlyContinue" 302 & reg delete "HKLM\SYSTEM\CurrentControlSet\Services\EventLog\Application\docker" /f 2>&1 | Out-Null 303 $ErrorActionPreference = "Stop" 304 Write-Host "Service removed" 305 } 306 - 307 name: Starting containerd 308 if: matrix.runtime == 'containerd' 309 run: | 310 Write-Host "Generating config" 311 & "${{ env.BIN_OUT }}\containerd.exe" config default | Out-File "$env:TEMP\ctn.toml" -Encoding ascii 312 Write-Host "Creating service" 313 New-Item -ItemType Directory "$env:TEMP\ctn-root" -ErrorAction SilentlyContinue | Out-Null 314 New-Item -ItemType Directory "$env:TEMP\ctn-state" -ErrorAction SilentlyContinue | Out-Null 315 Start-Process -Wait "${{ env.BIN_OUT }}\containerd.exe" ` 316 -ArgumentList "--log-level=debug", ` 317 "--config=$env:TEMP\ctn.toml", ` 318 "--address=\\.\pipe\containerd-containerd", ` 319 "--root=$env:TEMP\ctn-root", ` 320 "--state=$env:TEMP\ctn-state", ` 321 "--log-file=$env:TEMP\ctn.log", ` 322 "--register-service" 323 Write-Host "Starting service" 324 Start-Service -Name containerd 325 Start-Sleep -Seconds 5 326 Write-Host "Service started successfully!" 327 - 328 name: Starting test daemon 329 run: | 330 Write-Host "Creating service" 331 If ("${{ matrix.runtime }}" -eq "containerd") { 332 $runtimeArg="--containerd=\\.\pipe\containerd-containerd" 333 echo "DOCKER_WINDOWS_CONTAINERD_RUNTIME=1" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append 334 } 335 New-Item -ItemType Directory "$env:TEMP\moby-root" -ErrorAction SilentlyContinue | Out-Null 336 New-Item -ItemType Directory "$env:TEMP\moby-exec" -ErrorAction SilentlyContinue | Out-Null 337 Start-Process -Wait -NoNewWindow "${{ env.BIN_OUT }}\dockerd" ` 338 -ArgumentList $runtimeArg, "--debug", ` 339 "--host=npipe:////./pipe/docker_engine", ` 340 "--data-root=$env:TEMP\moby-root", ` 341 "--exec-root=$env:TEMP\moby-exec", ` 342 "--pidfile=$env:TEMP\docker.pid", ` 343 "--register-service" 344 Write-Host "Starting service" 345 Start-Service -Name docker 346 Write-Host "Service started successfully!" 347 - 348 name: Waiting for test daemon to start 349 run: | 350 $tries=20 351 Write-Host "Waiting for the test daemon to start..." 352 While ($true) { 353 $ErrorActionPreference = "SilentlyContinue" 354 & "${{ env.BIN_OUT }}\docker" version 355 $ErrorActionPreference = "Stop" 356 If ($LastExitCode -eq 0) { 357 break 358 } 359 $tries-- 360 If ($tries -le 0) { 361 Throw "Failed to get a response from the daemon" 362 } 363 Write-Host -NoNewline "." 364 Start-Sleep -Seconds 1 365 } 366 Write-Host "Test daemon started and replied!" 367 env: 368 DOCKER_HOST: npipe:////./pipe/docker_engine 369 - 370 name: Docker info 371 run: | 372 & "${{ env.BIN_OUT }}\docker" info 373 env: 374 DOCKER_HOST: npipe:////./pipe/docker_engine 375 - 376 name: Building contrib/busybox 377 run: | 378 & "${{ env.BIN_OUT }}\docker" build -t busybox ` 379 --build-arg WINDOWS_BASE_IMAGE ` 380 --build-arg WINDOWS_BASE_IMAGE_TAG ` 381 .\contrib\busybox\ 382 env: 383 DOCKER_HOST: npipe:////./pipe/docker_engine 384 - 385 name: List images 386 run: | 387 & "${{ env.BIN_OUT }}\docker" images 388 env: 389 DOCKER_HOST: npipe:////./pipe/docker_engine 390 - 391 name: Set up Go 392 uses: actions/setup-go@v3 393 with: 394 go-version: ${{ env.GO_VERSION }} 395 - 396 name: Test integration 397 if: matrix.test == './...' 398 run: | 399 .\hack\make.ps1 -TestIntegration 400 env: 401 DOCKER_HOST: npipe:////./pipe/docker_engine 402 GO111MODULE: "off" 403 TEST_CLIENT_BINARY: ${{ env.BIN_OUT }}\docker 404 - 405 name: Test integration-cli 406 if: matrix.test != './...' 407 run: | 408 .\hack\make.ps1 -TestIntegrationCli 409 env: 410 DOCKER_HOST: npipe:////./pipe/docker_engine 411 GO111MODULE: "off" 412 TEST_CLIENT_BINARY: ${{ env.BIN_OUT }}\docker 413 INTEGRATION_TESTRUN: ${{ matrix.test }} 414 - 415 name: Send to Codecov 416 if: inputs.send_coverage 417 uses: codecov/codecov-action@v3 418 with: 419 working-directory: ${{ env.GOPATH }}\src\github.com\docker\docker 420 directory: bundles 421 env_vars: RUNNER_OS 422 flags: integration,${{ matrix.runtime }} 423 - 424 name: Docker info 425 run: | 426 & "${{ env.BIN_OUT }}\docker" info 427 env: 428 DOCKER_HOST: npipe:////./pipe/docker_engine 429 - 430 name: Stop containerd 431 if: always() && matrix.runtime == 'containerd' 432 run: | 433 $ErrorActionPreference = "SilentlyContinue" 434 Stop-Service -Force -Name containerd 435 $ErrorActionPreference = "Stop" 436 - 437 name: Containerd logs 438 if: always() && matrix.runtime == 'containerd' 439 run: | 440 Copy-Item "$env:TEMP\ctn.log" -Destination ".\bundles\containerd.log" 441 Get-Content "$env:TEMP\ctn.log" | Out-Host 442 - 443 name: Stop daemon 444 if: always() 445 run: | 446 $ErrorActionPreference = "SilentlyContinue" 447 Stop-Service -Force -Name docker 448 $ErrorActionPreference = "Stop" 449 - 450 # as the daemon is registered as a service we have to check the event 451 # logs against the docker provider. 452 name: Daemon event logs 453 if: always() 454 run: | 455 Get-WinEvent -ea SilentlyContinue ` 456 -FilterHashtable @{ProviderName= "docker"; LogName = "application"} | 457 Select-Object -Property TimeCreated, @{N='Detailed Message'; E={$_.Message}} | 458 Sort-Object @{Expression="TimeCreated";Descending=$false} | 459 Select-Object -ExpandProperty 'Detailed Message' | Tee-Object -file ".\bundles\daemon.log" 460 - 461 name: Upload reports 462 if: always() 463 uses: actions/upload-artifact@v3 464 with: 465 name: ${{ inputs.os }}-integration-reports-${{ matrix.runtime }} 466 path: ${{ env.GOPATH }}\src\github.com\docker\docker\bundles\* 467 468 integration-test-report: 469 runs-on: ubuntu-latest 470 if: always() 471 needs: 472 - integration-test 473 strategy: 474 fail-fast: false 475 matrix: 476 runtime: 477 - builtin 478 - containerd 479 steps: 480 - 481 name: Set up Go 482 uses: actions/setup-go@v3 483 with: 484 go-version: ${{ env.GO_VERSION }} 485 - 486 name: Download artifacts 487 uses: actions/download-artifact@v3 488 with: 489 name: ${{ inputs.os }}-integration-reports-${{ matrix.runtime }} 490 path: /tmp/artifacts 491 - 492 name: Install teststat 493 run: | 494 go install github.com/vearutop/teststat@${{ env.TESTSTAT_VERSION }} 495 - 496 name: Create summary 497 run: | 498 teststat -markdown $(find /tmp/artifacts -type f -name '*.json' -print0 | xargs -0) >> $GITHUB_STEP_SUMMARY