Skip to content

Commit 3141e72

Browse files
tablackburnclaude
andcommitted
ci: adopt psake shared ModuleCI workflow
Replace the bespoke test + import-smoke jobs with a thin caller of the org's shared psake/.github ModuleCI workflow, which runs the full build/test suite on PowerShell 7+ across Linux/Windows/macOS and on the real Windows PowerShell 5.1 (Desktop) engine. The dedicated 5.1 job subsumes the previous import-only smoke test, so a regression like the 0.8.0 ternary that broke module import on 5.1 is caught by the standard test run. Pin to a tag/SHA once the 5.1 job has merged upstream. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 84361ef commit 3141e72

1 file changed

Lines changed: 14 additions & 62 deletions

File tree

.github/workflows/test.yml

Lines changed: 14 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,22 @@
11
name: Test
22
permissions:
33
contents: read
4+
checks: write
5+
pull-requests: write
6+
issues: write
47
on:
58
push:
6-
branches: [ $default-branch ]
9+
branches: [ main ]
710
pull_request:
811
workflow_dispatch:
912
jobs:
10-
test:
11-
name: Test
12-
runs-on: ${{ matrix.os }}
13-
strategy:
14-
fail-fast: false
15-
matrix:
16-
os: [ubuntu-latest, windows-latest, macOS-latest]
17-
steps:
18-
- uses: actions/checkout@v4
19-
- name: Test
20-
shell: pwsh
21-
env:
22-
DEBUG: ${{ runner.debug == '1' }}
23-
run: |
24-
if($env:DEBUG -eq 'true' -or $env:DEBUG -eq '1') {
25-
$DebugPreference = 'Continue'
26-
}
27-
./build.ps1 -Task Test -Bootstrap
28-
29-
# Smoke test on the lowest supported engine. The manifest declares support for Windows
30-
# PowerShell (Desktop), so the module must parse and import there. This job caught the 0.8.0
31-
# regression where a PowerShell 7+-only ternary operator broke module import on 5.1.
32-
# The root .psm1 is imported directly (rather than the .psd1) so the real dot-source loader runs
33-
# without the manifest's RequiredModules bootstrap, keeping the smoke test fast and dependency-free.
34-
import-smoke:
35-
name: Import smoke (Windows PowerShell 5.1)
36-
runs-on: windows-latest
37-
steps:
38-
- uses: actions/checkout@v4
39-
- name: Parse and import module under Windows PowerShell 5.1
40-
shell: powershell
41-
run: |
42-
$ErrorActionPreference = 'Stop'
43-
"Engine: $($PSVersionTable.PSEdition) $($PSVersionTable.PSVersion)"
44-
45-
$moduleRoot = Join-Path $PWD 'PowerShellBuild'
46-
47-
# 1. Parse every module file with the 5.1 language parser to catch syntax the lowest
48-
# supported engine cannot load (for example the PowerShell 7+ ternary operator).
49-
$files = Get-ChildItem -Path $moduleRoot -Recurse -Include *.ps1, *.psm1, *.psd1
50-
$parseFailed = $false
51-
foreach ($file in $files) {
52-
$tokens = $parseErrors = $null
53-
[System.Management.Automation.Language.Parser]::ParseFile($file.FullName, [ref]$tokens, [ref]$parseErrors) > $null
54-
if ($parseErrors) {
55-
$parseFailed = $true
56-
Write-Host "Parse errors in $($file.FullName):"
57-
$parseErrors | ForEach-Object { Write-Host " line $($_.Extent.StartLineNumber): $($_.Message)" }
58-
}
59-
}
60-
if ($parseFailed) {
61-
throw 'One or more module files failed to parse under Windows PowerShell 5.1.'
62-
}
63-
"Parsed $($files.Count) module files with no errors."
64-
65-
# 2. Import the root module to run the real dot-source loader and confirm it loads on 5.1.
66-
Import-Module (Join-Path $moduleRoot 'PowerShellBuild.psm1') -Force -ErrorAction Stop
67-
if (-not (Get-Command Get-PSBuildCertificate -ErrorAction SilentlyContinue)) {
68-
throw 'PowerShellBuild imported but expected functions are missing.'
69-
}
70-
'PowerShellBuild imported successfully under Windows PowerShell 5.1.'
13+
# Delegate to the psake org's shared module CI workflow. It runs the full build/test suite
14+
# (Build + Analyze + Pester) on PowerShell 7+ across Linux/Windows/macOS and on the real
15+
# Windows PowerShell 5.1 (Desktop) engine, so regressions like the 0.8.0 ternary that broke
16+
# module import on 5.1 are caught by the standard test run rather than a separate smoke test.
17+
ci:
18+
name: CI
19+
# TODO: pin to a tagged release or commit SHA of psake/.github once the 5.1 (test_powershell)
20+
# job has merged there. Until then `@main` is required so this resolves to a version that
21+
# includes the Windows PowerShell 5.1 job.
22+
uses: psake/.github/.github/workflows/ModuleCI.yml@main

0 commit comments

Comments
 (0)