diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index cc37fe0..c731640 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -4,6 +4,10 @@ run-name: "Action-Test - [${{ github.event.pull_request.title }} #${{ github.eve on: [pull_request] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + permissions: {} jobs: diff --git a/.github/workflows/Auto-Release.yml b/.github/workflows/Auto-Release.yml index 4734f27..ec157c9 100644 --- a/.github/workflows/Auto-Release.yml +++ b/.github/workflows/Auto-Release.yml @@ -14,7 +14,8 @@ on: - labeled concurrency: - group: ${{ github.workflow }} + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true permissions: contents: write diff --git a/.github/workflows/Linter.yml b/.github/workflows/Linter.yml index cfd32e6..0a31f9b 100644 --- a/.github/workflows/Linter.yml +++ b/.github/workflows/Linter.yml @@ -4,6 +4,10 @@ run-name: "Linter - [${{ github.event.pull_request.title }} #${{ github.event.pu on: [pull_request] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + permissions: contents: read packages: read diff --git a/scripts/helpers/Test-PSModule.ps1 b/scripts/helpers/Test-PSModule.ps1 index 725c307..07a9428 100644 --- a/scripts/helpers/Test-PSModule.ps1 +++ b/scripts/helpers/Test-PSModule.ps1 @@ -167,7 +167,6 @@ function Test-PSModule { Verbosity = 'Detailed' } } - Verbose = $false } Write-Verbose 'PesterParams:' Write-Verbose "$($pesterParams | ConvertTo-Json -Depth 4 -WarningAction SilentlyContinue)" @@ -175,13 +174,10 @@ function Test-PSModule { #endregion #region Run tests - Start-LogGroup 'Run tests' $verbosepref = $VerbosePreference $VerbosePreference = 'SilentlyContinue' $results = Invoke-Pester @pesterParams $VerbosePreference = $verbosepref - Write-Verbose 'Done' - Stop-LogGroup #endregion $results diff --git a/scripts/tests/PSScriptAnalyzer/PSScriptAnalyzer.Tests.ps1 b/scripts/tests/PSScriptAnalyzer/PSScriptAnalyzer.Tests.ps1 index 203b212..2a6039b 100644 --- a/scripts/tests/PSScriptAnalyzer/PSScriptAnalyzer.Tests.ps1 +++ b/scripts/tests/PSScriptAnalyzer/PSScriptAnalyzer.Tests.ps1 @@ -20,14 +20,17 @@ Param( ) BeforeDiscovery { - $rules = @() - $ruleObjects = Get-ScriptAnalyzerRule | Sort-Object -Property Severity + $rules = [Collections.Generic.List[System.Collections.Specialized.OrderedDictionary]]::new() + $ruleObjects = Get-ScriptAnalyzerRule -Verbose:$false | Sort-Object -Property Severity, CommonName foreach ($ruleObject in $ruleObjects) { - $hashTable = @{} - foreach ($property in $ruleObject.PSObject.Properties) { - $hashTable[$property.Name] = $property.Value - } - $rules += $hashTable + $rules.Add( + [ordered]@{ + RuleName = $ruleObject.RuleName + CommonName = $ruleObject.CommonName + Severity = $ruleObject.Severity + Description = $ruleObject.Description + } + ) } Write-Warning "Discovered [$($rules.Count)] rules" $relativeSettingsFilePath = $SettingsFilePath.Replace($PSScriptRoot, '').Trim('\').Trim('/') @@ -35,19 +38,18 @@ BeforeDiscovery { Describe "PSScriptAnalyzer tests using settings file [$relativeSettingsFilePath]" { BeforeAll { - $testResults = Invoke-ScriptAnalyzer -Path $Path -Settings $SettingsFilePath -Recurse + $testResults = Invoke-ScriptAnalyzer -Path $Path -Settings $SettingsFilePath -Recurse -Verbose:$false Write-Warning "Found [$($testResults.Count)] issues" } - It ' ()' -ForEach $rules { - $issues = @('') - $issues += $testResults | Where-Object -Property RuleName -EQ $ruleName | ForEach-Object { - $relativePath = $_.ScriptPath.Replace($Path, '').Trim('\').Trim('/') - " - $relativePath`:L$($_.Line):C$($_.Column): $($_.Message)" - } - if ($issues.Count -gt 1) { - $issues[0] = "[$($issues.Count - 1)] issues found:" + Context 'Severity: <_>' -ForEach 'Error', 'Warning', 'Information' { + It ' ()' -ForEach ($rules | Where-Object -Property Severity -EQ $_) { + $issues = [Collections.Generic.List[string]]::new() + $testResults | Where-Object -Property RuleName -EQ $RuleName | ForEach-Object { + $relativePath = $_.ScriptPath.Replace($Path, '').Trim('\').Trim('/') + $issues.Add(([Environment]::NewLine + " - $relativePath`:L$($_.Line):C$($_.Column)")) + } + $issues -join '' | Should -BeNullOrEmpty -Because $Description } - $issues -join [Environment]::NewLine | Should -BeNullOrEmpty } }