From: Daniel Stone Date: Thu, 16 Apr 2020 22:31:47 +0000 (+0100) Subject: ci/windows: Make Chocolatey installs more reliable X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e6c7bdc85138abe00bc9db355f302778926b38e5;p=mesa.git 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 Reviewed-by: Eric Anholt Reviewed-by: Jose Fonseca Part-of: --- diff --git a/.gitlab-ci/windows/mesa_deps.ps1 b/.gitlab-ci/windows/mesa_deps.ps1 index d700d3e5d55..28499e484ce 100644 --- a/.gitlab-ci/windows/mesa_deps.ps1 +++ b/.gitlab-ci/windows/mesa_deps.ps1 @@ -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"