| name: 'Setup Windows test daemon' | |
| description: 'Set up the Windows test daemon as a service' | |
| inputs: | |
| bin_out: | |
| description: 'Path containing the Docker binaries' | |
| required: true | |
| containerd: | |
| description: 'Containerd mode (embedded or external)' | |
| required: true | |
| runtime: | |
| description: 'Runtime mode (containerd or legacy)' | |
| required: true | |
| storage: | |
| description: 'Storage mode (snapshotter or graphdriver)' | |
| required: true | |
| runs: | |
| using: composite | |
| steps: | |
| - | |
| # Docker is not installed as a PackageManagement package, so remove its | |
| # service directly to let the test daemon register under the same name. | |
| name: Removing current daemon | |
| shell: pwsh | |
| run: | | |
| if (Get-Service docker -ErrorAction SilentlyContinue) { | |
| $dockerVersion = (docker version -f "{{.Server.Version}}") | |
| Write-Host "Current installed Docker version: $dockerVersion" | |
| # remove service | |
| Stop-Service -Force -Name docker | |
| Remove-Service -Name docker | |
| # removes event log entry. we could use "Remove-EventLog -LogName -Source docker" | |
| # but this cmd is not available atm | |
| $ErrorActionPreference = "SilentlyContinue" | |
| & reg delete "HKLM\SYSTEM\CurrentControlSet\Services\EventLog\Application\docker" /f 2>&1 | Out-Null | |
| $ErrorActionPreference = "Stop" | |
| Write-Host "Service removed" | |
| } | |
| - | |
| name: Starting test daemon | |
| shell: pwsh | |
| env: | |
| BIN_OUT: ${{ inputs.bin_out }} | |
| INPUT_CONTAINERD: ${{ inputs.containerd }} | |
| INPUT_RUNTIME: ${{ inputs.runtime }} | |
| INPUT_STORAGE: ${{ inputs.storage }} | |
| run: | | |
| Write-Host "Creating service" | |
| $args = @( | |
| "--debug", | |
| "--host=npipe:////./pipe/docker_engine", ` | |
| "--data-root=$env:TEMP\moby-root", ` | |
| "--exec-root=$env:TEMP\moby-exec", ` | |
| "--pidfile=$env:TEMP\docker.pid", ` | |
| "--register-service" | |
| ) | |
| If ($env:INPUT_CONTAINERD -eq "embedded") { | |
| $args += "--feature=embedded-containerd" | |
| } ElseIf ($env:INPUT_RUNTIME -eq "containerd") { | |
| $args += "--default-runtime=io.containerd.runhcs.v1" | |
| echo "DOCKER_WINDOWS_CONTAINERD_RUNTIME=1" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append | |
| } | |
| if ($env:INPUT_STORAGE -eq "snapshotter") { | |
| $args += "--feature=containerd-snapshotter" | |
| } | |
| New-Item -ItemType Directory "$env:TEMP\moby-root" -ErrorAction SilentlyContinue | Out-Null | |
| New-Item -ItemType Directory "$env:TEMP\moby-exec" -ErrorAction SilentlyContinue | Out-Null | |
| Start-Process -Wait -NoNewWindow "$env:BIN_OUT\dockerd" -ArgumentList $args | |
| # Make the env-var visible to the service-managed dockerd, as there's no CLI flag for this option. | |
| $dockerEnviron = @("DOCKER_MIN_API_VERSION=1.24") | |
| $dockerEnviron += @(Get-Item Env:\OTEL_* -ErrorAction SilentlyContinue | ForEach-Object { "$($_.Name)=$($_.Value)" }) | |
| If ($env:INPUT_STORAGE -eq "graphdriver") { | |
| $dockerEnviron += @("TEST_INTEGRATION_USE_GRAPHDRIVER=1") | |
| echo "TEST_INTEGRATION_USE_GRAPHDRIVER=1" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append | |
| } | |
| If ($env:INPUT_CONTAINERD -eq "embedded") { | |
| $dockerEnviron += @("TEST_INTEGRATION_CONTAINERD_EMBEDDED=1") | |
| echo "TEST_INTEGRATION_CONTAINERD_EMBEDDED=1" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append | |
| } | |
| New-ItemProperty -Name "Environment" -Path "HKLM:\SYSTEM\CurrentControlSet\Services\docker" -PropertyType MultiString -Value $dockerEnviron | |
| Write-Host "Starting service" | |
| Start-Service -Name docker | |
| Write-Host "Service started successfully!" | |
| - | |
| name: Waiting for test daemon to start | |
| shell: pwsh | |
| env: | |
| BIN_OUT: ${{ inputs.bin_out }} | |
| INPUT_CONTAINERD: ${{ inputs.containerd }} | |
| INPUT_RUNTIME: ${{ inputs.runtime }} | |
| DOCKER_HOST: npipe:////./pipe/docker_engine | |
| run: | | |
| $tries=20 | |
| Write-Host "Waiting for the test daemon to start..." | |
| While ($true) { | |
| $ErrorActionPreference = "SilentlyContinue" | |
| & "$env:BIN_OUT\docker" version | |
| $ErrorActionPreference = "Stop" | |
| If ($LastExitCode -eq 0) { | |
| break | |
| } | |
| $tries-- | |
| If ($tries -le 0) { | |
| Throw "Failed to get a response from the daemon" | |
| } | |
| Write-Host -NoNewline "." | |
| Start-Sleep -Seconds 1 | |
| } | |
| Write-Host "Test daemon started and replied!" | |
| If ($env:INPUT_CONTAINERD -eq "external" -and $env:INPUT_RUNTIME -eq "containerd") { | |
| $containerdProcesses = Get-Process -Name containerd -ErrorAction:SilentlyContinue | |
| If (-not $containerdProcesses) { | |
| Throw "containerd process is not running" | |
| } else { | |
| foreach ($process in $containerdProcesses) { | |
| $processPath = (Get-Process -Id $process.Id -FileVersionInfo).FileName | |
| Write-Output "Running containerd instance binary Path: $($processPath)" | |
| } | |
| } | |
| } |