fix(ci): ephemeral lint venv on main
Stops a main-triggered Lint run from poisoning the shared production venv (see feature branch commit for full rationale). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -69,7 +69,12 @@ jobs:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
PYTHONIOENCODING: utf-8
|
PYTHONIOENCODING: utf-8
|
||||||
VENV_DIR: F:\CI\python\venv
|
# Job-local, ephemeral venv. MUST NOT be the production venv
|
||||||
|
# (F:\CI\python\venv): an editable install here would repoint the
|
||||||
|
# shared orchestrator package at this run's transient checkout and
|
||||||
|
# break every later smoke/build job with "No module named
|
||||||
|
# ci_orchestrator". github.workspace is discarded after the job.
|
||||||
|
VENV_DIR: ${{ github.workspace }}\.venv-lint
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@@ -94,30 +99,14 @@ jobs:
|
|||||||
|
|
||||||
$venvPy = Join-Path $env:VENV_DIR 'Scripts\python.exe'
|
$venvPy = Join-Path $env:VENV_DIR 'Scripts\python.exe'
|
||||||
|
|
||||||
# Probe: a broken venv (pyvenv.cfg pointing to a deleted base interpreter)
|
# Always build a fresh, job-local venv. Never reuse or repair a
|
||||||
# writes "No Python at ..." to stderr; under $ErrorActionPreference='Stop'
|
# shared one — lint must be fully isolated from the production
|
||||||
# native stderr becomes a terminating exception (AGENTS.md error #12),
|
# orchestrator venv.
|
||||||
# so probe with SilentlyContinue + try/catch.
|
|
||||||
$venvOk = $false
|
|
||||||
if (Test-Path $venvPy) {
|
|
||||||
try {
|
|
||||||
$prevEAP = $ErrorActionPreference
|
|
||||||
$ErrorActionPreference = 'SilentlyContinue'
|
|
||||||
& $venvPy --version 2>&1 | Out-Null
|
|
||||||
if ($LASTEXITCODE -eq 0) { $venvOk = $true }
|
|
||||||
}
|
|
||||||
catch { $venvOk = $false }
|
|
||||||
finally { $ErrorActionPreference = $prevEAP }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (-not $venvOk) {
|
|
||||||
Write-Host "Venv missing or broken, (re)bootstrapping at $env:VENV_DIR with $env:CI_PYTHON_LAUNCHER"
|
|
||||||
if (Test-Path $env:VENV_DIR) {
|
if (Test-Path $env:VENV_DIR) {
|
||||||
Remove-Item $env:VENV_DIR -Recurse -Force
|
Remove-Item $env:VENV_DIR -Recurse -Force
|
||||||
}
|
}
|
||||||
& $env:CI_PYTHON_LAUNCHER -m venv $env:VENV_DIR
|
& $env:CI_PYTHON_LAUNCHER -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
|
||||||
|
|||||||
Reference in New Issue
Block a user