From c4d66c8dc7574c9ee7337414a182564ac8371250 Mon Sep 17 00:00:00 2001 From: Mikhail Timofeev <48208649+miketimofeev@users.noreply.github.com> Date: Fri, 19 Feb 2021 18:33:28 +0300 Subject: [PATCH] [Ubuntu] Add Fastlane (#2751) --- .../SoftwareReport/SoftwareReport.Common.psm1 | 2 +- .../SoftwareReport.Generator.ps1 | 4 ++++ .../SoftwareReport/SoftwareReport.Tools.psm1 | 5 ++++ images/linux/scripts/installers/ruby.sh | 19 +++++++++++---- images/linux/scripts/tests/Tools.Tests.ps1 | 23 +++++++++++++++++++ images/linux/toolsets/toolset-1604.json | 3 ++- images/linux/toolsets/toolset-1804.json | 3 ++- images/linux/toolsets/toolset-2004.json | 5 +++- 8 files changed, 56 insertions(+), 8 deletions(-) diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 index 62d47590..e8a98317 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 @@ -102,7 +102,7 @@ function Get-GemVersion { $result = Get-CommandResult "gem --version" $result.Output -match "(?\d+\.\d+\.\d+)" | Out-Null $gemVersion = $Matches.version - return "Gem $gemVersion" + return "RubyGems $gemVersion" } function Get-MinicondaVersion { diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 index a8654cb7..ee7dc994 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 @@ -144,6 +144,10 @@ if (-not (Test-IsUbuntu16)) { ) } +if (Test-IsUbuntu20) { + $toolsList += (Get-FastlaneVersion) +} + $markdown += New-MDList -Style Unordered -Lines ($toolsList | Sort-Object) $markdown += New-MDHeader "CLI Tools" -Level 3 diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 index be10c2fa..e6650fca 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 @@ -264,6 +264,11 @@ function Get-AWSSAMVersion { return "AWS SAM CLI $(sam --version | Take-OutputPart -Part -1)" } +function Get-FastlaneVersion { + $fastlaneVersion = fastlane --version | Select-String "^fastlane [0-9]" | Take-OutputPart -Part 1 + return "Fastlane $fastlaneVersion" +} + function Get-HubCliVersion { $hubVersion = hub --version | Select-String "hub version" | Take-OutputPart -Part 2 return "Hub CLI $hubVersion" diff --git a/images/linux/scripts/installers/ruby.sh b/images/linux/scripts/installers/ruby.sh index 06583260..bd260a55 100644 --- a/images/linux/scripts/installers/ruby.sh +++ b/images/linux/scripts/installers/ruby.sh @@ -1,13 +1,22 @@ #!/bin/bash -e ################################################################################ ## File: ruby.sh -## Desc: Installs Ruby requirements +## Desc: Installs Ruby requirements and ruby gems ################################################################################ source $HELPER_SCRIPTS/install.sh -sudo apt-get install ruby-full -sudo gem update --system +apt-get install ruby-full +gem update + +# Install ruby gems from toolset +gemsToInstall=$(get_toolset_value ".rubygems[] .name") +if [ -n "$gemsToInstall" ]; then + for gem in $gemsToInstall; do + echo "Installing gem $gem" + gem install $gem + done +fi # Install Ruby requirements apt-get install -y libz-dev openssl libssl-dev @@ -43,4 +52,6 @@ for TOOLSET_VERSION in ${TOOLSET_VERSIONS[@]}; do echo "Create complete file" touch $COMPLETE_FILE_PATH fi -done \ No newline at end of file +done + +invoke_tests "Tools" "Ruby" \ No newline at end of file diff --git a/images/linux/scripts/tests/Tools.Tests.ps1 b/images/linux/scripts/tests/Tools.Tests.ps1 index 8b244730..e17b21d6 100644 --- a/images/linux/scripts/tests/Tools.Tests.ps1 +++ b/images/linux/scripts/tests/Tools.Tests.ps1 @@ -344,3 +344,26 @@ Describe "Python" { "$PythonCommand --version" | Should -ReturnZeroExitCode } } + +Describe "Ruby" { + $testCases = @("ruby", "gem") | ForEach-Object { @{RubyCommand = $_} } + + It "" -TestCases $testCases { + param ( + [string] $RubyCommand + ) + + "$RubyCommand --version" | Should -ReturnZeroExitCode + } + + $gemTestCases = (Get-ToolsetContent).rubygems | ForEach-Object { + @{gemName = $_.name} + } + + if ($gemTestCases) + { + It "Gem is installed" -TestCases $gemTestCases { + "gem list -i '^$gemName$'" | Should -MatchCommandOutput "true" + } + } +} \ No newline at end of file diff --git a/images/linux/toolsets/toolset-1604.json b/images/linux/toolsets/toolset-1604.json index 6985369b..615570ae 100644 --- a/images/linux/toolsets/toolset-1604.json +++ b/images/linux/toolsets/toolset-1604.json @@ -278,5 +278,6 @@ "7.4", "8.0" ] - } + }, + "rubygems": [] } diff --git a/images/linux/toolsets/toolset-1804.json b/images/linux/toolsets/toolset-1804.json index 13158650..c4c0fe7a 100644 --- a/images/linux/toolsets/toolset-1804.json +++ b/images/linux/toolsets/toolset-1804.json @@ -281,5 +281,6 @@ "7.4", "8.0" ] - } + }, + "rubygems": [] } diff --git a/images/linux/toolsets/toolset-2004.json b/images/linux/toolsets/toolset-2004.json index 90d606e5..0566dc16 100644 --- a/images/linux/toolsets/toolset-2004.json +++ b/images/linux/toolsets/toolset-2004.json @@ -255,5 +255,8 @@ "7.4", "8.0" ] - } + }, + "rubygems": [ + {"name": "fastlane"} + ] }