[macos] Add toolcache for arm (#7974)

This commit is contained in:
Shamil Mubarakshin
2023-07-28 12:37:00 +02:00
committed by GitHub
parent 9a403df7bd
commit fc2f35d593
10 changed files with 199 additions and 114 deletions

View File

@@ -156,3 +156,13 @@ function Add-EnvironmentVariable {
function isVeertu {
return (Test-Path -Path "/Library/Application Support/Veertu")
}
function Get-Architecture {
$arch = arch
if ($arch -ne "arm64")
{
$arch = "x64"
}
return $arch
}

View File

@@ -22,23 +22,23 @@ function Get-ToolsetToolFullPath
return $installationDir
}
$arch = Get-Architecture
$toolcache = Get-ToolsetValue "toolcache"
foreach ($tool in $toolcache)
{
$toolName = $tool.name
$toolArch = $tool.arch
$toolEnvironment = $tool.variable_template
$toolEnvironment = $tool.arch.$arch.variable_template
if (-not $toolEnvironment)
{
continue
}
foreach ($toolVersion in $tool.versions)
foreach ($toolVersion in $tool.arch.$arch.versions)
{
Write-Host "Set $toolName $toolVersion environment variable..."
$toolPath = Get-ToolsetToolFullPath -ToolName $toolName -ToolVersion $toolVersion -ToolArchitecture $toolArch
$toolPath = Get-ToolsetToolFullPath -ToolName $toolName -ToolVersion $toolVersion -ToolArchitecture $arch
$envName = $toolEnvironment -f $toolVersion.split(".")
# Add environment variable name=value

View File

@@ -75,8 +75,9 @@ function InstallPyPy
rm -f $PACKAGE_TAR_TEMP_PATH
}
arch=$(get_arch)
pypyVersions=$(curl https://downloads.python.org/pypy/versions.json)
toolsetVersions=$(get_toolset_value '.toolcache[] | select(.name | contains("PyPy")) | .versions[]')
toolsetVersions=$(get_toolset_value '.toolcache[] | select(.name | contains("PyPy")) | .arch.'$arch'.versions[]')
for toolsetVersion in $toolsetVersions; do
latestMajorPyPyVersion=$(echo $pypyVersions |

View File

@@ -23,7 +23,7 @@ if ! is_VenturaArm64; then
echo "Install Ruby from toolset..."
[ -n "$API_PAT" ] && authString=(-H "Authorization: token ${API_PAT}")
PACKAGE_TAR_NAMES=$(curl "${authString[@]}" -s "https://api.github.com/repos/ruby/ruby-builder/releases/latest" | jq -r '.assets[].name')
TOOLSET_VERSIONS=$(get_toolset_value '.toolcache[] | select(.name | contains("Ruby")) | .versions[]')
TOOLSET_VERSIONS=$(get_toolset_value '.toolcache[] | select(.name | contains("Ruby")) | .arch.'$arch'.versions[]')
RUBY_PATH="$AGENT_TOOLSDIRECTORY/Ruby"
echo "Check if Ruby hostedtoolcache folder exists..."

View File

@@ -28,6 +28,8 @@ Function Install-Asset {
Pop-Location
}
$arch = Get-Architecture
# Get toolcache content from toolset
$toolsToInstall = @("Python", "Node", "Go")
$tools = Get-ToolsetValue "toolcache" | Where-Object {$toolsToInstall -contains $_.Name}
@@ -37,10 +39,10 @@ foreach ($tool in $tools) {
$assets = Invoke-RestMethodWithRetry -Url $tool.url
# Get github release asset for each version
foreach ($version in $tool.versions) {
foreach ($version in $tool.arch.$arch.versions) {
$asset = $assets | Where-Object version -like $version `
| Select-Object -ExpandProperty files `
| Where-Object { ($_.platform -eq $tool.platform) -and ($_.arch -eq $tool.arch) -and ($_.platform_version -eq $tool.platform_version)} `
| Where-Object { ($_.platform -eq $tool.platform) -and ($_.arch -eq $arch)} `
| Select-Object -First 1
Write-Host "Installing $($tool.name) $version..."

View File

@@ -206,6 +206,13 @@ build {
]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
}
provisioner "shell" {
scripts = [
"./provision/core/toolset.ps1",
"./provision/core/configure-toolset.ps1"
]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} pwsh -f {{ .Path }}"
}
provisioner "shell" {
script = "./provision/core/delete-duplicate-sims.rb"
execute_command = "source $HOME/.bash_profile; ruby {{ .Path }}"

View File

@@ -1,6 +1,7 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
Import-Module "$PSScriptRoot/../helpers/Tests.Helpers.psm1" -DisableNameChecking
$arch = Get-Architecture
$os = Get-OSVersion
Describe "Toolcache" {
@@ -8,12 +9,12 @@ Describe "Toolcache" {
[array]$packages += Get-ToolsetValue -KeyPath "toolcache" | ForEach-Object {
return [PSCustomObject] @{
ToolName = ($_.name).ToLower()
Arch = $_.arch
Versions = $_.versions | ForEach-Object { $_.Replace(".*", "") }
Arch = $arch
Versions = $_.arch.$arch | Where-Object{ $_ } | ForEach-Object { $_.versions.Replace(".*", "") }
}
}
Context "Python" -Skip:($os.IsVenturaArm64) {
Context "Python" {
$pythonDirectory = Join-Path $toolcacheDirectory "Python"
$pythonPackage = $packages | Where-Object { $_.ToolName -eq "python" } | Select-Object -First 1
$testCase = @{ PythonDirectory = $pythonDirectory }
@@ -142,7 +143,7 @@ Describe "Toolcache" {
}
}
Context "Node" -Skip:($os.IsVenturaArm64) {
Context "Node" {
$nodeDirectory = Join-Path $toolcacheDirectory "node"
$nodePackage = $packages | Where-Object { $_.ToolName -eq "node" } | Select-Object -First 1
$testCase = @{ NodeDirectory = $nodeDirectory }
@@ -192,7 +193,7 @@ Describe "Toolcache" {
}
}
Context "Go" -Skip:($os.IsVenturaArm64) {
Context "Go" {
$goDirectory = Join-Path $toolcacheDirectory "go"
$goPackage = $packages | Where-Object { $_.ToolName -eq "go" } | Select-Object -First 1
$testCase = @{ GoDirectory = $goDirectory }

View File

@@ -245,61 +245,76 @@
{
"name": "Python",
"url" : "https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json",
"arch": "x64",
"platform" : "darwin",
"versions": [
"3.7.*",
"3.8.*",
"3.9.*",
"3.10.*",
"3.11.*"
]
"arch": {
"x64": {
"versions": [
"3.7.*",
"3.8.*",
"3.9.*",
"3.10.*",
"3.11.*"
]
}
}
},
{
"name": "PyPy",
"arch": "x64",
"platform" : "darwin",
"versions": [
"2.7",
"3.7",
"3.8",
"3.9"
]
"arch": {
"x64": {
"versions": [
"2.7",
"3.7",
"3.8",
"3.9"
]
}
}
},
{
"name": "Node",
"url" : "https://raw.githubusercontent.com/actions/node-versions/main/versions-manifest.json",
"platform" : "darwin",
"arch": "x64",
"versions": [
"14.*",
"16.*",
"18.*"
]
"arch": {
"x64": {
"versions": [
"14.*",
"16.*",
"18.*"
]
}
}
},
{
"name": "Go",
"url" : "https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json",
"arch": "x64",
"platform" : "darwin",
"variable_template" : "GOROOT_{0}_{1}_X64",
"versions": [
"1.18.*",
"1.19.*",
"1.20.*"
]
"arch": {
"x64": {
"variable_template" : "GOROOT_{0}_{1}_X64",
"versions": [
"1.18.*",
"1.19.*",
"1.20.*"
]
}
}
},
{
"name": "Ruby",
"arch": "x64",
"versions": [
"2.4.*",
"2.5.*",
"2.6.*",
"2.7.*",
"3.0.*",
"3.1.*"
]
"arch": {
"x64": {
"versions": [
"2.4.*",
"2.5.*",
"2.6.*",
"2.7.*",
"3.0.*",
"3.1.*"
]
}
}
}
],
"pipx": [

View File

@@ -231,58 +231,73 @@
{
"name": "Python",
"url" : "https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json",
"arch": "x64",
"platform" : "darwin",
"versions": [
"3.7.*",
"3.8.*",
"3.9.*",
"3.10.*",
"3.11.*"
]
"arch": {
"x64": {
"versions": [
"3.7.*",
"3.8.*",
"3.9.*",
"3.10.*",
"3.11.*"
]
}
}
},
{
"name": "PyPy",
"arch": "x64",
"platform" : "darwin",
"versions": [
"2.7",
"3.7",
"3.8",
"3.9"
]
"arch": {
"x64": {
"versions": [
"2.7",
"3.7",
"3.8",
"3.9"
]
}
}
},
{
"name": "Node",
"url" : "https://raw.githubusercontent.com/actions/node-versions/main/versions-manifest.json",
"platform" : "darwin",
"arch": "x64",
"versions": [
"14.*",
"16.*",
"18.*"
]
"arch": {
"x64": {
"versions": [
"14.*",
"16.*",
"18.*"
]
}
}
},
{
"name": "Go",
"url" : "https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json",
"arch": "x64",
"platform" : "darwin",
"variable_template" : "GOROOT_{0}_{1}_X64",
"versions": [
"1.18.*",
"1.19.*",
"1.20.*"
]
"arch": {
"x64": {
"variable_template" : "GOROOT_{0}_{1}_X64",
"versions": [
"1.18.*",
"1.19.*",
"1.20.*"
]
}
}
},
{
"name": "Ruby",
"arch": "x64",
"versions": [
"2.7.*",
"3.0.*",
"3.1.*"
]
"arch": {
"x64": {
"versions": [
"2.7.*",
"3.0.*",
"3.1.*"
]
}
}
}
],
"pipx": [

View File

@@ -121,54 +121,88 @@
{
"name": "Python",
"url" : "https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json",
"arch": "x64",
"platform" : "darwin",
"versions": [
"3.8.*",
"3.9.*",
"3.10.*",
"3.11.*"
]
"arch": {
"x64": {
"versions": [
"3.8.*",
"3.9.*",
"3.10.*",
"3.11.*"
]
},
"arm64": {
"versions": [
"3.10.*",
"3.11.*"
]
}
}
},
{
"name": "PyPy",
"arch": "x64",
"platform" : "darwin",
"versions": [
"2.7",
"3.7",
"3.8",
"3.9"
]
"arch": {
"x64": {
"versions": [
"2.7",
"3.7",
"3.8",
"3.9"
]
}
}
},
{
"name": "Node",
"url" : "https://raw.githubusercontent.com/actions/node-versions/main/versions-manifest.json",
"platform" : "darwin",
"arch": "x64",
"versions": [
"16.*",
"18.*"
]
"arch": {
"x64": {
"versions": [
"16.*",
"18.*"
]
},
"arm64": {
"versions": [
"16.*",
"18.*"
]
}
}
},
{
"name": "Go",
"url" : "https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json",
"arch": "x64",
"platform" : "darwin",
"variable_template" : "GOROOT_{0}_{1}_X64",
"versions": [
"1.19.*",
"1.20.*"
]
"arch": {
"x64": {
"variable_template" : "GOROOT_{0}_{1}_X64",
"versions": [
"1.19.*",
"1.20.*"
]
},
"arm64": {
"variable_template" : "GOROOT_{0}_{1}_ARM64",
"versions": [
"1.19.*",
"1.20.*"
]
}
}
},
{
"name": "Ruby",
"arch": "x64",
"versions": [
"3.0.*",
"3.1.*"
]
"arch": {
"x64": {
"versions": [
"3.0.*",
"3.1.*"
]
}
}
}
],
"go": {