ci/windows: Make Chocolatey installs more reliable

Chocolatey installs depend on downloading binaries from SourceForge,
which is an unreliable host: container builds often fail because it
cannot pick up winflexbison.

Add a loop to retry chocolatey installs if any installs have failed, and
ensure Python is in the accessible PowerShell path rather than relying
on the path being externally refreshed.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4631>
This commit is contained in:
Daniel Stone 2020-04-16 23:31:47 +01:00
parent ec1b96fdc8
commit e6c7bdc851

View File

@ -4,12 +4,40 @@ Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://cho
Import-Module "$env:ProgramData\chocolatey\helpers\chocolateyProfile.psm1"
Update-SessionEnvironment
Write-Host "Installing Chocolatey packages"
choco install --allow-empty-checksums -y cmake --installargs "ADD_CMAKE_TO_PATH=System"
choco install --allow-empty-checksums -y python3 git git-lfs ninja pkgconfiglite winflexbison
# Chocolatey tries to download winflexbison from SourceForge, which is not super reliable, and has no retry
# loop of its own - so we give it a helping hand here
For ($i = 0; $i -lt 5; $i++) {
choco install -y python3 --params="/InstallDir:C:\python3"
$python_install = $?
choco install --allow-empty-checksums -y cmake git git-lfs ninja pkgconfiglite winflexbison
$other_install = $?
$choco_installed = $other_install -and $python_install
if ($choco_installed) {
Break
}
}
if (!$choco_installed) {
Write-Host "Couldn't install dependencies from Chocolatey"
Exit 1
}
# Add Chocolatey's native install path
Update-SessionEnvironment
# Python adds itself to the system environment path, which doesn't get refreshed until we start a new shell
$env:PATH = "C:\python3;C:\python3\scripts;$env:PATH"
Start-Process -NoNewWindow -Wait git -ArgumentList 'config --global core.autocrlf false'
Get-Date
Write-Host "Installing Meson and Mako"
pip3 install meson mako
if (!$?) {
Write-Host "Failed to install dependencies from pip"
Exit 1
}
# we want more secure TLS 1.2 for most things, but it breaks SourceForge
# downloads so must be done after Chocolatey use
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;
@ -25,14 +53,6 @@ Get-Date
Write-Host "Installing Visual Studio 2019"
Start-Process -NoNewWindow -Wait C:\vs_buildtools.exe -ArgumentList '--wait --quiet --norestart --nocache --installPath C:\BuildTools --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Workload.NativeDesktop --add Microsoft.VisualStudio.Component.VC.ATL --add Microsoft.VisualStudio.Component.VC.ATLMFC --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Graphics.Tools --add Microsoft.VisualStudio.Component.Windows10SDK.18362 --includeRecommended'
Remove-Item C:\vs_buildtools.exe -Force
Get-Item C:\BuildTools | Out-Host
Get-Date
Write-Host "Installing Meson"
Start-Process -NoNewWindow -Wait pip3 -ArgumentList 'install meson'
Write-Host "Installing Mako"
Start-Process -NoNewWindow -Wait pip3 -ArgumentList 'install mako'
Get-Date
Write-Host "Complete"