ci(lint): detect broken venv (stale base interpreter) and rebuild
Lint / python (push) Failing after 8s
Lint / pssa (push) Successful in 24s

The venv at F:\CI\python\venv may exist but be broken if its pyvenv.cfg points to a deleted base interpreter (e.g. a stale actions/setup-python tool_cache). Detect this by running 'python --version' and rebuild the venv with py.exe -3.11 if it fails.
This commit is contained in:
2026-05-14 22:48:46 +02:00
parent 406c0e31a9
commit 0c7c9272ee
+17 -4
View File
@@ -81,15 +81,28 @@ jobs:
$ErrorActionPreference = 'Stop' $ErrorActionPreference = 'Stop'
# Production venv lives at F:\CI\python\venv (per AGENTS.md). # Production venv lives at F:\CI\python\venv (per AGENTS.md).
# If missing, bootstrap it via the Windows Python launcher (py -3.11), # If missing or broken (pyvenv.cfg points to a deleted base interpreter,
# since the act_runner SYSTEM service does NOT have plain "python" in PATH. # e.g. a stale actions/setup-python tool_cache), rebuild it via the
# Windows Python launcher (py -3.11). The act_runner SYSTEM service
# does NOT have plain "python" in PATH, but py.exe is installed system-wide.
$venvPy = Join-Path $env:VENV_DIR 'Scripts\python.exe' $venvPy = Join-Path $env:VENV_DIR 'Scripts\python.exe'
if (-not (Test-Path $venvPy)) {
Write-Host "Venv missing, bootstrapping at $env:VENV_DIR" $venvOk = $false
if (Test-Path $venvPy) {
& $venvPy --version 2>&1 | Out-Null
if ($LASTEXITCODE -eq 0) { $venvOk = $true }
}
if (-not $venvOk) {
Write-Host "Venv missing or broken, (re)bootstrapping at $env:VENV_DIR"
if (Test-Path $env:VENV_DIR) {
Remove-Item $env:VENV_DIR -Recurse -Force
}
$launcher = (Get-Command py.exe -ErrorAction Stop).Source $launcher = (Get-Command py.exe -ErrorAction Stop).Source
& $launcher -3.11 -m venv $env:VENV_DIR & $launcher -3.11 -m venv $env:VENV_DIR
if ($LASTEXITCODE -ne 0) { throw "venv creation failed" } if ($LASTEXITCODE -ne 0) { throw "venv creation failed" }
} }
Write-Host "Using venv python: $venvPy" Write-Host "Using venv python: $venvPy"
& $venvPy --version & $venvPy --version
if ($LASTEXITCODE -ne 0) { throw "python --version failed" } if ($LASTEXITCODE -ne 0) { throw "python --version failed" }