Skip to content
Merged
Show file tree
Hide file tree
Changes from 20 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
6 changes: 6 additions & 0 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ jobs:
shell: pwsh
run: ./pwsh/tools/install-powershell.ps1 -Daily

- name: If Debugging, start upterm for interactive pipeline troubleshooting
if: ${{ runner.debug == 1 }}
uses: lhotari/action-upterm@v1
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well that's cool...I need to share with Steve. He's been asking for something exactly like this.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm working on a version that lets you vscode remote into the github action, the tricky part is the authentication but it's definitely doable :)

with:
wait-timeout-minutes: 1

- name: Build and test
shell: pwsh
run: Invoke-Build -Configuration Release ${{ github.event_name == 'merge_group' && 'TestFull' || 'Test' }}
Expand Down
84 changes: 82 additions & 2 deletions PowerShellEditorServices.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,88 @@ Task BuildCmdletHelp -After AssembleModule {
}

Task SetupHelpForTests {
Write-Build DarkMagenta 'Updating help (for tests)'
Update-Help -Module Microsoft.PowerShell.Management, Microsoft.PowerShell.Utility -Force -Scope CurrentUser -UICulture en-US
# Some CI do not ship with help included, and the secure devops pipeline also does not allow internet access, so we must update help from our local repository source.

# Only commands in Microsoft.PowerShell.Archive can be tested for help so as to minimize the repository storage.
# This requires admin rights for PS5.1

#NOTE: You can run this task once as admin or update help separately, and continue to run tests as non-admin, if for instance developing locally.
Comment thread
andyleejordan marked this conversation as resolved.
Outdated

$installHelpScript = {
param(
[Parameter(Position = 0)][string]$helpPath
)
$PSVersion = $PSVersionTable.PSVersion
$ErrorActionPreference = 'Stop'
$helpPath = Resolve-Path $helpPath
if ($PSEdition -ne 'Desktop') {
$helpPath = Join-Path $helpPath '7'
}

if ((Get-Help Expand-Archive).remarks -notlike 'Get-Help cannot find the Help files*') {
Write-Host -Fore Green "PowerShell $PSVersion Archive Help is already installed"
Comment thread
andyleejordan marked this conversation as resolved.
Outdated
return
}

if ($PSEdition -eq 'Desktop') {
# Cant use requires RunAsAdministrator because PS isn't smart enough to know this is a subscript.
if (-not [Security.Principal.WindowsPrincipal]::new(
[Security.Principal.WindowsIdentity]::GetCurrent()
).IsInRole(
[Security.Principal.WindowsBuiltInRole]::Administrator
)) {
throw 'Windows PowerShell Update-Help requires admin rights. Please re-run the script in an elevated powershell session.'
Comment thread
andyleejordan marked this conversation as resolved.
Outdated
}
}

Write-Host -Fore Magenta "Powershell $PSVersion Archive Help is not installed, installing from $helpPath"
Comment thread
andyleejordan marked this conversation as resolved.
Outdated

$updateHelpParams = @{
Module = 'Microsoft.PowerShell.Archive'
SourcePath = $helpPath
UICulture = 'en-US'
Force = $true
Verbose = $true
}

#PS7+ does not require admin rights if currentuser is used for scope. 5.1 does not have this option.
Comment thread
andyleejordan marked this conversation as resolved.
Outdated
if ($PSEdition -ne 'Desktop') {
$updateHelpParams.'Scope' = 'CurrentUser'
}
#Update the help, and capture verbose output
Comment thread
andyleejordan marked this conversation as resolved.
Outdated
$updateHelpOutput = Update-Help @updateHelpParams *>&1

if ((Get-Help Expand-Archive).remarks -like 'Get-Help cannot find the Help files*') {
throw "Failed to install PowerShell $PSVersion Help: $updateHelpOutput"
} else {
Write-Host -Fore Green "Powershell $PSVersion Archive Help installed successfully"
Comment thread
andyleejordan marked this conversation as resolved.
Outdated
}
}

#Need this to inject the help file path, since PSScriptRoot won't work inside the script
Comment thread
andyleejordan marked this conversation as resolved.
Outdated
$helpPath = Resolve-Path "$PSScriptRoot\test\PowerShellEditorServices.Test.Shared\PSHelp" -ErrorAction Stop
Write-Host -Fore Magenta "Runner Help located at $helpPath"
Comment thread
andyleejordan marked this conversation as resolved.
Outdated

if (Get-Command powershell.exe -CommandType Application -ea 0) {
Write-Host -Fore Magenta 'Checking PowerShell 5.1 help'
Comment thread
andyleejordan marked this conversation as resolved.
Outdated
& powershell.exe -NoProfile -NonInteractive -Command $installHelpScript -args $helpPath
if ($LASTEXITCODE -ne 0) {
throw 'Failed to install PowerShell 5.1 Help.'
Comment thread
andyleejordan marked this conversation as resolved.
Outdated
}
}

if ($PwshDaily -and (Get-Command $PwshDaily -ea 0)) {
Write-Host -Fore Magenta "Checking PWSH Daily help at $PwshDaily"
Comment thread
andyleejordan marked this conversation as resolved.
Outdated
Invoke-BuildExec { & $PwshDaily -NoProfile -NonInteractive -Command $installHelpScript -args $helpPath }
if ($LASTEXITCODE -ne 0) {
throw 'Failed to install PowerShell Daily Help.'
Comment thread
andyleejordan marked this conversation as resolved.
Outdated
}
}

if ($PSEdition -eq 'Core') {
Write-Host -Fore Magenta 'Checking Runner Pwsh help'
Comment thread
andyleejordan marked this conversation as resolved.
Outdated
& $installHelpScript $helpPath
}
}

Task TestPS74 Build, SetupHelpForTests, {
Expand Down
3 changes: 2 additions & 1 deletion src/PowerShellEditorServices/Server/PsesDebugServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ public async Task StartAsync()
response.SupportsDelayedStackTraceLoading = true;

return Task.CompletedTask;
});
})
;
}).ConfigureAwait(false);
}

Expand Down
Loading