Files
local-ci-cd-system/.gitea/workflows/lint.yml
T
Simone 406c0e31a9
Lint / python (push) Failing after 18s
Lint / pssa (push) Successful in 24s
ci(lint): bootstrap venv via py.exe launcher; bump coverage to 80%
act_runner runs as SYSTEM and does not have plain 'python' in PATH; use py.exe launcher (-3.11) to bootstrap the venv when missing. The production venv at F:\CI\python\venv normally already exists, so the bootstrap is just a fallback. Also align coverage threshold to 80% (raised in A5, see AGENTS.md).
2026-05-14 22:46:13 +02:00

122 lines
3.8 KiB
YAML

# PSScriptAnalyzer + Python lint — runs on every push/PR that touches code files.
# Requires PSScriptAnalyzer installed on the runner host:
# Install-Module PSScriptAnalyzer -Scope AllUsers -Force
#
# Failures block the PR. Fix warnings with:
# Invoke-ScriptAnalyzer -Path scripts\ -Recurse -Fix
name: Lint
on:
push:
paths:
- '**.ps1'
- '**.psm1'
- '**.py'
- 'pyproject.toml'
- '.gitea/workflows/lint.yml'
pull_request:
paths:
- '**.ps1'
- '**.psm1'
- '**.py'
- 'pyproject.toml'
- '.gitea/workflows/lint.yml'
jobs:
pssa:
runs-on: windows-build
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Run PSScriptAnalyzer
shell: powershell
run: |
$ErrorActionPreference = 'Stop'
if (-not (Get-Module -ListAvailable PSScriptAnalyzer)) {
Write-Host "Installing PSScriptAnalyzer..."
Install-Module PSScriptAnalyzer -Scope CurrentUser -Force -AllowClobber
}
$settings = Join-Path $PWD 'PSScriptAnalyzerSettings.psd1'
$paths = @('scripts', 'template', 'Setup-Host.ps1')
$results = $paths | ForEach-Object {
if (Test-Path $_) {
Invoke-ScriptAnalyzer -Path $_ -Recurse -Settings $settings -Severity Error,Warning
}
}
if ($results) {
$results | Format-Table -AutoSize
Write-Error "PSScriptAnalyzer found $($results.Count) issue(s). Fix before merging."
exit 1
}
else {
Write-Host "PSScriptAnalyzer: no issues found."
}
python:
runs-on: windows-build
timeout-minutes: 20
env:
PYTHONIOENCODING: utf-8
VENV_DIR: F:\CI\python\venv
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup venv + install package
shell: powershell
run: |
$ErrorActionPreference = 'Stop'
# Production venv lives at F:\CI\python\venv (per AGENTS.md).
# If missing, bootstrap it via the Windows Python launcher (py -3.11),
# since the act_runner SYSTEM service does NOT have plain "python" in PATH.
$venvPy = Join-Path $env:VENV_DIR 'Scripts\python.exe'
if (-not (Test-Path $venvPy)) {
Write-Host "Venv missing, bootstrapping at $env:VENV_DIR"
$launcher = (Get-Command py.exe -ErrorAction Stop).Source
& $launcher -3.11 -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
shell: powershell
run: |
$venvPy = Join-Path $env:VENV_DIR 'Scripts\python.exe'
& $venvPy -m ruff check src tests/python
if ($LASTEXITCODE -ne 0) { throw "ruff failed" }
- name: mypy --strict
shell: powershell
run: |
$venvPy = Join-Path $env:VENV_DIR 'Scripts\python.exe'
& $venvPy -m mypy --strict src
if ($LASTEXITCODE -ne 0) { throw "mypy failed" }
- name: pytest (coverage >= 80%)
shell: powershell
run: |
$venvPy = Join-Path $env:VENV_DIR 'Scripts\python.exe'
& $venvPy -m pytest tests/python --cov=ci_orchestrator --cov-fail-under=80
if ($LASTEXITCODE -ne 0) { throw "pytest failed" }