diff --git a/images/macos/provision/core/ruby.sh b/images/macos/provision/core/ruby.sh index 61eb33c0..cf42b156 100755 --- a/images/macos/provision/core/ruby.sh +++ b/images/macos/provision/core/ruby.sh @@ -4,3 +4,40 @@ source ~/utils/utils.sh echo Installing Ruby... brew install ruby + +#if High Sierra - skip installation from toolset +if is_HighSierra; then + exit 0 +fi + +echo "Install Ruby from toolset..." +PACKAGE_TAR_NAMES=$(curl -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$" | 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 \ No newline at end of file diff --git a/images/macos/provision/core/toolcache.sh b/images/macos/provision/core/toolcache.sh deleted file mode 100755 index dab45deb..00000000 --- a/images/macos/provision/core/toolcache.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -e -o pipefail - -# Download hosted tool cache with npm -NPM_FEED="npm.pkg.github.com" -TOOLSET_PATH="$HOME/image-generation/toolcache.json" - -echo "Installing npm-toolcache..." -PACKAGE_LIST=($(jq -r 'keys | .[]' $TOOLSET_PATH)) - -# Execute in /tmp folder to avoid node_modules creation in $HOME -pushd /tmp - -# GitHub Package Registry doesn't support downloading public packages without auth so we have to authorize -# Put the .npmrc to /tmp directory on the image to make sure that it will deleted after image generation -echo "Configure auth for github package registry" -echo "@actions:registry=https://${NPM_FEED}/" >> ".npmrc" -echo "//${NPM_FEED}/:_authToken=${GITHUB_FEED_TOKEN}" >> ".npmrc" - -echo "Install packages..." -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; - -rm -f ".npmrc" - -popd \ No newline at end of file diff --git a/images/macos/templates/macOS-10.13.json b/images/macos/templates/macOS-10.13.json index 24ae7c3f..e9354e88 100644 --- a/images/macos/templates/macOS-10.13.json +++ b/images/macos/templates/macOS-10.13.json @@ -11,7 +11,6 @@ "output_folder": null, "vm_username": null, "vm_password": null, - "github_feed_token": null, "xcode_install_user": null, "xcode_install_password": null, "image_os": "macos1013" @@ -87,11 +86,6 @@ "source": "./toolsets/toolset-10.13.json", "destination": "~/image-generation/toolset.json" }, - { - "type": "file", - "source": "./toolsets/toolcache-10.13.json", - "destination": "~/image-generation/toolcache.json" - }, { "type": "shell", "execute_command": "chmod +x {{ .Path }}; sudo {{ .Vars }} {{ .Path }}", diff --git a/images/macos/templates/macOS-10.14.json b/images/macos/templates/macOS-10.14.json index e99ff39d..1dcec501 100644 --- a/images/macos/templates/macOS-10.14.json +++ b/images/macos/templates/macOS-10.14.json @@ -11,7 +11,6 @@ "output_folder": null, "vm_username": null, "vm_password": null, - "github_feed_token": null, "xcode_install_user": null, "xcode_install_password": null, "image_os": "macos1014" @@ -87,11 +86,6 @@ "source": "./toolsets/toolset-10.14.json", "destination": "~/image-generation/toolset.json" }, - { - "type": "file", - "source": "./toolsets/toolcache-10.14.json", - "destination": "~/image-generation/toolcache.json" - }, { "type": "shell", "execute_command": "chmod +x {{ .Path }}; sudo {{ .Vars }} {{ .Path }}", @@ -187,12 +181,8 @@ "./provision/core/miniconda.sh", "./provision/core/xcode-sims.sh", "./provision/core/xcode-postbuild.sh", - "./provision/core/toolcache.sh", "./provision/core/pypy.sh", "./provision/core/pipx-packages.sh" - ], - "environment_vars": [ - "GITHUB_FEED_TOKEN={{user `github_feed_token`}}" ] }, { diff --git a/images/macos/templates/macOS-10.15.json b/images/macos/templates/macOS-10.15.json index 530175f0..4d9ec838 100644 --- a/images/macos/templates/macOS-10.15.json +++ b/images/macos/templates/macOS-10.15.json @@ -11,7 +11,6 @@ "output_folder": null, "vm_username": null, "vm_password": null, - "github_feed_token": null, "xcode_install_user": null, "xcode_install_password": null, "image_os": "macos1015" @@ -87,11 +86,6 @@ "source": "./toolsets/toolset-10.15.json", "destination": "~/image-generation/toolset.json" }, - { - "type": "file", - "source": "./toolsets/toolcache-10.14.json", - "destination": "~/image-generation/toolcache.json" - }, { "type": "shell", "execute_command": "chmod +x {{ .Path }}; sudo {{ .Vars }} {{ .Path }}", @@ -188,12 +182,8 @@ "./provision/core/edge.sh", "./provision/core/firefox.sh", "./provision/core/xcode-postbuild.sh", - "./provision/core/toolcache.sh", "./provision/core/pypy.sh", "./provision/core/pipx-packages.sh" - ], - "environment_vars": [ - "GITHUB_FEED_TOKEN={{user `github_feed_token`}}" ] }, { diff --git a/images/macos/templates/macOS-11.0.json b/images/macos/templates/macOS-11.0.json index debb3c34..663beec3 100644 --- a/images/macos/templates/macOS-11.0.json +++ b/images/macos/templates/macOS-11.0.json @@ -11,7 +11,6 @@ "output_folder": null, "vm_username": null, "vm_password": null, - "github_feed_token": null, "xcode_install_user": null, "xcode_install_password": null, "image_os": "macos11" @@ -87,11 +86,6 @@ "source": "./toolsets/toolset-11.0.json", "destination": "~/image-generation/toolset.json" }, - { - "type": "file", - "source": "./toolsets/toolcache-11.0.json", - "destination": "~/image-generation/toolcache.json" - }, { "type": "shell", "execute_command": "chmod +x {{ .Path }}; sudo {{ .Vars }} {{ .Path }}", @@ -185,11 +179,7 @@ "./provision/core/chrome.sh", "./provision/core/edge.sh", "./provision/core/firefox.sh", - "./provision/core/toolcache.sh", "./provision/core/pipx-packages.sh" - ], - "environment_vars": [ - "GITHUB_FEED_TOKEN={{user `github_feed_token`}}" ] }, { diff --git a/images/macos/tests/Toolcache.Tests.ps1 b/images/macos/tests/Toolcache.Tests.ps1 index fc4a3729..74ac6cfd 100644 --- a/images/macos/tests/Toolcache.Tests.ps1 +++ b/images/macos/tests/Toolcache.Tests.ps1 @@ -1,240 +1,243 @@ -Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1" -Import-Module "$PSScriptRoot/../helpers/Tests.Helpers.psm1" - -$os = Get-OSVersion - -Describe "Toolcache" { - $toolcacheDirectory = Join-Path $env:HOME "hostedtoolcache" - $packages = (Get-ToolcachePackages).PSObject.Properties | ForEach-Object { - $packageNameParts = $_.Name.Split("-") - return [PSCustomObject] @{ - ToolName = $packageNameParts[1] - Arch = $packageNameParts[4] - Versions = $_.Value - } - } - - [array]$packages += Get-ToolsetValue -KeyPath "toolcache" | ForEach-Object { - return [PSCustomObject] @{ - ToolName = ($_.name).ToLower() - Arch = $_.arch - Versions = $_.versions | ForEach-Object { $_.Replace(".*", "") } - } - } - - Context "Python" { - $pythonDirectory = Join-Path $toolcacheDirectory "Python" - $pythonPackage = $packages | Where-Object { $_.ToolName -eq "python" } | Select-Object -First 1 - $testCase = @{ PythonDirectory = $pythonDirectory } - - It "Toolcache directory exists" -TestCases $testCase { - param ( [string] $PythonDirectory ) - - $PythonDirectory | Should -Exist - } - - It "Toolcache directory contains at least one version of Python" -TestCases $testCase { - param ( [string] $PythonDirectory ) - - (Get-ChildItem -Path $PythonDirectory -Directory).Count | Should -BeGreaterThan 0 - } - - $pythonPackage.Versions | Where-Object { $_ } | ForEach-Object { - Context "$_" { - $versionDirectory = Get-ChildItem -Path $pythonDirectory -Directory -Filter "$_*" | Select-Object -First 1 - $pythonBinPath = Join-Path $versionDirectory.FullName $pythonPackage.Arch "python" - $testCase = @{ PythonVersion = $_; PythonBinPath = $pythonBinPath } - - It "Version" -TestCases $testCase { - param ( - [string] $PythonVersion, - [string] $PythonBinPath - ) - - $result = Get-CommandResult "$PythonBinPath --version" - $result.Output | Should -BeLike "*$PythonVersion*" - $result.ExitCode | Should -Be 0 - } - - It "Run test script" -TestCases $testCase { - param ( [string] $PythonBinPath ) - - "$PythonBinPath -c 'import sys;print(sys.version)'" | Should -ReturnZeroExitCode - } - } - } - } - - Context "Ruby" { - $rubyDirectory = Join-Path $toolcacheDirectory "Ruby" - $rubyPackage = $packages | Where-Object { $_.ToolName -eq "ruby" } | Select-Object -First 1 - $testCase = @{ RubyDirectory = $rubyDirectory } - - It "Toolcache directory exists" -TestCases $testCase { - param ( [string] $RubyDirectory ) - - $RubyDirectory | Should -Exist - } - - It "Toolcache directory contains at least one version of Ruby" -TestCases $testCase { - param ( [string] $RubyDirectory ) - - (Get-ChildItem -Path $RubyDirectory -Directory).Count | Should -BeGreaterThan 0 - } - - $rubyPackage.Versions | Where-Object { $_ } | ForEach-Object { - Context "$_" { - $versionDirectory = Get-ChildItem -Path $rubyDirectory -Directory -Filter "$_*" | Select-Object -First 1 - $rubyBinPath = Join-Path $versionDirectory.FullName $rubyPackage.Arch "bin" "ruby" - $testCase = @{ RubyVersion = $_; RubyBinPath = $rubyBinPath } - - It "Version" -TestCases $testCase { - param ( - [string] $RubyVersion, - [string] $RubyBinPath - ) - - $result = Get-CommandResult "$RubyBinPath --version" - $result.Output | Should -BeLike "*$RubyVersion*" - $result.ExitCode | Should -Be 0 - } - - It "Run test script" -TestCases $testCase { - param ( [string] $RubyBinPath ) - - "$RubyBinPath -e 'puts RUBY_VERSION'" | Should -ReturnZeroExitCode - } - } - } - } - Context "PyPy" -Skip:($os.IsBigSur) { - $pypyDirectory = Join-Path $toolcacheDirectory "PyPy" - $pypyPackage = $packages | Where-Object { $_.ToolName -eq "pypy" } | Select-Object -First 1 - $testCase = @{ PypyDirectory = $pypyDirectory } - - It "Toolcache directory exists" -TestCases $testCase { - param ( [string] $PypyDirectory ) - - $PypyDirectory | Should -Exist - } - - It "Toolcache directory contains at least one version of PyPy" -TestCases $testCase { - param ( [string] $PypyDirectory ) - - (Get-ChildItem -Path $PypyDirectory -Directory).Count | Should -BeGreaterThan 0 - } - - $pypyPackage.Versions | Where-Object { $_ } | ForEach-Object { - Context "$_" { - $versionDirectory = Get-ChildItem -Path $pypyDirectory -Directory -Filter "$_*" | Select-Object -First 1 - $binFilename = If ($_.StartsWith("3")) { "pypy3" } else { "pypy" } - $pypyBinPath = Join-Path $versionDirectory.FullName $pypyPackage.Arch "bin" $binFilename - $testCase = @{ PypyVersion = $_; PypyBinPath = $pypyBinPath } - - It "Version" -TestCases $testCase { - param ( - [string] $PypyVersion, - [string] $PypyBinPath - ) - - $result = Get-CommandResult "$PypyBinPath --version" - $result.Output | Should -BeLike "*$PypyVersion*" - $result.ExitCode | Should -Be 0 - } - - It "Run test script" -TestCases $testCase { - param ( [string] $PypyBinPath ) - - "$PypyBinPath -c 'import sys;print(sys.version)'" | Should -ReturnZeroExitCode - } - } - } - } - - Context "Node" -Skip:($os.IsHighSierra) { - $nodeDirectory = Join-Path $toolcacheDirectory "node" - $nodePackage = $packages | Where-Object { $_.ToolName -eq "node" } | Select-Object -First 1 - $testCase = @{ NodeDirectory = $nodeDirectory } - - It "Toolcache directory exists" -TestCases $testCase { - param ( [string] $NodeDirectory ) - - $NodeDirectory | Should -Exist - } - - It "Toolcache directory contains at least one version of Node" -TestCases $testCase { - param ( [string] $NodeDirectory ) - - (Get-ChildItem -Path $NodeDirectory -Directory).Count | Should -BeGreaterThan 0 - } - - $nodePackage.Versions | Where-Object { $_ } | ForEach-Object { - Context "$_" { - $versionDirectory = Get-ChildItem -Path $nodeDirectory -Directory -Filter "$_*" | Select-Object -First 1 - $nodeBinPath = Join-Path $versionDirectory.FullName $nodePackage.Arch "bin" "node" - $npmBinPath = Join-Path $versionDirectory.FullName $nodePackage.Arch "bin" "npm" - $testCase = @{ NodeVersion = $_; NodeBinPath = $nodeBinPath; NpmBinPath = $npmBinPath } - - It "Version Node" -TestCases $testCase { - param ( - [string] $NodeVersion, - [string] $NodeBinPath - ) - - $result = Get-CommandResult "$NodeBinPath --version" - $result.Output | Should -BeLike "*$NodeVersion*" - $result.ExitCode | Should -Be 0 - } - - It "Version Npm" -TestCases $testCase { - param ( [string] $NpmBinPath ) - - "$NpmBinPath --version" | Should -ReturnZeroExitCode - } - - It "Run test script" -TestCases $testCase { - param ( [string] $NodeBinPath ) - - "$NodeBinPath -e 'console.log(process.version)'" | Should -ReturnZeroExitCode - } - } - } - } - - Context "Go" -Skip:($os.IsHighSierra) { - $goDirectory = Join-Path $toolcacheDirectory "go" - $goPackage = $packages | Where-Object { $_.ToolName -eq "go" } | Select-Object -First 1 - $testCase = @{ GoDirectory = $goDirectory } - - It "Toolcache directory exists" -TestCases $testCase { - param ( [string] $GoDirectory ) - - $GoDirectory | Should -Exist - } - - It "Toolcache directory contains at least one version of Go" -TestCases $testCase { - param ( [string] $GoDirectory ) - - (Get-ChildItem -Path $GoDirectory -Directory).Count | Should -BeGreaterThan 0 - } - - $goPackage.Versions | Where-Object { $_ } | ForEach-Object { - Context "$_" { - $versionDirectory = Get-ChildItem -Path $goDirectory -Directory -Filter "$_*" | Select-Object -First 1 - $goBinPath = Join-Path $versionDirectory.FullName $goPackage.Arch "bin" "go" - $testCase = @{ GoVersion = $_; GoBinPath = $goBinPath } - - It "Version Go" -TestCases $testCase { - param ( - [string] $GoVersion, - [string] $GoBinPath - ) - - $result = Get-CommandResult "$GoBinPath version" - $result.Output | Should -BeLike "*$GoVersion*" - $result.ExitCode | Should -Be 0 - } - } - } - } +Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1" +Import-Module "$PSScriptRoot/../helpers/Tests.Helpers.psm1" + +$os = Get-OSVersion + +Describe "Toolcache" { + $toolcacheDirectory = Join-Path $env:HOME "hostedtoolcache" + [array]$packages = @() + if ($os.IsHighSierra) { + [array]$packages += (Get-ToolcachePackages).PSObject.Properties | ForEach-Object { + $packageNameParts = $_.Name.Split("-") + return [PSCustomObject] @{ + ToolName = $packageNameParts[1] + Arch = $packageNameParts[4] + Versions = $_.Value + } + } + } + + [array]$packages += Get-ToolsetValue -KeyPath "toolcache" | ForEach-Object { + return [PSCustomObject] @{ + ToolName = ($_.name).ToLower() + Arch = $_.arch + Versions = $_.versions | ForEach-Object { $_.Replace(".*", "") } + } + } + + Context "Python" { + $pythonDirectory = Join-Path $toolcacheDirectory "Python" + $pythonPackage = $packages | Where-Object { $_.ToolName -eq "python" } | Select-Object -First 1 + $testCase = @{ PythonDirectory = $pythonDirectory } + + It "Toolcache directory exists" -TestCases $testCase { + param ( [string] $PythonDirectory ) + + $PythonDirectory | Should -Exist + } + + It "Toolcache directory contains at least one version of Python" -TestCases $testCase { + param ( [string] $PythonDirectory ) + + (Get-ChildItem -Path $PythonDirectory -Directory).Count | Should -BeGreaterThan 0 + } + + $pythonPackage.Versions | Where-Object { $_ } | ForEach-Object { + Context "$_" { + $versionDirectory = Get-ChildItem -Path $pythonDirectory -Directory -Filter "$_*" | Select-Object -First 1 + $pythonBinPath = Join-Path $versionDirectory.FullName $pythonPackage.Arch "python" + $testCase = @{ PythonVersion = $_; PythonBinPath = $pythonBinPath } + + It "Version" -TestCases $testCase { + param ( + [string] $PythonVersion, + [string] $PythonBinPath + ) + + $result = Get-CommandResult "$PythonBinPath --version" + $result.Output | Should -BeLike "*$PythonVersion*" + $result.ExitCode | Should -Be 0 + } + + It "Run test script" -TestCases $testCase { + param ( [string] $PythonBinPath ) + + "$PythonBinPath -c 'import sys;print(sys.version)'" | Should -ReturnZeroExitCode + } + } + } + } + + Context "Ruby" { + $rubyDirectory = Join-Path $toolcacheDirectory "Ruby" + $rubyPackage = $packages | Where-Object { $_.ToolName -eq "Ruby" } | Select-Object -First 1 + $testCase = @{ RubyDirectory = $rubyDirectory } + + It "Toolcache directory exists" -TestCases $testCase { + param ( [string] $RubyDirectory ) + + $RubyDirectory | Should -Exist + } + + It "Toolcache directory contains at least one version of Ruby" -TestCases $testCase { + param ( [string] $RubyDirectory ) + + (Get-ChildItem -Path $RubyDirectory -Directory).Count | Should -BeGreaterThan 0 + } + + $rubyPackage.Versions | Where-Object { $_ } | ForEach-Object { + Context "$_" { + $versionDirectory = Get-ChildItem -Path $rubyDirectory -Directory -Filter "$_*" | Select-Object -First 1 + $rubyBinPath = Join-Path $versionDirectory.FullName $rubyPackage.Arch "bin" "ruby" + $testCase = @{ RubyVersion = $_; RubyBinPath = $rubyBinPath } + + It "Version" -TestCases $testCase { + param ( + [string] $RubyVersion, + [string] $RubyBinPath + ) + + $result = Get-CommandResult "$RubyBinPath --version" + $result.Output | Should -BeLike "*$RubyVersion*" + $result.ExitCode | Should -Be 0 + } + + It "Run test script" -TestCases $testCase { + param ( [string] $RubyBinPath ) + + "$RubyBinPath -e 'puts RUBY_VERSION'" | Should -ReturnZeroExitCode + } + } + } + } + Context "PyPy" -Skip:($os.IsBigSur) { + $pypyDirectory = Join-Path $toolcacheDirectory "PyPy" + $pypyPackage = $packages | Where-Object { $_.ToolName -eq "pypy" } | Select-Object -First 1 + $testCase = @{ PypyDirectory = $pypyDirectory } + + It "Toolcache directory exists" -TestCases $testCase { + param ( [string] $PypyDirectory ) + + $PypyDirectory | Should -Exist + } + + It "Toolcache directory contains at least one version of PyPy" -TestCases $testCase { + param ( [string] $PypyDirectory ) + + (Get-ChildItem -Path $PypyDirectory -Directory).Count | Should -BeGreaterThan 0 + } + + $pypyPackage.Versions | Where-Object { $_ } | ForEach-Object { + Context "$_" { + $versionDirectory = Get-ChildItem -Path $pypyDirectory -Directory -Filter "$_*" | Select-Object -First 1 + $binFilename = If ($_.StartsWith("3")) { "pypy3" } else { "pypy" } + $pypyBinPath = Join-Path $versionDirectory.FullName $pypyPackage.Arch "bin" $binFilename + $testCase = @{ PypyVersion = $_; PypyBinPath = $pypyBinPath } + + It "Version" -TestCases $testCase { + param ( + [string] $PypyVersion, + [string] $PypyBinPath + ) + + $result = Get-CommandResult "$PypyBinPath --version" + $result.Output | Should -BeLike "*$PypyVersion*" + $result.ExitCode | Should -Be 0 + } + + It "Run test script" -TestCases $testCase { + param ( [string] $PypyBinPath ) + + "$PypyBinPath -c 'import sys;print(sys.version)'" | Should -ReturnZeroExitCode + } + } + } + } + + Context "Node" -Skip:($os.IsHighSierra) { + $nodeDirectory = Join-Path $toolcacheDirectory "node" + $nodePackage = $packages | Where-Object { $_.ToolName -eq "node" } | Select-Object -First 1 + $testCase = @{ NodeDirectory = $nodeDirectory } + + It "Toolcache directory exists" -TestCases $testCase { + param ( [string] $NodeDirectory ) + + $NodeDirectory | Should -Exist + } + + It "Toolcache directory contains at least one version of Node" -TestCases $testCase { + param ( [string] $NodeDirectory ) + + (Get-ChildItem -Path $NodeDirectory -Directory).Count | Should -BeGreaterThan 0 + } + + $nodePackage.Versions | Where-Object { $_ } | ForEach-Object { + Context "$_" { + $versionDirectory = Get-ChildItem -Path $nodeDirectory -Directory -Filter "$_*" | Select-Object -First 1 + $nodeBinPath = Join-Path $versionDirectory.FullName $nodePackage.Arch "bin" "node" + $npmBinPath = Join-Path $versionDirectory.FullName $nodePackage.Arch "bin" "npm" + $testCase = @{ NodeVersion = $_; NodeBinPath = $nodeBinPath; NpmBinPath = $npmBinPath } + + It "Version Node" -TestCases $testCase { + param ( + [string] $NodeVersion, + [string] $NodeBinPath + ) + + $result = Get-CommandResult "$NodeBinPath --version" + $result.Output | Should -BeLike "*$NodeVersion*" + $result.ExitCode | Should -Be 0 + } + + It "Version Npm" -TestCases $testCase { + param ( [string] $NpmBinPath ) + + "$NpmBinPath --version" | Should -ReturnZeroExitCode + } + + It "Run test script" -TestCases $testCase { + param ( [string] $NodeBinPath ) + + "$NodeBinPath -e 'console.log(process.version)'" | Should -ReturnZeroExitCode + } + } + } + } + + Context "Go" -Skip:($os.IsHighSierra) { + $goDirectory = Join-Path $toolcacheDirectory "go" + $goPackage = $packages | Where-Object { $_.ToolName -eq "go" } | Select-Object -First 1 + $testCase = @{ GoDirectory = $goDirectory } + + It "Toolcache directory exists" -TestCases $testCase { + param ( [string] $GoDirectory ) + + $GoDirectory | Should -Exist + } + + It "Toolcache directory contains at least one version of Go" -TestCases $testCase { + param ( [string] $GoDirectory ) + + (Get-ChildItem -Path $GoDirectory -Directory).Count | Should -BeGreaterThan 0 + } + + $goPackage.Versions | Where-Object { $_ } | ForEach-Object { + Context "$_" { + $versionDirectory = Get-ChildItem -Path $goDirectory -Directory -Filter "$_*" | Select-Object -First 1 + $goBinPath = Join-Path $versionDirectory.FullName $goPackage.Arch "bin" "go" + $testCase = @{ GoVersion = $_; GoBinPath = $goBinPath } + + It "Version Go" -TestCases $testCase { + param ( + [string] $GoVersion, + [string] $GoBinPath + ) + + $result = Get-CommandResult "$GoBinPath version" + $result.Output | Should -BeLike "*$GoVersion*" + $result.ExitCode | Should -Be 0 + } + } + } + } } \ No newline at end of file diff --git a/images/macos/toolsets/toolcache-10.13.json b/images/macos/toolsets/toolcache-10.13.json deleted file mode 100644 index 1d415ac7..00000000 --- a/images/macos/toolsets/toolcache-10.13.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "@actions/toolcache-python-macos-1013-x64": [ - "2.7", "3.5", "3.6", "3.7", "3.8" - ], - "@actions/toolcache-ruby-macos-1013-x64": [ - "2.4", "2.5", "2.6", "2.7" - ] -} \ No newline at end of file diff --git a/images/macos/toolsets/toolcache-10.14.json b/images/macos/toolsets/toolcache-10.14.json deleted file mode 100644 index 4826303e..00000000 --- a/images/macos/toolsets/toolcache-10.14.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "@actions/toolcache-ruby-macos-1013-x64": [ - "2.4", "2.5", "2.6", "2.7" - ] -} \ No newline at end of file diff --git a/images/macos/toolsets/toolcache-11.0.json b/images/macos/toolsets/toolcache-11.0.json deleted file mode 100644 index 4826303e..00000000 --- a/images/macos/toolsets/toolcache-11.0.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "@actions/toolcache-ruby-macos-1013-x64": [ - "2.4", "2.5", "2.6", "2.7" - ] -} \ No newline at end of file diff --git a/images/macos/toolsets/toolset-10.13.json b/images/macos/toolsets/toolset-10.13.json index 8e2bcc9d..68343f01 100644 --- a/images/macos/toolsets/toolset-10.13.json +++ b/images/macos/toolsets/toolset-10.13.json @@ -210,6 +210,16 @@ "2.7", "3.6" ] + }, + { + "name": "Ruby", + "arch": "x64", + "versions": [ + "2.4.*", + "2.5.*", + "2.6.*", + "2.7.*" + ] } ], "pipx": [ diff --git a/images/macos/toolsets/toolset-10.14.json b/images/macos/toolsets/toolset-10.14.json index 9b1d3d30..16d3f86b 100644 --- a/images/macos/toolsets/toolset-10.14.json +++ b/images/macos/toolsets/toolset-10.14.json @@ -269,6 +269,16 @@ "1.14.*", "1.15.*" ] + }, + { + "name": "Ruby", + "arch": "x64", + "versions": [ + "2.4.*", + "2.5.*", + "2.6.*", + "2.7.*" + ] } ], "pipx": [ diff --git a/images/macos/toolsets/toolset-10.15.json b/images/macos/toolsets/toolset-10.15.json index 6a6e9b18..b682cd7b 100644 --- a/images/macos/toolsets/toolset-10.15.json +++ b/images/macos/toolsets/toolset-10.15.json @@ -190,6 +190,16 @@ "1.14.*", "1.15.*" ] + }, + { + "name": "Ruby", + "arch": "x64", + "versions": [ + "2.4.*", + "2.5.*", + "2.6.*", + "2.7.*" + ] } ], "pipx": [ diff --git a/images/macos/toolsets/toolset-11.0.json b/images/macos/toolsets/toolset-11.0.json index 1cdc2f46..8e6777e1 100644 --- a/images/macos/toolsets/toolset-11.0.json +++ b/images/macos/toolsets/toolset-11.0.json @@ -108,6 +108,16 @@ "versions": [ "1.15.*" ] + }, + { + "name": "Ruby", + "arch": "x64", + "versions": [ + "2.4.*", + "2.5.*", + "2.6.*", + "2.7.*" + ] } ], "pipx": [