unsloth/.github/scripts/ensure-docker-daemon.ps1
danielhanchen f09a1e71a9 Tighten the clean-machine CI comments
Comments only, no assertion logic, pins or leg definitions touched.

Reflowed every rationale block to denser wording and removed the
duplication that had built up across repeated steps: the desktop
workflow repeated the fork-PR skip, the desktop-v* tag resolution and
the restore-runner note once per platform, and the installer workflow
repeated its path-filter rationale in both the pull_request and push
blocks. Those now point at the first copy.

Every WHY is kept: why the masked legs avoid install.sh --local, what
UNSLOTH_CI_SOURCE_OVERLAY is for, why `absent` tests "must not work"
rather than command -v, why the .venv_t5_* sidecars are in the macho
scan scope, why the signature check is main-executables-only, why each
nobuild allowlist entry is a pure-Python sdist, why the WSL job gates
and what the pipe truncation was, and why the virgin container's
overlay=false row is still pinned.

Proved comments-only three ways: both workflow revisions parsed with
yaml.safe_load_all and every leaf walked (only `run:` scalars differ);
every changed bash body and .sh compared byte-for-byte after
`bash --pretty-print -n`; every changed pwsh body and .ps1 compared as
a token stream with Comment and NewLine tokens dropped. A negative
control injecting one non-comment line into each layer makes all of
them fail.
2026-07-29 06:33:16 +00:00

41 lines
1.7 KiB
PowerShell

# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved.
# Waits for the Windows Docker daemon on a hosted runner, starting the service if
# it is installed but not running.
#
# Docker is installed on every windows-2022 image (runner-images uses Microsoft's
# install-docker-ce.ps1 without -HyperV, so the daemon serves WINDOWS containers) but
# is not always RUNNING when a job starts: a spike run died 21s in with
# failed to connect to the docker API at npipe:////./pipe/docker_engine
# while a sibling job was fine. Without this wait that flake reads as "Windows
# containers are not available on hosted runners", the wrong conclusion entirely.
[CmdletBinding()]
param([int] $TimeoutMinutes = 5)
$deadline = (Get-Date).AddMinutes($TimeoutMinutes)
while ($true) {
docker info *>&1 | Out-Null
if ($LASTEXITCODE -eq 0) {
Write-Host "docker daemon is up"
break
}
if ((Get-Date) -ge $deadline) {
Write-Host "::error::the Docker daemon never became reachable within $TimeoutMinutes minutes"
Get-Service docker -ErrorAction SilentlyContinue | Format-List | Out-String | Write-Host
exit 1
}
$svc = Get-Service -Name docker -ErrorAction SilentlyContinue
Write-Host "docker service status: $(if ($svc) { $svc.Status } else { 'NOT INSTALLED' }); retrying..."
if ($svc -and $svc.Status -ne 'Running') {
Start-Service docker -ErrorAction SilentlyContinue
}
Start-Sleep -Seconds 5
}
# The failing `docker info` probes leave $LASTEXITCODE non-zero and the runner appends
# `exit $LASTEXITCODE` to every pwsh step (actions/runner#351), so without this reset a
# successful wait still fails the step.
$global:LASTEXITCODE = 0
exit 0