From 0a255311b1880d4158ec2d70d2359fb1052378d8 Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev <50947177+Darleev@users.noreply.github.com> Date: Thu, 14 Jan 2021 00:46:44 +0700 Subject: [PATCH] [macOS] Pester tests invocation after install. (#2421) * [macOS] Fail Pester tests on error * return it back * [macOS] Pester tests invokation after install * fix nitpicks * CocoaPods fix --- images/macos/provision/core/haskell.sh | 2 +- images/macos/provision/core/mongodb.sh | 2 +- images/macos/provision/core/php.sh | 5 +- images/macos/provision/core/pipx-packages.sh | 3 + images/macos/provision/core/postgresql.sh | 5 +- images/macos/provision/core/python.sh | 6 +- images/macos/provision/core/ruby.sh | 6 +- images/macos/provision/core/rubygem.sh | 6 +- images/macos/tests/Common.Tests.ps1 | 70 +------------------- images/macos/tests/Databases.Tests.ps1 | 16 +++++ images/macos/tests/Haskell.Tests.ps1 | 19 ++++++ images/macos/tests/PHP.Tests.ps1 | 15 +++++ images/macos/tests/RubyGem.Tests.ps1 | 33 +++++++++ 13 files changed, 111 insertions(+), 77 deletions(-) create mode 100644 images/macos/tests/Databases.Tests.ps1 create mode 100644 images/macos/tests/Haskell.Tests.ps1 create mode 100644 images/macos/tests/PHP.Tests.ps1 create mode 100644 images/macos/tests/RubyGem.Tests.ps1 diff --git a/images/macos/provision/core/haskell.sh b/images/macos/provision/core/haskell.sh index c2bfc015..73f4a7af 100644 --- a/images/macos/provision/core/haskell.sh +++ b/images/macos/provision/core/haskell.sh @@ -20,4 +20,4 @@ done echo "install cabal..." ghcup install-cabal -invoke_tests "Common" "Haskell" +invoke_tests "Haskell" diff --git a/images/macos/provision/core/mongodb.sh b/images/macos/provision/core/mongodb.sh index a2a690ef..4802dc38 100644 --- a/images/macos/provision/core/mongodb.sh +++ b/images/macos/provision/core/mongodb.sh @@ -11,4 +11,4 @@ echo "Installing mongodb..." brew tap mongodb/brew brew_smart_install "mongodb-community" -invoke_tests "Common" "Mongo" +invoke_tests "Databases" "Mongo" diff --git a/images/macos/provision/core/php.sh b/images/macos/provision/core/php.sh index cb7889fa..fef97641 100644 --- a/images/macos/provision/core/php.sh +++ b/images/macos/provision/core/php.sh @@ -1,8 +1,11 @@ #!/bin/bash -e -o pipefail source ~/utils/utils.sh +source ~/utils/invoke-tests.sh echo Installing PHP brew_smart_install "php" echo Installing composer -brew_smart_install "composer" \ No newline at end of file +brew_smart_install "composer" + +invoke_tests "PHP" \ No newline at end of file diff --git a/images/macos/provision/core/pipx-packages.sh b/images/macos/provision/core/pipx-packages.sh index 8e1da3f3..ae39ae82 100644 --- a/images/macos/provision/core/pipx-packages.sh +++ b/images/macos/provision/core/pipx-packages.sh @@ -1,5 +1,6 @@ #!/bin/bash -e -o pipefail source ~/utils/utils.sh +source ~/utils/invoke-tests.sh export PATH="$PATH:/opt/pipx_bin" @@ -17,3 +18,5 @@ for package in $pipx_packages; do pipx install $package fi done + +invoke_tests "PipxPackages" \ No newline at end of file diff --git a/images/macos/provision/core/postgresql.sh b/images/macos/provision/core/postgresql.sh index f09d1d6d..abcbaf7c 100644 --- a/images/macos/provision/core/postgresql.sh +++ b/images/macos/provision/core/postgresql.sh @@ -1,5 +1,6 @@ #!/bin/bash -e -o pipefail source ~/utils/utils.sh +source ~/utils/invoke-tests.sh #Install latest version of postgresql brew_smart_install "postgres" @@ -24,4 +25,6 @@ while [ $i -gt 0 ]; do done #Stop postgresql -brew services stop postgresql \ No newline at end of file +brew services stop postgresql + +invoke_tests "Databases" "PostgreSQL" \ No newline at end of file diff --git a/images/macos/provision/core/python.sh b/images/macos/provision/core/python.sh index 40287aa4..3c237df8 100755 --- a/images/macos/provision/core/python.sh +++ b/images/macos/provision/core/python.sh @@ -1,5 +1,5 @@ #!/bin/bash -e -o pipefail - +source ~/utils/invoke-tests.sh source ~/utils/utils.sh echo "Installing Python Tooling" @@ -26,4 +26,6 @@ brew_smart_install "pipx" echo "export PIPX_BIN_DIR=${PIPX_BIN_DIR}" >> "${HOME}/.bashrc" echo "export PIPX_HOME=${PIPX_HOME}" >> "${HOME}/.bashrc" -echo 'export PATH="$PIPX_BIN_DIR:$PATH"' >> "${HOME}/.bashrc" \ No newline at end of file +echo 'export PATH="$PIPX_BIN_DIR:$PATH"' >> "${HOME}/.bashrc" + +invoke_tests "Python" \ No newline at end of file diff --git a/images/macos/provision/core/ruby.sh b/images/macos/provision/core/ruby.sh index 952c0ea7..edd32dc6 100755 --- a/images/macos/provision/core/ruby.sh +++ b/images/macos/provision/core/ruby.sh @@ -1,5 +1,5 @@ #!/bin/bash -e -o pipefail - +source ~/utils/invoke-tests.sh source ~/utils/utils.sh echo Installing Ruby... @@ -40,4 +40,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 "Ruby" diff --git a/images/macos/provision/core/rubygem.sh b/images/macos/provision/core/rubygem.sh index e4060671..7184fe63 100755 --- a/images/macos/provision/core/rubygem.sh +++ b/images/macos/provision/core/rubygem.sh @@ -1,5 +1,5 @@ #!/bin/bash -e -o pipefail - +source ~/utils/invoke-tests.sh source ~/utils/utils.sh echo Updating RubyGems... @@ -29,4 +29,6 @@ echo Installing bundler... gem install bundler --force echo Installing fastlane tools... -gem install fastlane \ No newline at end of file +gem install fastlane + +invoke_tests "RubyGem" \ No newline at end of file diff --git a/images/macos/tests/Common.Tests.ps1 b/images/macos/tests/Common.Tests.ps1 index 6d47c471..65bc3ccc 100644 --- a/images/macos/tests/Common.Tests.ps1 +++ b/images/macos/tests/Common.Tests.ps1 @@ -156,61 +156,12 @@ Describe ".NET" { } } -Describe "CocoaPods" { - It "CocoaPods" { - "pod --version" | Should -ReturnZeroExitCode - } -} - Describe "Homebrew" { It "Homebrew" { "brew --version" | Should -ReturnZeroExitCode } } -Describe "Common utilities" { - - It "Bundler" { - "bundler --version" | Should -ReturnZeroExitCode - } - - Context "Nomad" -Skip:($os.IsBigSur) { - It "Nomad CLI" { - $result = Get-CommandResult "gem list" - $result.Output | Should -BeLike "*nomad-cli*" - } - - It "Nomad CLI IPA" { - "ipa --version" | Should -ReturnZeroExitCode - } - } - - It "Fastlane" { - "fastlane --version" | Should -ReturnZeroExitCode - } - - It "xcpretty" { - "xcpretty --version" | Should -ReturnZeroExitCode - } - - It "PostgreSQL-Client" { - "psql --version" | Should -ReturnZeroExitCode - } - - It "PostgreSQL-Server" { - "pg_config --version" | Should -ReturnZeroExitCode - } - - It "PHP" { - Get-WhichTool "php" | Should -Not -BeLike "/usr/bin/php*" - "php --version" | Should -ReturnZeroExitCode - } - - It "Composer" { - "composer --version" | Should -ReturnZeroExitCode - } -} - Describe "Rust" -Skip:($os.IsHighSierra) { It "Rustup is installed" { "rustup --version" | Should -ReturnZeroExitCode @@ -243,20 +194,6 @@ Describe "Rust" -Skip:($os.IsHighSierra) { } } -Describe "Haskell" -Skip:($os.IsHighSierra) { - It "GHCup" { - "ghcup --version" | Should -ReturnZeroExitCode - } - - It "GHC" { - "ghc --version" | Should -ReturnZeroExitCode - } - - It "Cabal" { - "cabal --version" | Should -ReturnZeroExitCode - } -} - Describe "GCC" -Skip:($os.IsHighSierra) { $testCases = @("8", "9", "10") | ForEach-Object { @{Version = $_} } @@ -369,9 +306,8 @@ Describe "Stack" -Skip:($os.IsHighSierra) { } } -Describe "Mongo" { - It "mongodb" { - "mongo --version" | Should -ReturnZeroExitCode - "mongod --version"| Should -ReturnZeroExitCode +Describe "CocoaPods" { + It "CocoaPods" { + "pod --version" | Should -ReturnZeroExitCode } } \ No newline at end of file diff --git a/images/macos/tests/Databases.Tests.ps1 b/images/macos/tests/Databases.Tests.ps1 new file mode 100644 index 00000000..6e06a231 --- /dev/null +++ b/images/macos/tests/Databases.Tests.ps1 @@ -0,0 +1,16 @@ +Describe "Mongo" { + It "mongodb" { + "mongo --version" | Should -ReturnZeroExitCode + "mongod --version"| Should -ReturnZeroExitCode + } +} + +Describe "PostgreSQL" { + It "PostgreSQL-Client" { + "psql --version" | Should -ReturnZeroExitCode + } + + It "PostgreSQL-Server" { + "pg_config --version" | Should -ReturnZeroExitCode + } +} \ No newline at end of file diff --git a/images/macos/tests/Haskell.Tests.ps1 b/images/macos/tests/Haskell.Tests.ps1 new file mode 100644 index 00000000..4bbf8884 --- /dev/null +++ b/images/macos/tests/Haskell.Tests.ps1 @@ -0,0 +1,19 @@ +$os = Get-OSVersion + +Describe "Haskell" -Skip:($os.IsHighSierra) { + Context "GHCup" { + It "GHCup" { + "ghcup --version" | Should -ReturnZeroExitCode + } + } + Context "GHC" { + It "GHC" { + "ghc --version" | Should -ReturnZeroExitCode + } + } + Context "Cabal" { + It "Cabal" { + "cabal --version" | Should -ReturnZeroExitCode + } + } +} \ No newline at end of file diff --git a/images/macos/tests/PHP.Tests.ps1 b/images/macos/tests/PHP.Tests.ps1 new file mode 100644 index 00000000..a7c9f380 --- /dev/null +++ b/images/macos/tests/PHP.Tests.ps1 @@ -0,0 +1,15 @@ +Describe "PHP" { + Context "PHP" { + It "PHP Path" { + Get-WhichTool "php" | Should -Not -BeLike "/usr/bin/php*" + } + It "PHP version" { + "php --version" | Should -ReturnZeroExitCode + } + } + Context "Composer" { + It "Composer" { + "composer --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 new file mode 100644 index 00000000..7cb5531b --- /dev/null +++ b/images/macos/tests/RubyGem.Tests.ps1 @@ -0,0 +1,33 @@ +$os = Get-OSVersion + +Describe "Bundler" { + It "Bundler" { + "bundler --version" | Should -ReturnZeroExitCode + } +} + +Describe "Nomad" -Skip:($os.IsBigSur) { + Context "Nomad" { + It "Nomad CLI" { + $result = Get-CommandResult "gem list" + $result.Output | Should -BeLike "*nomad-cli*" + } + } + Context "Nomad CLI" { + It "Nomad CLI IPA" { + "ipa --version" | Should -ReturnZeroExitCode + } + } +} + +Describe "Fastlane" { + It "Fastlane" { + "fastlane --version" | Should -ReturnZeroExitCode + } +} + +Describe "xcpretty" { + It "xcpretty" { + "xcpretty --version" | Should -ReturnZeroExitCode + } +} \ No newline at end of file