Skip to content

Merge pull request #908 from yasinBursali/fix/env-mount-ro-host-agent… #1985

Merge pull request #908 from yasinBursali/fix/env-mount-ro-host-agent…

Merge pull request #908 from yasinBursali/fix/env-mount-ro-host-agent… #1985

name: Lint PowerShell
on:
pull_request:
push:
branches:
- main
- master
jobs:
powershell-lint:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: dream-server
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install PSScriptAnalyzer
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module PSScriptAnalyzer -Force -Scope CurrentUser
- name: Run PowerShell Script Analyzer
shell: pwsh
run: |
$scripts = @()
$scripts += Get-ChildItem -Path installers -Filter *.ps1 -Recurse
# Also lint repo-root Windows entrypoint (outside dream-server/).
$rootInstaller = Join-Path ".." "install.ps1"
if (Test-Path $rootInstaller) {
$scripts += Get-Item $rootInstaller
}
$scripts = $scripts | Sort-Object -Property FullName -Unique
if (-not $scripts) {
Write-Host "No PowerShell scripts found."
exit 0
}
$failed = $false
foreach ($script in $scripts) {
Write-Host "Analyzing $($script.FullName)"
$results = Invoke-ScriptAnalyzer -Path $script.FullName -Settings ./PSScriptAnalyzerSettings.psd1 -Severity Error,Warning
if ($results) {
$results | Format-Table RuleName, Severity, Message, ScriptName, Line -AutoSize
$failed = $true
}
}
if ($failed) { exit 1 }