Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speedup CI by bootstrapping PowerShell module installations in background and in parallel, whilst the .NET SDK is being installed #1634

Merged
merged 13 commits into from
Apr 21, 2021
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