Partial fix: Windows 10 VM creation script syntax errors #90
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: PowerShell CI | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main ] | |
| env: | |
| POWERSHELL_TELEMETRY_OPTOUT: 1 | |
| jobs: | |
| lint: | |
| name: PowerShell Lint | |
| runs-on: ubuntu-latest | |
| continue-on-error: true | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install PowerShell modules | |
| shell: pwsh | |
| run: | | |
| Set-PSRepository PSGallery -InstallationPolicy Trusted | |
| Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser | |
| Import-Module PSScriptAnalyzer | |
| - name: Run PSScriptAnalyzer | |
| continue-on-error: true | |
| shell: pwsh | |
| run: | | |
| $results = Invoke-ScriptAnalyzer -Path ./scripts -Settings ./PSScriptAnalyzerSettings.psd1 -Recurse -ErrorAction SilentlyContinue | |
| if ($results) { | |
| Write-Host "PSScriptAnalyzer found $($results.Count) issues (non-blocking):" -ForegroundColor Yellow | |
| $results | ForEach-Object { | |
| Write-Host " $($_.Severity): $($_.RuleName) in $($_.ScriptName) at line $($_.Line)" -ForegroundColor Yellow | |
| Write-Host " $($_.Message)" -ForegroundColor White | |
| } | |
| $errors = $results | Where-Object { $_.Severity -eq 'Error' } | |
| Write-Host "Found $($errors.Count) errors (informational only)." -ForegroundColor Yellow | |
| } else { | |
| Write-Host "PSScriptAnalyzer found no issues!" -ForegroundColor Green | |
| } | |
| security: | |
| name: Security Scan | |
| runs-on: ubuntu-latest | |
| continue-on-error: true | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Check for secrets | |
| continue-on-error: true | |
| uses: gitleaks/gitleaks-action@v2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| validate-standards: | |
| name: Validate PowerShell Standards | |
| runs-on: ubuntu-latest | |
| continue-on-error: true | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Validate PowerShell Standards | |
| continue-on-error: true | |
| shell: pwsh | |
| run: | | |
| $scripts = Get-ChildItem -Path ./scripts -Filter "*.ps1" -Recurse | |
| $issues = @() | |
| $syntaxErrors = 0 | |
| foreach ($script in $scripts) { | |
| # Check syntax | |
| try { | |
| $null = [System.Management.Automation.PSParser]::Tokenize((Get-Content $script.FullName -Raw), [ref]$null) | |
| } catch { | |
| Write-Warning "Syntax error in $($script.Name): $($_.Exception.Message)" | |
| $syntaxErrors++ | |
| continue | |
| } | |
| $content = Get-Content -Path $script.FullName -Raw | |
| # Check for required elements | |
| if ($content -notmatch '#Requires -Version') { | |
| $issues += "$($script.Name): Missing #Requires -Version" | |
| } | |
| if ($content -match 'param\s*\(' -and $content -notmatch '\[CmdletBinding') { | |
| $issues += "$($script.Name): Missing [CmdletBinding()] with param block" | |
| } | |
| if ($content -notmatch '\.SYNOPSIS') { | |
| $issues += "$($script.Name): Missing .SYNOPSIS in comment-based help" | |
| } | |
| } | |
| Write-Host "Validation Summary (informational):" -ForegroundColor Cyan | |
| Write-Host " Total scripts: $($scripts.Count)" -ForegroundColor White | |
| Write-Host " Syntax errors: $syntaxErrors" -ForegroundColor Yellow | |
| Write-Host " Standard violations: $($issues.Count)" -ForegroundColor Yellow | |
| if ($syntaxErrors -gt 0) { | |
| Write-Host "Found syntax errors (informational only)." -ForegroundColor Yellow | |
| } | |
| if ($issues.Count -gt 0) { | |
| Write-Host "PowerShell standard violations found (informational):" -ForegroundColor Yellow | |
| $issues | ForEach-Object { Write-Host " $_" -ForegroundColor Gray } | |
| } else { | |
| Write-Host "All scripts meet PowerShell standards." -ForegroundColor Green | |
| } |