Add Ruby and Python to toolcache (#7529)

This commit is contained in:
Shamil Mubarakshin
2023-05-05 08:38:29 +02:00
committed by GitHub
parent 8cf8e32bb4
commit fddf50db2a
4 changed files with 95 additions and 37 deletions

View File

@@ -9,39 +9,37 @@ GEM_PATH=`gem env|awk '/EXECUTABLE DIRECTORY/ {print $4}'`
echo "GEM_PATH=$GEM_PATH" >> "$HOME/.bashrc"
echo 'export PATH="$GEM_PATH:/usr/local/opt/ruby@'${DEFAULT_RUBY_VERSION}'/bin:$PATH"' >> "$HOME/.bashrc"
if ! is_Ventura; 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[]')
RUBY_PATH="$AGENT_TOOLSDIRECTORY/Ruby"
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[]')
RUBY_PATH="$AGENT_TOOLSDIRECTORY/Ruby"
echo "Check if Ruby hostedtoolcache folder exists..."
if [ ! -d $RUBY_PATH ]; then
mkdir -p $RUBY_PATH
fi
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"
DOWNLOAD_URL="https://github.com/ruby/ruby-builder/releases/download/toolcache/${PACKAGE_TAR_NAME}"
download_with_retries $DOWNLOAD_URL "/tmp" $PACKAGE_TAR_NAME
echo "Expand '$PACKAGE_TAR_NAME' to the '$RUBY_VERSION_PATH' folder"
tar xf "/tmp/$PACKAGE_TAR_NAME" -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
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"
DOWNLOAD_URL="https://github.com/ruby/ruby-builder/releases/download/toolcache/${PACKAGE_TAR_NAME}"
download_with_retries $DOWNLOAD_URL "/tmp" $PACKAGE_TAR_NAME
echo "Expand '$PACKAGE_TAR_NAME' to the '$RUBY_VERSION_PATH' folder"
tar xf "/tmp/$PACKAGE_TAR_NAME" -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
invoke_tests "Ruby"

View File

@@ -187,11 +187,9 @@ $browsers.AddNode($(Build-BrowserWebdriversEnvironmentTable))
$java = $installedSoftware.AddHeader("Java")
$java.AddTable($(Get-JavaVersions))
if (-not $os.IsVentura) {
# Toolcache
$toolcache = $installedSoftware.AddHeader("Cached Tools")
$toolcache.AddNodes($(Build-ToolcacheSection))
}
# Toolcache
$toolcache = $installedSoftware.AddHeader("Cached Tools")
$toolcache.AddNodes($(Build-ToolcacheSection))
# Rust
$rust = $installedSoftware.AddHeader("Rust Tools")

View File

@@ -209,6 +209,7 @@ build {
"./provision/core/chrome.sh",
"./provision/core/edge.sh",
"./provision/core/firefox.sh",
"./provision/core/pypy.sh",
"./provision/core/bicep.sh",
"./provision/core/codeql-bundle.sh"
]
@@ -217,6 +218,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

@@ -94,6 +94,60 @@
"fastlane"
]
},
"toolcache": [
{
"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.*"
]
},
{
"name": "PyPy",
"arch": "x64",
"platform" : "darwin",
"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.*"
]
},
{
"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.*"
]
},
{
"name": "Ruby",
"arch": "x64",
"versions": [
"3.0.*",
"3.1.*"
]
}
],
"go": {
"default": "1.20"
},