Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
🩹 [Patch]: Default to built-in Invoke-ScriptAnalyzer settings#19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
af6bef353bd7f43c113d43cba6082b77ba080910d49abfd71b013966a2762b490ed94cb55d2f7ca0ea5e846a33fd5d218eFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -26,6 +26,8 @@ jobs: | ||
| steps: | ||
| - name: Checkout repo | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| persist-credentials: false | ||
| - name: Action-Test | ||
| uses: ./ | ||
| @@ -49,6 +51,8 @@ jobs: | ||
| steps: | ||
| - name: Checkout repo | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| persist-credentials: false | ||
| - name: Action-Test | ||
| uses: ./ | ||
| @@ -73,6 +77,8 @@ jobs: | ||
| steps: | ||
| - name: Checkout repo | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| persist-credentials: false | ||
| - name: Action-Test | ||
| uses: ./ | ||
| @@ -89,6 +95,32 @@ jobs: | ||
| Write-Host "Outcome: ${{ steps.action-test.outcome }}" | ||
| Write-Host "Conclusion: ${{ steps.action-test.conclusion }}" | ||
| ActionTestSrcWithManifestDefault: | ||
| name: Action-Test - [Src-WithManifest-Default] | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| Outcome: ${{ steps.action-test.outcome }} | ||
| Conclusion: ${{ steps.action-test.conclusion }} | ||
| steps: | ||
| - name: Checkout repo | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| persist-credentials: false | ||
| - name: Action-Test | ||
| uses: ./ | ||
| continue-on-error: true | ||
| id: action-test | ||
| with: | ||
| Path: src | ||
| WorkingDirectory: tests/srcWithManifestTestRepo | ||
| - name: Status | ||
| shell: pwsh | ||
| run: | | ||
| Write-Host "Outcome: ${{ steps.action-test.outcome }}" | ||
| Write-Host "Conclusion: ${{ steps.action-test.conclusion }}" | ||
| ActionTestOutputs: | ||
| name: Action-Test - [outputs] | ||
| runs-on: ubuntu-latest | ||
| @@ -98,6 +130,8 @@ jobs: | ||
| steps: | ||
| - name: Checkout repo | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| persist-credentials: false | ||
| - name: Action-Test | ||
| uses: ./ | ||
| @@ -118,25 +152,28 @@ jobs: | ||
| - ActionTestSrcSourceCode | ||
| - ActionTestSrcCustom | ||
| - ActionTestSrcWithManifest | ||
| - ActionTestSrcWithManifestDefault | ||
| - ActionTestOutputs | ||
| if: always() | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| ActionTestSrcSourceCodeOutcome: ${{ needs.ActionTestSrcSourceCode.outputs.Outcome }} | ||
| ActionTestSrcSourceCodeConclusion: ${{ needs.ActionTestSrcSourceCode.outputs.Conclusion }} | ||
| ActionTestSrcCustomOutcome: ${{ needs.ActionTestSrcCustom.outputs.Outcome }} | ||
| ActionTestSrcCustomConclusion: ${{ needs.ActionTestSrcCustom.outputs.Conclusion }} | ||
| ActionTestSrcWithManifestOutcome: ${{ needs.ActionTestSrcWithManifest.outputs.Outcome }} | ||
| ActionTestSrcWithManifestConclusion: ${{ needs.ActionTestSrcWithManifest.outputs.Conclusion }} | ||
| ActionTestOutputsOutcome: ${{ needs.ActionTestOutputs.outputs.Outcome }} | ||
| ActionTestOutputsConclusion: ${{ needs.ActionTestOutputs.outputs.Conclusion }} | ||
| SourceCodeOutcome: ${{ needs.ActionTestSrcSourceCode.outputs.Outcome }} | ||
| SourceCodeConclusion: ${{ needs.ActionTestSrcSourceCode.outputs.Conclusion }} | ||
| CustomOutcome: ${{ needs.ActionTestSrcCustom.outputs.Outcome }} | ||
| CustomConclusion: ${{ needs.ActionTestSrcCustom.outputs.Conclusion }} | ||
| WithManifestOutcome: ${{ needs.ActionTestSrcWithManifest.outputs.Outcome }} | ||
| WithManifestConclusion: ${{ needs.ActionTestSrcWithManifest.outputs.Conclusion }} | ||
| WithManifestDefaultOutcome: ${{ needs.ActionTestSrcWithManifestDefault.outputs.Outcome }} | ||
| WithManifestDefaultConclusion: ${{ needs.ActionTestSrcWithManifestDefault.outputs.Conclusion }} | ||
| OutputsOutcome: ${{ needs.ActionTestOutputs.outputs.Outcome }} | ||
| OutputsConclusion: ${{ needs.ActionTestOutputs.outputs.Conclusion }} | ||
| steps: | ||
| - name: Checkout repo | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| persist-credentials: false | ||
| - name: Aggregated Status | ||
| uses: PSModule/Github-Script@v1 | ||
| with: | ||
| Script: | | ||
| # Aggregated Status | ||
| tests/Get-AggregatedStatus.ps1 | ||
| Script: tests/Get-AggregatedStatus.ps1 | ||
MariusStorhaug marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -11,17 +11,25 @@ | ||
| Justification = 'Write-Host is used for log output.' | ||
| )] | ||
| [CmdLetBinding()] | ||
| Param( | ||
| param( | ||
| [Parameter(Mandatory)] | ||
| [string] $Path, | ||
| [Parameter(Mandatory)] | ||
| [Parameter()] | ||
| [string] $SettingsFilePath | ||
| ) | ||
| BeforeDiscovery { | ||
| LogGroup "PSScriptAnalyzer tests using settings file [$SettingsFilePath]" { | ||
| $settings = Import-PowerShellDataFile -Path $SettingsFilePath | ||
| $hasSettingsFile = -not [string]::IsNullOrEmpty($SettingsFilePath) | ||
| $settingsDescription = $hasSettingsFile ? "settings file [$SettingsFilePath]" : 'default settings' | ||
MariusStorhaug marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| LogGroup "PSScriptAnalyzer tests using $settingsDescription" { | ||
| if ($hasSettingsFile) { | ||
| $settings = Import-PowerShellDataFile -Path $SettingsFilePath | ||
| } else { | ||
| $settings = @{} | ||
| } | ||
| $rules = [Collections.Generic.List[System.Collections.Specialized.OrderedDictionary]]::new() | ||
| $ruleObjects = Get-ScriptAnalyzerRule -Verbose:$false | Sort-Object -Property Severity, CommonName | ||
| $Severeties = $ruleObjects | Select-Object -ExpandProperty Severity -Unique | ||
| @@ -65,13 +73,18 @@ BeforeDiscovery { | ||
| Describe 'PSScriptAnalyzer' { | ||
| BeforeAll { | ||
| $relativeSettingsFilePath = if ($SettingsFilePath.StartsWith($PSScriptRoot)) { | ||
| $SettingsFilePath.Replace($PSScriptRoot, 'Action:').Trim('\').Trim('/') | ||
| } elseif ($SettingsFilePath.StartsWith($env:GITHUB_WORKSPACE)) { | ||
| $SettingsFilePath.Replace($env:GITHUB_WORKSPACE, 'Workspace:').Trim('\').Trim('/') | ||
| } else { | ||
| $SettingsFilePath | ||
| $hasSettingsFile = -not [string]::IsNullOrEmpty($SettingsFilePath) | ||
| if ($hasSettingsFile) { | ||
| $relativeSettingsFilePath = if ($SettingsFilePath.StartsWith($PSScriptRoot)) { | ||
| $SettingsFilePath.Replace($PSScriptRoot, 'Action:').Trim('\').Trim('/') | ||
| } elseif ($SettingsFilePath.StartsWith($env:GITHUB_WORKSPACE)) { | ||
| $SettingsFilePath.Replace($env:GITHUB_WORKSPACE, 'Workspace:').Trim('\').Trim('/') | ||
| } else { | ||
| $SettingsFilePath | ||
| } | ||
| } | ||
| $Path = Resolve-Path -Path $Path | Select-Object -ExpandProperty Path | ||
| $relativePath = if ($Path.StartsWith($PSScriptRoot)) { | ||
| $Path.Replace($PSScriptRoot, 'Action:').Trim('\').Trim('/').Replace('\', '/') | ||
| @@ -88,9 +101,25 @@ Describe 'PSScriptAnalyzer' { | ||
| GITHUB_WORKSPACE = $env:GITHUB_WORKSPACE | ||
| } | ||
| LogGroup "Invoke-ScriptAnalyzer -Path [$relativePath] -Settings [$relativeSettingsFilePath]" { | ||
| $testResults = Invoke-ScriptAnalyzer -Path $Path -Settings $SettingsFilePath -Recurse -Verbose | ||
| $invokeParams = @{ | ||
| Path = $Path | ||
| Recurse = $true | ||
| } | ||
| if ($hasSettingsFile) { | ||
| $invokeParams['Settings'] = $SettingsFilePath | ||
| } | ||
| $logMessage = if ($hasSettingsFile) { | ||
| "Invoke-ScriptAnalyzer -Path '$relativePath' -Recurse -Settings '$relativeSettingsFilePath'" | ||
| } else { | ||
| "Invoke-ScriptAnalyzer -Path '$relativePath' -Recurse (using default settings)" | ||
| } | ||
| LogGroup $logMessage { | ||
| $testResults = Invoke-ScriptAnalyzer @invokeParams | ||
| } | ||
| LogGroup "TestResults [$($testResults.Count)]" { | ||
| $testResults | Select-Object -Property * | Format-List | Out-String -Stream | ForEach-Object { | ||
| Write-Verbose $_ -Verbose | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.