From f33a870bf16028e11a5b814288737178e7e54a9b Mon Sep 17 00:00:00 2001 From: Dibir Magomedsaygitov <61747324+dibir-magomedsaygitov@users.noreply.github.com> Date: Wed, 10 Jun 2020 19:42:15 +0300 Subject: [PATCH] Switch provisioners to install Boost from GitHub releases on Windows (#972) * switch provisioners to install boost from github releases * minor fixes * separate boosts by toolset versions * minor fix * switch provisioners for win16 * fix bugs * fix validation * minor fix * fix validation * fix validation * fix validation * minor fix * change toolset version for win16 * minor fixes * minor fix * fix validation * update links to toolset-json * add arch to BoostInstallationDir --- images/win/Windows2016-Azure.json | 12 +----- images/win/Windows2019-Azure.json | 12 +----- .../win/scripts/Installers/Install-Boost.ps1 | 4 +- .../scripts/Installers/Install-Toolset.ps1 | 12 ++++-- .../win/scripts/Installers/Validate-Boost.ps1 | 39 ------------------- .../scripts/Installers/Validate-Toolset.ps1 | 10 +++-- images/win/toolcache-2016.json | 3 -- images/win/toolcache-2019.json | 6 --- images/win/toolset-2016.json | 11 ++++++ images/win/toolset-2019.json | 20 ++++++++++ 10 files changed, 52 insertions(+), 77 deletions(-) delete mode 100644 images/win/scripts/Installers/Validate-Boost.ps1 diff --git a/images/win/Windows2016-Azure.json b/images/win/Windows2016-Azure.json index ba6197d2..ccfdf0cc 100644 --- a/images/win/Windows2016-Azure.json +++ b/images/win/Windows2016-Azure.json @@ -612,7 +612,8 @@ { "type": "powershell", "environment_vars": [ - "ROOT_FOLDER={{user `root_folder`}}" + "ROOT_FOLDER={{user `root_folder`}}", + "TOOLSET_JSON_PATH={{user `toolset_json_path`}}" ], "scripts":[ "{{ template_dir }}/scripts/Installers/Install-Boost.ps1" @@ -782,15 +783,6 @@ "{{ template_dir }}/scripts/Installers/Validate-Go.ps1" ] }, - { - "type": "powershell", - "environment_vars": [ - "ROOT_FOLDER={{user `root_folder`}}" - ], - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-Boost.ps1" - ] - }, { "type": "powershell", "scripts":[ diff --git a/images/win/Windows2019-Azure.json b/images/win/Windows2019-Azure.json index 3b5ba9d7..77935fd7 100644 --- a/images/win/Windows2019-Azure.json +++ b/images/win/Windows2019-Azure.json @@ -573,7 +573,8 @@ { "type": "powershell", "environment_vars": [ - "ROOT_FOLDER={{user `root_folder`}}" + "ROOT_FOLDER={{user `root_folder`}}", + "TOOLSET_JSON_PATH={{user `toolset_json_path`}}" ], "scripts":[ "{{ template_dir }}/scripts/Installers/Install-Boost.ps1" @@ -767,15 +768,6 @@ "{{ template_dir }}/scripts/Installers/Validate-Go.ps1" ] }, - { - "type": "powershell", - "environment_vars": [ - "ROOT_FOLDER={{user `root_folder`}}" - ], - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-Boost.ps1" - ] - }, { "type": "powershell", "scripts":[ diff --git a/images/win/scripts/Installers/Install-Boost.ps1 b/images/win/scripts/Installers/Install-Boost.ps1 index d46a150c..a11013fe 100644 --- a/images/win/scripts/Installers/Install-Boost.ps1 +++ b/images/win/scripts/Installers/Install-Boost.ps1 @@ -8,11 +8,11 @@ Import-Module -Name ImageHelpers $SoftwareName = "Boost" $BoostDirectory = Join-Path -Path $env:AGENT_TOOLSDIRECTORY -ChildPath $SoftwareName -$BoostVersions = (Get-ToolsByName -SoftwareName $SoftwareName).Versions | Foreach-Object {"{0}.0" -f $_} +$BoostVersions = (Get-ToolsetContent | Select-Object -ExpandProperty toolcache | Where-Object { $_.Name -eq "Boost"}).Versions foreach($BoostVersion in $BoostVersions) { - $BoostInstallationDir = Join-Path -Path $BoostDirectory -ChildPath $BoostVersion + $BoostInstallationDir = Join-Path -Path $BoostDirectory -ChildPath "$BoostVersion\X86_64" $EnvBoostPath = "BOOST_ROOT_{0}" -f ($BoostVersion.Replace('.', '_')) setx $EnvBoostPath $BoostInstallationDir /M | Out-Null diff --git a/images/win/scripts/Installers/Install-Toolset.ps1 b/images/win/scripts/Installers/Install-Toolset.ps1 index bc2aa59d..197c5268 100644 --- a/images/win/scripts/Installers/Install-Toolset.ps1 +++ b/images/win/scripts/Installers/Install-Toolset.ps1 @@ -15,7 +15,13 @@ Function Install-Asset { $assetArchivePath = Start-DownloadWithRetry -Url $ReleaseAsset.download_url -Name $ReleaseAsset.filename Write-Host "Extract $($ReleaseAsset.filename) content..." - 7z.exe x $assetArchivePath -o"$assetFolderPath" -y | Out-Null + if ($assetArchivePath.EndsWith(".tar.gz")) { + $assetTarPath = $assetArchivePath.TrimEnd(".tar.gz") + Extract-7Zip -Path $assetArchivePath -DestinationPath $assetTarPath + Extract-7Zip -Path $assetTarPath -DestinationPath $assetFolderPath + } else { + Extract-7Zip -Path $assetArchivePath -DestinationPath $assetFolderPath + } Write-Host "Invoke installation script..." Push-Location -Path $assetFolderPath @@ -48,7 +54,7 @@ $ErrorActionPreference = "Stop" Import-Module -Name ImageHelpers -Force # Get toolcache content from toolset -$ToolsToInstall = @("Python", "Node") +$ToolsToInstall = @("Python", "Node", "Boost") $tools = Get-ToolsetContent | Select-Object -ExpandProperty toolcache | Where {$ToolsToInstall -contains $_.Name} foreach ($tool in $tools) { @@ -60,7 +66,7 @@ foreach ($tool in $tools) { $asset = $assets | Where-Object version -like $toolVersion ` | Sort-Object -Property {[version]$_.version} -Descending ` | Select-Object -ExpandProperty files ` - | Where-Object { ($_.platform -eq $tool.platform) -and ($_.arch -eq $tool.arch) } ` + | Where-Object { ($_.platform -eq $tool.platform) -and ($_.arch -eq $tool.arch) -and ($_.toolset -eq $tool.toolset) } ` | Select-Object -First 1 Write-Host "Installing $($tool.name) $toolVersion $($tool.arch)..." diff --git a/images/win/scripts/Installers/Validate-Boost.ps1 b/images/win/scripts/Installers/Validate-Boost.ps1 deleted file mode 100644 index 83bf3d08..00000000 --- a/images/win/scripts/Installers/Validate-Boost.ps1 +++ /dev/null @@ -1,39 +0,0 @@ -################################################################################ -## File: Validate-Boost.ps1 -## Desc: Validate Boost -################################################################################ - -Import-Module -Name ImageHelpers - -function Validate-BoostVersion -{ - Param - ( - [String]$BoostRootPath, - [String]$BoostRelease - ) - - $ReleasePath = Join-Path -Path $BoostRootPath -ChildPath $BoostRelease - - if (Test-Path "$ReleasePath\b2.exe") - { - Write-Host "Boost.Build $BoostRelease is successfully installed" - return - } - - Write-Host "$BoostRelease not found" - exit 1 -} - -$SoftwareName = 'Boost' -$BoostRootDirectory = Join-Path -Path $env:AGENT_TOOLSDIRECTORY -ChildPath $SoftwareName -$BoostTools = Get-ToolsByName -SoftwareName $SoftwareName - -foreach ($BoostTool in $BoostTools) -{ - $BoostVersionsToInstall = $BoostTool.Versions | Foreach-Object {"{0}.0" -f $_} - foreach($BoostVersion in $BoostVersionsToInstall) - { - Validate-BoostVersion -BoostRootPath $BoostRootDirectory -BoostRelease $BoostVersion - } -} diff --git a/images/win/scripts/Installers/Validate-Toolset.ps1 b/images/win/scripts/Installers/Validate-Toolset.ps1 index c5460053..ad0ce41b 100644 --- a/images/win/scripts/Installers/Validate-Toolset.ps1 +++ b/images/win/scripts/Installers/Validate-Toolset.ps1 @@ -67,8 +67,8 @@ foreach($tool in $tools) { foreach ($version in $tool.versions) { # Add wildcard if missing - if (-not $version.Contains('*')) { - $version += '.*' + if ($version.Split(".").Length -lt 3) { + $version += ".*" } # Check if version folder exists @@ -90,8 +90,10 @@ foreach($tool in $tools) { exit 1 } - Write-Host "Run validation test for $($tool.name)($($tool.arch)) $($foundVersion.name) executables..." - Run-ExecutableTests -Executables $toolExecs -ToolPath $foundVersionArchPath + if ($toolExecs) { + Write-Host "Run validation test for $($tool.name)($($tool.arch)) $($foundVersion.name) executables..." + Run-ExecutableTests -Executables $toolExecs -ToolPath $foundVersionArchPath + } } if (-not ([string]::IsNullOrEmpty($tool.default))) { diff --git a/images/win/toolcache-2016.json b/images/win/toolcache-2016.json index 449be64f..b3f9c3c0 100644 --- a/images/win/toolcache-2016.json +++ b/images/win/toolcache-2016.json @@ -1,8 +1,5 @@ { "@actions/toolcache-ruby-windows-x64": [ "2.4", "2.5", "2.6", "2.7" - ], - "@actions/toolcache-boost-windows-msvc-14.1-x32-x64": [ - "1.69", "1.72" ] } \ No newline at end of file diff --git a/images/win/toolcache-2019.json b/images/win/toolcache-2019.json index 354f518f..b3f9c3c0 100644 --- a/images/win/toolcache-2019.json +++ b/images/win/toolcache-2019.json @@ -1,11 +1,5 @@ { "@actions/toolcache-ruby-windows-x64": [ "2.4", "2.5", "2.6", "2.7" - ], - "@actions/toolcache-boost-windows-msvc-14.1-x32-x64": [ - "1.69" - ], - "@actions/toolcache-boost-windows-msvc-14.2-x32-x64": [ - "1.72" ] } \ No newline at end of file diff --git a/images/win/toolset-2016.json b/images/win/toolset-2016.json index 9eb2be40..edc8dde2 100644 --- a/images/win/toolset-2016.json +++ b/images/win/toolset-2016.json @@ -47,6 +47,17 @@ "12.*", "14.*" ] + }, + { + "name": "Boost", + "url" : "https://raw.githubusercontent.com/actions/boost-versions/master/versions-manifest.json", + "arch": "x86_64", + "platform" : "win32", + "toolset": "msvc14.1", + "versions": [ + "1.69.0", + "1.72.0" + ] } ] } \ No newline at end of file diff --git a/images/win/toolset-2019.json b/images/win/toolset-2019.json index 9eb2be40..ff5fef6b 100644 --- a/images/win/toolset-2019.json +++ b/images/win/toolset-2019.json @@ -47,6 +47,26 @@ "12.*", "14.*" ] + }, + { + "name": "Boost", + "url" : "https://raw.githubusercontent.com/akv-platform/boost-hostedtoolcache/master/versions-manifest.json", + "arch": "x86_64", + "platform" : "win32", + "toolset": "msvc14.1", + "versions": [ + "1.69.0" + ] + }, + { + "name": "Boost", + "url" : "https://raw.githubusercontent.com/actions/boost-versions/master/versions-manifest.json", + "arch": "x86_64", + "platform" : "win32", + "toolset": "msvc14.2", + "versions": [ + "1.72.0" + ] } ] } \ No newline at end of file