From 4c30ace0cceabc2f5277e1dbcd88d9cbf9e1449d Mon Sep 17 00:00:00 2001 From: Maksim Petrov Date: Mon, 30 Dec 2019 11:40:10 +0300 Subject: [PATCH 1/7] Toolcache: Add NPM Toolcache support for Windows/Linux --- .../installers/1804/hosted-tool-cache.sh | 54 ------------- images/linux/scripts/installers/boost.sh | 7 -- .../{1604 => }/hosted-tool-cache.sh | 48 ++++++------ .../scripts/installers/test-toolcache.sh | 75 +++++++++++++++---- images/linux/toolcache-1604.json | 14 ++++ images/linux/toolcache-1804.json | 14 ++++ images/linux/ubuntu1604.json | 14 +++- images/linux/ubuntu1804.json | 14 +++- images/win/Windows2016-Azure.json | 40 ++++++---- images/win/Windows2019-Azure.json | 40 ++++++---- .../scripts/Installers/Download-ToolCache.ps1 | 71 ++++++++++-------- .../win/scripts/Installers/Install-Boost.ps1 | 27 +------ .../scripts/Installers/Validate-ToolCache.ps1 | 72 +++++++++++++----- images/win/toolcache.json | 17 +++++ 14 files changed, 300 insertions(+), 207 deletions(-) delete mode 100644 images/linux/scripts/installers/1804/hosted-tool-cache.sh rename images/linux/scripts/installers/{1604 => }/hosted-tool-cache.sh (51%) create mode 100644 images/linux/toolcache-1604.json create mode 100644 images/linux/toolcache-1804.json create mode 100644 images/win/toolcache.json diff --git a/images/linux/scripts/installers/1804/hosted-tool-cache.sh b/images/linux/scripts/installers/1804/hosted-tool-cache.sh deleted file mode 100644 index 10180a240..000000000 --- a/images/linux/scripts/installers/1804/hosted-tool-cache.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash -################################################################################ -## File: hosted-tool-cache.sh -## Desc: Downloads and installs hosted tools cache -################################################################################ - -# Source the helpers for use with the script -source $HELPER_SCRIPTS/document.sh - -# Fail out if any setups fail -set -e - -# Download hosted tool cache -AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache -echo "AGENT_TOOLSDIRECTORY=$AGENT_TOOLSDIRECTORY" | tee -a /etc/environment -azcopy --recursive \ - --source https://vstsagenttools.blob.core.windows.net/tools/hostedtoolcache/ubuntu-1804 \ - --destination $AGENT_TOOLSDIRECTORY - -# Install tools from hosted tool cache -original_directory=$PWD -setups=$(find $AGENT_TOOLSDIRECTORY -name setup.sh) -for setup in $setups; do - chmod +x $setup; - cd $(dirname $setup); - ./$(basename $setup); - cd $original_directory; -done; - -DocumentInstalledItem "Python:" -pythons=$(ls $AGENT_TOOLSDIRECTORY/Python) -for python in $pythons; do - DocumentInstalledItemIndent "Python $python" -done; - -# PyPy is also configured using the setup-python action -pypys=$(ls $AGENT_TOOLSDIRECTORY/PyPy) -for pypy in $pypys; do - DocumentInstalledItemIndent "PyPy $pypy" - # Add symlinks for pypy2 and pypy3 to usr/local/bin, there should only be 2 versions of PyPy in the tools cache that is downloaded - if [ ${pypy:0:1} -eq "3" ] ; then - # add pypy 3.X to PATH - ln -s $AGENT_TOOLSDIRECTORY/PyPy/$pypy/x64/bin/pypy3 /usr/local/bin/pypy3 - else - # add pypy 2.X to PATH - ln -s $AGENT_TOOLSDIRECTORY/PyPy/$pypy/x64/bin/pypy /usr/local/bin/pypy - fi -done; - -DocumentInstalledItem "Ruby:" -rubys=$(ls $AGENT_TOOLSDIRECTORY/Ruby) -for ruby in $rubys; do - DocumentInstalledItemIndent "Ruby $ruby" -done; \ No newline at end of file diff --git a/images/linux/scripts/installers/boost.sh b/images/linux/scripts/installers/boost.sh index 3b7d6b043..673b1f61e 100644 --- a/images/linux/scripts/installers/boost.sh +++ b/images/linux/scripts/installers/boost.sh @@ -7,7 +7,6 @@ # Source the helpers for use with the script source $HELPER_SCRIPTS/document.sh -BOOST_ZIP_PATH=/opt/hostedtoolcache/Boost BOOST_LIB=/usr/local/share/boost # Install Boost @@ -15,9 +14,6 @@ for BOOST_VERSION in ${BOOST_VERSIONS//,/ } do BOOST_SYMLINK_VER=`echo "${BOOST_VERSION//[.]/_}"` BOOST_ROOT="BOOST_ROOT_$BOOST_SYMLINK_VER" - BOOST_ZIP="boost_`echo $BOOST_VERSION`_gcc.zip" - - unzip $BOOST_ZIP_PATH/$BOOST_ZIP -d $BOOST_LIB echo "$BOOST_ROOT=$BOOST_LIB/$BOOST_VERSION" | tee -a /etc/environment if [[ $BOOST_VERSION == $BOOST_DEFAULT ]]; then @@ -26,6 +22,3 @@ do DocumentInstalledItem "Boost C++ Libraries $BOOST_VERSION" done - -# Deleting archives with Boost Libraries -rm -rf $BOOST_ZIP_PATH diff --git a/images/linux/scripts/installers/1604/hosted-tool-cache.sh b/images/linux/scripts/installers/hosted-tool-cache.sh similarity index 51% rename from images/linux/scripts/installers/1604/hosted-tool-cache.sh rename to images/linux/scripts/installers/hosted-tool-cache.sh index c68f9747e..66ab532ea 100644 --- a/images/linux/scripts/installers/1604/hosted-tool-cache.sh +++ b/images/linux/scripts/installers/hosted-tool-cache.sh @@ -10,21 +10,23 @@ source $HELPER_SCRIPTS/document.sh # Fail out if any setups fail set -e -# Download hosted tool cache AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache +mkdir $AGENT_TOOLSDIRECTORY echo "AGENT_TOOLSDIRECTORY=$AGENT_TOOLSDIRECTORY" | tee -a /etc/environment -azcopy --recursive \ - --source https://vstsagenttools.blob.core.windows.net/tools/hostedtoolcache/linux \ - --destination $AGENT_TOOLSDIRECTORY -# Install tools from hosted tool cache -original_directory=$PWD -setups=$(find $AGENT_TOOLSDIRECTORY -name setup.sh) -for setup in $setups; do - chmod +x $setup; - cd $(dirname $setup); - ./$(basename $setup); - cd $original_directory; +chmod -R 777 $AGENT_TOOLSDIRECTORY + +echo "Installing npm-toolcache..." +TOOLSET_PATH="$INSTALLER_SCRIPT_FOLDER/toolcache.json" + +PACKAGE_LIST=($(jq -r 'keys | .[]' $TOOLSET_PATH)) + +for PACKAGE_NAME in ${PACKAGE_LIST[@]}; do + PACKAGE_VERSIONS=($(jq -r ".[\"$PACKAGE_NAME\"] | .[]" $TOOLSET_PATH)) + for PACKAGE_VERSION in ${PACKAGE_VERSIONS[@]}; do + echo "Install ${PACKAGE_NAME}@${PACKAGE_VERSION}" + npm install ${PACKAGE_NAME}@${PACKAGE_VERSION} --registry=${TOOLCACHE_REGISTRY} + done; done; DocumentInstalledItem "Python:" @@ -33,22 +35,14 @@ for python in $pythons; do DocumentInstalledItemIndent "Python $python" done; -# PyPy is also configured using the setup-python action -pypys=$(ls $AGENT_TOOLSDIRECTORY/PyPy) -for pypy in $pypys; do - DocumentInstalledItemIndent "PyPy $pypy" - # Add symlinks for pypy2 and pypy3 to usr/local/bin, there should only be 2 versions of PyPy in the tools cache that is downloaded - if [ ${pypy:0:1} -eq "3" ] ; then - # add pypy 3.X to PATH - ln -s $AGENT_TOOLSDIRECTORY/PyPy/$pypy/x64/bin/pypy3 /usr/local/bin/pypy3 - else - # add pypy 2.X to PATH - ln -s $AGENT_TOOLSDIRECTORY/PyPy/$pypy/x64/bin/pypy /usr/local/bin/pypy - fi -done; - DocumentInstalledItem "Ruby:" rubys=$(ls $AGENT_TOOLSDIRECTORY/Ruby) for ruby in $rubys; do DocumentInstalledItemIndent "Ruby $ruby" -done; \ No newline at end of file +done; + +DocumentInstalledItem "PyPy:" +pypys=$(ls $AGENT_TOOLSDIRECTORY/PyPy) +for pypy in $pypys; do + DocumentInstalledItemIndent "PyPy $pypy" +done; diff --git a/images/linux/scripts/installers/test-toolcache.sh b/images/linux/scripts/installers/test-toolcache.sh index af2dd359f..785218b3e 100644 --- a/images/linux/scripts/installers/test-toolcache.sh +++ b/images/linux/scripts/installers/test-toolcache.sh @@ -9,6 +9,22 @@ # Fail out if any tests fail set -e +# defune array of key aliases +key_alias_array=() +bash --version +# define dicionary for key_alias and its values +declare -A toolcache_key_value +PACKAGE_LIST=($(jq -r 'keys | .[]' "$INSTALLER_SCRIPT_FOLDER/toolcache.json")) +for PACKAGE_NAME in ${PACKAGE_LIST[@]}; do + + # get key alias + key_alias=$(echo $PACKAGE_NAME | cut -f2 -d-) + echo $key_alias + + # set dictionary + toolcache_key_value+=(["$key_alias"]="$PACKAGE_NAME") +done; + AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache # Python test @@ -18,19 +34,19 @@ if [ -d "$AGENT_TOOLSDIRECTORY/Python" ]; then echo "Python versions folders: ${python_dirs[@]}" echo "------------------------------------------" if [ -n "$python_dirs" ]; then - for version_dir in "${python_dirs[@]}" + PACKAGE_VERSIONS=($(jq -r ".[\"${toolcache_key_value[python]}\"] | .[]" "$INSTALLER_SCRIPT_FOLDER/toolcache.json")) + for python_version in ${PACKAGE_VERSIONS[@]} do + version_dir=$(find . -name "$python_version.*" -print -quit) echo "Test $AGENT_TOOLSDIRECTORY/Python/$version_dir:" - expected_ver=$(echo $version_dir | egrep -o '[0-9]+\.[0-9]+') actual_ver=$($AGENT_TOOLSDIRECTORY/Python/$version_dir/x64/python -c 'import sys;print(sys.version)'| head -1 | egrep -o '[0-9]+\.[0-9]+') - - if [ "$expected_ver" = "$actual_ver" ]; then + if [ "$actual_ver" = "$python_version" ]; then echo "Passed!" else - echo "Expected: $expected_ver; Actual: $actual_ver" + echo "Expected: $python_version; Actual: $actual_ver" exit 1 fi - done + done; else echo "$AGENT_TOOLSDIRECTORY/Python does not include any folders" exit 1 @@ -47,19 +63,19 @@ if [ -d "$AGENT_TOOLSDIRECTORY/Ruby" ]; then echo "Ruby versions folders: ${ruby_dirs[@]}" echo "--------------------------------------" if [ -n "$ruby_dirs" ]; then - for version_dir in "${ruby_dirs[@]}" + PACKAGE_VERSIONS=($(jq -r ".[\"${toolcache_key_value[ruby]}\"] | .[]" "$INSTALLER_SCRIPT_FOLDER/toolcache.json")) + for ruby_version in ${PACKAGE_VERSIONS[@]} do + version_dir=$(find . -name "$ruby_version.*" -print -quit) echo "Test $AGENT_TOOLSDIRECTORY/Ruby/$version_dir:" - expected_ver=$(echo $version_dir | egrep -o '[0-9]+\.[0-9]+') actual_ver=$($AGENT_TOOLSDIRECTORY/Ruby/$version_dir/x64/bin/ruby -e "puts RUBY_VERSION" | egrep -o '[0-9]+\.[0-9]+') - - if [ "$expected_ver" = "$actual_ver" ]; then - echo "Passed!" + if [ "$actual_ver" = "$ruby_version" ]; then + echo "Passed!" else - echo "Expected: $expected_ver; Actual: $actual_ver" - exit 1 + echo "Expected: $ruby_version; Actual: $actual_ver" + exit 1 fi - done + done; else echo "$AGENT_TOOLSDIRECTORY/Ruby does not include any folders" exit 1 @@ -68,3 +84,34 @@ else echo "$AGENT_TOOLSDIRECTORY/Ruby does not exist" exit 1 fi + +# PyPy tests +if [ -d "$AGENT_TOOLSDIRECTORY/PyPy" ]; then + cd $AGENT_TOOLSDIRECTORY/PyPy + pypy_dirs=($(find . -mindepth 1 -maxdepth 1 -type d | sed "s|^\./||")) + echo "PyPy versions folders: ${pypy_dirs[@]}" + echo "------------------------------------------" + if [ -n "$pypy_dirs" ]; then + PACKAGE_VERSIONS=($(jq -r ".[\"${toolcache_key_value[pypy]}\"] | .[]" "$INSTALLER_SCRIPT_FOLDER/toolcache.json")) + for pypy_version in ${PACKAGE_VERSIONS[@]} + do + version_dir=$(find . -name "$pypy_version.*" -print -quit) + pypy_path=$(find . -regex "$version_dir/x64/bin/pypy[0-9]*" -print -quit) + echo $pypy_path + actual_ver=$($pypy_path -c 'import sys;print(sys.version)'| head -1 | egrep -o '[0-9]+\.[0-9]+' | cut -d '.' -f 1) + echo "actual_ver = $actual_ver : pypy_version = $pypy_version" + if [ "$actual_ver" = "$pypy_version" ]; then + echo "Passed!" + else + echo "Expected: $pypy_version; Actual: $actual_ver" + exit 1 + fi + done; + else + echo "$AGENT_TOOLSDIRECTORY/PyPy does not include any folders" + exit 1 + fi +else + echo "$AGENT_TOOLSDIRECTORY/PyPy does not exist" + exit 1 +fi \ No newline at end of file diff --git a/images/linux/toolcache-1604.json b/images/linux/toolcache-1604.json new file mode 100644 index 000000000..2674d57af --- /dev/null +++ b/images/linux/toolcache-1604.json @@ -0,0 +1,14 @@ +{ + "toolcache-python-ubuntu-1604-x64": [ + "2.7", "3.5", "3.6", "3.7", "3.8" + ], + "toolcache-ruby-ubuntu-1604-x64": [ + "2.4", "2.5", "2.6" + ], + "toolcache-pypy-ubuntu-1604-x64": [ + "2", "3" + ], + "toolcache-boost-ubuntu-1604-x64": [ + "1.69" + ] +} \ No newline at end of file diff --git a/images/linux/toolcache-1804.json b/images/linux/toolcache-1804.json new file mode 100644 index 000000000..ca75563cd --- /dev/null +++ b/images/linux/toolcache-1804.json @@ -0,0 +1,14 @@ +{ + "toolcache-python-ubuntu-1804-x64": [ + "2.7", "3.5", "3.6", "3.7", "3.8" + ], + "toolcache-ruby-ubuntu-1804-x64": [ + "2.4", "2.5", "2.6" + ], + "toolcache-pypy-ubuntu-1804-x64": [ + "2", "3" + ], + "toolcache-boost-ubuntu-1804-x64": [ + "1.69" + ] +} \ No newline at end of file diff --git a/images/linux/ubuntu1604.json b/images/linux/ubuntu1604.json index a1e9d27fa..650f3daec 100644 --- a/images/linux/ubuntu1604.json +++ b/images/linux/ubuntu1604.json @@ -20,7 +20,8 @@ "helper_script_folder": "/imagegeneration/helpers", "vm_size": "Standard_DS2_v2", "capture_name_prefix": "packer", - "image_version": "dev" + "image_version": "dev", + "toolcache_registry": "https://buildcanary.pkgs.visualstudio.com/PipelineCanary/_packaging/hostedtoolcache/npm/registry/" }, "builders": [ { @@ -167,19 +168,26 @@ ], "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" }, + { + "type": "file", + "source": "{{template_dir}}/toolcache-1604.json", + "destination": "{{user `installer_script_folder`}}/toolcache.json" + }, { "type": "shell", "scripts":[ "{{template_dir}}/scripts/installers/1604/android.sh", "{{template_dir}}/scripts/installers/1604/azpowershell.sh", "{{template_dir}}/scripts/helpers/containercache.sh", - "{{template_dir}}/scripts/installers/1604/hosted-tool-cache.sh", + "{{template_dir}}/scripts/installers/hosted-tool-cache.sh", "{{template_dir}}/scripts/installers/python.sh", "{{template_dir}}/scripts/installers/test-toolcache.sh" ], "environment_vars": [ "METADATA_FILE={{user `metadata_file`}}", - "HELPER_SCRIPTS={{user `helper_script_folder`}}" + "HELPER_SCRIPTS={{user `helper_script_folder`}}", + "TOOLCACHE_REGISTRY={{user `toolcache_registry`}}", + "INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}" ], "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" }, diff --git a/images/linux/ubuntu1804.json b/images/linux/ubuntu1804.json index 2c10a6822..5c59b4833 100644 --- a/images/linux/ubuntu1804.json +++ b/images/linux/ubuntu1804.json @@ -20,7 +20,8 @@ "helper_script_folder": "/imagegeneration/helpers", "vm_size": "Standard_DS2_v2", "capture_name_prefix": "packer", - "image_version": "dev" + "image_version": "dev", + "toolcache_registry": "https://buildcanary.pkgs.visualstudio.com/PipelineCanary/_packaging/hostedtoolcache/npm/registry/" }, "builders": [ { @@ -170,19 +171,26 @@ ], "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" }, + { + "type": "file", + "source": "{{template_dir}}/toolcache-1804.json", + "destination": "{{user `installer_script_folder`}}/toolcache.json" + }, { "type": "shell", "scripts":[ "{{template_dir}}/scripts/installers/1804/android.sh", "{{template_dir}}/scripts/installers/1804/azpowershell.sh", "{{template_dir}}/scripts/helpers/containercache.sh", - "{{template_dir}}/scripts/installers/1804/hosted-tool-cache.sh", + "{{template_dir}}/scripts/installers/hosted-tool-cache.sh", "{{template_dir}}/scripts/installers/python.sh", "{{template_dir}}/scripts/installers/test-toolcache.sh" ], "environment_vars": [ "METADATA_FILE={{user `metadata_file`}}", - "HELPER_SCRIPTS={{user `helper_script_folder`}}" + "HELPER_SCRIPTS={{user `helper_script_folder`}}", + "TOOLCACHE_REGISTRY={{user `toolcache_registry`}}", + "INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}" ], "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" }, diff --git a/images/win/Windows2016-Azure.json b/images/win/Windows2016-Azure.json index c51dcdfe5..8c93fad94 100644 --- a/images/win/Windows2016-Azure.json +++ b/images/win/Windows2016-Azure.json @@ -16,6 +16,7 @@ "private_virtual_network_with_public_ip": "{{env `PRIVATE_VIRTUAL_NETWORK_WITH_PUBLIC_IP`}}", "vm_size": "Standard_DS4_v2", + "root_folder": "C:", "image_folder": "C:\\image", "commit_file": "C:\\image\\commit.txt", "metadata_file": "C:\\image\\metadata.txt", @@ -24,7 +25,8 @@ "install_user": "installer", "install_password": null, "capture_name_prefix": "packer", - "image_version": "dev" + "image_version": "dev", + "toolcache_registry": "https://buildcanary.pkgs.visualstudio.com/PipelineCanary/_packaging/hostedtoolcache/npm/registry/" }, "builders": [ { @@ -268,6 +270,27 @@ }, { "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Install-NodeLts.ps1" + ] + }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Install-7zip.ps1" + ] + }, + { + "type": "file", + "source": "{{template_dir}}/toolcache.json", + "destination": "{{user `root_folder`}}/toolcache.json" + }, + { + "type": "powershell", + "environment_vars":[ + "TOOLCACHE_REGISTRY={{ user `toolcache_registry` }}", + "ROOT_FOLDER={{user `root_folder`}}" + ], "scripts":[ "{{ template_dir }}/scripts/Installers/Download-ToolCache.ps1" ] @@ -362,12 +385,6 @@ "{{ template_dir }}/scripts/Installers/Validate-WinAppDriver.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Install-NodeLts.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -450,12 +467,6 @@ "{{ template_dir }}/scripts/Installers/Install-AzureCosmosDbEmulator.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Install-7zip.ps1" - ] - }, { "type": "powershell", "environment_vars": [ @@ -562,6 +573,9 @@ }, { "type": "powershell", + "environment_vars":[ + "ROOT_FOLDER={{user `root_folder`}}" + ], "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-ToolCache.ps1" ] diff --git a/images/win/Windows2019-Azure.json b/images/win/Windows2019-Azure.json index 6875b7f07..5251a965b 100644 --- a/images/win/Windows2019-Azure.json +++ b/images/win/Windows2019-Azure.json @@ -16,6 +16,7 @@ "private_virtual_network_with_public_ip": "{{env `PRIVATE_VIRTUAL_NETWORK_WITH_PUBLIC_IP`}}", "vm_size": "Standard_DS4_v2", + "root_folder": "C:", "image_folder": "C:\\image", "commit_file": "C:\\image\\commit.txt", "metadata_file": "C:\\image\\metadata.txt", @@ -24,7 +25,8 @@ "install_user": "installer", "install_password": null, "capture_name_prefix": "packer", - "image_version": "dev" + "image_version": "dev", + "toolcache_registry": "https://buildcanary.pkgs.visualstudio.com/PipelineCanary/_packaging/hostedtoolcache/npm/registry/" }, "sensitive-variables": ["install_password", "ssh_password", "client_secret"], "builders": [ @@ -238,6 +240,27 @@ }, { "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Install-NodeLts.ps1" + ] + }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Install-7zip.ps1" + ] + }, + { + "type": "file", + "source": "{{template_dir}}/toolcache.json", + "destination": "{{user `root_folder`}}/toolcache.json" + }, + { + "type": "powershell", + "environment_vars":[ + "TOOLCACHE_REGISTRY={{ user `toolcache_registry` }}", + "ROOT_FOLDER={{user `root_folder`}}" + ], "scripts":[ "{{ template_dir }}/scripts/Installers/Download-ToolCache.ps1" ] @@ -332,12 +355,6 @@ "{{ template_dir }}/scripts/Installers/Validate-WinAppDriver.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Install-NodeLts.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -420,12 +437,6 @@ "{{ template_dir }}/scripts/Installers/Install-AzureCosmosDbEmulator.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Install-7zip.ps1" - ] - }, { "type": "powershell", "environment_vars": [ @@ -532,6 +543,9 @@ }, { "type": "powershell", + "environment_vars":[ + "ROOT_FOLDER={{user `root_folder`}}" + ], "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-ToolCache.ps1" ] diff --git a/images/win/scripts/Installers/Download-ToolCache.ps1 b/images/win/scripts/Installers/Download-ToolCache.ps1 index b7a49a285..967046d09 100644 --- a/images/win/scripts/Installers/Download-ToolCache.ps1 +++ b/images/win/scripts/Installers/Download-ToolCache.ps1 @@ -1,51 +1,62 @@ ################################################################################ ## File: Download-ToolCache.ps1 +## Team: CI-Build ## Desc: Download tool cache ################################################################################ -Function InstallTool -{ - Param - ( - [System.Object]$ExecutablePath +Function Install-NpmPackage { + [CmdletBinding()] + param( + [Parameter(Mandatory=$true)] + [System.String] + $Name, + [Parameter(Mandatory=$true)] + [System.String] + $NpmRegistry ) - Write-Host $ExecutablePath.DirectoryName - Set-Location -Path $ExecutablePath.DirectoryName - Get-Location | Write-Host - if (Test-Path 'tool.zip') - { + Write-Host "Installing npm '$Name' package from '$NpmRegistry'" + + npm install $Name --registry=$NpmRegistry +} + +Function InstallTool { + [CmdletBinding()] + param( + [System.IO.FileInfo]$ExecutablePath + ) + + Set-Location -Path $ExecutablePath.DirectoryName -PassThru | Write-Host + if (Test-Path 'tool.zip') { Expand-Archive 'tool.zip' -DestinationPath '.' } cmd.exe /c 'install_to_tools_cache.bat' } -$SourceUrl = "https://vstsagenttools.blob.core.windows.net/tools" - +# HostedToolCache Path $Dest = "C:/" - $Path = "hostedtoolcache/windows" - -$env:Path = "C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy;" + $env:Path - -Write-Host "Started AzCopy from $SourceUrl to $Dest" - -AzCopy /Source:$SourceUrl /Dest:$Dest /S /V /Pattern:$Path - $ToolsDirectory = $Dest + $Path -$current = Get-Location -Set-Location -Path $ToolsDirectory - -Get-ChildItem -Recurse -Depth 4 -Filter install_to_tools_cache.bat | ForEach-Object { - #In order to work correctly Python 3.4 x86 must be installed after x64, this is achieved by current toolcache catalog structure - InstallTool($_) -} - -Set-Location -Path $current - +# Define AGENT_TOOLSDIRECTORY environment variable +$env:AGENT_TOOLSDIRECTORY = $ToolsDirectory setx AGENT_TOOLSDIRECTORY $ToolsDirectory /M +# Install tools form NPM + +$ToolVersionsFileContent = Get-Content -Path "$env:ROOT_FOLDER/toolcache.json" -Raw +$ToolVersions = ConvertFrom-Json -InputObject $ToolVersionsFileContent + +$ToolVersions.PSObject.Properties | ForEach-Object { + $PackageName = $_.Name + $PackageVersions = $_.Value + $NpmPackages = $PackageVersions | ForEach-Object { "$PackageName@$_" } + foreach($NpmPackage in $NpmPackages) { + Install-NpmPackage -Name $NpmPackage -NpmRegistry $env:TOOLCACHE_REGISTRY + } +} + #junction point from the previous Python2 directory to the toolcache Python2 +Write-Host "Create symlink to Python2" $python2Dir = (Get-Item -Path ($ToolsDirectory + '/Python/2.7*/x64')).FullName cmd.exe /c mklink /d "C:\Python27amd64" "$python2Dir" diff --git a/images/win/scripts/Installers/Install-Boost.ps1 b/images/win/scripts/Installers/Install-Boost.ps1 index a076a47af..281363336 100644 --- a/images/win/scripts/Installers/Install-Boost.ps1 +++ b/images/win/scripts/Installers/Install-Boost.ps1 @@ -1,28 +1,16 @@ ################################################################################ -## File: Install-Boost.ps1 +## File: Set-BoostRoot.ps1 +## Team: CI-Build ## Desc: Install boost using tool cache ################################################################################ -$ToolCache = 'C:\hostedtoolcache\windows\boost' $BoostDirectory = Join-Path -Path $env:ProgramFiles -ChildPath "Boost" -$BoostVersionsToInstall = $env:BOOST_VERSIONS.split(',') +$BoostVersions = $env:BOOST_VERSIONS.split(',') $BoostDefault = $env:BOOST_DEFAULT -foreach($BoostVersion in $BoostVersionsToInstall) +foreach($BoostVersion in $BoostVersions) { - $ZipName = Join-Path -Path $ToolCache -ChildPath "boost_${BoostVersion}_msvc-14.1.zip" - - if (-Not (Test-Path $ZipName)) - { - Write-Host "$ZipName not found" - exit 1 - } - - Write-Host "Expanding $ZipName" - $BoostInstallationDir = Join-Path -Path $BoostDirectory -ChildPath $BoostVersion - # Expand-Archive slower for 70% than 7z - & "$env:ProgramFiles\7-Zip\7z.exe" x $ZipName -o"$BoostDirectory" -y $EnvBoostPath = "BOOST_ROOT_{0}" -f ($BoostVersion.Replace('.', '_')) setx $EnvBoostPath $BoostInstallationDir /M | Out-Null @@ -36,10 +24,3 @@ foreach($BoostVersion in $BoostVersionsToInstall) setx BOOST_ROOT $BoostInstallationDir /M | Out-Null } } - -# Removing boost cache folder -Write-Host "Removing boost cache folder" -if (Test-Path $ToolCache) -{ - Remove-Item -Path $ToolCache -Force -Recurse -} diff --git a/images/win/scripts/Installers/Validate-ToolCache.ps1 b/images/win/scripts/Installers/Validate-ToolCache.ps1 index 832cf13c3..df61f6f6c 100644 --- a/images/win/scripts/Installers/Validate-ToolCache.ps1 +++ b/images/win/scripts/Installers/Validate-ToolCache.ps1 @@ -12,6 +12,21 @@ function GetChildFolders { return Get-ChildItem -Path $Path -Directory -Name } +function Get-ToolcachePackages { + $toolcachePath = Join-Path $env:ROOT_FOLDER "toolcache.json" + return Get-Content -Raw $toolcachePath | ConvertFrom-Json +} + +$packages = (Get-ToolcachePackages).PSObject.Properties | ForEach-Object { + $packageNameParts = $_.Name.Split("-") + $toolName = $packageNameParts[1] + return [PSCustomObject] @{ + ToolName = $packageNameParts[1] + Versions = $_.Value + Arch = $packageNameParts[3] + } +} + function ToolcacheTest { param ( [Parameter(Mandatory = $True)] @@ -22,36 +37,53 @@ function ToolcacheTest { if (Test-Path "$env:AGENT_TOOLSDIRECTORY\$SoftwareName") { $description = "" - [array]$versions = GetChildFolders -Path "$env:AGENT_TOOLSDIRECTORY\$SoftwareName" - if ($versions.count -gt 0){ - foreach ($version in $versions) + [array]$instaledVersions = GetChildFolders -Path "$env:AGENT_TOOLSDIRECTORY\$SoftwareName" + if ($instaledVersions.count -gt 0){ + $softwarePackages = $packages | Where-Object { $_.ToolName -eq $SoftwareName } + foreach($softwarePackage in $softwarePackages) { - $architectures = GetChildFolders -Path "$env:AGENT_TOOLSDIRECTORY\$SoftwareName\$version" - - Write-Host "$SoftwareName version - $version : $([system.String]::Join(",", $architectures))" - - foreach ($arch in $architectures) + foreach ($version in $softwarePackage.Versions) { - $path = "$env:AGENT_TOOLSDIRECTORY\$SoftwareName\$version\$arch" - foreach ($test in $ExecTests) - { - if (Test-Path "$path\$test") - { - Write-Host "$SoftwareName($test) $version($arch) is successfully installed:" - Write-Host (& "$path\$test" --version) + $foundVersion = $instaledVersions | where { $_.StartsWith($version) } + + if ($foundVersion -ne $null){ + + $architectures = GetChildFolders -Path "$env:AGENT_TOOLSDIRECTORY\$SoftwareName\$foundVersion" + + $softwareArch = $softwarePackage.Arch + + if ($architectures -Contains $softwareArch) { + $path = "$env:AGENT_TOOLSDIRECTORY\$SoftwareName\$foundVersion\$softwareArch" + foreach ($test in $ExecTests) + { + if (Test-Path "$path\$test") + { + Write-Host "$SoftwareName($test) $foundVersion($softwareArch) is successfully installed:" + Write-Host (& "$path\$test" --version) + } + else + { + Write-Host "$SoftwareName($test) $foundVersion ($softwareArch) is not installed" + exit 1 + } + } + $description += "_Version:_ $foundVersion ($softwareArch)
" } else { - Write-Host "$SoftwareName($test) $version ($arch) is not installed" + Write-Host "$env:AGENT_TOOLSDIRECTORY\$SoftwareName\$foundVersion does not include required architecture" exit 1 } } - - $description += "_Version:_ $version ($arch)
" + else + { + Write-Host "$env:AGENT_TOOLSDIRECTORY\$SoftwareName\$version.* was not found" + exit 1 + } } - } - Add-SoftwareDetailsToMarkdown -SoftwareName $SoftwareName -DescriptionMarkdown $description + Add-SoftwareDetailsToMarkdown -SoftwareName $SoftwareName -DescriptionMarkdown $description + } } else { diff --git a/images/win/toolcache.json b/images/win/toolcache.json new file mode 100644 index 000000000..69434da3a --- /dev/null +++ b/images/win/toolcache.json @@ -0,0 +1,17 @@ +{ + "toolcache-python-windows-x64": [ + "2.7", "3.5", "3.6", "3.7", "3.8" + ], + "toolcache-python-windows-x86": [ + "2.7", "3.5", "3.6", "3.7", "3.8" + ], + "toolcache-ruby-windows-x64": [ + "2.4", "2.5", "2.6" + ], + "toolcache-pypy-windows-x86": [ + "2", "3" + ], + "toolcache-boost-windows-x64": [ + "1.69" + ] +} \ No newline at end of file From 6aa21f425e3682f83779027b52af37b0d12524e6 Mon Sep 17 00:00:00 2001 From: Maksim Petrov Date: Mon, 30 Dec 2019 14:44:06 +0300 Subject: [PATCH 2/7] Toolcache: remove InstallTool function from Download-ToolCache.ps1 --- .../win/scripts/Installers/Download-ToolCache.ps1 | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/images/win/scripts/Installers/Download-ToolCache.ps1 b/images/win/scripts/Installers/Download-ToolCache.ps1 index 967046d09..eef9f7d96 100644 --- a/images/win/scripts/Installers/Download-ToolCache.ps1 +++ b/images/win/scripts/Installers/Download-ToolCache.ps1 @@ -20,19 +20,6 @@ Function Install-NpmPackage { npm install $Name --registry=$NpmRegistry } -Function InstallTool { - [CmdletBinding()] - param( - [System.IO.FileInfo]$ExecutablePath - ) - - Set-Location -Path $ExecutablePath.DirectoryName -PassThru | Write-Host - if (Test-Path 'tool.zip') { - Expand-Archive 'tool.zip' -DestinationPath '.' - } - cmd.exe /c 'install_to_tools_cache.bat' -} - # HostedToolCache Path $Dest = "C:/" $Path = "hostedtoolcache/windows" From d1ed5029b5e3fb2ba27662dd1751b5968155e86b Mon Sep 17 00:00:00 2001 From: Maksim Petrov Date: Mon, 30 Dec 2019 14:51:09 +0300 Subject: [PATCH 3/7] Toolcache: fix typos in windows toolcache provisioners --- images/win/scripts/Installers/Download-ToolCache.ps1 | 3 +-- images/win/scripts/Installers/Validate-ToolCache.ps1 | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/images/win/scripts/Installers/Download-ToolCache.ps1 b/images/win/scripts/Installers/Download-ToolCache.ps1 index eef9f7d96..b031a827e 100644 --- a/images/win/scripts/Installers/Download-ToolCache.ps1 +++ b/images/win/scripts/Installers/Download-ToolCache.ps1 @@ -29,8 +29,7 @@ $ToolsDirectory = $Dest + $Path $env:AGENT_TOOLSDIRECTORY = $ToolsDirectory setx AGENT_TOOLSDIRECTORY $ToolsDirectory /M -# Install tools form NPM - +# Install HostedToolCache tools via NPM $ToolVersionsFileContent = Get-Content -Path "$env:ROOT_FOLDER/toolcache.json" -Raw $ToolVersions = ConvertFrom-Json -InputObject $ToolVersionsFileContent diff --git a/images/win/scripts/Installers/Validate-ToolCache.ps1 b/images/win/scripts/Installers/Validate-ToolCache.ps1 index df61f6f6c..cde063511 100644 --- a/images/win/scripts/Installers/Validate-ToolCache.ps1 +++ b/images/win/scripts/Installers/Validate-ToolCache.ps1 @@ -37,14 +37,14 @@ function ToolcacheTest { if (Test-Path "$env:AGENT_TOOLSDIRECTORY\$SoftwareName") { $description = "" - [array]$instaledVersions = GetChildFolders -Path "$env:AGENT_TOOLSDIRECTORY\$SoftwareName" - if ($instaledVersions.count -gt 0){ + [array]$installedVersions = GetChildFolders -Path "$env:AGENT_TOOLSDIRECTORY\$SoftwareName" + if ($installedVersions.count -gt 0){ $softwarePackages = $packages | Where-Object { $_.ToolName -eq $SoftwareName } foreach($softwarePackage in $softwarePackages) { foreach ($version in $softwarePackage.Versions) { - $foundVersion = $instaledVersions | where { $_.StartsWith($version) } + $foundVersion = $installedVersions | where { $_.StartsWith($version) } if ($foundVersion -ne $null){ From 1f4d54a801c6bef7a418b8efc66122450ea4896a Mon Sep 17 00:00:00 2001 From: Maksim Petrov Date: Mon, 30 Dec 2019 15:59:47 +0300 Subject: [PATCH 4/7] Toolcache: fix typo in comment for test-toolcache.sh --- images/linux/scripts/installers/test-toolcache.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/linux/scripts/installers/test-toolcache.sh b/images/linux/scripts/installers/test-toolcache.sh index 785218b3e..203a5afe3 100644 --- a/images/linux/scripts/installers/test-toolcache.sh +++ b/images/linux/scripts/installers/test-toolcache.sh @@ -9,7 +9,7 @@ # Fail out if any tests fail set -e -# defune array of key aliases +# define array of key aliases key_alias_array=() bash --version # define dicionary for key_alias and its values From d98bb53cf6015cd6581cc13e83dbfed480f06c53 Mon Sep 17 00:00:00 2001 From: Maksim Petrov Date: Mon, 6 Jan 2020 14:53:39 +0300 Subject: [PATCH 5/7] Toolcache: fix typo in test-toolcache comment --- images/linux/scripts/installers/test-toolcache.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/linux/scripts/installers/test-toolcache.sh b/images/linux/scripts/installers/test-toolcache.sh index 203a5afe3..0a64882a2 100644 --- a/images/linux/scripts/installers/test-toolcache.sh +++ b/images/linux/scripts/installers/test-toolcache.sh @@ -12,7 +12,7 @@ set -e # define array of key aliases key_alias_array=() bash --version -# define dicionary for key_alias and its values +# define dictionary for key_alias and its values declare -A toolcache_key_value PACKAGE_LIST=($(jq -r 'keys | .[]' "$INSTALLER_SCRIPT_FOLDER/toolcache.json")) for PACKAGE_NAME in ${PACKAGE_LIST[@]}; do From 9c67ed5210479082c9228c9ba8c523caef35986b Mon Sep 17 00:00:00 2001 From: Maksim Petrov <47208721+vmapetr@users.noreply.github.com> Date: Thu, 9 Jan 2020 15:27:54 +0300 Subject: [PATCH 6/7] Toolcache: Rework linux toolcache tests, add Ruby 2.7.0 support (#5) * Toolcache: rework linux toolcache tests * Toolcache: add Ruby 2.7 for windows/linux --- .../scripts/installers/test-toolcache.sh | 153 +++++++----------- images/linux/toolcache-1604.json | 2 +- images/linux/toolcache-1804.json | 2 +- images/win/toolcache.json | 2 +- 4 files changed, 59 insertions(+), 100 deletions(-) diff --git a/images/linux/scripts/installers/test-toolcache.sh b/images/linux/scripts/installers/test-toolcache.sh index 0a64882a2..c54118e19 100644 --- a/images/linux/scripts/installers/test-toolcache.sh +++ b/images/linux/scripts/installers/test-toolcache.sh @@ -6,112 +6,71 @@ # Must be procecessed after tool cache setup(hosted-tool-cache.sh). +Test_Hostedtoolcache_Tool() { + TOOL_NAME=$1 + TOOL_BIN_PATH=$2 + TOOL_COMMAND=$3 + + if [ -d "$AGENT_TOOLSDIRECTORY/$TOOL_NAME" ]; then + cd $AGENT_TOOLSDIRECTORY/$TOOL_NAME + + tool_dirs=($(find . -mindepth 1 -maxdepth 1 -type d | sed "s|^\./||")) + + echo "--------------------------------------------" + echo "$TOOL_NAME versions folders: ${tool_dirs[@]}" + echo "--------------------------------------------" + + if [ -n "$tool_dirs" ]; then + tool_key=$(echo $TOOL_NAME | tr "[:upper:]" "[:lower:]") + package_versions=($(jq -r ".[\"${TOOLCACHE_KEY_VALUE[$tool_key]}\"] | .[]" "$INSTALLER_SCRIPT_FOLDER/toolcache.json")) + + for tool_version in ${package_versions[@]} + do + version_dir=$(find . -name "$tool_version.*" -print -quit) + + echo "Test $AGENT_TOOLSDIRECTORY/$TOOL_NAME/$version_dir:" + + version_bin_path=$(find . -regex "$version_dir/$TOOL_BIN_PATH" -print -quit) + actual_version=$(eval $AGENT_TOOLSDIRECTORY/$TOOL_NAME/$version_bin_path $TOOL_COMMAND) + + if [ "$actual_version" = "$tool_version" ]; then + echo "Passed!" + else + echo "Expected: $tool_version; Actual: $actual_version" + + exit 1 + fi + done; + else + echo "$AGENT_TOOLSDIRECTORY/$tool_version does not include any folders" + + exit 1 + fi + else + echo "$AGENT_TOOLSDIRECTORY/$tool_version does not exist" + + exit 1 + fi +} + # Fail out if any tests fail set -e -# define array of key aliases -key_alias_array=() -bash --version # define dictionary for key_alias and its values -declare -A toolcache_key_value -PACKAGE_LIST=($(jq -r 'keys | .[]' "$INSTALLER_SCRIPT_FOLDER/toolcache.json")) -for PACKAGE_NAME in ${PACKAGE_LIST[@]}; do +declare -A TOOLCACHE_KEY_VALUE +package_list=($(jq -r 'keys | .[]' "$INSTALLER_SCRIPT_FOLDER/toolcache.json")) + +for package_name in ${package_list[@]}; do # get key alias - key_alias=$(echo $PACKAGE_NAME | cut -f2 -d-) - echo $key_alias + key_alias=$(echo $package_name | cut -f2 -d-) # set dictionary - toolcache_key_value+=(["$key_alias"]="$PACKAGE_NAME") + TOOLCACHE_KEY_VALUE+=(["$key_alias"]="$package_name") done; AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache -# Python test -if [ -d "$AGENT_TOOLSDIRECTORY/Python" ]; then - cd $AGENT_TOOLSDIRECTORY/Python - python_dirs=($(find . -mindepth 1 -maxdepth 1 -type d | sed "s|^\./||")) - echo "Python versions folders: ${python_dirs[@]}" - echo "------------------------------------------" - if [ -n "$python_dirs" ]; then - PACKAGE_VERSIONS=($(jq -r ".[\"${toolcache_key_value[python]}\"] | .[]" "$INSTALLER_SCRIPT_FOLDER/toolcache.json")) - for python_version in ${PACKAGE_VERSIONS[@]} - do - version_dir=$(find . -name "$python_version.*" -print -quit) - echo "Test $AGENT_TOOLSDIRECTORY/Python/$version_dir:" - actual_ver=$($AGENT_TOOLSDIRECTORY/Python/$version_dir/x64/python -c 'import sys;print(sys.version)'| head -1 | egrep -o '[0-9]+\.[0-9]+') - if [ "$actual_ver" = "$python_version" ]; then - echo "Passed!" - else - echo "Expected: $python_version; Actual: $actual_ver" - exit 1 - fi - done; - else - echo "$AGENT_TOOLSDIRECTORY/Python does not include any folders" - exit 1 - fi -else - echo "$AGENT_TOOLSDIRECTORY/Python does not exist" - exit 1 -fi - -# Ruby test -if [ -d "$AGENT_TOOLSDIRECTORY/Ruby" ]; then - cd $AGENT_TOOLSDIRECTORY/Ruby - ruby_dirs=($(find . -mindepth 1 -maxdepth 1 -type d | sed "s|^\./||")) - echo "Ruby versions folders: ${ruby_dirs[@]}" - echo "--------------------------------------" - if [ -n "$ruby_dirs" ]; then - PACKAGE_VERSIONS=($(jq -r ".[\"${toolcache_key_value[ruby]}\"] | .[]" "$INSTALLER_SCRIPT_FOLDER/toolcache.json")) - for ruby_version in ${PACKAGE_VERSIONS[@]} - do - version_dir=$(find . -name "$ruby_version.*" -print -quit) - echo "Test $AGENT_TOOLSDIRECTORY/Ruby/$version_dir:" - actual_ver=$($AGENT_TOOLSDIRECTORY/Ruby/$version_dir/x64/bin/ruby -e "puts RUBY_VERSION" | egrep -o '[0-9]+\.[0-9]+') - if [ "$actual_ver" = "$ruby_version" ]; then - echo "Passed!" - else - echo "Expected: $ruby_version; Actual: $actual_ver" - exit 1 - fi - done; - else - echo "$AGENT_TOOLSDIRECTORY/Ruby does not include any folders" - exit 1 - fi -else - echo "$AGENT_TOOLSDIRECTORY/Ruby does not exist" - exit 1 -fi - -# PyPy tests -if [ -d "$AGENT_TOOLSDIRECTORY/PyPy" ]; then - cd $AGENT_TOOLSDIRECTORY/PyPy - pypy_dirs=($(find . -mindepth 1 -maxdepth 1 -type d | sed "s|^\./||")) - echo "PyPy versions folders: ${pypy_dirs[@]}" - echo "------------------------------------------" - if [ -n "$pypy_dirs" ]; then - PACKAGE_VERSIONS=($(jq -r ".[\"${toolcache_key_value[pypy]}\"] | .[]" "$INSTALLER_SCRIPT_FOLDER/toolcache.json")) - for pypy_version in ${PACKAGE_VERSIONS[@]} - do - version_dir=$(find . -name "$pypy_version.*" -print -quit) - pypy_path=$(find . -regex "$version_dir/x64/bin/pypy[0-9]*" -print -quit) - echo $pypy_path - actual_ver=$($pypy_path -c 'import sys;print(sys.version)'| head -1 | egrep -o '[0-9]+\.[0-9]+' | cut -d '.' -f 1) - echo "actual_ver = $actual_ver : pypy_version = $pypy_version" - if [ "$actual_ver" = "$pypy_version" ]; then - echo "Passed!" - else - echo "Expected: $pypy_version; Actual: $actual_ver" - exit 1 - fi - done; - else - echo "$AGENT_TOOLSDIRECTORY/PyPy does not include any folders" - exit 1 - fi -else - echo "$AGENT_TOOLSDIRECTORY/PyPy does not exist" - exit 1 -fi \ No newline at end of file +Test_Hostedtoolcache_Tool "Python" "x64/python" "-c 'import sys;print(sys.version)'| head -1 | egrep -o '[0-9]+\.[0-9]+'" +Test_Hostedtoolcache_Tool "Ruby" "x64/bin/ruby" "-e 'puts RUBY_VERSION' | egrep -o '[0-9]+\.[0-9]+'" +Test_Hostedtoolcache_Tool "PyPy" "x64/bin/pypy[0-9]*" "-c 'import sys;print(sys.version)'| head -1 | egrep -o '[0-9]+\.[0-9]+' | cut -d '.' -f 1" diff --git a/images/linux/toolcache-1604.json b/images/linux/toolcache-1604.json index 2674d57af..ea7f73c24 100644 --- a/images/linux/toolcache-1604.json +++ b/images/linux/toolcache-1604.json @@ -3,7 +3,7 @@ "2.7", "3.5", "3.6", "3.7", "3.8" ], "toolcache-ruby-ubuntu-1604-x64": [ - "2.4", "2.5", "2.6" + "2.4", "2.5", "2.6", "2.7" ], "toolcache-pypy-ubuntu-1604-x64": [ "2", "3" diff --git a/images/linux/toolcache-1804.json b/images/linux/toolcache-1804.json index ca75563cd..b076eaf2c 100644 --- a/images/linux/toolcache-1804.json +++ b/images/linux/toolcache-1804.json @@ -3,7 +3,7 @@ "2.7", "3.5", "3.6", "3.7", "3.8" ], "toolcache-ruby-ubuntu-1804-x64": [ - "2.4", "2.5", "2.6" + "2.4", "2.5", "2.6", "2.7" ], "toolcache-pypy-ubuntu-1804-x64": [ "2", "3" diff --git a/images/win/toolcache.json b/images/win/toolcache.json index 69434da3a..32aae3d50 100644 --- a/images/win/toolcache.json +++ b/images/win/toolcache.json @@ -6,7 +6,7 @@ "2.7", "3.5", "3.6", "3.7", "3.8" ], "toolcache-ruby-windows-x64": [ - "2.4", "2.5", "2.6" + "2.4", "2.5", "2.6", "2.7" ], "toolcache-pypy-windows-x86": [ "2", "3" From 078d0714a3cde809a2954ee59e8c870a5aebda83 Mon Sep 17 00:00:00 2001 From: Maksim Petrov Date: Fri, 10 Jan 2020 16:31:22 +0300 Subject: [PATCH 7/7] Toolcache: Small improvement in linux toolcache tests --- images/linux/scripts/installers/test-toolcache.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/images/linux/scripts/installers/test-toolcache.sh b/images/linux/scripts/installers/test-toolcache.sh index c54118e19..2601db4b4 100644 --- a/images/linux/scripts/installers/test-toolcache.sh +++ b/images/linux/scripts/installers/test-toolcache.sh @@ -8,8 +8,7 @@ Test_Hostedtoolcache_Tool() { TOOL_NAME=$1 - TOOL_BIN_PATH=$2 - TOOL_COMMAND=$3 + TOOL_EXEC_TEST=$2 if [ -d "$AGENT_TOOLSDIRECTORY/$TOOL_NAME" ]; then cd $AGENT_TOOLSDIRECTORY/$TOOL_NAME @@ -30,8 +29,7 @@ Test_Hostedtoolcache_Tool() { echo "Test $AGENT_TOOLSDIRECTORY/$TOOL_NAME/$version_dir:" - version_bin_path=$(find . -regex "$version_dir/$TOOL_BIN_PATH" -print -quit) - actual_version=$(eval $AGENT_TOOLSDIRECTORY/$TOOL_NAME/$version_bin_path $TOOL_COMMAND) + actual_version=$(eval $AGENT_TOOLSDIRECTORY/$TOOL_NAME/$version_dir/$TOOL_EXEC_TEST) if [ "$actual_version" = "$tool_version" ]; then echo "Passed!" @@ -71,6 +69,6 @@ done; AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache -Test_Hostedtoolcache_Tool "Python" "x64/python" "-c 'import sys;print(sys.version)'| head -1 | egrep -o '[0-9]+\.[0-9]+'" -Test_Hostedtoolcache_Tool "Ruby" "x64/bin/ruby" "-e 'puts RUBY_VERSION' | egrep -o '[0-9]+\.[0-9]+'" -Test_Hostedtoolcache_Tool "PyPy" "x64/bin/pypy[0-9]*" "-c 'import sys;print(sys.version)'| head -1 | egrep -o '[0-9]+\.[0-9]+' | cut -d '.' -f 1" +Test_Hostedtoolcache_Tool "Python" "x64/python -c 'import sys;print(sys.version)'| head -1 | egrep -o '[0-9]+\.[0-9]+'" +Test_Hostedtoolcache_Tool "Ruby" "x64/bin/ruby -e 'puts RUBY_VERSION' | egrep -o '[0-9]+\.[0-9]+'" +Test_Hostedtoolcache_Tool "PyPy" "x64/bin/python -c 'import sys;print(sys.version)'| head -1 | egrep -o '[0-9]+\.[0-9]+' | cut -d '.' -f 1"