From d022b0d6a8c5af920ebca61c6709f75f8f62aef3 Mon Sep 17 00:00:00 2001 From: Dibir Magomedsaygitov <61747324+dibir-magomedsaygitov@users.noreply.github.com> Date: Fri, 10 Sep 2021 14:41:17 +0300 Subject: [PATCH] [macOS] Move Ruby and Go versions to toolset (#4046) --- images/macos/provision/core/commonutils.sh | 3 --- images/macos/provision/core/golang.sh | 11 +++++++++++ images/macos/provision/core/ruby.sh | 3 ++- images/macos/provision/core/rubygem.sh | 2 +- images/macos/templates/macOS-10.13.json | 1 + images/macos/templates/macOS-10.14.json | 1 + images/macos/templates/macOS-10.15.json | 1 + images/macos/templates/macOS-11.json | 1 + images/macos/tests/BasicTools.Tests.ps1 | 5 ----- images/macos/tests/Common.Tests.ps1 | 6 ++++++ images/macos/tests/RubyGem.Tests.ps1 | 2 +- images/macos/toolsets/toolset-10.13.json | 15 +++++++++++++- images/macos/toolsets/toolset-10.14.json | 23 +++++++++++++--------- images/macos/toolsets/toolset-10.15.json | 23 +++++++++++++--------- images/macos/toolsets/toolset-11.json | 23 +++++++++++++--------- 15 files changed, 81 insertions(+), 39 deletions(-) create mode 100644 images/macos/provision/core/golang.sh diff --git a/images/macos/provision/core/commonutils.sh b/images/macos/provision/core/commonutils.sh index 550e1abe0..a13f6a7d1 100644 --- a/images/macos/provision/core/commonutils.sh +++ b/images/macos/provision/core/commonutils.sh @@ -19,9 +19,6 @@ if is_Less_Catalina; then echo "export USE_BAZEL_VERSION=${USE_BAZEL_VERSION}" >> "${HOME}/.bashrc" fi -# Create symlinks for Go 1.15 to preserve backward compatibility -ln -sf $(brew --prefix go@1.15)/bin/* /usr/local/bin/ - # Invoke bazel to download bazel version via bazelisk bazel diff --git a/images/macos/provision/core/golang.sh b/images/macos/provision/core/golang.sh new file mode 100644 index 000000000..3c37431fa --- /dev/null +++ b/images/macos/provision/core/golang.sh @@ -0,0 +1,11 @@ +#!/bin/bash -e -o pipefail +source ~/utils/utils.sh + +DEFAULT_GO_VERSION=$(get_toolset_value '.go.default') +echo "Installing Go..." +brew_smart_install "go@${DEFAULT_GO_VERSION}" + +# Create symlinks to preserve backward compatibility. Symlinks are not created when non-latest go is being installed +ln -sf $(brew --prefix go@${DEFAULT_GO_VERSION})/bin/* /usr/local/bin/ + +invoke_tests "Common" "Go" \ No newline at end of file diff --git a/images/macos/provision/core/ruby.sh b/images/macos/provision/core/ruby.sh index 9c6cefb17..900eb92e6 100755 --- a/images/macos/provision/core/ruby.sh +++ b/images/macos/provision/core/ruby.sh @@ -1,8 +1,9 @@ #!/bin/bash -e -o pipefail source ~/utils/utils.sh +DEFAULT_RUBY_VERSION=$(get_toolset_value '.ruby.default') echo Installing Ruby... -brew_smart_install "ruby@2.7" +brew_smart_install "ruby@${DEFAULT_RUBY_VERSION}" #if High Sierra - skip installation from toolset if is_HighSierra; then diff --git a/images/macos/provision/core/rubygem.sh b/images/macos/provision/core/rubygem.sh index ce5dea454..60cd1c93d 100755 --- a/images/macos/provision/core/rubygem.sh +++ b/images/macos/provision/core/rubygem.sh @@ -4,7 +4,7 @@ source ~/utils/utils.sh echo Updating RubyGems... gem update --system -gemsToInstall=$(get_toolset_value ".rubygems[]") +gemsToInstall=$(get_toolset_value '.ruby.rubygems | .[]') if [ -n "$gemsToInstall" ]; then for gem in $gemsToInstall; do echo "Installing gem $gem" diff --git a/images/macos/templates/macOS-10.13.json b/images/macos/templates/macOS-10.13.json index 306997dac..56f3b3e68 100644 --- a/images/macos/templates/macOS-10.13.json +++ b/images/macos/templates/macOS-10.13.json @@ -159,6 +159,7 @@ "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}", "scripts": [ "./provision/core/commonutils.sh", + "./provision/core/golang.sh", "./provision/core/openjdk.sh", "./provision/core/php.sh", "./provision/core/aws.sh", diff --git a/images/macos/templates/macOS-10.14.json b/images/macos/templates/macOS-10.14.json index fd898affc..6316bf328 100644 --- a/images/macos/templates/macOS-10.14.json +++ b/images/macos/templates/macOS-10.14.json @@ -159,6 +159,7 @@ "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}", "scripts": [ "./provision/core/commonutils.sh", + "./provision/core/golang.sh", "./provision/core/swiftlint.sh", "./provision/core/openjdk.sh", "./provision/core/php.sh", diff --git a/images/macos/templates/macOS-10.15.json b/images/macos/templates/macOS-10.15.json index 5fe2b3bbd..9bdd785aa 100644 --- a/images/macos/templates/macOS-10.15.json +++ b/images/macos/templates/macOS-10.15.json @@ -160,6 +160,7 @@ "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}", "scripts": [ "./provision/core/commonutils.sh", + "./provision/core/golang.sh", "./provision/core/swiftlint.sh", "./provision/core/openjdk.sh", "./provision/core/php.sh", diff --git a/images/macos/templates/macOS-11.json b/images/macos/templates/macOS-11.json index 327b9dd50..a1a87f424 100644 --- a/images/macos/templates/macOS-11.json +++ b/images/macos/templates/macOS-11.json @@ -165,6 +165,7 @@ "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}", "scripts": [ "./provision/core/commonutils.sh", + "./provision/core/golang.sh", "./provision/core/swiftlint.sh", "./provision/core/openjdk.sh", "./provision/core/php.sh", diff --git a/images/macos/tests/BasicTools.Tests.ps1 b/images/macos/tests/BasicTools.Tests.ps1 index e5248800c..9ff7b1da1 100644 --- a/images/macos/tests/BasicTools.Tests.ps1 +++ b/images/macos/tests/BasicTools.Tests.ps1 @@ -24,11 +24,6 @@ Describe "SwiftFormat" { } } -Describe "Go" { - It "Go" { - "go version" | Should -ReturnZeroExitCode - } -} Describe "GnuPG" { It "GnuPG" { diff --git a/images/macos/tests/Common.Tests.ps1 b/images/macos/tests/Common.Tests.ps1 index 0c2366a1b..382605e9b 100644 --- a/images/macos/tests/Common.Tests.ps1 +++ b/images/macos/tests/Common.Tests.ps1 @@ -97,4 +97,10 @@ Describe "Bicep" { It "Bicep" { "bicep --version" | Should -ReturnZeroExitCode } +} + +Describe "Go" { + It "Go" { + "go version" | Should -ReturnZeroExitCode + } } \ No newline at end of file diff --git a/images/macos/tests/RubyGem.Tests.ps1 b/images/macos/tests/RubyGem.Tests.ps1 index a875ec8c7..0dee6064c 100644 --- a/images/macos/tests/RubyGem.Tests.ps1 +++ b/images/macos/tests/RubyGem.Tests.ps1 @@ -1,5 +1,5 @@ Describe "RubyGems" { - $gemTestCases = Get-ToolsetValue -KeyPath "rubygems" | ForEach-Object { + $gemTestCases = Get-ToolsetValue -KeyPath "ruby.rubygems" | ForEach-Object { @{gemName = $_} } diff --git a/images/macos/toolsets/toolset-10.13.json b/images/macos/toolsets/toolset-10.13.json index 48bd440a8..169b4c5fb 100644 --- a/images/macos/toolsets/toolset-10.13.json +++ b/images/macos/toolsets/toolset-10.13.json @@ -229,7 +229,6 @@ "gh", "gnupg", "gnu-tar", - "go@1.15", "helm", "libpq", "llvm", @@ -279,5 +278,19 @@ "versions": [ "2.1" ] + }, + "ruby": { + "default": "2.7", + "rubygems": [ + "xcode-install", + "cocoapods", + "nomad-cli", + "xcpretty", + "bundler", + "fastlane" + ] + }, + "go": { + "default": "1.15" } } \ No newline at end of file diff --git a/images/macos/toolsets/toolset-10.14.json b/images/macos/toolsets/toolset-10.14.json index 3dedb345b..8ed724a8e 100644 --- a/images/macos/toolsets/toolset-10.14.json +++ b/images/macos/toolsets/toolset-10.14.json @@ -250,7 +250,6 @@ "gh", "gnupg", "gnu-tar", - "go@1.15", "helm", "kotlin", "libpq", @@ -350,12 +349,18 @@ "2.1" ] }, - "rubygems": [ - "xcode-install", - "cocoapods", - "nomad-cli", - "xcpretty", - "bundler", - "fastlane" - ] + "ruby": { + "default": "2.7", + "rubygems": [ + "xcode-install", + "cocoapods", + "nomad-cli", + "xcpretty", + "bundler", + "fastlane" + ] + }, + "go": { + "default": "1.15" + } } diff --git a/images/macos/toolsets/toolset-10.15.json b/images/macos/toolsets/toolset-10.15.json index e0bf7db1e..5a5a60a3c 100644 --- a/images/macos/toolsets/toolset-10.15.json +++ b/images/macos/toolsets/toolset-10.15.json @@ -201,7 +201,6 @@ "gh", "gnupg", "gnu-tar", - "go@1.15", "helm", "kotlin", "libpq", @@ -304,12 +303,18 @@ "5.0" ] }, - "rubygems": [ - "xcode-install", - "cocoapods", - "nomad-cli", - "xcpretty", - "bundler", - "fastlane" - ] + "ruby": { + "default": "2.7", + "rubygems": [ + "xcode-install", + "cocoapods", + "nomad-cli", + "xcpretty", + "bundler", + "fastlane" + ] + }, + "go": { + "default": "1.15" + } } diff --git a/images/macos/toolsets/toolset-11.json b/images/macos/toolsets/toolset-11.json index 130695add..bd3590bfe 100644 --- a/images/macos/toolsets/toolset-11.json +++ b/images/macos/toolsets/toolset-11.json @@ -147,7 +147,6 @@ "gh", "gnupg", "gnu-tar", - "go@1.15", "helm", "kotlin", "libpq", @@ -239,12 +238,18 @@ "5.0" ] }, - "rubygems": [ - "xcode-install", - "cocoapods", - "nomad-cli", - "xcpretty", - "bundler", - "fastlane" - ] + "ruby": { + "default": "2.7", + "rubygems": [ + "xcode-install", + "cocoapods", + "nomad-cli", + "xcpretty", + "bundler", + "fastlane" + ] + }, + "go": { + "default": "1.15" + } }