Skip to content

Commit bbf258b

Browse files
Test PowerShell Preview in CI (#2070)
Since the Daily no longer exists.
1 parent 8862e51 commit bbf258b

File tree

3 files changed

+51
-8
lines changed

3 files changed

+51
-8
lines changed

Diff for: .github/workflows/ci-test.yml

+24-5
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,43 @@ jobs:
3131
shell: pwsh
3232

3333
- name: Build
34-
run: ./build.ps1 -Configuration Release -All
34+
run: ./build.ps1 -Configuration Release -All -Verbose
3535
shell: pwsh
3636

3737
- name: Package
38-
run: ./build.ps1 -BuildNupkg
38+
run: ./build.ps1 -BuildNupkg -Verbose
3939
shell: pwsh
4040

4141
- name: Test
42-
run: ./build.ps1 -Test
42+
run: ./build.ps1 -Test -Verbose
4343
shell: pwsh
4444

4545
- name: Test Windows PowerShell
46+
if: matrix.os == 'windows-latest'
4647
run: |
4748
Install-Module Pester -Scope CurrentUser -Force -SkipPublisherCheck
48-
./build.ps1 -Test
49-
if: matrix.os == 'windows-latest'
49+
./build.ps1 -Test -Verbose
5050
shell: powershell
5151

52+
- name: Download PowerShell install script
53+
uses: actions/checkout@v4
54+
with:
55+
repository: PowerShell/PowerShell
56+
path: pwsh
57+
sparse-checkout: tools/install-powershell.ps1
58+
sparse-checkout-cone-mode: false
59+
60+
- name: Install preview
61+
continue-on-error: true
62+
run: ./pwsh/tools/install-powershell.ps1 -Preview -Destination ./preview
63+
shell: pwsh
64+
65+
- name: Test preview
66+
run: |
67+
$PwshPreview = if ($isWindows) { "./preview/pwsh.exe" } else { "./preview/pwsh" }
68+
./build.ps1 -Test -WithPowerShell:$PwshPreview -Verbose
69+
shell: pwsh
70+
5271
- name: Upload build artifacts
5372
uses: actions/upload-artifact@v4
5473
if: always()

Diff for: build.ps1

+7-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ param(
3232

3333
[Parameter(ParameterSetName='Test')]
3434
[switch] $InProcess,
35+
[string] $WithPowerShell,
3536

3637
[Parameter(ParameterSetName='BuildAll')]
3738
[switch] $Catalog,
@@ -85,7 +86,12 @@ END {
8586
Start-CreatePackage
8687
}
8788
"Test" {
88-
Test-ScriptAnalyzer -InProcess:$InProcess
89+
$testArgs = @{
90+
InProcess = $InProcess
91+
WithPowerShell = $WithPowerShell
92+
Verbose = $verboseWanted
93+
}
94+
Test-ScriptAnalyzer @testArgs
8995
return
9096
}
9197
default {

Diff for: build.psm1

+20-2
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,10 @@ function New-Catalog
308308
function Test-ScriptAnalyzer
309309
{
310310
[CmdletBinding()]
311-
param ( [switch] $InProcess )
311+
param (
312+
[switch] $InProcess,
313+
[string] $WithPowerShell
314+
)
312315

313316
END {
314317
# versions 3 and 4 don't understand versioned module paths, so we need to rename the directory of the version to
@@ -347,11 +350,19 @@ function Test-ScriptAnalyzer
347350
$analyzerPsd1Path = Join-Path -Path $script:destinationDir -ChildPath "$analyzerName.psd1"
348351
$scriptBlock = [scriptblock]::Create("Import-Module '$analyzerPsd1Path'; Invoke-Pester -Path $testScripts -CI")
349352
if ( $InProcess ) {
353+
Write-Verbose "Testing with PowerShell $($PSVersionTable.PSVersion)"
350354
& $scriptBlock
351355
}
356+
elseif ( $WithPowerShell ) {
357+
$pwshVersion = & $WithPowerShell --version
358+
Write-Verbose "Testing with $pwshVersion"
359+
& $WithPowerShell -Command $scriptBlock
360+
}
352361
else {
353362
$powershell = (Get-Process -id $PID).MainModule.FileName
354-
& ${powershell} -NoProfile -Command $scriptBlock
363+
$pwshVersion = & $powershell --version
364+
Write-Verbose "Testing with $pwshVersion"
365+
& $powershell -NoProfile -Command $scriptBlock
355366
}
356367
}
357368
finally {
@@ -555,6 +566,13 @@ function Get-DotnetExe
555566
$script:DotnetExe = $dotnetHuntPath
556567
return $dotnetHuntPath
557568
}
569+
570+
$dotnetHuntPath = "C:\Program Files\dotnet\dotnet.exe"
571+
Write-Verbose -Verbose "checking Windows $dotnetHuntPath"
572+
if ( test-path $dotnetHuntPath ) {
573+
$script:DotnetExe = $dotnetHuntPath
574+
return $dotnetHuntPath
575+
}
558576
}
559577
else {
560578
$dotnetHuntPath = "$HOME/.dotnet/dotnet"

0 commit comments

Comments
 (0)