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.
  • Loading branch information
jonnybottles committed Nov 20, 2024
1 parent ea16c4b commit 3180b21
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
28 changes: 16 additions & 12 deletions .github/workflows/psscriptanalyzer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
jobs:
analyze:
name: PSScriptAnalyzer
runs-on: windows-latest
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
Expand All @@ -27,8 +27,13 @@ jobs:
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
$settingsPath = Join-Path $env:GITHUB_WORKSPACE '.github' 'psscriptanalyzer' 'PSScriptAnalyzerSettings.psd1'
Write-Host "Settings path: $settingsPath"
Write-Host "`nVerifying .github structure:"
Get-ChildItem -Path (Join-Path $env:GITHUB_WORKSPACE '.github') -Recurse |
Select-Object FullName
- name: Install PSScriptAnalyzer
shell: pwsh
Expand All @@ -39,21 +44,20 @@ jobs:
- name: Run PSScriptAnalyzer
shell: pwsh
run: |
$settingsPath = "./.github/psscriptanalyzer/PSScriptAnalyzerSettings.psd1"
$settingsPath = Join-Path $env:GITHUB_WORKSPACE '.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
Write-Host "Using settings file: $settingsPath"
if (-not (Test-Path $settingsPath)) {
Write-Error "PSScriptAnalyzer settings file not found at: $settingsPath"
exit 1
}
$results = @()
$files = Get-ChildItem -Path . -Recurse -Include *.ps1,*.psm1,*.psd1 |
Where-Object { $_.FullName -notlike '*\node_modules\*' }
$files = Get-ChildItem -Path $env:GITHUB_WORKSPACE -Recurse -Include *.ps1,*.psm1,*.psd1 |
Where-Object {
$_.FullName -notlike '*\node_modules\*' -and
$_.FullName -notlike '*/.git/*'
}
foreach ($file in $files) {
Write-Host "Analyzing $($file.FullName)"
Expand All @@ -66,7 +70,7 @@ jobs:
if ($results) {
Write-Host "Found $($results.Count) issues"
$results | Format-Table -AutoSize | Out-String | Write-Host
$results | Format-Table -AutoSize | Out-File psscriptanalyzer-results.txt
$results | Format-Table -AutoSize | Out-File (Join-Path $env:GITHUB_WORKSPACE 'psscriptanalyzer-results.txt')
exit 1
} else {
Write-Host "No PSScriptAnalyzer issues found"
Expand Down
2 changes: 1 addition & 1 deletion Hawk/tests/general/Test-PreCommitHook.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# 3. Observe the PSScriptAnalyzer warnings/errors

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

0 comments on commit 3180b21

Please sign in to comment.