9c84e66dc3
fix(script): add CmdletBinding attribute to Set-GuestInfoIP function for better process support
103 lines
2.6 KiB
YAML
103 lines
2.6 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:
|
|
workflow_dispatch:
|
|
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: linux-build
|
|
timeout-minutes: 10
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 1
|
|
|
|
- name: Run PSScriptAnalyzer
|
|
shell: pwsh
|
|
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: linux-build
|
|
timeout-minutes: 20
|
|
|
|
env:
|
|
PYTHONIOENCODING: utf-8
|
|
VENV_DIR: ${{ github.workspace }}/.venv-lint
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 1
|
|
|
|
- name: Setup venv + install package
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
rm -rf "$VENV_DIR"
|
|
python3 -m venv "$VENV_DIR"
|
|
"$VENV_DIR/bin/python" -m pip install --upgrade pip
|
|
"$VENV_DIR/bin/python" -m pip install -e ".[dev]"
|
|
|
|
- name: ruff
|
|
shell: bash
|
|
run: |
|
|
"$VENV_DIR/bin/python" -m ruff check src tests/python
|
|
|
|
- name: mypy --strict
|
|
shell: bash
|
|
run: |
|
|
"$VENV_DIR/bin/python" -m mypy --strict src
|
|
|
|
- name: pytest (coverage >= 90%)
|
|
shell: bash
|
|
run: |
|
|
"$VENV_DIR/bin/python" -m pytest tests/python --cov=ci_orchestrator --cov-fail-under=90
|