-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test bad results in workflow now that reverted back to yaml workflow.
- Loading branch information
1 parent
b8a1b26
commit ec01690
Showing
3 changed files
with
33 additions
and
83 deletions.
There are no files selected for viewing
60 changes: 0 additions & 60 deletions
60
Hawk/internal/scripts/git_hub_action_scripts/Invoke-GitHubPSScriptAnalyzer.ps1
This file was deleted.
Oops, something went wrong.
45 changes: 27 additions & 18 deletions
45
Hawk/internal/scripts/pre_commit_hook_scripts/Invoke-PowerShellScriptAnalyzer.ps1
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,34 @@ | ||
$ErrorActionPreference = 'Stop' | ||
$settings = Join-Path (Get-Location) 'Hawk/internal/configurations/PSScriptAnalyzerSettings.psd1' | ||
if ($MyInvocation.ScriptName -eq (Join-Path $PSScriptRoot 'Invoke-PowerShellScriptAnalyzer.ps1')) { | ||
$excludedFiles = @( | ||
'C:\Users\xxbut\code\hawk\Hawk\tests\general\Test-PreCommitHook.ps1' | ||
) | ||
|
||
# Define the list of files to exclude | ||
$excludedFiles = @( | ||
'none' | ||
) | ||
$files = git diff --cached --name-only --diff-filter=AM | Where-Object { $_ -match '\.(ps1|psm1|psd1)$' } | ||
$hasErrors = $false | ||
|
||
$files = git diff --cached --name-only --diff-filter=AM | Where-Object { $_ -match '\.(ps1|psm1|psd1)$' } | ||
$hasErrors = $false | ||
|
||
foreach ($file in $files) { | ||
if ($excludedFiles -notcontains $file) { | ||
Write-Output "Analyzing $file..." | ||
$results = Invoke-ScriptAnalyzer -Path $file -Settings $settings | ||
if ($results) { | ||
$results | Format-Table -AutoSize | ||
$hasErrors = $true | ||
foreach ($file in $files) { | ||
if ($excludedFiles -contains $file) { | ||
Write-Output "Skipping analysis for excluded file: $file" | ||
} | ||
else { | ||
Write-Output "Analyzing $file..." | ||
$results = Invoke-ScriptAnalyzer -Path $file -Settings $settings | ||
if ($results) { | ||
$results | Format-Table -AutoSize | ||
$hasErrors = $true | ||
} | ||
} | ||
} | ||
|
||
if ($hasErrors) { | ||
Write-Output "PSScriptAnalyzer found errors. Exiting with error code 1." | ||
exit 1 | ||
} | ||
else { | ||
Write-Output "Skipping analysis for excluded file: $file" | ||
Write-Output "No PSScriptAnalyzer issues found. Exiting with code 0." | ||
exit 0 | ||
} | ||
} | ||
if ($hasErrors) { exit 1 } | ||
else { | ||
# Original script content | ||
} |
This file contains 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