Skip to content

Commit

Permalink
Speedup CI by bootstrapping PowerShell module installations in backgr…
Browse files Browse the repository at this point in the history
…ound and in parallel, whilst the .NET SDK is being installed (#1634)
  • Loading branch information
bergmeister authored Apr 21, 2021
1 parent 4e93b8e commit 1ff493e
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions tools/appveyor.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function Install-Pester {
Write-Verbose -Verbose "Installing Pester via Install-Module"
Install-Module -Name Pester -Force -SkipPublisherCheck -Scope CurrentUser -Repository PSGallery
}
Write-Verbose -Verbose 'Installed Pester'
}
}

Expand All @@ -27,16 +28,20 @@ function Invoke-AppVeyorInstall {
[switch] $SkipPesterInstallation
)

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

if ($null -eq (Get-Module -ListAvailable PowershellGet)) {
# WMF 4 image build
Write-Verbose -Verbose "Installing platyPS via nuget"
nuget install platyPS -source https://www.powershellgallery.com/api/v2 -outputDirectory "$Env:ProgramFiles\WindowsPowerShell\Modules\." -ExcludeVersion
}
else {
Write-Verbose -Verbose "Installing platyPS via Install-Module"
Install-Module -Name platyPS -Force -Scope CurrentUser -Repository PSGallery
$installPowerShellModulesjobs += Start-Job {
if ($null -eq (Get-Module -ListAvailable PowershellGet)) {
# WMF 4 image build
Write-Verbose -Verbose "Installing platyPS via nuget"
nuget install platyPS -source https://www.powershellgallery.com/api/v2 -outputDirectory "$Env:ProgramFiles\WindowsPowerShell\Modules\." -ExcludeVersion
}
else {
Write-Verbose -Verbose "Installing platyPS via Install-Module"
Install-Module -Name platyPS -Force -Scope CurrentUser -Repository PSGallery
}
Write-Verbose -Verbose 'Installed platyPS'
}

# 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
Expand Down Expand Up @@ -70,6 +75,14 @@ function Invoke-AppVeyorInstall {
[Net.ServicePointManager]::SecurityProtocol = $originalSecurityProtocol
Remove-Item .\dotnet-install.*
}
Write-Verbose -Verbose 'Installed required .Net CORE SDK'
}

Wait-Job $installPowerShellModulesjobs | Receive-Job
$installPowerShellModulesjobs | ForEach-Object {
if ($_.State -eq 'Failed') {
throw 'Installing PowerShell modules failed, see job logs above'
}
}
}

Expand Down

0 comments on commit 1ff493e

Please sign in to comment.