FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Test PowerShell Preview in CI by andyleejordan · Pull Request #2070 · PowerShell/PSScriptAnalyzer · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .ps1  (1) .psm1  (1) .yml  (1) All 3 file types selected
Only manifest files
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
29 changes: 24 additions & 5 deletions .github/workflows/ci-test.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,43 @@ jobs:
shell: pwsh

- name: Build
run: ./build.ps1 -Configuration Release -All
run: ./build.ps1 -Configuration Release -All -Verbose
shell: pwsh

- name: Package
run: ./build.ps1 -BuildNupkg
run: ./build.ps1 -BuildNupkg -Verbose
shell: pwsh

- name: Test
run: ./build.ps1 -Test
run: ./build.ps1 -Test -Verbose
shell: pwsh

- name: Test Windows PowerShell
if: matrix.os == 'windows-latest'
run: |
Install-Module Pester -Scope CurrentUser -Force -SkipPublisherCheck
./build.ps1 -Test
if: matrix.os == 'windows-latest'
./build.ps1 -Test -Verbose
shell: powershell

- name: Download PowerShell install script
uses: actions/checkout@v4
with:
repository: PowerShell/PowerShell
path: pwsh
sparse-checkout: tools/install-powershell.ps1
sparse-checkout-cone-mode: false

- name: Install preview
continue-on-error: true
run: ./pwsh/tools/install-powershell.ps1 -Preview -Destination ./preview
shell: pwsh

- name: Test preview
run: |
$PwshPreview = if ($isWindows) { "./preview/pwsh.exe" } else { "./preview/pwsh" }
./build.ps1 -Test -WithPowerShell:$PwshPreview -Verbose
shell: pwsh

- name: Upload build artifacts
uses: actions/upload-artifact@v4
if: always()
Expand Down
8 changes: 7 additions & 1 deletion build.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ param(

[Parameter(ParameterSetName='Test')]
[switch] $InProcess,
[string] $WithPowerShell,

[Parameter(ParameterSetName='BuildAll')]
[switch] $Catalog,
Expand Down Expand Up @@ -85,7 +86,12 @@ END {
Start-CreatePackage
}
"Test" {
Test-ScriptAnalyzer -InProcess:$InProcess
$testArgs = @{
InProcess = $InProcess
WithPowerShell = $WithPowerShell
Verbose = $verboseWanted
}
Test-ScriptAnalyzer @testArgs
return
}
default {
Expand Down
22 changes: 20 additions & 2 deletions build.psm1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,10 @@ function New-Catalog
function Test-ScriptAnalyzer
{
[CmdletBinding()]
param ( [switch] $InProcess )
param (
[switch] $InProcess,
[string] $WithPowerShell
)

END {
# versions 3 and 4 don't understand versioned module paths, so we need to rename the directory of the version to
Expand Down Expand Up @@ -347,11 +350,19 @@ function Test-ScriptAnalyzer
$analyzerPsd1Path = Join-Path -Path $script:destinationDir -ChildPath "$analyzerName.psd1"
$scriptBlock = [scriptblock]::Create("Import-Module '$analyzerPsd1Path'; Invoke-Pester -Path $testScripts -CI")
if ( $InProcess ) {
Write-Verbose "Testing with PowerShell $($PSVersionTable.PSVersion)"
& $scriptBlock
}
elseif ( $WithPowerShell ) {
$pwshVersion = & $WithPowerShell --version
Write-Verbose "Testing with $pwshVersion"
& $WithPowerShell -Command $scriptBlock
}
else {
$powershell = (Get-Process -id $PID).MainModule.FileName
& ${powershell} -NoProfile -Command $scriptBlock
$pwshVersion = & $powershell --version
Write-Verbose "Testing with $pwshVersion"
& $powershell -NoProfile -Command $scriptBlock
}
}
finally {
Expand Down Expand Up @@ -555,6 +566,13 @@ function Get-DotnetExe
$script:DotnetExe = $dotnetHuntPath
return $dotnetHuntPath
}

$dotnetHuntPath = "C:\Program Files\dotnet\dotnet.exe"
Write-Verbose -Verbose "checking Windows $dotnetHuntPath"
if ( test-path $dotnetHuntPath ) {
$script:DotnetExe = $dotnetHuntPath
return $dotnetHuntPath
}
}
else {
$dotnetHuntPath = "$HOME/.dotnet/dotnet"
Expand Down

Back | FazBrowse Home | New Git URL