Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion psakeFile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,33 @@
task Test -Depends Init, Analyze, Pester -description 'Run test suite'

task Analyze -depends Build {
$analysis = Invoke-ScriptAnalyzer -Path $settings.ModuleOutDir -Recurse -Verbose:$false -Settings ([IO.Path]::Combine($env:BHModulePath, 'ScriptAnalyzerSettings.psd1'))
# PSScriptAnalyzer crashes intermittently on an internal race of its own, unrelated to the
# code being analyzed, and a re-run always succeeds. See psake/PowerShellBuild#136.
$analyzerParameters = @{
Path = $settings.ModuleOutDir
Recurse = $true
Verbose = $false
Settings = [IO.Path]::Combine($env:BHModulePath, 'ScriptAnalyzerSettings.psd1')
ErrorAction = 'Stop'
}
$maximumAttempt = 3
for ($attempt = 1; $attempt -le $maximumAttempt; $attempt++) {
try {
$analysis = Invoke-ScriptAnalyzer @analyzerParameters
break
} catch {
$errorRecord = $_
if ($attempt -eq $maximumAttempt) {
throw $errorRecord
}
Write-Warning (
"PSScriptAnalyzer failed on attempt $attempt of $maximumAttempt and will be retried. " +
"[$($errorRecord.FullyQualifiedErrorId)] $($errorRecord.Exception.Message)"
)
Start-Sleep -Seconds 2
}
}

$errors = $analysis | Where-Object {$_.Severity -eq 'Error'}
$warnings = $analysis | Where-Object {$_.Severity -eq 'Warning'}
if (@($errors).Count -gt 0) {
Expand Down Expand Up @@ -89,7 +115,7 @@

# Commented out rather than removed to allow easy use in future
# Generate Invoke-Build tasks from Psake tasks
# $psakePath = [IO.Path]::Combine($settings.ModuleOutDir, 'psakefile.ps1')

Check warning on line 118 in psakeFile.ps1

View workflow job for this annotation

GitHub Actions / CI / Run Linters

Unknown word (psakefile) Suggestions: (pagefile, planefile, pageFile, Pagefile, planeFile)
# $ibPath = [IO.Path]::Combine($settings.ModuleOutDir, 'IB.tasks.ps1')
# & .\Build\Convert-PSAke.ps1 $psakePath | Out-File -Encoding UTF8 $ibPath
}
Expand Down
Loading