From f1b80cd41781ef6d7f197ef707fa6a70f6a7d787 Mon Sep 17 00:00:00 2001 From: Derek Campbell Date: Sun, 4 Oct 2026 21:27:36 +0100 Subject: [PATCH 1/5] Adopt central PowerShell lint workflow Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/ci.yml | 36 +++++------------------------------- README.md | 10 ++++++---- lint.ps1 | 5 ++--- 3 files changed, 13 insertions(+), 38 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b20ea77..3b8a29b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,37 +19,11 @@ jobs: lint: name: Lint (PSScriptAnalyzer) - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - with: - persist-credentials: false - - - name: Install PSScriptAnalyzer - shell: pwsh - run: | - Set-PSRepository -Name PSGallery -InstallationPolicy Trusted - Install-Module PSScriptAnalyzer -Scope CurrentUser -Force -ErrorAction Stop - - - name: Run PSScriptAnalyzer - shell: pwsh - run: | - $settings = "$env:GITHUB_WORKSPACE/PSScriptAnalyzerSettings.psd1" - $lessonResults = Invoke-ScriptAnalyzer -Path "$env:GITHUB_WORKSPACE/lessons" -Settings $settings -Recurse - $testResults = Invoke-ScriptAnalyzer -Path "$env:GITHUB_WORKSPACE/tests" -Settings $settings -Recurse - - $allResults = @($lessonResults) + @($testResults) - - if ($allResults.Count -gt 0) { - $allResults | Format-Table -AutoSize - Write-Error "PSScriptAnalyzer found $($allResults.Count) issue(s). See table above." - exit 1 - } - else { - Write-Output "PSScriptAnalyzer: no issues found." - } + uses: DevOpsDerek/workflows/.github/workflows/lint/powershell.yml@cd4f07509e9efb0c498217c3be352e762bd0c149 + with: + psscriptanalyzer-version: 1.24.0 + working-directory: . + settings-path: PSScriptAnalyzerSettings.psd1 test: name: Test (Pester) diff --git a/README.md b/README.md index 1a7abf7..d0581a0 100644 --- a/README.md +++ b/README.md @@ -82,10 +82,12 @@ pwsh ./lint.ps1 ## CI and Documentation Automation CI keeps separate PSScriptAnalyzer and Pester jobs, with tests running after -lint succeeds. CI analyzes both `lessons/` and `tests/` using -`PSScriptAnalyzerSettings.psd1` and fails on any diagnostic; the local -`lint.ps1` helper fails only on errors. Pester 5 or later writes NUnit XML to -`test-results.xml`, uploaded as `pester-test-results` even when tests fail. +lint succeeds. CI uses the central PSScriptAnalyzer workflow, pinned to an exact +module version, and analyzes PowerShell sources under the repository root using +`PSScriptAnalyzerSettings.psd1`; it fails on Error and Warning diagnostics. +The local `lint.ps1` helper uses the same settings and diagnostic threshold for +`lessons/` and `tests/`. Pester 5 or later writes NUnit XML to `test-results.xml`, +uploaded as `pester-test-results` even when tests fail. Automation validation comes from [`DevOpsDerek/workflows` at commit `dac4b81c298cb3ea6821ea312efa5375f42d5ccb`](https://github.com/DevOpsDerek/workflows/tree/dac4b81c298cb3ea6821ea312efa5375f42d5ccb). diff --git a/lint.ps1 b/lint.ps1 index a1d2a21..569a671 100644 --- a/lint.ps1 +++ b/lint.ps1 @@ -14,7 +14,7 @@ $paths = @( (Join-Path -Path $projectRoot -ChildPath 'tests') ) -$results = Invoke-ScriptAnalyzer -Path $paths -Settings $settingsPath -Recurse +$results = Invoke-ScriptAnalyzer -Path $paths -Settings $settingsPath -Recurse -Severity Error, Warning if (-not $results) { Write-Output 'No ScriptAnalyzer issues found.' @@ -25,7 +25,6 @@ $results | Sort-Object ScriptName, Line, Column | Format-Table Severity, RuleName, ScriptName, Line, Message -AutoSize -$errorResults = $results | Where-Object Severity -eq 'Error' -if ($errorResults) { +if ($results) { exit 1 } From 6d9c6cbd62a4eb76bbd6cd9114c1ce092b3507a0 Mon Sep 17 00:00:00 2001 From: Derek Campbell Date: Sun, 4 Oct 2026 21:31:09 +0100 Subject: [PATCH 2/5] Use top-level central PowerShell lint workflow Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3b8a29b..86d3349 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: lint: name: Lint (PSScriptAnalyzer) - uses: DevOpsDerek/workflows/.github/workflows/lint/powershell.yml@cd4f07509e9efb0c498217c3be352e762bd0c149 + uses: DevOpsDerek/workflows/.github/workflows/lint-powershell.yml@c4ac3847334c8944a48619ae4f3f0d622f4a074b with: psscriptanalyzer-version: 1.24.0 working-directory: . From d869e5d7d888e8c63fba75ddb8212b532e3a97b1 Mon Sep 17 00:00:00 2001 From: Derek Campbell Date: Sun, 4 Oct 2026 21:32:17 +0100 Subject: [PATCH 3/5] Pin published PowerShell lint workflow Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 86d3349..0408e8f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: lint: name: Lint (PSScriptAnalyzer) - uses: DevOpsDerek/workflows/.github/workflows/lint-powershell.yml@c4ac3847334c8944a48619ae4f3f0d622f4a074b + uses: DevOpsDerek/workflows/.github/workflows/lint-powershell.yml@35ec3f531b5eb0f0f42f232f23e1dc5735e36c35 with: psscriptanalyzer-version: 1.24.0 working-directory: . From c2f65ca32cc5326552074e8de928288083d7aec2 Mon Sep 17 00:00:00 2001 From: Derek Campbell Date: Sun, 4 Oct 2026 21:37:09 +0100 Subject: [PATCH 4/5] Pin fixed central PowerShell lint workflow Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0408e8f..15d1cb1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: lint: name: Lint (PSScriptAnalyzer) - uses: DevOpsDerek/workflows/.github/workflows/lint-powershell.yml@35ec3f531b5eb0f0f42f232f23e1dc5735e36c35 + uses: DevOpsDerek/workflows/.github/workflows/lint-powershell.yml@5ecebff22598835cbf5ccd7bfa07c036cce22ee9 with: psscriptanalyzer-version: 1.24.0 working-directory: . From c8ca40b5b1c7967651a0f47ff930ca202b76661b Mon Sep 17 00:00:00 2001 From: Derek Campbell Date: Sun, 4 Oct 2026 21:39:23 +0100 Subject: [PATCH 5/5] Pin current central PowerShell lint workflow Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 15d1cb1..d6d7e3f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: lint: name: Lint (PSScriptAnalyzer) - uses: DevOpsDerek/workflows/.github/workflows/lint-powershell.yml@5ecebff22598835cbf5ccd7bfa07c036cce22ee9 + uses: DevOpsDerek/workflows/.github/workflows/lint-powershell.yml@30f86d7d8536364b0a31de4bc66214b39e8785bb with: psscriptanalyzer-version: 1.24.0 working-directory: .