Merge pull request #909 from yasinBursali/fix/apply-template-sync-bui… #1987
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: 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 } |