Merge branch 'master' into add-parallel-on-linux

This commit is contained in:
RammusXu
2020-02-03 09:43:20 +08:00
committed by GitHub
62 changed files with 2336 additions and 1755 deletions

View File

@@ -32,6 +32,7 @@ apt-fast install -y --no-install-recommends \
telnet \
time \
unzip \
upx \
wget \
zip \
tzdata
@@ -55,7 +56,7 @@ apt-fast install -y --no-install-recommends \
# Run tests to determine that the software installed as expected
echo "Testing to make sure that script performed as expected, and basic scenarios work"
for cmd in curl file ftp jq netcat ssh parallel rsync shellcheck sudo telnet time unzip wget zip; do
for cmd in curl file ftp jq netcat ssh parallel rsync shellcheck sudo telnet time unzip upx wget zip; do
if ! command -v $cmd; then
echo "$cmd was not installed"
exit 1
@@ -85,6 +86,7 @@ DocumentInstalledItemIndent "sudo"
DocumentInstalledItemIndent "telnet"
DocumentInstalledItemIndent "time"
DocumentInstalledItemIndent "unzip"
DocumentInstalledItemIndent "upx"
DocumentInstalledItemIndent "wget"
DocumentInstalledItemIndent "zip"
DocumentInstalledItemIndent "tzdata"

View File

@@ -7,7 +7,7 @@
source $HELPER_SCRIPTS/apt.sh
source $HELPER_SCRIPTS/document.sh
LATEST_DOTNET_PACKAGE=dotnet-sdk-3.0
LATEST_DOTNET_PACKAGES=("dotnet-sdk-3.0" "dotnet-sdk-3.1")
LSB_RELEASE=$(lsb_release -rs)
@@ -30,21 +30,23 @@ mksamples()
set -e
echo "Determing if .NET Core ($LATEST_DOTNET_PACKAGE) is installed"
if ! IsInstalled $LATEST_DOTNET_PACKAGE; then
echo "Could not find .NET Core ($LATEST_DOTNET_PACKAGE), installing..."
wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
dpkg -i packages-microsoft-prod.deb
apt-get update
apt-get install apt-transport-https
apt-get update
apt-get install $LATEST_DOTNET_PACKAGE
else
echo ".NET Core ($LATEST_DOTNET_PACKAGE) is already installed"
fi
for latest_package in ${LATEST_DOTNET_PACKAGES[@]}; do
echo "Determing if .NET Core ($latest_package) is installed"
if ! IsInstalled $latest_package; then
echo "Could not find .NET Core ($latest_package), installing..."
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-bionic-prod bionic main" > /etc/apt/sources.list.d/dotnetdev.list'
apt-get install apt-transport-https
apt-get update
apt-get install $latest_package -y
else
echo ".NET Core ($latest_package) is already installed"
fi
done
# Get list of all released SDKs from channels which are not end-of-life or preview
release_urls=("https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/2.1/releases.json" "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/2.2/releases.json" "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/2.1/releases.json")
release_urls=("https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/2.1/releases.json" "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/2.2/releases.json" "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/3.0/releases.json" "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/3.1/releases.json")
sdks=()
for release_url in ${release_urls[@]}; do
echo "${release_url}"

View File

@@ -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/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;
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;

View File

@@ -7,6 +7,6 @@
source $HELPER_SCRIPTS/document.sh
AddTitle "Hosted Ubuntu 1604 Image ($(lsb_release -ds))"
WriteItem "The following software is installed on machines in the Hosted Ubuntu 1604 ($IMAGE_VERSION) pool"
AddTitle "$(lsb_release -ds)"
WriteItem "The following software is installed on machines with the $IMAGE_VERSION update."
WriteItem "***"

View File

@@ -10,9 +10,6 @@ source $HELPER_SCRIPTS/apt.sh
set -e
echo "Install curl"
apt-get install -y --no-install-recommends curl
echo "Install dnsutils"
apt-get install -y --no-install-recommends dnsutils
@@ -64,6 +61,9 @@ apt-get install -y --no-install-recommends time
echo "Install unzip"
apt-get install -y --no-install-recommends unzip
echo "Install upx"
apt-get install -y --no-install-recommends upx
echo "Install wget"
apt-get install -y --no-install-recommends wget
@@ -153,6 +153,7 @@ DocumentInstalledItemIndent "sudo"
DocumentInstalledItemIndent "telnet"
DocumentInstalledItemIndent "time"
DocumentInstalledItemIndent "unzip"
DocumentInstalledItemIndent "upx"
DocumentInstalledItemIndent "wget"
DocumentInstalledItemIndent "zip"
DocumentInstalledItemIndent "tzdata"

View File

@@ -7,7 +7,7 @@
source $HELPER_SCRIPTS/apt.sh
source $HELPER_SCRIPTS/document.sh
LATEST_DOTNET_PACKAGE=dotnet-sdk-3.0
LATEST_DOTNET_PACKAGES=("dotnet-sdk-3.0" "dotnet-sdk-3.1")
LSB_RELEASE=$(lsb_release -rs)
@@ -30,21 +30,23 @@ mksamples()
set -e
echo "Determing if .NET Core ($LATEST_DOTNET_PACKAGE) is installed"
if ! IsInstalled $LATEST_DOTNET_PACKAGE; then
echo "Could not find .NET Core ($LATEST_DOTNET_PACKAGE), installing..."
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-bionic-prod bionic main" > /etc/apt/sources.list.d/dotnetdev.list'
apt-get install apt-transport-https
apt-get update
apt-get install $LATEST_DOTNET_PACKAGE -y
else
echo ".NET Core ($LATEST_DOTNET_PACKAGE) is already installed"
fi
for latest_package in ${LATEST_DOTNET_PACKAGES[@]}; do
echo "Determing if .NET Core ($latest_package) is installed"
if ! IsInstalled $latest_package; then
echo "Could not find .NET Core ($latest_package), installing..."
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-bionic-prod bionic main" > /etc/apt/sources.list.d/dotnetdev.list'
apt-get install apt-transport-https
apt-get update
apt-get install $latest_package -y
else
echo ".NET Core ($latest_package) is already installed"
fi
done
# Get list of all released SDKs from channels which are not end-of-life or preview
release_urls=("https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/2.1/releases.json" "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/2.2/releases.json" "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/3.0/releases.json")
release_urls=("https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/2.1/releases.json" "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/2.2/releases.json" "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/3.0/releases.json" "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/3.1/releases.json")
sdks=()
for release_url in ${release_urls[@]}; do
echo "${release_url}"

View File

@@ -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;

View File

@@ -7,6 +7,6 @@
source $HELPER_SCRIPTS/document.sh
AddTitle "Hosted Ubuntu 1804 Image ($(lsb_release -ds))"
WriteItem "The following software is installed on machines in the Hosted Ubuntu 1804 (v$IMAGE_VERSION) pool"
AddTitle "$(lsb_release -ds)"
WriteItem "The following software is installed on machines with the $IMAGE_VERSION update."
WriteItem "***"

View File

@@ -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

View File

@@ -28,4 +28,4 @@ done
# Document what was added to the image
echo "Lastly, documenting what we added to the metadata file"
DocumentInstalledItem "Clang 6.0 ($(clang-6.0 --version | head -n 1))"
DocumentInstalledItem "Clang 6.0 ($(clang-6.0 --version | head -n 1 | sed 's/~/\\~/g'))"

View File

@@ -12,7 +12,7 @@ echo "Checking to see if the installer script has already been run"
if command -v cmake; then
echo "Example variable already set to $EXAMPLE_VAR"
else
curl -sL https://cmake.org/files/v3.12/cmake-3.12.4-Linux-x86_64.sh -o cmakeinstall.sh \
curl -sL https://cmake.org/files/v3.16/cmake-3.16.2-Linux-x86_64.sh -o cmakeinstall.sh \
&& chmod +x cmakeinstall.sh \
&& ./cmakeinstall.sh --prefix=/usr/local --exclude-subdir \
&& rm cmakeinstall.sh

View File

@@ -1,7 +1,7 @@
#!/bin/bash
################################################################################
## File: google-chrome.sh
## Desc: Installs google-chrome
## Desc: Installs google-chrome, chromedriver and selenium server
################################################################################
# Source the helpers for use with the script
@@ -25,3 +25,55 @@ fi
# Document what was added to the image
echo "Lastly, documenting what we added to the metadata file"
DocumentInstalledItem "Google Chrome ($(google-chrome --version))"
CHROME_VERSION=$(google-chrome --product-version)
CHROME_VERSION=${CHROME_VERSION%.*}
# Determine latest release of chromedriver
# Compatibility of Google Chrome and Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/downloads/version-selection
LATEST_CHROMEDRIVER_VERSION=$(curl "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_VERSION")
# Download and unpack latest release of chromedriver
echo "Downloading chromedriver v$LATEST_CHROMEDRIVER_VERSION..."
wget "https://chromedriver.storage.googleapis.com/$LATEST_CHROMEDRIVER_VERSION/chromedriver_linux64.zip"
unzip chromedriver_linux64.zip
rm chromedriver_linux64.zip
CHROMEDRIVER_BIN="/usr/bin/chromedriver"
mv "chromedriver" $CHROMEDRIVER_BIN
chown root:root $CHROMEDRIVER_BIN
chmod +x $CHROMEDRIVER_BIN
echo "CHROMEWEBDRIVER=$CHROMEDRIVER_BIN" | tee -a /etc/environment
# Run tests to determine that the chromedriver installed as expected
echo "Testing to make sure that script performed as expected, and basic scenarios work"
if ! command -v chromedriver; then
echo "chromedriver was not installed"
exit 1
fi
echo "Lastly, documenting what we added to the metadata file"
DocumentInstalledItem "Chromedriver ($(chromedriver --version)); Chrome Driver is available via CHROMEWEBDRIVER environment variable"
# Determine latest selenium standalone server version
SELENIUM_LATEST_VERSION_URL=https://api.github.com/repos/SeleniumHQ/selenium/releases/latest
SELENIUM_VERSION=$(curl $SELENIUM_LATEST_VERSION_URL | jq '.name' | tr -d '"' | cut -d ' ' -f 2)
SELENIUM_VERSION_MAJOR_MINOR=$(echo $SELENIUM_VERSION | cut -d '.' -f 1,2)
# Download selenium standalone server
echo "Downloading selenium-server-standalone v$SELENIUM_VERSION..."
SELENIUM_JAR_NAME="selenium-server-standalone-$SELENIUM_VERSION.jar"
wget https://selenium-release.storage.googleapis.com/$SELENIUM_VERSION_MAJOR_MINOR/$SELENIUM_JAR_NAME
echo "Testing to make sure that script performed as expected, and basic scenarios work"
if [ ! -f "$SELENIUM_JAR_NAME" ]; then
echo "Selenium server was not installed"
exit 1
fi
SELENIUM_JAR_PATH="/usr/share/java/selenium-server-standalone.jar"
mv $SELENIUM_JAR_NAME $SELENIUM_JAR_PATH
echo "SELENIUM_JAR_PATH=$SELENIUM_JAR_PATH" | tee -a /etc/environment
echo "Lastly, documenting what we added to the metadata file"
DocumentInstalledItem "Selenium server standalone (available via SELENIUM_JAR_PATH environment variable)"

View File

@@ -0,0 +1,68 @@
#!/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
TOOLCACHE_REGISTRY="npm.pkg.github.com"
AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache
mkdir $AGENT_TOOLSDIRECTORY
echo "AGENT_TOOLSDIRECTORY=$AGENT_TOOLSDIRECTORY" | tee -a /etc/environment
chmod -R 777 $AGENT_TOOLSDIRECTORY
echo "Configure npm to use github package registry for '@actions' scope"
npm config set @actions:registry "https://${TOOLCACHE_REGISTRY}"
# Execute in /imagegeneration/installers folder to avoid node_modules creation in $HOME
pushd $INSTALLER_SCRIPT_FOLDER
# GitHub Package Registry doesn't support downloading public packages without auth so we have to authorize
echo "Configure auth for github package registry"
echo "//${TOOLCACHE_REGISTRY}/:_authToken=${GITHUB_FEED_TOKEN}" > ".npmrc"
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}
exit_code=$?
if [ $exit_code -ne 0 ]; then
echo "${PACKAGE_NAME}@${PACKAGE_VERSION} installation failure; Error:${exit_code}"
exit 1
fi
done;
done;
popd
DocumentInstalledItem "Python:"
pythons=$(ls $AGENT_TOOLSDIRECTORY/Python)
for python in $pythons; do
DocumentInstalledItemIndent "Python $python"
done;
DocumentInstalledItem "Ruby:"
rubys=$(ls $AGENT_TOOLSDIRECTORY/Ruby)
for ruby in $rubys; do
DocumentInstalledItemIndent "Ruby $ruby"
done;
DocumentInstalledItem "PyPy:"
pypys=$(ls $AGENT_TOOLSDIRECTORY/PyPy)
for pypy in $pypys; do
DocumentInstalledItemIndent "PyPy $pypy"
done;

View File

@@ -9,7 +9,7 @@ source $HELPER_SCRIPTS/document.sh
source $HELPER_SCRIPTS/apt.sh
# Install KIND
KIND_VERSION="v0.5.1"
KIND_VERSION="v0.7.0"
curl -L -o /usr/local/bin/kind "https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-linux-amd64"
chmod +x /usr/local/bin/kind

View File

@@ -12,6 +12,9 @@ export ACCEPT_EULA=Y
# Install MySQL Client
apt-get install mysql-client -y
# InstallMySQL database development files
apt-get install libmysqlclient-dev -y
# Install MySQL Server
MYSQL_ROOT_PASSWORD=root
echo "mysql-server mysql-server/root_password password $MYSQL_ROOT_PASSWORD" | debconf-set-selections

View File

@@ -7,5 +7,11 @@
# Source the helpers for use with the script
source $HELPER_SCRIPTS/document.sh
sudo apt-get install ruby-full
sudo gem update --system
# Install Ruby requirements
apt-get install -y libz-dev openssl libssl-dev
DocumentInstalledItem "ruby ($(ruby --version 2>&1 | cut -d ' ' -f 2))"
DocumentInstalledItem "gem ($(gem -v 2>&1 | tail -n 1))"

View File

@@ -6,65 +6,69 @@
# Must be procecessed after tool cache setup(hosted-tool-cache.sh).
Test_Hostedtoolcache_Tool() {
TOOL_NAME=$1
TOOL_EXEC_TEST=$2
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:"
actual_version=$(eval $AGENT_TOOLSDIRECTORY/$TOOL_NAME/$version_dir/$TOOL_EXEC_TEST)
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 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
# get key alias
key_alias=$(echo $package_name | cut -f2 -d-)
# set dictionary
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
for version_dir in "${python_dirs[@]}"
do
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
echo "Passed!"
else
echo "Expected: $expected_ver; 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
for version_dir in "${ruby_dirs[@]}"
do
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!"
else
echo "Expected: $expected_ver; 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
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"