Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Give the small Windows checks one box per image instead of one box per check (#9143)

Daniel Han9eb614207a4e
diff --git a/.github/workflows/studio-windows-inference-smoke.yml b/.github/workflows/studio-windows-inference-smoke.yml
index 8d0c90eba50..74755369ae1 100644
--- a/.github/workflows/studio-windows-inference-smoke.yml
+++ b/.github/workflows/studio-windows-inference-smoke.yml
@@ -1638,12 +1638,56 @@ jobs:
# ─────────────────────────────────────────────────────────────────────
# Job B: the GPU (CUDA) prebuilt path is also VS-free (resolve/availability)
# ─────────────────────────────────────────────────────────────────────
- no-vs-gpu-resolve:
- name: GPU prebuilt resolves without Visual Studio
- runs-on: windows-latest
- timeout-minutes: 15
+ # ── One box per Windows IMAGE, instead of one box per check ──────────────
+ # These were six separate Windows job-runs (pester, no-vs-gpu-resolve, and the
+ # two cells each of vs-integration and vcredist-clean-box) whose EXECUTION times
+ # are 16-34s. Measured over recent main runs, every Windows job in this repo
+ # waits 2600-3400s in the queue before it starts, whatever it then does: the
+ # VS 2022 detection cell averages 16s of execution behind 2606s of queueing.
+ # On Windows the scarce resource is the slot, not the minute, so six slots
+ # delivering 155s of total work is the expensive part -- and the queue those
+ # slots create is what Chat UI Tests (1108s exec, 3164s queue) waits in.
+ #
+ # Grouped by runner image, because the image IS the thing under test and a
+ # check must never move off the platform it validates. windows-2022 keeps its
+ # own box for VS 2022 detection; windows-2025-vs2026 keeps its own for VS 2026.
+ # Six job-runs become three, and no check changes what it runs on.
+ #
+ # Ordering inside a box is load-bearing: the VC++ round-trip literally
+ # uninstalls the runtime and restores the registry in a `finally`, so it runs
+ # LAST everywhere. The phases before it install a PowerShell module and pip
+ # packages and build a simulated no-build-tools tree under the workspace; none
+ # of them writes the VC++ registry keys the round-trip reads as ground truth,
+ # so its clean-box precondition still holds when it starts.
+ small-checks:
+ name: ${{ matrix.name }}
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - os: windows-latest
+ name: setup.ps1 units, no-VS resolve, VC++ round-trip (windows-latest)
+ phases: ' pester no-vs-gpu vcredist '
+ - os: windows-2025-vs2026
+ name: real-VS detection + VC++ round-trip (VS 2026)
+ phases: ' vs-detect vcredist '
+ label: 'VS 2026'
+ expectGen: 'Visual Studio 18 2026'
+ expectToolset: 'v180'
+ - os: windows-2022
+ name: real-VS detection (VS 2022)
+ phases: ' vs-detect '
+ label: 'VS 2022'
+ expectGen: 'Visual Studio 17 2022'
+ expectToolset: 'v170'
+ runs-on: ${{ matrix.os }}
+ # 15 + 15 + 20 as three jobs. They share one checkout now and the phases are
+ # tens of seconds each; 30 bounds a hang without hiding one.
+ timeout-minutes: 30
defaults:
run:
+ # One step in the no-VS resolve phase relies on this default. Every other
+ # step below declares its own shell.
shell: bash
env:
PYTHONIOENCODING: utf-8
@@ -1653,113 +1697,80 @@ jobs:
with:
persist-credentials: false
+ # Needed by the pester and no-VS resolve phases only; the detection and
+ # round-trip phases are pure PowerShell against the runner image.
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
+ if: ${{ contains(matrix.phases, ' pester ') || contains(matrix.phases, ' no-vs-gpu ') }}
with:
python-version: '3.12'
- - name: Prepare no-build-tools simulation
+ - name: Detect the real Visual Studio with setup.ps1 functions
+ if: ${{ !cancelled() && contains(matrix.phases, ' vs-detect ') }}
shell: pwsh
+ env:
+ EXPECT_GEN: ${{ matrix.expectGen }}
+ EXPECT_TOOLSET: ${{ matrix.expectToolset }}
run: |
$ErrorActionPreference = 'Stop'
- $root = Join-Path $env:GITHUB_WORKSPACE 'no-build-tools'
- $pf = Join-Path $root 'ProgramFiles'
- $pfx86 = Join-Path $root 'ProgramFilesx86'
- New-Item -ItemType Directory -Force -Path $pf, $pfx86 | Out-Null
-
- $blocked = [System.Collections.Generic.HashSet[string]]::new([StringComparer]::OrdinalIgnoreCase)
- foreach ($tool in @('cmake', 'cl.exe')) {
- foreach ($cmd in (Get-Command $tool -All -ErrorAction SilentlyContinue)) {
- if ($cmd.Source) {
- $dir = Split-Path -Parent $cmd.Source
- if ($dir) { [void] $blocked.Add($dir) }
- }
- }
+ . (Join-Path $env:GITHUB_WORKSPACE 'tests/studio_setup_ps1/Get-FunctionSource.ps1')
+ $setup = Join-Path $env:GITHUB_WORKSPACE 'studio/setup.ps1'
+ foreach ($fn in @('Resolve-VsGeneratorFromLabel', 'Get-VcBuildCustomizationsDir', 'Find-VsBuildTools')) {
+ . ([scriptblock]::Create((Get-FunctionSource -Path $setup -Name $fn)))
}
- $pathParts = $env:Path -split [IO.Path]::PathSeparator |
- Where-Object { $_ -and -not $blocked.Contains($_) }
- $noBuildToolsPath = $pathParts -join [IO.Path]::PathSeparator
-
- "NO_BUILD_TOOLS_PROGRAMFILES=$pf" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
- "NO_BUILD_TOOLS_PROGRAMFILES_X86=$pfx86" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
- "NO_BUILD_TOOLS_PATH<<NO_BUILD_TOOLS_PATH_EOF" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
- $noBuildToolsPath | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
- "NO_BUILD_TOOLS_PATH_EOF" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
+ # Ground truth from the real vswhere (independent of our code), for visibility.
+ $vsw = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
+ if (Test-Path $vsw) {
+ $year = (& $vsw -latest -property catalog_productLineVersion 2>$null | Select-Object -First 1)
+ $path = (& $vsw -latest -property installationPath 2>$null | Select-Object -First 1)
+ Write-Host "Real vswhere: productLineVersion='$year' installPath='$path'"
+ } else {
+ Write-Host "vswhere not present at $vsw (relying on filesystem fallback)"
+ }
- - name: Windows CUDA and ROCm prebuilts exist in unslothai/llama.cpp (what GPU users download, no VS)
- env:
- GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: |
- curl -fsSL -H "Authorization: Bearer $GH_TOKEN" \
- "https://api.github.com/repos/unslothai/llama.cpp/releases/latest" > /tmp/rel.json
- echo "release: $(jq -r .tag_name /tmp/rel.json)"
- ASSETS=$(jq -r '.assets[].name' /tmp/rel.json)
- echo "$ASSETS" | grep -iE 'windows-x64-cuda[0-9]' || {
- echo "::error::no Windows x64 CUDA prebuilt asset found in unslothai/llama.cpp latest release"
- echo "$ASSETS"; exit 1; }
- # AMD parity: hosted runners have no AMD GPU, so the resolver step below
- # can't exercise the ROCm path (it resolves to CPU). Pin the per-gfx
- # Windows ROCm bundles here so a release that drops them fails loudly --
- # the AMD no-VS guarantee otherwise rides only on shared resolver code.
- echo "$ASSETS" | grep -iE 'windows-x64-rocm-gfx' || {
- echo "::error::no Windows x64 ROCm (per-gfx) prebuilt asset found in unslothai/llama.cpp latest release"
- echo "$ASSETS"; exit 1; }
- echo "Windows CUDA and ROCm prebuilts are available -- GPU users get them without compiling."
+ # Our detection must find the real VS and report the expected generator.
+ $r = Find-VsBuildTools
+ if (-not $r) { throw "Find-VsBuildTools returned null on a host with real $env:EXPECT_GEN" }
+ Write-Host "Find-VsBuildTools -> Generator='$($r.Generator)' Source='$($r.Source)' InstallPath='$($r.InstallPath)'"
+ if ($r.Generator -ne $env:EXPECT_GEN) {
+ throw "Detection mismatch: got '$($r.Generator)', expected '$env:EXPECT_GEN'"
+ }
+ if (-not (Test-Path $r.InstallPath)) { throw "Detected InstallPath does not exist: $($r.InstallPath)" }
- - name: The prebuilt resolver runs without Visual Studio
- shell: pwsh
- env:
- GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: |
- $ErrorActionPreference = 'Stop'
- # pwsh: bash cannot export `ProgramFiles(x86)`; set in-script so the
- # python child inherits the overrides.
- $env:ProgramFiles = $env:NO_BUILD_TOOLS_PROGRAMFILES
- ${env:ProgramFiles(x86)} = $env:NO_BUILD_TOOLS_PROGRAMFILES_X86
- $env:Path = $env:NO_BUILD_TOOLS_PATH
- # Resolver-only (no GPU on hosted runners, so the host resolves to the
- # CPU bundle). The point is that resolution needs no compiler/VS.
- python -m pip install --upgrade huggingface_hub
- if ($LASTEXITCODE -ne 0) { Write-Host "::error::pip install huggingface_hub failed"; exit 1 }
- python studio/install_llama_prebuilt.py --resolve-prebuilt latest --output-format json > resolve.json
- if ($LASTEXITCODE -ne 0) {
- Write-Host "::error::resolver exited non-zero"
- if (Test-Path resolve.json) { Get-Content resolve.json }
- exit 1
+ # Toolset path derivation must match the expected v-number...
+ $bc = Get-VcBuildCustomizationsDir -VsInstallPath $r.InstallPath -Generator $r.Generator
+ $derived = Split-Path (Split-Path $bc -Parent) -Leaf # e.g. v170 / v180
+ Write-Host "Get-VcBuildCustomizationsDir -> '$bc' (toolset='$derived')"
+ if ($derived -ne $env:EXPECT_TOOLSET) {
+ throw "Toolset mismatch: derived '$derived', expected '$env:EXPECT_TOOLSET'"
}
- Get-Content resolve.json
- Write-Host "Prebuilt resolver ran with no Visual Studio present."
- - name: Clean no-build-tools simulation
- if: always()
- shell: pwsh
- run: |
- Remove-Item -LiteralPath (Join-Path $env:GITHUB_WORKSPACE 'no-build-tools') -Recurse -Force -ErrorAction SilentlyContinue
+ # ...and that v-number is a real folder on the VS install (where CUDA's
+ # BuildCustomizations would land).
+ $vcRoot = Join-Path $r.InstallPath 'MSBuild\Microsoft\VC'
+ if (Test-Path $vcRoot) {
+ $realToolsets = @((Get-ChildItem -Path $vcRoot -Directory -ErrorAction SilentlyContinue).Name)
+ Write-Host "Real VC toolset dirs: $($realToolsets -join ', ')"
+ if ($realToolsets -notcontains $derived) {
+ throw "Derived toolset '$derived' is not present on the real $env:EXPECT_GEN install (have: $($realToolsets -join ', '))"
+ }
+ Write-Host "OK: toolset '$derived' exists on the real VS install."
+ } else {
+ Write-Warning "VC MSBuild root absent ($vcRoot) - C++ workload not installed; skipping on-disk toolset check."
+ }
- # ── folded from studio-setup-ps1-vs2026.yml: setup.ps1 unit tests + real-VS detection + vcredist ──
- pester:
- name: setup.ps1 unit tests (VS 2026 / CMake guard)
- runs-on: windows-latest
- timeout-minutes: 15
- steps:
- - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- with:
- persist-credentials: false
+ Write-Host "PASS: real $env:EXPECT_GEN detected correctly with toolset '$derived'."
- # This workflow is in its own `paths` filter, so editing the bootstrap below
- # always runs this job. No pytest workflow filters on this file, so running the
- # guard here is what makes it fire on a workflow-only change.
- - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
- with:
- python-version: '3.12'
- name: Guard the Pester bootstrap
+ if: ${{ !cancelled() && contains(matrix.phases, ' pester ') }}
shell: bash
run: |
python -m pip install --quiet pyyaml pytest
python -m pytest tests/studio/test_pester_bootstrap_hardening.py -q
- name: Install Pester v5
+ if: ${{ !cancelled() && contains(matrix.phases, ' pester ') }}
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
@@ -1827,6 +1838,7 @@ jobs:
$loaded | Select-Object Name, Version | Format-Table
- name: Run Pester suite
+ if: ${{ !cancelled() && contains(matrix.phases, ' pester ') }}
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
@@ -1846,102 +1858,100 @@ jobs:
Invoke-Pester -Configuration $cfg
- name: Upload Pester results
- if: always()
+ if: ${{ always() && contains(matrix.phases, ' pester ') }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: pester-results-setup-ps1
path: pester-results.xml
if-no-files-found: warn
- vs-integration:
- # Real detection against the VS installed on the runner image (no mocks).
- name: real-VS detection (${{ matrix.label }})
- strategy:
- fail-fast: false
- matrix:
- include:
- - { os: windows-2022, label: 'VS 2022', expectGen: 'Visual Studio 17 2022', expectToolset: 'v170' }
- - { os: windows-2025-vs2026, label: 'VS 2026', expectGen: 'Visual Studio 18 2026', expectToolset: 'v180' }
- runs-on: ${{ matrix.os }}
- timeout-minutes: 15
- steps:
- - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- with:
- persist-credentials: false
- - name: Detect the real Visual Studio with setup.ps1 functions
+ - name: Prepare no-build-tools simulation
+ if: ${{ !cancelled() && contains(matrix.phases, ' no-vs-gpu ') }}
shell: pwsh
- env:
- EXPECT_GEN: ${{ matrix.expectGen }}
- EXPECT_TOOLSET: ${{ matrix.expectToolset }}
run: |
$ErrorActionPreference = 'Stop'
- . (Join-Path $env:GITHUB_WORKSPACE 'tests/studio_setup_ps1/Get-FunctionSource.ps1')
- $setup = Join-Path $env:GITHUB_WORKSPACE 'studio/setup.ps1'
- foreach ($fn in @('Resolve-VsGeneratorFromLabel', 'Get-VcBuildCustomizationsDir', 'Find-VsBuildTools')) {
- . ([scriptblock]::Create((Get-FunctionSource -Path $setup -Name $fn)))
- }
+ $root = Join-Path $env:GITHUB_WORKSPACE 'no-build-tools'
+ $pf = Join-Path $root 'ProgramFiles'
+ $pfx86 = Join-Path $root 'ProgramFilesx86'
+ New-Item -ItemType Directory -Force -Path $pf, $pfx86 | Out-Null
- # Ground truth from the real vswhere (independent of our code), for visibility.
- $vsw = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
- if (Test-Path $vsw) {
- $year = (& $vsw -latest -property catalog_productLineVersion 2>$null | Select-Object -First 1)
- $path = (& $vsw -latest -property installationPath 2>$null | Select-Object -First 1)
- Write-Host "Real vswhere: productLineVersion='$year' installPath='$path'"
- } else {
- Write-Host "vswhere not present at $vsw (relying on filesystem fallback)"
+ $blocked = [System.Collections.Generic.HashSet[string]]::new([StringComparer]::OrdinalIgnoreCase)
+ foreach ($tool in @('cmake', 'cl.exe')) {
+ foreach ($cmd in (Get-Command $tool -All -ErrorAction SilentlyContinue)) {
+ if ($cmd.Source) {
+ $dir = Split-Path -Parent $cmd.Source
+ if ($dir) { [void] $blocked.Add($dir) }
+ }
+ }
}
- # Our detection must find the real VS and report the expected generator.
- $r = Find-VsBuildTools
- if (-not $r) { throw "Find-VsBuildTools returned null on a host with real $env:EXPECT_GEN" }
- Write-Host "Find-VsBuildTools -> Generator='$($r.Generator)' Source='$($r.Source)' InstallPath='$($r.InstallPath)'"
- if ($r.Generator -ne $env:EXPECT_GEN) {
- throw "Detection mismatch: got '$($r.Generator)', expected '$env:EXPECT_GEN'"
- }
- if (-not (Test-Path $r.InstallPath)) { throw "Detected InstallPath does not exist: $($r.InstallPath)" }
+ $pathParts = $env:Path -split [IO.Path]::PathSeparator |
+ Where-Object { $_ -and -not $blocked.Contains($_) }
+ $noBuildToolsPath = $pathParts -join [IO.Path]::PathSeparator
- # Toolset path derivation must match the expected v-number...
- $bc = Get-VcBuildCustomizationsDir -VsInstallPath $r.InstallPath -Generator $r.Generator
- $derived = Split-Path (Split-Path $bc -Parent) -Leaf # e.g. v170 / v180
- Write-Host "Get-VcBuildCustomizationsDir -> '$bc' (toolset='$derived')"
- if ($derived -ne $env:EXPECT_TOOLSET) {
- throw "Toolset mismatch: derived '$derived', expected '$env:EXPECT_TOOLSET'"
- }
+ "NO_BUILD_TOOLS_PROGRAMFILES=$pf" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
+ "NO_BUILD_TOOLS_PROGRAMFILES_X86=$pfx86" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
+ "NO_BUILD_TOOLS_PATH<<NO_BUILD_TOOLS_PATH_EOF" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
+ $noBuildToolsPath | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
+ "NO_BUILD_TOOLS_PATH_EOF" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
- # ...and that v-number is a real folder on the VS install (where CUDA's
- # BuildCustomizations would land).
- $vcRoot = Join-Path $r.InstallPath 'MSBuild\Microsoft\VC'
- if (Test-Path $vcRoot) {
- $realToolsets = @((Get-ChildItem -Path $vcRoot -Directory -ErrorAction SilentlyContinue).Name)
- Write-Host "Real VC toolset dirs: $($realToolsets -join ', ')"
- if ($realToolsets -notcontains $derived) {
- throw "Derived toolset '$derived' is not present on the real $env:EXPECT_GEN install (have: $($realToolsets -join ', '))"
- }
- Write-Host "OK: toolset '$derived' exists on the real VS install."
- } else {
- Write-Warning "VC MSBuild root absent ($vcRoot) - C++ workload not installed; skipping on-disk toolset check."
+ - name: Windows CUDA and ROCm prebuilts exist in unslothai/llama.cpp (what GPU users download, no VS)
+ if: ${{ !cancelled() && contains(matrix.phases, ' no-vs-gpu ') }}
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ curl -fsSL -H "Authorization: Bearer $GH_TOKEN" \
+ "https://api.github.com/repos/unslothai/llama.cpp/releases/latest" > /tmp/rel.json
+ echo "release: $(jq -r .tag_name /tmp/rel.json)"
+ ASSETS=$(jq -r '.assets[].name' /tmp/rel.json)
+ echo "$ASSETS" | grep -iE 'windows-x64-cuda[0-9]' || {
+ echo "::error::no Windows x64 CUDA prebuilt asset found in unslothai/llama.cpp latest release"
+ echo "$ASSETS"; exit 1; }
+ # AMD parity: hosted runners have no AMD GPU, so the resolver step below
+ # can't exercise the ROCm path (it resolves to CPU). Pin the per-gfx
+ # Windows ROCm bundles here so a release that drops them fails loudly --
+ # the AMD no-VS guarantee otherwise rides only on shared resolver code.
+ echo "$ASSETS" | grep -iE 'windows-x64-rocm-gfx' || {
+ echo "::error::no Windows x64 ROCm (per-gfx) prebuilt asset found in unslothai/llama.cpp latest release"
+ echo "$ASSETS"; exit 1; }
+ echo "Windows CUDA and ROCm prebuilts are available -- GPU users get them without compiling."
+
+ - name: The prebuilt resolver runs without Visual Studio
+ if: ${{ !cancelled() && contains(matrix.phases, ' no-vs-gpu ') }}
+ shell: pwsh
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ $ErrorActionPreference = 'Stop'
+ # pwsh: bash cannot export `ProgramFiles(x86)`; set in-script so the
+ # python child inherits the overrides.
+ $env:ProgramFiles = $env:NO_BUILD_TOOLS_PROGRAMFILES
+ ${env:ProgramFiles(x86)} = $env:NO_BUILD_TOOLS_PROGRAMFILES_X86
+ $env:Path = $env:NO_BUILD_TOOLS_PATH
+ # Resolver-only (no GPU on hosted runners, so the host resolves to the
+ # CPU bundle). The point is that resolution needs no compiler/VS.
+ python -m pip install --upgrade huggingface_hub
+ if ($LASTEXITCODE -ne 0) { Write-Host "::error::pip install huggingface_hub failed"; exit 1 }
+ python studio/install_llama_prebuilt.py --resolve-prebuilt latest --output-format json > resolve.json
+ if ($LASTEXITCODE -ne 0) {
+ Write-Host "::error::resolver exited non-zero"
+ if (Test-Path resolve.json) { Get-Content resolve.json }
+ exit 1
}
+ Get-Content resolve.json
+ Write-Host "Prebuilt resolver ran with no Visual Studio present."
- Write-Host "PASS: real $env:EXPECT_GEN detected correctly with toolset '$derived'."
+ - name: Clean no-build-tools simulation
+ if: ${{ always() && contains(matrix.phases, ' no-vs-gpu ') }}
+ shell: pwsh
+ run: |
+ Remove-Item -LiteralPath (Join-Path $env:GITHUB_WORKSPACE 'no-build-tools') -Recurse -Force -ErrorAction SilentlyContinue
- vcredist-clean-box:
- # Validate Test-VCRedistInstalled + Ensure-VCRedist on a throwaway runner:
- # present on the stock image, fires on a clean box (signals removed restorably),
- # then a literal uninstall/reinstall round trip. Always restored before the end.
- name: VC++ runtime detect + install round-trip (${{ matrix.os }})
- strategy:
- fail-fast: false
- matrix:
- os: [windows-latest, windows-2025-vs2026]
- runs-on: ${{ matrix.os }}
- timeout-minutes: 20
- steps:
- - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- with:
- persist-credentials: false
+ # ── folded from studio-setup-ps1-vs2026.yml: setup.ps1 unit tests + real-VS detection + vcredist ──
- name: Detect present, fire on a clean box, and round-trip the install
+ if: ${{ !cancelled() && contains(matrix.phases, ' vcredist ') }}
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
diff --git a/tests/studio/test_pester_bootstrap_hardening.py b/tests/studio/test_pester_bootstrap_hardening.py
index e4036eb916c..d3b9fa43787 100644
--- a/tests/studio/test_pester_bootstrap_hardening.py
+++ b/tests/studio/test_pester_bootstrap_hardening.py
@@ -32,13 +32,27 @@ _WORKFLOW = REPO_ROOT / ".github" / "workflows" / "studio-windows-inference-smok
_GUARD_WORKFLOW = REPO_ROOT / ".github" / "workflows" / "pester-guard-ci.yml"
-def _bootstrap_step() -> dict:
+def _pester_steps() -> list[dict]:
+ """Every step of whichever job carries the Pester phase.
+
+ Found by content rather than by job id: the phase used to be a job called `pester` and
+ is now one phase of a job that groups the small Windows checks by runner image, and
+ keying on the id meant this whole file went red on a rename that changed nothing it
+ asserts.
+ """
workflow = yaml.safe_load(_WORKFLOW.read_text(encoding = "utf-8"))
- steps = workflow["jobs"]["pester"]["steps"]
- for step in steps:
+ for job in workflow["jobs"].values():
+ steps = job.get("steps") or []
+ if any("Install Pester" in (s.get("name") or "") for s in steps):
+ return steps
+ raise AssertionError("no job in the workflow installs Pester")
+
+
+def _bootstrap_step() -> dict:
+ for step in _pester_steps():
if "Install Pester" in (step.get("name") or ""):
return step
- raise AssertionError("no Pester install step in the pester job")
+ raise AssertionError("no Pester install step")
def test_bootstrap_step_exists_and_runs_under_pwsh():
@@ -114,10 +128,9 @@ def test_the_guard_runs_from_the_workflow_it_guards():
# as_posix(), not str(): this runs on windows-latest, where str() would give
# backslashes and never match the forward-slash paths in the YAML.
assert _WORKFLOW.relative_to(REPO_ROOT).as_posix() in on["pull_request"]["paths"]
- steps = workflow["jobs"]["pester"]["steps"]
assert any(
- Path(__file__).name in (s.get("run") or "") for s in steps
- ), "the pester job must run this guard, or a workflow-only edit skips it entirely"
+ Path(__file__).name in (s.get("run") or "") for s in _pester_steps()
+ ), "the Pester phase must run this guard, or a workflow-only edit skips it entirely"
def test_editing_the_guard_runs_it_on_windows():
diff --git a/tests/studio/test_windows_small_checks_stay_on_their_image.py b/tests/studio/test_windows_small_checks_stay_on_their_image.py
new file mode 100644
index 00000000000..1a50cf1936e
--- /dev/null
+++ b/tests/studio/test_windows_small_checks_stay_on_their_image.py
@@ -0,0 +1,149 @@
+# SPDX-License-Identifier: AGPL-3.0-only
+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+"""The Windows small checks share a box per IMAGE, and never move off their image.
+
+Six Windows job-runs (the Pester units, the no-VS prebuilt resolve, and the two cells each
+of real-VS detection and the VC++ round-trip) executed for 16-34s apiece. On this repo's
+Windows pool that is not what they cost: measured over recent main runs every Windows job
+waits 2600-3400s for a slot whatever it then does, so six slots delivering 155s of work is
+the expense, and the queue those slots make is what the 18-minute Chat UI job sits in.
+They are now three job-runs, one per runner image.
+
+The image is the thing under test -- VS 2022 detection is only meaningful on the image that
+ships VS 2022 -- so the merge must never be allowed to drift into running a check somewhere
+cheaper. That is the first assertion here, and it is the one that would otherwise fail
+silently: a check running on the wrong Windows image mostly still passes.
+
+The second is ordering. The VC++ phase uninstalls the runtime and restores the registry in
+a ``finally``; it has to be the last phase on any box it shares, or it hands a perturbed
+machine to whatever runs next.
+"""
+
+import re
+from pathlib import Path
+
+import pytest
+import yaml
+
+REPO = Path(__file__).resolve().parents[2]
+WORKFLOW = REPO / ".github" / "workflows" / "studio-windows-inference-smoke.yml"
+JOB = "small-checks"
+
+# What each phase is allowed to run on. Kept here deliberately: this is the platform
+# contract, and a test that read it back out of the workflow could not detect the workflow
+# being wrong.
+EXPECTED_IMAGES = {
+ "pester": {"windows-latest"},
+ "no-vs-gpu": {"windows-latest"},
+ "vcredist": {"windows-latest", "windows-2025-vs2026"},
+ "vs-detect": {"windows-2022", "windows-2025-vs2026"},
+}
+
+
+def _job() -> dict:
+ return yaml.safe_load(WORKFLOW.read_text(encoding = "utf-8"))["jobs"][JOB]
+
+
+def _cells() -> list[dict]:
+ return _job()["strategy"]["matrix"]["include"]
+
+
+def _phases(cell: dict) -> list[str]:
+ return str(cell["phases"]).split()
+
+
+def _tokens_in(cond: str) -> set[str]:
+ return set(re.findall(r"contains\(matrix\.phases, ' ([a-z-]+) '\)", cond))
+
+
[email protected]("phase", sorted(EXPECTED_IMAGES))
+def test_each_phase_runs_on_exactly_the_images_it_validates(phase):
+ got = {str(c["os"]) for c in _cells() if phase in _phases(c)}
+ assert got == EXPECTED_IMAGES[phase], (
+ f"{phase} runs on {sorted(got)}, expected {sorted(EXPECTED_IMAGES[phase])}. Windows "
+ f"checks exist to prove behaviour on a specific Windows image; moving one to another "
+ f"image usually still passes, which is why this is asserted rather than observed."
+ )
+
+
+def test_every_cell_is_a_windows_image():
+ for cell in _cells():
+ assert str(cell["os"]).startswith("windows-"), cell
+
+
+def test_no_phase_is_stranded_and_no_cell_is_idle():
+ declared = {p for c in _cells() for p in _phases(c)}
+ assert declared == set(EXPECTED_IMAGES), (
+ f"the matrix declares {sorted(declared)} but the contract covers "
+ f"{sorted(EXPECTED_IMAGES)}"
+ )
+ used = set()
+ for step in _job()["steps"]:
+ used |= _tokens_in(str(step.get("if", "")))
+ stranded = declared - used
+ assert not stranded, (
+ f"these phases are named in the matrix but gate no step, so a cell asks for work "
+ f"that does not exist: {sorted(stranded)}"
+ )
+ unreachable = used - declared
+ assert not unreachable, (
+ f"these steps gate on a phase no cell declares, so they run nowhere and cannot "
+ f"fail: {sorted(unreachable)}"
+ )
+
+
+def test_every_step_is_gated_so_a_cell_runs_only_its_own_phases():
+ ungated = [
+ s.get("name") or s.get("uses")
+ for s in _job()["steps"]
+ if "matrix.phases" not in str(s.get("if", "")) and "checkout" not in str(s.get("uses", ""))
+ ]
+ assert not ungated, f"these steps carry no phase gate and would run on every image: {ungated}"
+
+
+def test_the_vcredist_round_trip_is_the_last_phase_on_any_box_it_shares():
+ """It uninstalls the VC++ runtime and restores the registry in a `finally`."""
+ steps = _job()["steps"]
+ last_vcredist = max(
+ i for i, s in enumerate(steps) if "vcredist" in _tokens_in(str(s.get("if", "")))
+ )
+ after = [
+ s.get("name")
+ for s in steps[last_vcredist + 1 :]
+ if _tokens_in(str(s.get("if", ""))) - {"vcredist"}
+ ]
+ assert not after, (
+ f"these phases run after the VC++ round-trip has torn down and restored the "
+ f"runtime, so they see a perturbed machine: {after}"
+ )
+
+
+def test_a_failing_phase_still_lets_the_others_on_that_box_report():
+ """Three separate jobs gave this for free; one job has to say it.
+
+ Provisioning steps (``setup-python``) are exempt and SHOULD fail-fast: a phase that
+ needs an interpreter which never installed has nothing useful to report. The rule is
+ for the phase work itself, which is every step with a ``run:`` body.
+ """
+ offenders = [
+ s.get("name") or s.get("uses")
+ for s in _job()["steps"]
+ if "matrix.phases" in str(s.get("if", ""))
+ and "run" in s
+ and not ("cancelled()" in str(s["if"]) or "always()" in str(s["if"]))
+ ]
+ assert not offenders, (
+ f"these steps inherit the implicit success(), so an earlier phase failing on the "
+ f"same box silently skips them: {offenders}"
+ )
+
+
+def test_the_merged_job_did_not_absorb_the_two_long_jobs():
+ """inference-smoke (718s) and no-vs-cpu (464s) stay on their own runners.
+
+ Their cost is execution, not slot occupancy, so folding them in would serialise ~20
+ minutes behind checks that take seconds.
+ """
+ jobs = yaml.safe_load(WORKFLOW.read_text(encoding = "utf-8"))["jobs"]
+ assert {"inference-smoke", "no-vs-cpu"} <= set(jobs), sorted(jobs)