-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Python toolcache installation from Github releases for Ubuntu (#704)
Change logic to install Python to Ubuntu images to use GitHub releases from https://github.com/actions/python-versions
- Loading branch information
Showing
10 changed files
with
189 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
################################################################################ | ||
## File: Install-Toolset.ps1 | ||
## Team: CI-Build | ||
## Desc: Install toolset | ||
################################################################################ | ||
|
||
Function Install-Asset { | ||
param( | ||
[Parameter(Mandatory = $true)] | ||
[object] $ReleaseAsset | ||
) | ||
|
||
Write-Host "Download $($ReleaseAsset.filename)" | ||
wget $ReleaseAsset.download_url -nv --retry-connrefused --tries=10 | ||
|
||
Write-Host "Extract $($ReleaseAsset.filename) content..." | ||
$assetFolderPath = Join-Path $env:INSTALLER_SCRIPT_FOLDER $($ReleaseAsset.filename) | ||
New-Item -ItemType Directory -Path $assetFolderPath | ||
tar -xzf $ReleaseAsset.filename -C $assetFolderPath | ||
|
||
Write-Host "Invoke installation script..." | ||
Push-Location -Path $assetFolderPath | ||
Invoke-Expression "bash ./setup.sh" | ||
Pop-Location | ||
} | ||
|
||
$ErrorActionPreference = "Stop" | ||
|
||
# Get toolset content | ||
$toolsetJson = Get-Content -Path "$env:INSTALLER_SCRIPT_FOLDER/toolset.json" -Raw | ||
$tools = ConvertFrom-Json -InputObject $toolsetJson | Select-Object -ExpandProperty toolcache | ||
|
||
foreach ($tool in $tools) { | ||
# Get versions manifest for current tool | ||
$assets = Invoke-RestMethod $tool.url | ||
|
||
# Get github release asset for each version | ||
foreach ($toolVersion in $tool.versions) { | ||
$asset = $assets | Where-Object version -like $toolVersion ` | ||
| Select-Object -ExpandProperty files ` | ||
| Where-Object { ($_.platform -eq $tool.platform) -and ($_.platform_version -eq $tool.platform_version)} ` | ||
| Select-Object -First 1 | ||
|
||
Write-Host "Installing $($tool.name) $toolVersion $($tool.arch)..." | ||
if ($asset -ne $null) { | ||
Install-Asset -ReleaseAsset $asset | ||
} | ||
else { | ||
Write-Host "Asset was not found in versions manifest" | ||
exit 1 | ||
} | ||
} | ||
} | ||
|
||
chown -R "$($env:SUDO_USER):$($env:SUDO_USER)" /opt/hostedtoolcache/Python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
################################################################################ | ||
## File: Validate-Toolset.ps1 | ||
## Team: CI-Build | ||
## Desc: Validate Toolset | ||
################################################################################ | ||
|
||
function Run-ExecutableTests { | ||
param ( | ||
[Parameter(Mandatory)] [string[]] $Executables, | ||
[Parameter(Mandatory)] [string] $ToolPath | ||
) | ||
|
||
foreach ($executable in $Executables) { | ||
$executablePath = Join-Path $ToolPath $executable | ||
|
||
Write-Host "Check $executable..." | ||
if (Test-Path $executablePath) { | ||
Write-Host "$executable is successfully installed: $(& $executablePath --version)" | ||
} else { | ||
Write-Host "$executablePath is not installed!" | ||
exit 1 | ||
} | ||
} | ||
} | ||
|
||
$ErrorActionPreference = "Stop" | ||
|
||
# Define executables for cached tools | ||
$toolsExecutables = @{ Python = @("python", "bin/pip") } | ||
|
||
# Get toolset content | ||
$toolsetJson = Get-Content -Path "$env:INSTALLER_SCRIPT_FOLDER/toolset.json" -Raw | ||
$tools = ConvertFrom-Json -InputObject $toolsetJson | Select-Object -ExpandProperty toolcache | ||
|
||
foreach($tool in $tools) { | ||
Invoke-Expression "bash -c `"source $env:HELPER_SCRIPTS/document.sh; DocumentInstalledItem '$($tool.name):'`"" | ||
|
||
$toolPath = Join-Path $env:AGENT_TOOLSDIRECTORY $tool.name | ||
# Get executables for current tool | ||
$toolExecs = $toolsExecutables[$tool.name] | ||
|
||
foreach ($version in $tool.versions) { | ||
# Check if version folder exists | ||
$expectedVersionPath = Join-Path $toolPath $version | ||
if (-not (Test-Path $expectedVersionPath)) { | ||
Write-Host "Expected $($tool.name) $version folder is not found!" | ||
exit 1 | ||
} | ||
|
||
# Take latest installed version in case if toolset version contains wildcards | ||
$foundVersion = Get-Item $expectedVersionPath ` | ||
| Sort-Object -Property {[version]$_.name} -Descending ` | ||
| Select-Object -First 1 | ||
$foundVersionPath = Join-Path $foundVersion $tool.arch | ||
|
||
Write-Host "Run validation test for $($tool.name)($($tool.arch)) $($foundVersion.name) executables..." | ||
Run-ExecutableTests -Executables $toolExecs -ToolPath $foundVersionPath | ||
|
||
# Add tool version to documentation | ||
Invoke-Expression "bash -c `"source $env:HELPER_SCRIPTS/document.sh; DocumentInstalledItemIndent '$($tool.name) $($foundVersion.name)'`"" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"toolcache": [ | ||
{ | ||
"name": "Python", | ||
"url" : "https://raw.githubusercontent.com/actions/python-versions/master/versions-manifest.json", | ||
"platform" : "linux", | ||
"platform_version": "16.04", | ||
"arch": "x64", | ||
"versions": [ | ||
"2.7.*", | ||
"3.5.*", | ||
"3.6.*", | ||
"3.7.*", | ||
"3.8.*" | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"toolcache": [ | ||
{ | ||
"name": "Python", | ||
"url" : "https://raw.githubusercontent.com/actions/python-versions/master/versions-manifest.json", | ||
"platform" : "linux", | ||
"platform_version": "18.04", | ||
"arch": "x64", | ||
"versions": [ | ||
"2.7.*", | ||
"3.5.*", | ||
"3.6.*", | ||
"3.7.*", | ||
"3.8.*" | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters