fix(lint): change Python job runner from Windows to Linux and update shell to Bash
fix(script): add CmdletBinding attribute to Set-GuestInfoIP function for better process support
This commit is contained in:
+14
-51
@@ -64,17 +64,12 @@ jobs:
|
|||||||
}
|
}
|
||||||
|
|
||||||
python:
|
python:
|
||||||
runs-on: windows-build
|
runs-on: linux-build
|
||||||
timeout-minutes: 20
|
timeout-minutes: 20
|
||||||
|
|
||||||
env:
|
env:
|
||||||
PYTHONIOENCODING: utf-8
|
PYTHONIOENCODING: utf-8
|
||||||
# Job-local, ephemeral venv. MUST NOT be the production venv
|
VENV_DIR: ${{ github.workspace }}/.venv-lint
|
||||||
# (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
|
||||||
@@ -83,57 +78,25 @@ jobs:
|
|||||||
fetch-depth: 1
|
fetch-depth: 1
|
||||||
|
|
||||||
- name: Setup venv + install package
|
- name: Setup venv + install package
|
||||||
shell: powershell
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
$ErrorActionPreference = 'Stop'
|
set -euo pipefail
|
||||||
|
rm -rf "$VENV_DIR"
|
||||||
# Production venv lives at $env:VENV_DIR (F:\CI\python\venv per AGENTS.md).
|
python3 -m venv "$VENV_DIR"
|
||||||
# The system Python used to bootstrap it is configured once in
|
"$VENV_DIR/bin/python" -m pip install --upgrade pip
|
||||||
# runner/config.yaml as CI_PYTHON_LAUNCHER (single source of truth).
|
"$VENV_DIR/bin/python" -m pip install -e ".[dev]"
|
||||||
if (-not $env:CI_PYTHON_LAUNCHER) {
|
|
||||||
throw "CI_PYTHON_LAUNCHER not set. Configure it in runner/config.yaml (runner.envs) and restart act_runner."
|
|
||||||
}
|
|
||||||
if (-not (Test-Path $env:CI_PYTHON_LAUNCHER)) {
|
|
||||||
throw "CI_PYTHON_LAUNCHER points to '$env:CI_PYTHON_LAUNCHER' which does not exist."
|
|
||||||
}
|
|
||||||
|
|
||||||
$venvPy = Join-Path $env:VENV_DIR 'Scripts\python.exe'
|
|
||||||
|
|
||||||
# Always build a fresh, job-local venv. Never reuse or repair a
|
|
||||||
# shared one — lint must be fully isolated from the production
|
|
||||||
# orchestrator venv.
|
|
||||||
if (Test-Path $env:VENV_DIR) {
|
|
||||||
Remove-Item $env:VENV_DIR -Recurse -Force
|
|
||||||
}
|
|
||||||
& $env:CI_PYTHON_LAUNCHER -m venv $env:VENV_DIR
|
|
||||||
if ($LASTEXITCODE -ne 0) { throw "venv creation failed" }
|
|
||||||
|
|
||||||
Write-Host "Using venv python: $venvPy"
|
|
||||||
& $venvPy --version
|
|
||||||
if ($LASTEXITCODE -ne 0) { throw "python --version failed" }
|
|
||||||
|
|
||||||
& $venvPy -m pip install --upgrade pip
|
|
||||||
if ($LASTEXITCODE -ne 0) { throw "pip upgrade failed" }
|
|
||||||
& $venvPy -m pip install -e ".[dev]"
|
|
||||||
if ($LASTEXITCODE -ne 0) { throw "pip install failed" }
|
|
||||||
|
|
||||||
- name: ruff
|
- name: ruff
|
||||||
shell: powershell
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
$venvPy = Join-Path $env:VENV_DIR 'Scripts\python.exe'
|
"$VENV_DIR/bin/python" -m ruff check src tests/python
|
||||||
& $venvPy -m ruff check src tests/python
|
|
||||||
if ($LASTEXITCODE -ne 0) { throw "ruff failed" }
|
|
||||||
|
|
||||||
- name: mypy --strict
|
- name: mypy --strict
|
||||||
shell: powershell
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
$venvPy = Join-Path $env:VENV_DIR 'Scripts\python.exe'
|
"$VENV_DIR/bin/python" -m mypy --strict src
|
||||||
& $venvPy -m mypy --strict src
|
|
||||||
if ($LASTEXITCODE -ne 0) { throw "mypy failed" }
|
|
||||||
|
|
||||||
- name: pytest (coverage >= 90%)
|
- name: pytest (coverage >= 90%)
|
||||||
shell: powershell
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
$venvPy = Join-Path $env:VENV_DIR 'Scripts\python.exe'
|
"$VENV_DIR/bin/python" -m pytest tests/python --cov=ci_orchestrator --cov-fail-under=90
|
||||||
& $venvPy -m pytest tests/python --cov=ci_orchestrator --cov-fail-under=90
|
|
||||||
if ($LASTEXITCODE -ne 0) { throw "pytest failed" }
|
|
||||||
|
|||||||
@@ -146,6 +146,7 @@ if (-not (Test-Path $OutputDir)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Set-GuestInfoIP {
|
function Set-GuestInfoIP {
|
||||||
|
[CmdletBinding(SupportsShouldProcess)]
|
||||||
param([string]$VmxPath, [string]$IP, [string]$Mask, [string]$Gw)
|
param([string]$VmxPath, [string]$IP, [string]$Mask, [string]$Gw)
|
||||||
$keys = @('guestinfo.ip-assignment', 'guestinfo.netmask', 'guestinfo.gateway')
|
$keys = @('guestinfo.ip-assignment', 'guestinfo.netmask', 'guestinfo.gateway')
|
||||||
$lines = (Get-Content -LiteralPath $VmxPath -Encoding UTF8) |
|
$lines = (Get-Content -LiteralPath $VmxPath -Encoding UTF8) |
|
||||||
|
|||||||
Reference in New Issue
Block a user