Skip to content

Commit 1ff493e

Browse files
authored
Speedup CI by bootstrapping PowerShell module installations in background and in parallel, whilst the .NET SDK is being installed (#1634)
1 parent 4e93b8e commit 1ff493e

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

tools/appveyor.psm1

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function Install-Pester {
1717
Write-Verbose -Verbose "Installing Pester via Install-Module"
1818
Install-Module -Name Pester -Force -SkipPublisherCheck -Scope CurrentUser -Repository PSGallery
1919
}
20+
Write-Verbose -Verbose 'Installed Pester'
2021
}
2122
}
2223

@@ -27,16 +28,20 @@ function Invoke-AppVeyorInstall {
2728
[switch] $SkipPesterInstallation
2829
)
2930

30-
if (-not $SkipPesterInstallation.IsPresent) { Install-Pester }
31+
$installPowerShellModulesjobs = @()
32+
if (-not $SkipPesterInstallation.IsPresent) { $installPowerShellModulesjobs += Start-Job ${Function:Install-Pester} }
3133

32-
if ($null -eq (Get-Module -ListAvailable PowershellGet)) {
33-
# WMF 4 image build
34-
Write-Verbose -Verbose "Installing platyPS via nuget"
35-
nuget install platyPS -source https://www.powershellgallery.com/api/v2 -outputDirectory "$Env:ProgramFiles\WindowsPowerShell\Modules\." -ExcludeVersion
36-
}
37-
else {
38-
Write-Verbose -Verbose "Installing platyPS via Install-Module"
39-
Install-Module -Name platyPS -Force -Scope CurrentUser -Repository PSGallery
34+
$installPowerShellModulesjobs += Start-Job {
35+
if ($null -eq (Get-Module -ListAvailable PowershellGet)) {
36+
# WMF 4 image build
37+
Write-Verbose -Verbose "Installing platyPS via nuget"
38+
nuget install platyPS -source https://www.powershellgallery.com/api/v2 -outputDirectory "$Env:ProgramFiles\WindowsPowerShell\Modules\." -ExcludeVersion
39+
}
40+
else {
41+
Write-Verbose -Verbose "Installing platyPS via Install-Module"
42+
Install-Module -Name platyPS -Force -Scope CurrentUser -Repository PSGallery
43+
}
44+
Write-Verbose -Verbose 'Installed platyPS'
4045
}
4146

4247
# Do not use 'build.ps1 -bootstrap' option for bootstraping the .Net SDK as it does not work well in CI with the AppVeyor Ubuntu image
@@ -70,6 +75,14 @@ function Invoke-AppVeyorInstall {
7075
[Net.ServicePointManager]::SecurityProtocol = $originalSecurityProtocol
7176
Remove-Item .\dotnet-install.*
7277
}
78+
Write-Verbose -Verbose 'Installed required .Net CORE SDK'
79+
}
80+
81+
Wait-Job $installPowerShellModulesjobs | Receive-Job
82+
$installPowerShellModulesjobs | ForEach-Object {
83+
if ($_.State -eq 'Failed') {
84+
throw 'Installing PowerShell modules failed, see job logs above'
85+
}
7386
}
7487
}
7588

0 commit comments

Comments
 (0)