From fddf50db2a0b037213032de1e4115b36c93bf112 Mon Sep 17 00:00:00 2001 From: Shamil Mubarakshin <127750046+shamil-mubarakshin@users.noreply.github.com> Date: Fri, 5 May 2023 08:38:29 +0200 Subject: [PATCH] Add Ruby and Python to toolcache (#7529) --- images/macos/provision/core/ruby.sh | 62 +++++++++---------- .../SoftwareReport.Generator.ps1 | 8 +-- images/macos/templates/macOS-13.anka.pkr.hcl | 8 +++ images/macos/toolsets/toolset-13.json | 54 ++++++++++++++++ 4 files changed, 95 insertions(+), 37 deletions(-) diff --git a/images/macos/provision/core/ruby.sh b/images/macos/provision/core/ruby.sh index 9741eab32..0b60142ff 100755 --- a/images/macos/provision/core/ruby.sh +++ b/images/macos/provision/core/ruby.sh @@ -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" diff --git a/images/macos/software-report/SoftwareReport.Generator.ps1 b/images/macos/software-report/SoftwareReport.Generator.ps1 index 908fd5b39..2e05d3d8a 100644 --- a/images/macos/software-report/SoftwareReport.Generator.ps1 +++ b/images/macos/software-report/SoftwareReport.Generator.ps1 @@ -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") diff --git a/images/macos/templates/macOS-13.anka.pkr.hcl b/images/macos/templates/macOS-13.anka.pkr.hcl index 5b0b71119..d02c4893e 100644 --- a/images/macos/templates/macOS-13.anka.pkr.hcl +++ b/images/macos/templates/macOS-13.anka.pkr.hcl @@ -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 }}" diff --git a/images/macos/toolsets/toolset-13.json b/images/macos/toolsets/toolset-13.json index 706603660..32206718d 100644 --- a/images/macos/toolsets/toolset-13.json +++ b/images/macos/toolsets/toolset-13.json @@ -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" },