Skip to content

Commit

Permalink
Change PSScriptAnalyzerSettings.psd1 path to not include GitHub works…
Browse files Browse the repository at this point in the history
…pace environment variable.
jonnybottles committed Nov 20, 2024
1 parent fb74377 commit ea16c4b
Showing 2 changed files with 24 additions and 7 deletions.
29 changes: 23 additions & 6 deletions .github/workflows/psscriptanalyzer.yml
Original file line number Diff line number Diff line change
@@ -22,6 +22,14 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Debug Paths
shell: pwsh
run: |
Write-Host "Current location: $(Get-Location)"
Write-Host "GITHUB_WORKSPACE: $env:GITHUB_WORKSPACE"
Write-Host "Directory contents:"
Get-ChildItem -Path . -Recurse | Select-Object FullName
- name: Install PSScriptAnalyzer
shell: pwsh
run: |
@@ -31,7 +39,13 @@ jobs:
- name: Run PSScriptAnalyzer
shell: pwsh
run: |
$settingsPath = ".github/psscriptanalyzer/PSScriptAnalyzerSettings.psd1"
$settingsPath = "./.github/psscriptanalyzer/PSScriptAnalyzerSettings.psd1"
Write-Host "Looking for settings file..."
Write-Host "Settings path: $settingsPath"
Write-Host "`n.github folder contents:"
Get-ChildItem -Path "./.github" -Recurse | Select-Object FullName
if (-not (Test-Path $settingsPath)) {
Write-Error "PSScriptAnalyzer settings file not found at: $settingsPath"
exit 1
@@ -44,21 +58,24 @@ jobs:
foreach ($file in $files) {
Write-Host "Analyzing $($file.FullName)"
$fileResults = Invoke-ScriptAnalyzer -Path $file.FullName -Settings $settingsPath
$results += $fileResults
if ($fileResults) {
$results += $fileResults
}
}
if ($results) {
$results | Format-Table -AutoSize | Tee-Object -FilePath "psscriptanalyzer-results.txt"
Write-Error "PSScriptAnalyzer found $($results.Count) issues"
Write-Host "Found $($results.Count) issues"
$results | Format-Table -AutoSize | Out-String | Write-Host
$results | Format-Table -AutoSize | Out-File psscriptanalyzer-results.txt
exit 1
} else {
Write-Host "No PSScriptAnalyzer issues found"
}
- name: Upload Results
if: failure()
if: always()
uses: actions/upload-artifact@v4
with:
name: psscriptanalyzer-results
path: psscriptanalyzer-results.txt
if-no-files-found: warn
if-no-files-found: warn
2 changes: 1 addition & 1 deletion Hawk/tests/general/Test-PreCommitHook.ps1
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
# 3. Observe the PSScriptAnalyzer warnings/errors

#region Good Code Examples - These will pass PSScriptAnalyzer
# add comment to testss
# add comment to tests
function Test-GoodFunction {
[CmdletBinding()]
param (

0 comments on commit ea16c4b

Please sign in to comment.