mirror of
https://github.com/actions/runner-images.git
synced 2025-12-10 19:16:48 +00:00
[macOS] Add Ruby toolcache on arm64 images. (#10768)
Co-authored-by: Erik Bershel <erik-bershel@github.com>
This commit is contained in:
@@ -12,8 +12,10 @@ echo "Installing Ruby..."
|
||||
brew_smart_install "ruby@${DEFAULT_RUBY_VERSION}"
|
||||
if [[ $arch == "arm64" ]]; then
|
||||
export PATH=/opt/homebrew/opt/ruby@${DEFAULT_RUBY_VERSION}/bin:$PATH
|
||||
ruby_suffix="macos-13-arm64"
|
||||
else
|
||||
export PATH=/usr/local/opt/ruby@${DEFAULT_RUBY_VERSION}/bin:$PATH
|
||||
ruby_suffix="macos-latest"
|
||||
fi
|
||||
|
||||
GEM_PATH=$(gem env|awk '/EXECUTABLE DIRECTORY/ {print $4}')
|
||||
@@ -24,37 +26,36 @@ else
|
||||
echo 'export PATH="$GEM_PATH:/usr/local/opt/ruby@'${DEFAULT_RUBY_VERSION}'/bin:$PATH"' >> $HOME/.bashrc
|
||||
fi
|
||||
|
||||
if ! is_Arm64; then
|
||||
echo "Install Ruby from toolset..."
|
||||
[ -n "$API_PAT" ] && authString=(-H "Authorization: token ${API_PAT}")
|
||||
PACKAGE_TAR_NAMES=$(curl "${authString[@]}" -fsSL "https://api.github.com/repos/ruby/ruby-builder/releases/latest" | jq -r '.assets[].name')
|
||||
TOOLSET_VERSIONS=$(get_toolset_value '.toolcache[] | select(.name | contains("Ruby")) | .arch.'$arch'.versions[]')
|
||||
RUBY_PATH=$AGENT_TOOLSDIRECTORY/Ruby
|
||||
echo "Install Ruby from toolset..."
|
||||
[ -n "$API_PAT" ] && authString=(-H "Authorization: token ${API_PAT}")
|
||||
PACKAGE_TAR_NAMES=$(curl "${authString[@]}" -fsSL "https://api.github.com/repos/ruby/ruby-builder/releases/latest" | jq -r '.assets[].name')
|
||||
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..."
|
||||
if [[ ! -d $RUBY_PATH ]]; then
|
||||
mkdir -p $RUBY_PATH
|
||||
fi
|
||||
echo "ruby path - $RUBY_PATH "
|
||||
for TOOLSET_VERSION in ${TOOLSET_VERSIONS[@]}; do
|
||||
PACKAGE_TAR_NAME=$(echo "$PACKAGE_TAR_NAMES" | grep "^ruby-${TOOLSET_VERSION}-macos-latest.tar.gz$" | egrep -v "rc|preview" | sort -V | tail -1)
|
||||
RUBY_VERSION=$(echo "$PACKAGE_TAR_NAME" | cut -d'-' -f 2)
|
||||
RUBY_VERSION_PATH="$RUBY_PATH/$RUBY_VERSION"
|
||||
|
||||
echo "Create Ruby $RUBY_VERSION directory..."
|
||||
mkdir -p $RUBY_VERSION_PATH
|
||||
|
||||
echo "Downloading tar archive $PACKAGE_TAR_NAME"
|
||||
ARCHIVE_PATH=$(download_with_retry "https://github.com/ruby/ruby-builder/releases/download/toolcache/${PACKAGE_TAR_NAME}")
|
||||
|
||||
echo "Expand $PACKAGE_TAR_NAME to the $RUBY_VERSION_PATH folder"
|
||||
tar xf $ARCHIVE_PATH -C $RUBY_VERSION_PATH
|
||||
COMPLETE_FILE_PATH=$RUBY_VERSION_PATH/x64.complete
|
||||
if [[ ! -f $COMPLETE_FILE_PATH ]]; then
|
||||
echo "Create complete file"
|
||||
touch $COMPLETE_FILE_PATH
|
||||
fi
|
||||
done
|
||||
echo "Check if Ruby hostedtoolcache folder exists..."
|
||||
if [[ ! -d $RUBY_PATH ]]; then
|
||||
mkdir -p $RUBY_PATH
|
||||
fi
|
||||
echo "ruby path - $RUBY_PATH"
|
||||
|
||||
invoke_tests "Ruby.$arch"
|
||||
for toolset_version in ${TOOLSET_VERSIONS[@]}; do
|
||||
package_tar_name=$(echo "$PACKAGE_TAR_NAMES" | grep "^ruby-${toolset_version}-${ruby_suffix}.tar.gz$" | egrep -v "rc|preview" | sort -V | tail -1)
|
||||
ruby_version=$(echo "$package_tar_name" | cut -d'-' -f 2)
|
||||
ruby_version_path="$RUBY_PATH/$ruby_version"
|
||||
|
||||
echo "Create Ruby $ruby_version directory..."
|
||||
mkdir -p $ruby_version_path
|
||||
|
||||
echo "Downloading tar archive $package_tar_name"
|
||||
archive_path=$(download_with_retry "https://github.com/ruby/ruby-builder/releases/download/toolcache/${package_tar_name}")
|
||||
|
||||
echo "Expand $package_tar_name to the $ruby_version_path folder"
|
||||
tar xf $archive_path -C $ruby_version_path
|
||||
complete_file_path=$ruby_version_path/$arch.complete
|
||||
if [[ ! -f $complete_file_path ]]; then
|
||||
echo "Create complete file"
|
||||
touch $complete_file_path
|
||||
fi
|
||||
done
|
||||
|
||||
invoke_tests "Ruby"
|
||||
|
||||
@@ -42,13 +42,9 @@ function Build-ToolcacheSection {
|
||||
[ToolVersionsListNode]::new("PyPy", $(Get-ToolcachePyPyVersions), '^\d+\.\d+', "List")
|
||||
)
|
||||
}
|
||||
if ((-not $os.IsVenturaArm64) -and (-not $os.IsSonomaArm64) -and (-not $os.IsSequoiaArm64)) {
|
||||
$nodes += @(
|
||||
[ToolVersionsListNode]::new("Ruby", $(Get-ToolcacheRubyVersions), '^\d+\.\d+', "List")
|
||||
)
|
||||
}
|
||||
|
||||
$nodes += @(
|
||||
[ToolVersionsListNode]::new("Ruby", $(Get-ToolcacheRubyVersions), '^\d+\.\d+', "List")
|
||||
[ToolVersionsListNode]::new("Python", $(Get-ToolcachePythonVersions), '^\d+\.\d+', "List"),
|
||||
[ToolVersionsListNode]::new("Node.js", $(Get-ToolcacheNodeVersions), '^\d+', "List"),
|
||||
[ToolVersionsListNode]::new("Go", $(Get-ToolcacheGoVersions), '^\d+\.\d+', "List")
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
|
||||
Import-Module "$PSScriptRoot/Helpers.psm1" -DisableNameChecking
|
||||
|
||||
$os = Get-OSVersion
|
||||
|
||||
Describe "Ruby" -Skip:(-not $os.IsArm64) {
|
||||
Describe "Ruby" {
|
||||
It "Ruby is available" {
|
||||
"ruby --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
@@ -13,10 +11,11 @@ Describe "Ruby" -Skip:(-not $os.IsArm64) {
|
||||
}
|
||||
|
||||
It "Ruby tools are consistent" {
|
||||
$expectedPrefix = "/opt/homebrew"
|
||||
Get-ToolPath "ruby" | Should -Match "$($expectedPrefix)*"
|
||||
Get-ToolPath "gem" | Should -Match "$($expectedPrefix)*"
|
||||
Get-ToolPath "bundler" | Should -Match "$($expectedPrefix)*"
|
||||
$os = Get-OSVersion
|
||||
$expectedPrefix = if ($os.IsArm64) { "/opt/homebrew" } else { "/usr/local" }
|
||||
Get-ToolPath "ruby" | Should -Match "^$expectedPrefix.*"
|
||||
Get-ToolPath "gem" | Should -Match "^$expectedPrefix.*"
|
||||
Get-ToolPath "bundler" | Should -Match "^$expectedPrefix.*"
|
||||
}
|
||||
|
||||
It "Ruby gems permissions are valid" {
|
||||
@@ -1,26 +0,0 @@
|
||||
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
|
||||
Import-Module "$PSScriptRoot/Helpers.psm1" -DisableNameChecking
|
||||
|
||||
$os = Get-OSVersion
|
||||
|
||||
Describe "Ruby" -Skip:($os.IsArm64) {
|
||||
It "Ruby is available" {
|
||||
"ruby --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "Ruby is installed via HomeBrew" {
|
||||
Get-ToolPath "ruby" | Should -Not -BeLike "/usr/bin/ruby*"
|
||||
}
|
||||
|
||||
It "Ruby tools are consistent" {
|
||||
$expectedPrefix = "/usr/local"
|
||||
Get-ToolPath "ruby" | Should -Match "$($expectedPrefix)*"
|
||||
Get-ToolPath "gem" | Should -Match "$($expectedPrefix)*"
|
||||
Get-ToolPath "bundler" | Should -Match "$($expectedPrefix)*"
|
||||
}
|
||||
|
||||
It "Ruby gems permissions are valid" {
|
||||
"gem install bundle" | Should -ReturnZeroExitCode
|
||||
"gem uninstall bundle" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
@@ -215,6 +215,14 @@
|
||||
"3.2.*",
|
||||
"3.3.*"
|
||||
]
|
||||
},
|
||||
"arm64": {
|
||||
"versions": [
|
||||
"3.0.*",
|
||||
"3.1.*",
|
||||
"3.2.*",
|
||||
"3.3.*"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,6 +203,14 @@
|
||||
"3.2.*",
|
||||
"3.3.*"
|
||||
]
|
||||
},
|
||||
"arm64": {
|
||||
"versions": [
|
||||
"3.0.*",
|
||||
"3.1.*",
|
||||
"3.2.*",
|
||||
"3.3.*"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,7 +188,15 @@
|
||||
"x64": {
|
||||
"versions": [
|
||||
"3.1.*",
|
||||
"3.2.*"
|
||||
"3.2.*",
|
||||
"3.3.*"
|
||||
]
|
||||
},
|
||||
"arm64": {
|
||||
"versions": [
|
||||
"3.1.*",
|
||||
"3.2.*",
|
||||
"3.3.*"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user