Skip to content

Commit 7935cf8

Browse files
Improve E2E Test Fixtures to be less flaky (#2208)
* Improve E2E Test Fixtures to be less flaky * Adjust test skips * Fix dangling IsLinux reference * Kick Hover Test issue can down the road * Make CanSendGetCommandRequestAsync Skip in CI Again * Remove unneded using namespace * Bump GetCommandRequest to 2 minutes It took longer than 1 minute in Github Actions! * Skip HoverRequest on Windows for Now * Swap management for utility command and ensure help is cached. * Fix symbol test regression oopsie * Update POST * Fix DSC Test Contengent assuming #2208 (comment) is OK from @andyleejordan * Fix Help Update Process * Add upterm debugging to pipeline * Expand help update to all potential pwsh versions * Add PS7 Help * Try Help CAB again * Apparently it's a zip not a cab on Linux... * Fixup PS5.1 Help Script * Switch to Microsoft.PowerShell.Archive for help tests for smaller artifact size. * Clean up build script comments --------- Co-authored-by: Andy Jordan <[email protected]>
1 parent 9d56407 commit 7935cf8

25 files changed

+718
-823
lines changed

.github/workflows/ci-test.yml

+6
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ jobs:
5151
shell: pwsh
5252
run: ./pwsh/tools/install-powershell.ps1 -Daily
5353

54+
- name: If Debugging, start upterm for interactive pipeline troubleshooting
55+
if: ${{ runner.debug == 1 }}
56+
uses: lhotari/action-upterm@v1
57+
with:
58+
wait-timeout-minutes: 1
59+
5460
- name: Build and test
5561
shell: pwsh
5662
run: Invoke-Build -Configuration Release ${{ github.event_name == 'merge_group' && 'TestFull' || 'Test' }}

PowerShellEditorServices.build.ps1

+82-2
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,88 @@ Task BuildCmdletHelp -After AssembleModule {
193193
}
194194

195195
Task SetupHelpForTests {
196-
Write-Build DarkMagenta 'Updating help (for tests)'
197-
Update-Help -Module Microsoft.PowerShell.Management, Microsoft.PowerShell.Utility -Force -Scope CurrentUser -UICulture en-US
196+
# 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.
197+
198+
# Only commands in Microsoft.PowerShell.Archive can be tested for help so as to minimize the repository storage.
199+
# This requires admin rights for PS5.1
200+
201+
# 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.
202+
203+
$installHelpScript = {
204+
param(
205+
[Parameter(Position = 0)][string]$helpPath
206+
)
207+
$PSVersion = $PSVersionTable.PSVersion
208+
$ErrorActionPreference = 'Stop'
209+
$helpPath = Resolve-Path $helpPath
210+
if ($PSEdition -ne 'Desktop') {
211+
$helpPath = Join-Path $helpPath '7'
212+
}
213+
214+
if ((Get-Help Expand-Archive).remarks -notlike 'Get-Help cannot find the Help files*') {
215+
Write-Host -ForegroundColor Green "PowerShell $PSVersion Archive help is already installed"
216+
return
217+
}
218+
219+
if ($PSEdition -eq 'Desktop') {
220+
# Cant use requires RunAsAdministrator because PS isn't smart enough to know this is a subscript.
221+
if (-not [Security.Principal.WindowsPrincipal]::new(
222+
[Security.Principal.WindowsIdentity]::GetCurrent()
223+
).IsInRole(
224+
[Security.Principal.WindowsBuiltInRole]::Administrator
225+
)) {
226+
throw 'Windows PowerShell Update-Help requires admin rights. Please re-run the script in an elevated PowerShell session!'
227+
}
228+
}
229+
230+
Write-Host -ForegroundColor Magenta "PowerShell $PSVersion Archive help is not installed, installing from $helpPath"
231+
232+
$updateHelpParams = @{
233+
Module = 'Microsoft.PowerShell.Archive'
234+
SourcePath = $helpPath
235+
UICulture = 'en-US'
236+
Force = $true
237+
Verbose = $true
238+
}
239+
240+
# PS7+ does not require admin rights if CurrentUser is used for scope. PS5.1 does not have this option.
241+
if ($PSEdition -ne 'Desktop') {
242+
$updateHelpParams.'Scope' = 'CurrentUser'
243+
}
244+
# Update the help and capture verbose output
245+
$updateHelpOutput = Update-Help @updateHelpParams *>&1
246+
247+
if ((Get-Help Expand-Archive).remarks -like 'Get-Help cannot find the Help files*') {
248+
throw "Failed to install PowerShell $PSVersion Help: $updateHelpOutput"
249+
} else {
250+
Write-Host -ForegroundColor Green "PowerShell $PSVersion Archive help installed successfully"
251+
}
252+
}
253+
254+
# Need this to inject the help file path since PSScriptRoot won't work inside the script
255+
$helpPath = Resolve-Path "$PSScriptRoot\test\PowerShellEditorServices.Test.Shared\PSHelp" -ErrorAction Stop
256+
Write-Build DarkMagenta "Runner help located at $helpPath"
257+
258+
if (Get-Command powershell.exe -CommandType Application -ea 0) {
259+
Write-Build DarkMagenta 'Checking PowerShell 5.1 help'
260+
& powershell.exe -NoProfile -NonInteractive -Command $installHelpScript -args $helpPath
261+
if ($LASTEXITCODE -ne 0) {
262+
throw 'Failed to install PowerShell 5.1 help!'
263+
}
264+
}
265+
266+
if ($PwshDaily -and (Get-Command $PwshDaily -ea 0)) {
267+
Write-Build DarkMagenta "Checking PowerShell Daily help at $PwshDaily"
268+
Invoke-BuildExec { & $PwshDaily -NoProfile -NonInteractive -Command $installHelpScript -args $helpPath }
269+
if ($LASTEXITCODE -ne 0) {
270+
throw 'Failed to install PowerShell Daily help!'
271+
}
272+
}
273+
274+
if ($PSEdition -eq 'Core') {
275+
Write-Build DarkMagenta "Checking this PowerShell process's help"
276+
& $installHelpScript $helpPath
277+
}
198278
}
199279

200280
Task TestPS74 Build, SetupHelpForTests, {

src/PowerShellEditorServices/Server/PsesDebugServer.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ public async Task StartAsync()
120120
response.SupportsDelayedStackTraceLoading = true;
121121

122122
return Task.CompletedTask;
123-
});
123+
})
124+
;
124125
}).ConfigureAwait(false);
125126
}
126127

0 commit comments

Comments
 (0)