From 5cc1411e140f88fc6e24375d4137cd26146d6b78 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Tue, 7 Jul 2020 11:38:29 +0300 Subject: [PATCH 01/17] add cargo dep to linux --- images/linux/scripts/installers/rust.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/images/linux/scripts/installers/rust.sh b/images/linux/scripts/installers/rust.sh index 605bce11..824ec899 100644 --- a/images/linux/scripts/installers/rust.sh +++ b/images/linux/scripts/installers/rust.sh @@ -19,13 +19,15 @@ source $CARGO_HOME/env # Install common tools rustup component add rustfmt clippy cargo install bindgen cbindgen +cargo install cargo-audit +cargo install cargo-outdated echo "Test installation of the Rust toochain" # Permissions chmod -R 777 $(dirname $RUSTUP_HOME) -for cmd in rustup rustc rustdoc cargo rustfmt cargo-clippy bindgen cbindgen; do +for cmd in rustup rustc rustdoc cargo rustfmt cargo-clippy bindgen cbindgen 'cargo audit' 'cargo outdated'; do if ! command -v $cmd --version; then echo "$cmd was not installed or is not found on the path" exit 1 @@ -54,3 +56,5 @@ DocumentInstalledItem "clippy ($(cargo-clippy --version 2>&1 | cut -d ' ' -f 2)) DocumentInstalledItem "rustdoc ($(rustdoc --version 2>&1 | cut -d ' ' -f 2))" DocumentInstalledItem "bindgen ($(bindgen --version 2>&1 | cut -d ' ' -f 2))" DocumentInstalledItem "cbindgen ($(cbindgen --version 2>&1 | cut -d ' ' -f 2))" +DocumentInstalledItem "cargo audit ($(cargo audit --version 2>&1 | cut -d ' ' -f 2))" +DocumentInstalledItem "cargo outdated ($(cargo outdated --version 2>&1 | cut -d ' ' -f 2))" \ No newline at end of file From df8858b77f4c30c382c9d6525e8780d25948e7f0 Mon Sep 17 00:00:00 2001 From: Dibir Magomedsaygitov Date: Tue, 7 Jul 2020 16:40:02 +0300 Subject: [PATCH 02/17] install oras-cli on ubuntu --- images/linux/scripts/installers/oras-cli.sh | 30 +++++++++++++++++++++ images/linux/ubuntu1604.json | 1 + images/linux/ubuntu1804.json | 1 + images/linux/ubuntu2004.json | 1 + 4 files changed, 33 insertions(+) create mode 100644 images/linux/scripts/installers/oras-cli.sh diff --git a/images/linux/scripts/installers/oras-cli.sh b/images/linux/scripts/installers/oras-cli.sh new file mode 100644 index 00000000..941ccf48 --- /dev/null +++ b/images/linux/scripts/installers/oras-cli.sh @@ -0,0 +1,30 @@ +#!/bin/bash +################################################################################ +## File: oras-cli.sh +## Desc: Installs ORAS Cli +################################################################################ + +# Source the helpers for use with the script +source $HELPER_SCRIPTS/document.sh + +# Determine latest ORAS CLI version +ORAS_CLI_LATEST_VERSION_URL=https://api.github.com/repos/deislabs/oras/releases/latest +ORAS_CLI_VERSION=$(curl $ORAS_CLI_LATEST_VERSION_URL | jq '.name' | tr -d '"' | cut -d 'v' -f 2) + +# Install ORAS CLI +curl -LO https://github.com/deislabs/oras/releases/download/v${ORAS_CLI_VERSION}/oras_${ORAS_CLI_VERSION}_linux_amd64.tar.gz +mkdir -p oras-install/ +tar -xzvf oras_${ORAS_CLI_VERSION}_linux_amd64.tar.gz -C oras-install/ +mv oras-install/oras /usr/local/bin/ +rm -rf oras_${ORAS_CLI_VERSION}_linux_amd64.tar.gz oras-install/ + +# Run tests to determine that the software installed as expected +echo "Testing to make sure that script performed as expected, and basic scenarios work" +if ! oras version; then + echo "ORAS CLI was not installed" + exit 1 +fi + +# Document what was added to the image +echo "Lastly, documenting what we added to the metadata file" +DocumentInstalledItem "ORAS $(oras version | head -1 | awk {'print $2'})" \ No newline at end of file diff --git a/images/linux/ubuntu1604.json b/images/linux/ubuntu1604.json index d90ddb16..1f92e349 100644 --- a/images/linux/ubuntu1604.json +++ b/images/linux/ubuntu1604.json @@ -214,6 +214,7 @@ "{{template_dir}}/scripts/installers/mysql.sh", "{{template_dir}}/scripts/installers/nodejs.sh", "{{template_dir}}/scripts/installers/bazel.sh", + "{{template_dir}}/scripts/installers/oras-cli.sh", "{{template_dir}}/scripts/installers/phantomjs.sh", "{{template_dir}}/scripts/installers/php.sh", "{{template_dir}}/scripts/installers/pollinate.sh", diff --git a/images/linux/ubuntu1804.json b/images/linux/ubuntu1804.json index 4327b60c..5a33bf26 100644 --- a/images/linux/ubuntu1804.json +++ b/images/linux/ubuntu1804.json @@ -218,6 +218,7 @@ "{{template_dir}}/scripts/installers/nvm.sh", "{{template_dir}}/scripts/installers/nodejs.sh", "{{template_dir}}/scripts/installers/bazel.sh", + "{{template_dir}}/scripts/installers/oras-cli.sh", "{{template_dir}}/scripts/installers/phantomjs.sh", "{{template_dir}}/scripts/installers/php.sh", "{{template_dir}}/scripts/installers/pollinate.sh", diff --git a/images/linux/ubuntu2004.json b/images/linux/ubuntu2004.json index 34476275..7a07b3e6 100644 --- a/images/linux/ubuntu2004.json +++ b/images/linux/ubuntu2004.json @@ -216,6 +216,7 @@ "{{template_dir}}/scripts/installers/nvm.sh", "{{template_dir}}/scripts/installers/nodejs.sh", "{{template_dir}}/scripts/installers/bazel.sh", + "{{template_dir}}/scripts/installers/oras-cli.sh", "{{template_dir}}/scripts/installers/phantomjs.sh", "{{template_dir}}/scripts/installers/php.sh", "{{template_dir}}/scripts/installers/pollinate.sh", From 845dc20aebeeb7faee0cd3f98ffb18e10b28e66d Mon Sep 17 00:00:00 2001 From: Dibir Magomedsaygitov Date: Tue, 7 Jul 2020 17:25:41 +0300 Subject: [PATCH 03/17] minor fixes --- images/linux/scripts/installers/oras-cli.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/images/linux/scripts/installers/oras-cli.sh b/images/linux/scripts/installers/oras-cli.sh index 941ccf48..0381522b 100644 --- a/images/linux/scripts/installers/oras-cli.sh +++ b/images/linux/scripts/installers/oras-cli.sh @@ -1,7 +1,7 @@ #!/bin/bash ################################################################################ ## File: oras-cli.sh -## Desc: Installs ORAS Cli +## Desc: Installs ORAS CLI ################################################################################ # Source the helpers for use with the script @@ -10,13 +10,14 @@ source $HELPER_SCRIPTS/document.sh # Determine latest ORAS CLI version ORAS_CLI_LATEST_VERSION_URL=https://api.github.com/repos/deislabs/oras/releases/latest ORAS_CLI_VERSION=$(curl $ORAS_CLI_LATEST_VERSION_URL | jq '.name' | tr -d '"' | cut -d 'v' -f 2) +ORAS_CLI_ARCHIVE="oras_${ORAS_CLI_VERSION}_linux_amd64.tar.gz" # Install ORAS CLI -curl -LO https://github.com/deislabs/oras/releases/download/v${ORAS_CLI_VERSION}/oras_${ORAS_CLI_VERSION}_linux_amd64.tar.gz +curl -LO https://github.com/deislabs/oras/releases/download/v${ORAS_CLI_VERSION}/${ORAS_CLI_ARCHIVE} mkdir -p oras-install/ -tar -xzvf oras_${ORAS_CLI_VERSION}_linux_amd64.tar.gz -C oras-install/ +tar -xzvf $ORAS_CLI_ARCHIVE -C oras-install/ mv oras-install/oras /usr/local/bin/ -rm -rf oras_${ORAS_CLI_VERSION}_linux_amd64.tar.gz oras-install/ +rm -rf $ORAS_CLI_ARCHIVE oras-install/ # Run tests to determine that the software installed as expected echo "Testing to make sure that script performed as expected, and basic scenarios work" From 5f5c60ef989eb60eec6b31271d2daf40f88f1bb9 Mon Sep 17 00:00:00 2001 From: Dibir Magomedsaygitov Date: Tue, 7 Jul 2020 19:14:31 +0300 Subject: [PATCH 04/17] minor fixes --- images/linux/scripts/installers/oras-cli.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/images/linux/scripts/installers/oras-cli.sh b/images/linux/scripts/installers/oras-cli.sh index 0381522b..d23763ad 100644 --- a/images/linux/scripts/installers/oras-cli.sh +++ b/images/linux/scripts/installers/oras-cli.sh @@ -9,15 +9,15 @@ source $HELPER_SCRIPTS/document.sh # Determine latest ORAS CLI version ORAS_CLI_LATEST_VERSION_URL=https://api.github.com/repos/deislabs/oras/releases/latest -ORAS_CLI_VERSION=$(curl $ORAS_CLI_LATEST_VERSION_URL | jq '.name' | tr -d '"' | cut -d 'v' -f 2) -ORAS_CLI_ARCHIVE="oras_${ORAS_CLI_VERSION}_linux_amd64.tar.gz" +ORAS_CLI_DOWNLOAD_URL=$(curl -s $ORAS_CLI_LATEST_VERSION_URL | jq -r '.assets[].browser_download_url | select(contains("linux_amd64.tar.gz"))') +ORAS_CLI_ARCHIVE=$(basename $ORAS_CLI_DOWNLOAD_URL) # Install ORAS CLI -curl -LO https://github.com/deislabs/oras/releases/download/v${ORAS_CLI_VERSION}/${ORAS_CLI_ARCHIVE} -mkdir -p oras-install/ +cd /tmp +curl -LO $ORAS_CLI_DOWNLOAD_URL -o $ORAS_CLI_ARCHIVE +mkdir -p oras-install tar -xzvf $ORAS_CLI_ARCHIVE -C oras-install/ mv oras-install/oras /usr/local/bin/ -rm -rf $ORAS_CLI_ARCHIVE oras-install/ # Run tests to determine that the software installed as expected echo "Testing to make sure that script performed as expected, and basic scenarios work" @@ -28,4 +28,4 @@ fi # Document what was added to the image echo "Lastly, documenting what we added to the metadata file" -DocumentInstalledItem "ORAS $(oras version | head -1 | awk {'print $2'})" \ No newline at end of file +DocumentInstalledItem "ORAS $(oras version | awk 'NR==1{print $2})" \ No newline at end of file From 5faa6abe7d27502ef05e873405276241d3bbeb6c Mon Sep 17 00:00:00 2001 From: Dibir Magomedsaygitov Date: Tue, 7 Jul 2020 19:23:45 +0300 Subject: [PATCH 05/17] implement download_with_retries function --- images/linux/scripts/helpers/install.sh | 4 ++-- images/linux/scripts/installers/oras-cli.sh | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/images/linux/scripts/helpers/install.sh b/images/linux/scripts/helpers/install.sh index 0843983e..c61c2431 100644 --- a/images/linux/scripts/helpers/install.sh +++ b/images/linux/scripts/helpers/install.sh @@ -14,9 +14,9 @@ download_with_retries() { local COMPRESSED="$4" if [ $COMPRESSED == "compressed" ]; then - COMMAND="curl $URL -4 -s --compressed -o '$DEST/$NAME'" + COMMAND="curl $URL -4 -sL --compressed -o '$DEST/$NAME'" else - COMMAND="curl $URL -4 -s -o '$DEST/$NAME'" + COMMAND="curl $URL -4 -sL -o '$DEST/$NAME'" fi echo "Downloading $URL..." diff --git a/images/linux/scripts/installers/oras-cli.sh b/images/linux/scripts/installers/oras-cli.sh index d23763ad..02e3f0a1 100644 --- a/images/linux/scripts/installers/oras-cli.sh +++ b/images/linux/scripts/installers/oras-cli.sh @@ -6,6 +6,7 @@ # Source the helpers for use with the script source $HELPER_SCRIPTS/document.sh +source $HELPER_SCRIPTS/install.sh # Determine latest ORAS CLI version ORAS_CLI_LATEST_VERSION_URL=https://api.github.com/repos/deislabs/oras/releases/latest @@ -14,7 +15,7 @@ ORAS_CLI_ARCHIVE=$(basename $ORAS_CLI_DOWNLOAD_URL) # Install ORAS CLI cd /tmp -curl -LO $ORAS_CLI_DOWNLOAD_URL -o $ORAS_CLI_ARCHIVE +download_with_retries $ORAS_CLI_DOWNLOAD_URL mkdir -p oras-install tar -xzvf $ORAS_CLI_ARCHIVE -C oras-install/ mv oras-install/oras /usr/local/bin/ From 26e56e5076e78184888b24a0e828005005b2b80c Mon Sep 17 00:00:00 2001 From: Dibir Magomedsaygitov Date: Tue, 7 Jul 2020 22:56:48 +0300 Subject: [PATCH 06/17] fix bug --- images/linux/scripts/installers/oras-cli.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/linux/scripts/installers/oras-cli.sh b/images/linux/scripts/installers/oras-cli.sh index 02e3f0a1..d5b4748a 100644 --- a/images/linux/scripts/installers/oras-cli.sh +++ b/images/linux/scripts/installers/oras-cli.sh @@ -29,4 +29,4 @@ fi # Document what was added to the image echo "Lastly, documenting what we added to the metadata file" -DocumentInstalledItem "ORAS $(oras version | awk 'NR==1{print $2})" \ No newline at end of file +DocumentInstalledItem "ORAS $(oras version | awk 'NR==1{print $2}')" \ No newline at end of file From 5323f8f7d4620bf79d7ebe6d50db60f85c615cd9 Mon Sep 17 00:00:00 2001 From: Dibir Magomedsaygitov Date: Wed, 8 Jul 2020 11:13:21 +0300 Subject: [PATCH 07/17] remove temporary path --- images/linux/scripts/installers/oras-cli.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/images/linux/scripts/installers/oras-cli.sh b/images/linux/scripts/installers/oras-cli.sh index d5b4748a..056a3696 100644 --- a/images/linux/scripts/installers/oras-cli.sh +++ b/images/linux/scripts/installers/oras-cli.sh @@ -17,8 +17,7 @@ ORAS_CLI_ARCHIVE=$(basename $ORAS_CLI_DOWNLOAD_URL) cd /tmp download_with_retries $ORAS_CLI_DOWNLOAD_URL mkdir -p oras-install -tar -xzvf $ORAS_CLI_ARCHIVE -C oras-install/ -mv oras-install/oras /usr/local/bin/ +tar -zxvf $ORAS_CLI_ARCHIVE -C /usr/local/bin oras # Run tests to determine that the software installed as expected echo "Testing to make sure that script performed as expected, and basic scenarios work" @@ -29,4 +28,4 @@ fi # Document what was added to the image echo "Lastly, documenting what we added to the metadata file" -DocumentInstalledItem "ORAS $(oras version | awk 'NR==1{print $2}')" \ No newline at end of file +DocumentInstalledItem "ORAS CLI $(oras version | awk 'NR==1{print $2}')" \ No newline at end of file From 2d2a590672a203d5f1586c7dfc57c9f23cc44e4c Mon Sep 17 00:00:00 2001 From: Dibir Magomedsaygitov Date: Wed, 8 Jul 2020 11:43:12 +0300 Subject: [PATCH 08/17] minor fix --- images/linux/scripts/installers/oras-cli.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/images/linux/scripts/installers/oras-cli.sh b/images/linux/scripts/installers/oras-cli.sh index 056a3696..c4546ccb 100644 --- a/images/linux/scripts/installers/oras-cli.sh +++ b/images/linux/scripts/installers/oras-cli.sh @@ -16,7 +16,6 @@ ORAS_CLI_ARCHIVE=$(basename $ORAS_CLI_DOWNLOAD_URL) # Install ORAS CLI cd /tmp download_with_retries $ORAS_CLI_DOWNLOAD_URL -mkdir -p oras-install tar -zxvf $ORAS_CLI_ARCHIVE -C /usr/local/bin oras # Run tests to determine that the software installed as expected From 1c22abb30d225c8bba9877056ade8b56196fe2a5 Mon Sep 17 00:00:00 2001 From: "no-reply@microsoft.com" Date: Wed, 8 Jul 2020 18:02:55 +0000 Subject: [PATCH 09/17] Updating readme file for macos-10.15 version 20200702.1 --- images/macos/macos-10.15-Readme.md | 32 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/images/macos/macos-10.15-Readme.md b/images/macos/macos-10.15-Readme.md index 6936556d..4fbba9f5 100644 --- a/images/macos/macos-10.15-Readme.md +++ b/images/macos/macos-10.15-Readme.md @@ -2,7 +2,7 @@ - System Version: macOS 10.15.5 (19F101) - Kernel Version: Darwin 19.5.0 - System Integrity Protection: Enabled -- Image Version: 20200625.2 +- Image Version: 20200702.1 ## Installed Software ### Language and Runtime @@ -18,9 +18,9 @@ - gcc-9 (Homebrew GCC 9.3.0_1) 9.3.0 - GNU Fortran (Homebrew GCC 8.4.0_1) 8.4.0 - GNU Fortran (Homebrew GCC 9.3.0_1) 9.3.0 -- Node.js v12.18.1 +- Node.js v12.18.2 - NVM 0.35.3 -- NVM - Cached node versions: v6.17.1 v8.17.0 v10.21.0 v12.18.1 v13.14.0 v14.4.0 +- NVM - Cached node versions: v6.17.1 v8.17.0 v10.21.0 v12.18.2 v13.14.0 v14.5.0 - PowerShell 7.0.2 - Python 2.7.17 - Python 3.7.7 @@ -36,7 +36,7 @@ - Bundler version 2.1.4 - Carthage 0.35.0 - CocoaPods 1.9.3 -- Homebrew 2.4.2 +- Homebrew 2.4.3 - NPM 6.14.5 - Yarn 1.22.4 - NuGet 5.6.0.6489 @@ -47,10 +47,10 @@ ### Project Management - Apache Maven 3.6.3 -- Gradle 6.5 +- Gradle 6.5.1 ### Utilities -- Curl 7.71.0 +- Curl 7.71.1 - Git: 2.27.0 - Git LFS: 2.11.0 - GitHub CLI: 0.10.1 @@ -67,7 +67,7 @@ - aria2 1.35.0 - azcopy 10.4.3 - zstd 1.4.5 -- bazel 3.3.0 +- bazel 3.3.1 - bazelisk v1.5.0 - helm v3.2.4+g0ad800e - virtualbox 6.1.10r138449 @@ -77,13 +77,13 @@ - 7-Zip 16.02 ### Tools -- Fastlane 2.149.1 +- Fastlane 2.150.1 - Cmake 3.17.3 -- App Center CLI 2.6.0 +- App Center CLI 2.6.1 - Azure CLI 2.8.0 -- AWS CLI 2.0.25 +- AWS CLI 2.0.27 - AWS SAM CLI 0.53.0 -- Aliyun CLI 3.0.48 +- Aliyun CLI 3.0.49 - GHCup v0.1.5-p2 - GHC 8.10.1 - Cabal 3.2.0.0 @@ -94,9 +94,9 @@ - SafariDriver 13.1.1 (15609.2.9.1.2) - Google Chrome 83.0.4103.116 - ChromeDriver 83.0.4103.39 -- Microsoft Edge 83.0.478.56 -- MSEdgeDriver 83.0.478.56 -- Mozilla Firefox 77.0.1 +- Microsoft Edge 83.0.478.58 +- MSEdgeDriver 83.0.478.58 +- Mozilla Firefox 78.0.1 - geckodriver 0.26.0 ### Cached Tools @@ -109,8 +109,8 @@ #### Python - 2.7.18 - 3.5.9 -- 3.6.10 -- 3.7.7 +- 3.6.11 +- 3.7.8 - 3.8.3 #### PyPy From c6950533af3e7bb78729ae8be7f459758eb327ce Mon Sep 17 00:00:00 2001 From: Sergey Dolin Date: Thu, 9 Jul 2020 11:57:02 +0500 Subject: [PATCH 10/17] Add WSL (#1081) * Add WSL * Move WSL to the end of the provision * Add elevated_user * No restart VM * Add Validation * Add WSL note in Readme.md * Rename WSL1 to WSL Co-authored-by: Sergey Dolin --- images/win/Windows2019-Azure.json | 16 +++++++++++++++- images/win/scripts/Installers/Validate-WSL.ps1 | 14 ++++++++++++++ .../Installers/Windows2019/Install-WSL.ps1 | 8 ++++++++ .../SoftwareReport/SoftwareReport.Generator.ps1 | 5 +++++ 4 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 images/win/scripts/Installers/Validate-WSL.ps1 create mode 100644 images/win/scripts/Installers/Windows2019/Install-WSL.ps1 diff --git a/images/win/Windows2019-Azure.json b/images/win/Windows2019-Azure.json index cf10a903..d5bf5f73 100644 --- a/images/win/Windows2019-Azure.json +++ b/images/win/Windows2019-Azure.json @@ -109,6 +109,14 @@ ], "execution_policy": "unrestricted" }, + { + "type": "powershell", + "elevated_user": "SYSTEM", + "elevated_password": "", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Windows2019/Install-WSL.ps1" + ] + }, { "type": "powershell", "scripts":[ @@ -243,6 +251,12 @@ "{{ template_dir }}/scripts/Installers/Validate-Wix.ps1" ] }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Validate-WSL.ps1" + ] + }, { "type": "powershell", "scripts":[ @@ -1062,4 +1076,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/images/win/scripts/Installers/Validate-WSL.ps1 b/images/win/scripts/Installers/Validate-WSL.ps1 new file mode 100644 index 00000000..83da6933 --- /dev/null +++ b/images/win/scripts/Installers/Validate-WSL.ps1 @@ -0,0 +1,14 @@ +################################################################################ +## File: Validate-WSL.ps1 +## Desc: Validate WSL CLI existst +################################################################################ + +if (Get-Command -Name 'wsl') +{ + Write-Host 'wsl is on path' +} +else +{ + Write-Host 'wsl not on path' + exit 1 +} diff --git a/images/win/scripts/Installers/Windows2019/Install-WSL.ps1 b/images/win/scripts/Installers/Windows2019/Install-WSL.ps1 new file mode 100644 index 00000000..2e83a1b8 --- /dev/null +++ b/images/win/scripts/Installers/Windows2019/Install-WSL.ps1 @@ -0,0 +1,8 @@ +################################################################################ +## File: Install-WSL.ps1 +## Desc: Install Windows Subsystem for Linux +################################################################################ + +Write-Host "Install Windows Subsystem for Linux" + +Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux -NoRestart \ No newline at end of file diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 b/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 index b1ba9152..0f7f1fa0 100644 --- a/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 +++ b/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 @@ -22,6 +22,11 @@ $markdown += New-MDList -Style Unordered -Lines @( "Image Version: $env:ImageVersion" ) +$markdown += New-MDHeader "Enabled windows optional features" -Level 2 +$markdown += New-MDList -Style Unordered -Lines @( + "Windows Subsystem for Linux" +) + $markdown += New-MDHeader "Installed Software" -Level 2 $markdown += New-MDHeader "Language and Runtime" -Level 3 From 148b628e0b664316b2b0e384ed44b2d7a4872168 Mon Sep 17 00:00:00 2001 From: Maxim Lobanov Date: Thu, 9 Jul 2020 10:53:29 +0300 Subject: [PATCH 11/17] Implement Pester tests --- images/win/Windows2016-Azure.json | 41 ++----- images/win/Windows2019-Azure.json | 41 ++----- .../scripts/ImageHelpers/ImageHelpers.psm1 | 5 + .../win/scripts/ImageHelpers/TestsHelpers.ps1 | 106 ++++++++++++++++++ .../win/scripts/Installers/Install-7zip.ps1 | 2 + .../win/scripts/Installers/Install-Cmake.ps1 | 2 + .../scripts/Installers/Install-JavaTools.ps1 | 2 + .../scripts/Installers/Install-MongoDB.ps1 | 2 + .../win/scripts/Installers/Validate-7zip.ps1 | 15 --- .../win/scripts/Installers/Validate-Cmake.ps1 | 16 --- .../scripts/Installers/Validate-JavaTools.ps1 | 79 ------------- .../win/scripts/Installers/Validate-Kind.ps1 | 14 --- .../scripts/Installers/Validate-MongoDB.ps1 | 24 ---- .../Installers/Windows2016/Initialize-VM.ps1 | 2 + .../Installers/Windows2019/Initialize-VM.ps1 | 2 + images/win/scripts/Tests/Databases.Tests.ps1 | 8 ++ images/win/scripts/Tests/Java.Tests.ps1 | 36 ++++++ images/win/scripts/Tests/RunAll-Tests.ps1 | 1 + images/win/scripts/Tests/Tools.Tests.ps1 | 17 +++ 19 files changed, 207 insertions(+), 208 deletions(-) create mode 100644 images/win/scripts/ImageHelpers/TestsHelpers.ps1 delete mode 100644 images/win/scripts/Installers/Validate-7zip.ps1 delete mode 100644 images/win/scripts/Installers/Validate-Cmake.ps1 delete mode 100644 images/win/scripts/Installers/Validate-JavaTools.ps1 delete mode 100644 images/win/scripts/Installers/Validate-Kind.ps1 delete mode 100644 images/win/scripts/Installers/Validate-MongoDB.ps1 create mode 100644 images/win/scripts/Tests/Databases.Tests.ps1 create mode 100644 images/win/scripts/Tests/Java.Tests.ps1 create mode 100644 images/win/scripts/Tests/RunAll-Tests.ps1 create mode 100644 images/win/scripts/Tests/Tools.Tests.ps1 diff --git a/images/win/Windows2016-Azure.json b/images/win/Windows2016-Azure.json index 05333241..349591cd 100644 --- a/images/win/Windows2016-Azure.json +++ b/images/win/Windows2016-Azure.json @@ -84,6 +84,11 @@ "source": "{{ template_dir }}/scripts/SoftwareReport", "destination": "{{user `image_folder`}}" }, + { + "type": "file", + "source": "{{ template_dir }}/scripts/Tests", + "destination": "{{user `image_folder`}}" + }, { "type": "windows-shell", "inline": [ @@ -839,18 +844,6 @@ "{{ template_dir }}/scripts/Installers/Validate-AliyunCli.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-JavaTools.ps1" - ] - }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-Cmake.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -911,12 +904,6 @@ "{{ template_dir }}/scripts/Installers/Validate-AzureCosmosDbEmulator.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-7zip.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -983,18 +970,6 @@ "{{ template_dir }}/scripts/Installers/Validate-KubernetesCli.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-Kind.ps1" - ] - }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-MongoDB.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -1019,6 +994,12 @@ "type": "windows-restart", "restart_timeout": "10m" }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Tests/RunAll-Tests.ps1" + ] + }, { "type": "powershell", "inline": [ diff --git a/images/win/Windows2019-Azure.json b/images/win/Windows2019-Azure.json index d5bf5f73..94a9a937 100644 --- a/images/win/Windows2019-Azure.json +++ b/images/win/Windows2019-Azure.json @@ -84,6 +84,11 @@ "source": "{{ template_dir }}/scripts/SoftwareReport", "destination": "{{user `image_folder`}}" }, + { + "type": "file", + "source": "{{ template_dir }}/scripts/Tests", + "destination": "{{user `image_folder`}}" + }, { "type": "windows-shell", "inline": [ @@ -826,18 +831,6 @@ "{{ template_dir }}/scripts/Installers/Validate-NodeLts.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-JavaTools.ps1" - ] - }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-Cmake.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -899,12 +892,6 @@ ] }, { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-7zip.ps1" - ] - }, - { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-Packer.ps1" @@ -976,18 +963,6 @@ "{{ template_dir }}/scripts/Installers/Validate-KubernetesCli.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-Kind.ps1" - ] - }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-MongoDB.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -1024,6 +999,12 @@ "type": "windows-restart", "restart_timeout": "10m" }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Tests/RunAll-Tests.ps1" + ] + }, { "type": "powershell", "inline": [ diff --git a/images/win/scripts/ImageHelpers/ImageHelpers.psm1 b/images/win/scripts/ImageHelpers/ImageHelpers.psm1 index 95a7d6c7..da144956 100644 --- a/images/win/scripts/ImageHelpers/ImageHelpers.psm1 +++ b/images/win/scripts/ImageHelpers/ImageHelpers.psm1 @@ -4,6 +4,7 @@ param() . $PSScriptRoot\PathHelpers.ps1 . $PSScriptRoot\InstallHelpers.ps1 . $PSScriptRoot\ChocoHelpers.ps1 +. $PSScriptRoot\TestsHelpers.ps1 Export-ModuleMember -Function @( 'Test-MachinePath' @@ -28,4 +29,8 @@ Export-ModuleMember -Function @( 'Test-IsWin16' 'Choco-Install' 'Extract-7Zip' + 'Get-CommandResult' + 'Get-WhichTool' + 'Get-EnvironmentVariable' + 'Invoke-PesterTests' ) diff --git a/images/win/scripts/ImageHelpers/TestsHelpers.ps1 b/images/win/scripts/ImageHelpers/TestsHelpers.ps1 new file mode 100644 index 00000000..fdc341cc --- /dev/null +++ b/images/win/scripts/ImageHelpers/TestsHelpers.ps1 @@ -0,0 +1,106 @@ +function Get-CommandResult { + Param ( + [Parameter(Mandatory)][string] $Command + ) + # CMD trick to suppress and show error output because some commands write to stderr (for example, "python --version") + [string[]]$output = & $env:comspec /c "$Command 2>&1" + $exitCode = $LASTEXITCODE + + return @{ + Output = $output + ExitCode = $exitCode + } +} + +# Gets path to the tool, analogue of 'which tool' +function Get-WhichTool { + Param ( + [Parameter(Mandatory)][string] $Tool + ) + return (Get-Command $Tool).Path +} + +# Gets value of environment variable by the name +function Get-EnvironmentVariable($variable) { + return [System.Environment]::GetEnvironmentVariable($variable) +} + +# Update environment variables without reboot +function Update-Environment { + $variables = [Environment]::GetEnvironmentVariables("Machine") + $variables.Keys | ForEach-Object { + $key = $_ + $value = $variables[$key] + Set-Item -Path "env:$key" -Value $value + } + # We need to refresh PATH the latest one because it could include other variables "%M2_HOME%/bin" + $env:PATH = [Environment]::GetEnvironmentVariable("PATH", "Machine") +} + +# Run Pester tests for specific tool +function Invoke-PesterTests { + Param( + [Parameter(Mandatory)][string] $TestFile, + [string] $TestName + ) + + $testPath = "C:\image\Tests\${TestFile}.Tests.ps1" + if (-not (Test-Path $testPath)) { + throw "Unable to find test file '$TestFile' on '$testPath'." + } + + $configuration = [PesterConfiguration] @{ + Run = @{ Path = $testPath; PassThru = $true } + Output = @{ Verbosity = "Detailed" } + } + if ($TestName) { + $configuration.Filter.FullName = $TestName + } + + # Update environment variables without reboot + Update-Environment + + # Switch ErrorActionPreference to Stop temporary to make sure that tests will on silent errors too + $backupErrorActionPreference = $ErrorActionPreference + $ErrorActionPreference = "Stop" + $results = Invoke-Pester -Configuration $configuration + $ErrorActionPreference = $backupErrorActionPreference + + # Fail in case if no tests are run + if (-not ($results -and ($results.FailedCount -eq 0) -and ($results.PassedCount -gt 0))) { + $results + throw "Test run has finished with errors" + } +} + +# Pester Assert to check exit code of command +function ShouldReturnZeroExitCode { + Param( + [String]$ActualValue, + [switch]$Negate, + [string] $Because + ) + + $result = Get-CommandResult $ActualValue + + [bool]$succeeded = $result.ExitCode -eq 0 + if ($Negate) { $succeeded = -not $succeeded } + + + + if (-not $succeeded) + { + $CommandResultIndent = " " * 4 + $commandOutput = ($result.Output | ForEach-Object { "${CommandResultIndent}${_}" }) -join "`n" + $failureMessage = "Command '${ActualValue}' has finished with exit code ${actualExitCode}`n${commandOutput}" + } + + return [PSCustomObject] @{ + Succeeded = $succeeded + FailureMessage = $failureMessage + } +} + +If (Get-Command -Name Add-AssertionOperator -ErrorAction SilentlyContinue) { + Add-AssertionOperator -Name ReturnZeroExitCode -InternalName ShouldReturnZeroExitCode -Test ${function:ShouldReturnZeroExitCode} +} \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-7zip.ps1 b/images/win/scripts/Installers/Install-7zip.ps1 index 419c8178..9ad1e204 100644 --- a/images/win/scripts/Installers/Install-7zip.ps1 +++ b/images/win/scripts/Installers/Install-7zip.ps1 @@ -4,3 +4,5 @@ ################################################################################ Choco-Install -PackageName 7zip.install + +Invoke-PesterTests -TestFile "Tools" -TestName "7-Zip" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-Cmake.ps1 b/images/win/scripts/Installers/Install-Cmake.ps1 index 37183d5e..8baa82e2 100644 --- a/images/win/scripts/Installers/Install-Cmake.ps1 +++ b/images/win/scripts/Installers/Install-Cmake.ps1 @@ -4,3 +4,5 @@ ################################################################################ Choco-Install -PackageName cmake.install -ArgumentList "--installargs",'ADD_CMAKE_TO_PATH=""System""' + +Invoke-PesterTests -TestFile "Tools" -TestName "CMake" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-JavaTools.ps1 b/images/win/scripts/Installers/Install-JavaTools.ps1 index 49b95e3a..759d132f 100644 --- a/images/win/scripts/Installers/Install-JavaTools.ps1 +++ b/images/win/scripts/Installers/Install-JavaTools.ps1 @@ -126,3 +126,5 @@ $archivePath = Start-DownloadWithRetry -Url $uri -Name "cobertura.zip" Extract-7Zip -Path $archivePath -DestinationPath "C:\" setx COBERTURA_HOME $coberturaPath /M + +Invoke-PesterTests -TestFile "Java" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-MongoDB.ps1 b/images/win/scripts/Installers/Install-MongoDB.ps1 index 245e5b98..177300e9 100644 --- a/images/win/scripts/Installers/Install-MongoDB.ps1 +++ b/images/win/scripts/Installers/Install-MongoDB.ps1 @@ -7,3 +7,5 @@ Choco-Install -PackageName mongodb $mongoPath = (Get-CimInstance Win32_Service -Filter "Name LIKE 'mongodb'").PathName $mongoBin = Split-Path -Path $mongoPath.split('"')[1] Add-MachinePathItem "$mongoBin" + +Invoke-PesterTests -TestFile "Databases" -TestName "MongoDB" \ No newline at end of file diff --git a/images/win/scripts/Installers/Validate-7zip.ps1 b/images/win/scripts/Installers/Validate-7zip.ps1 deleted file mode 100644 index d29d394e..00000000 --- a/images/win/scripts/Installers/Validate-7zip.ps1 +++ /dev/null @@ -1,15 +0,0 @@ -################################################################################ -## File: Validate-7zip.ps1 -## Desc: Validate 7zip -################################################################################ - -if (Get-Command -Name '7z') -{ - Write-Host '7zip on path' -} -else -{ - Write-Host '7zip is not on path' - exit 1 -} - diff --git a/images/win/scripts/Installers/Validate-Cmake.ps1 b/images/win/scripts/Installers/Validate-Cmake.ps1 deleted file mode 100644 index df683591..00000000 --- a/images/win/scripts/Installers/Validate-Cmake.ps1 +++ /dev/null @@ -1,16 +0,0 @@ -################################################################################ -## File: Validate-Cmake.ps1 -## Desc: Validate Cmake -################################################################################ - -if(Get-Command -Name 'cmake') -{ - Write-Host "CMake $(cmake -version) on path" -} -else -{ - Write-Host "CMake not on path" - exit 1 -} - - diff --git a/images/win/scripts/Installers/Validate-JavaTools.ps1 b/images/win/scripts/Installers/Validate-JavaTools.ps1 deleted file mode 100644 index 50513156..00000000 --- a/images/win/scripts/Installers/Validate-JavaTools.ps1 +++ /dev/null @@ -1,79 +0,0 @@ -################################################################################ -## File: Validate-JavaTools.ps1 -## Desc: Validate various JDKs and java tools -################################################################################ - -Function Validate-JavaVersion { - param ( - [Parameter(Mandatory)] [string] $Version, - [switch] $Default - ) - - Write-Host "Checking Java $version" - - # Set Path to get Java - if (-not $Default) - { - # Take 7 & 8 for versions 1.7 and 1.8 - $versionNumber = $version.Split(".") | Select-Object -Last 1 - - $javaPath = [System.Environment]::GetEnvironmentVariable("JAVA_HOME_${versionNumber}_X64") - if ([string]::IsNullOrEmpty($javaPath)) - { - Write-Host "Environment variable 'JAVA_HOME_${versionNumber}_X64' is null" - exit 1 - } - - $javaBin = "$javaPath\bin;" - $env:Path = $javaBin + $env:Path - } - else - { - Validate-JavaVersion -Version $Version - } - - $isJavaExists = $($(& $env:comspec "/s /c java -version 2>&1") | Out-String) -match '^(?.+) version "(?.+)".*' - - if ($isJavaExists) - { - $javaVersion = $matches.version - } - else - { - Write-Host "Java $version was not found" - exit 1 - } - - $isJavaCorrect = $javaVersion.StartsWith($version) - - if($isJavaCorrect) - { - Write-Host "Java $javaVersion found" - # Reset Path to the default one in case we need to check the default Java later - $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") - } - else - { - Write-Host "Expected Java $version, but found $javaVersion" - exit 1 - } -} - -if((Get-Command -Name 'java') -and (Get-Command -Name 'mvn') -and (Get-Command -Name 'ant') -and (Get-Command -Name 'gradle')) -{ - Write-Host "Java $(java -version) on path" - Write-Host "Maven $(mvn -version) on path" - Write-Host "Ant $(ant -version) on path" - Write-Host "Gradle $(gradle -version) on path" -} -else -{ - Write-Host "one of Java,Maven,Ant,Gradle is not on path." - exit 1 -} - -Write-Host "Checking installed Java versions" -Validate-JavaVersion -Version "1.7" -Validate-JavaVersion -Version "1.8" -Default -Validate-JavaVersion -Version "11" -Validate-JavaVersion -Version "13" diff --git a/images/win/scripts/Installers/Validate-Kind.ps1 b/images/win/scripts/Installers/Validate-Kind.ps1 deleted file mode 100644 index 9147f462..00000000 --- a/images/win/scripts/Installers/Validate-Kind.ps1 +++ /dev/null @@ -1,14 +0,0 @@ -################################################################################ -## File: Validate-Kind.ps1 -## Desc: Validate Kind. -################################################################################ - -if (Get-Command -Name 'kind') -{ - Write-Host "kind $(kind version) in path" -} -else -{ - Write-Host "kind is not in path" - exit 1 -} diff --git a/images/win/scripts/Installers/Validate-MongoDB.ps1 b/images/win/scripts/Installers/Validate-MongoDB.ps1 deleted file mode 100644 index 517f824c..00000000 --- a/images/win/scripts/Installers/Validate-MongoDB.ps1 +++ /dev/null @@ -1,24 +0,0 @@ -################################################################################ -## File: Validate-MongoDB.ps1 -## Desc: Validate MongoDB -################################################################################ - -if (Get-Command -Name 'mongod') -{ - Write-Host 'mongod is on path' -} -else -{ - Write-Host 'mongod not on path' - exit 1 -} - -if (Get-Command -Name 'mongo') -{ - Write-Host 'mongo is on path' -} -else -{ - Write-Host 'mongo not on path' - exit 1 -} diff --git a/images/win/scripts/Installers/Windows2016/Initialize-VM.ps1 b/images/win/scripts/Installers/Windows2016/Initialize-VM.ps1 index 794c1b0f..5afc6e61 100644 --- a/images/win/scripts/Installers/Windows2016/Initialize-VM.ps1 +++ b/images/win/scripts/Installers/Windows2016/Initialize-VM.ps1 @@ -41,6 +41,8 @@ Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force Install-Module -Name PowerShellGet -Force Set-PSRepository -InstallationPolicy Trusted -Name PSGallery +Write-Host "Install the latest Pester version" +Install-Module Pester -Scope AllUsers -SkipPublisherCheck -Force Write-Host "Disable Antivirus" Set-MpPreference -DisableRealtimeMonitoring $true diff --git a/images/win/scripts/Installers/Windows2019/Initialize-VM.ps1 b/images/win/scripts/Installers/Windows2019/Initialize-VM.ps1 index 99c238e8..e57ccb98 100644 --- a/images/win/scripts/Installers/Windows2019/Initialize-VM.ps1 +++ b/images/win/scripts/Installers/Windows2019/Initialize-VM.ps1 @@ -38,6 +38,8 @@ Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force Install-Module -Name PowerShellGet -Force Set-PSRepository -InstallationPolicy Trusted -Name PSGallery +Write-Host "Install the latest Pester version" +Install-Module Pester -Scope AllUsers -SkipPublisherCheck -Force Write-Host "Disable Antivirus" Set-MpPreference -DisableRealtimeMonitoring $true diff --git a/images/win/scripts/Tests/Databases.Tests.ps1 b/images/win/scripts/Tests/Databases.Tests.ps1 new file mode 100644 index 00000000..b7cda7a4 --- /dev/null +++ b/images/win/scripts/Tests/Databases.Tests.ps1 @@ -0,0 +1,8 @@ +Describe "MongoDB" { + It "" -TestCases @( + @{ ToolName = "mongo" } + @{ ToolName = "mongod" } + ) { + "$ToolName --version" | Should -ReturnZeroExitCode + } +} \ No newline at end of file diff --git a/images/win/scripts/Tests/Java.Tests.ps1 b/images/win/scripts/Tests/Java.Tests.ps1 new file mode 100644 index 00000000..04a749bd --- /dev/null +++ b/images/win/scripts/Tests/Java.Tests.ps1 @@ -0,0 +1,36 @@ +Describe "Java" { + It "Java is default" -TestCases @(@{ DefaultJavaVersion = 8 }) { + $actualJavaPath = Get-EnvironmentVariable "JAVA_HOME" + $expectedJavaPath = Get-EnvironmentVariable "JAVA_HOME_${DefaultJavaVersion}_X64" + + $actualJavaPath | Should -Not -BeNullOrEmpty + $expectedJavaPath | Should -Not -BeNullOrEmpty + $actualJavaPath | Should -Be $expectedJavaPath + } + + It "" -TestCases @( + @{ ToolName = "java" } + @{ ToolName = "mvn" } + @{ ToolName = "ant" } + @{ ToolName = "gradle" } + ) { + "$ToolName -version" | Should -ReturnZeroExitCode + } + + It "Java " -TestCases @( + @{ Version = "1.7" } + @{ Version = "1.8" } + @{ Version = "11" } + @{ Version = "13" } + ) { + $versionNumber = $version.Split(".") | Select-Object -Last 1 + + $javaVariableValue = Get-EnvironmentVariable "JAVA_HOME_${versionNumber}_X64" + $javaVariableValue | Should -Not -BeNullOrEmpty + $javaPath = Join-Path $javaVariableValue "bin\java" + + $result = Get-CommandResult "`"$javaPath`" -version" + $result.ExitCode | Should -Be 0 + $result.Output[0] | Should -Match ([regex]::Escape("openjdk version `"${Version}.")) + } +} \ No newline at end of file diff --git a/images/win/scripts/Tests/RunAll-Tests.ps1 b/images/win/scripts/Tests/RunAll-Tests.ps1 new file mode 100644 index 00000000..1d8e835c --- /dev/null +++ b/images/win/scripts/Tests/RunAll-Tests.ps1 @@ -0,0 +1 @@ +Invoke-PesterTests "*" \ No newline at end of file diff --git a/images/win/scripts/Tests/Tools.Tests.ps1 b/images/win/scripts/Tests/Tools.Tests.ps1 new file mode 100644 index 00000000..6ddbcb21 --- /dev/null +++ b/images/win/scripts/Tests/Tools.Tests.ps1 @@ -0,0 +1,17 @@ +Describe "7-Zip" { + It "7z" { + "7z" | Should -ReturnZeroExitCode + } +} + +Describe "CMake" { + It "cmake" { + "cmake --version" | Should -ReturnZeroExitCode + } +} + +Describe "Kind" { + It "Kind" { + "kind version" | Should -ReturnZeroExitCode + } +} \ No newline at end of file From 006744204f7188db3676116261c610b672a53994 Mon Sep 17 00:00:00 2001 From: Maxim Lobanov Date: Thu, 9 Jul 2020 11:06:29 +0300 Subject: [PATCH 12/17] run tests for Kind --- images/win/scripts/Installers/Install-Kind.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/images/win/scripts/Installers/Install-Kind.ps1 b/images/win/scripts/Installers/Install-Kind.ps1 index 0e97cc04..b1c936fc 100644 --- a/images/win/scripts/Installers/Install-Kind.ps1 +++ b/images/win/scripts/Installers/Install-Kind.ps1 @@ -38,3 +38,5 @@ catch Write-Host $_.Exception.Message exit 1 } + +Invoke-PesterTests -TestFile "Tools" -TestName "Kind" \ No newline at end of file From d693730c54e8fe75a7bb3e6c9a1919649033ee37 Mon Sep 17 00:00:00 2001 From: Maxim Lobanov Date: Thu, 9 Jul 2020 13:22:07 +0300 Subject: [PATCH 13/17] fix comments --- images/win/scripts/ImageHelpers/TestsHelpers.ps1 | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/images/win/scripts/ImageHelpers/TestsHelpers.ps1 b/images/win/scripts/ImageHelpers/TestsHelpers.ps1 index fdc341cc..5f8b5809 100644 --- a/images/win/scripts/ImageHelpers/TestsHelpers.ps1 +++ b/images/win/scripts/ImageHelpers/TestsHelpers.ps1 @@ -69,15 +69,15 @@ function Invoke-PesterTests { # Fail in case if no tests are run if (-not ($results -and ($results.FailedCount -eq 0) -and ($results.PassedCount -gt 0))) { $results - throw "Test run has finished with errors" + throw "Test run has failed" } } # Pester Assert to check exit code of command function ShouldReturnZeroExitCode { Param( - [String]$ActualValue, - [switch]$Negate, + [String] $ActualValue, + [switch] $Negate, [string] $Because ) @@ -86,8 +86,6 @@ function ShouldReturnZeroExitCode { [bool]$succeeded = $result.ExitCode -eq 0 if ($Negate) { $succeeded = -not $succeeded } - - if (-not $succeeded) { $CommandResultIndent = " " * 4 From 9bd0f97777916e836e2406ca5dae82d726349bd2 Mon Sep 17 00:00:00 2001 From: Maxim Lobanov Date: Thu, 9 Jul 2020 14:09:44 +0300 Subject: [PATCH 14/17] fix spacing --- images/win/scripts/ImageHelpers/TestsHelpers.ps1 | 4 ++-- images/win/scripts/Tests/Java.Tests.ps1 | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/images/win/scripts/ImageHelpers/TestsHelpers.ps1 b/images/win/scripts/ImageHelpers/TestsHelpers.ps1 index 5f8b5809..ee962129 100644 --- a/images/win/scripts/ImageHelpers/TestsHelpers.ps1 +++ b/images/win/scripts/ImageHelpers/TestsHelpers.ps1 @@ -88,8 +88,8 @@ function ShouldReturnZeroExitCode { if (-not $succeeded) { - $CommandResultIndent = " " * 4 - $commandOutput = ($result.Output | ForEach-Object { "${CommandResultIndent}${_}" }) -join "`n" + $сommandOutputIndent = " " * 4 + $commandOutput = ($result.Output | ForEach-Object { "${сommandOutputIndent}${_}" }) -join "`n" $failureMessage = "Command '${ActualValue}' has finished with exit code ${actualExitCode}`n${commandOutput}" } diff --git a/images/win/scripts/Tests/Java.Tests.ps1 b/images/win/scripts/Tests/Java.Tests.ps1 index 04a749bd..9ca9be19 100644 --- a/images/win/scripts/Tests/Java.Tests.ps1 +++ b/images/win/scripts/Tests/Java.Tests.ps1 @@ -9,12 +9,12 @@ Describe "Java" { } It "" -TestCases @( - @{ ToolName = "java" } - @{ ToolName = "mvn" } - @{ ToolName = "ant" } - @{ ToolName = "gradle" } + @{ ToolName = "java" } + @{ ToolName = "mvn" } + @{ ToolName = "ant" } + @{ ToolName = "gradle" } ) { - "$ToolName -version" | Should -ReturnZeroExitCode + "$ToolName -version" | Should -ReturnZeroExitCode } It "Java " -TestCases @( From 205fb1887e3e4354898e36e9e449f1d2ea3ee4f8 Mon Sep 17 00:00:00 2001 From: Maxim Lobanov Date: Thu, 9 Jul 2020 14:27:06 +0300 Subject: [PATCH 15/17] Update TestsHelpers.ps1 --- images/win/scripts/ImageHelpers/TestsHelpers.ps1 | 8 -------- 1 file changed, 8 deletions(-) diff --git a/images/win/scripts/ImageHelpers/TestsHelpers.ps1 b/images/win/scripts/ImageHelpers/TestsHelpers.ps1 index ee962129..5cc69dec 100644 --- a/images/win/scripts/ImageHelpers/TestsHelpers.ps1 +++ b/images/win/scripts/ImageHelpers/TestsHelpers.ps1 @@ -12,14 +12,6 @@ function Get-CommandResult { } } -# Gets path to the tool, analogue of 'which tool' -function Get-WhichTool { - Param ( - [Parameter(Mandatory)][string] $Tool - ) - return (Get-Command $Tool).Path -} - # Gets value of environment variable by the name function Get-EnvironmentVariable($variable) { return [System.Environment]::GetEnvironmentVariable($variable) From a2b104ff7e6199522e34aef1c952cb40384294da Mon Sep 17 00:00:00 2001 From: Maxim Lobanov Date: Thu, 9 Jul 2020 14:29:02 +0300 Subject: [PATCH 16/17] Update ImageHelpers.psm1 --- images/win/scripts/ImageHelpers/ImageHelpers.psm1 | 1 - 1 file changed, 1 deletion(-) diff --git a/images/win/scripts/ImageHelpers/ImageHelpers.psm1 b/images/win/scripts/ImageHelpers/ImageHelpers.psm1 index da144956..d711f745 100644 --- a/images/win/scripts/ImageHelpers/ImageHelpers.psm1 +++ b/images/win/scripts/ImageHelpers/ImageHelpers.psm1 @@ -30,7 +30,6 @@ Export-ModuleMember -Function @( 'Choco-Install' 'Extract-7Zip' 'Get-CommandResult' - 'Get-WhichTool' 'Get-EnvironmentVariable' 'Invoke-PesterTests' ) From 5f8c5c4fcf25bc380d4faf0f7d00af386904d222 Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov <47745270+al-cheb@users.noreply.github.com> Date: Thu, 9 Jul 2020 21:22:33 +0300 Subject: [PATCH 17/17] Return sqlite3 and patchelf (#1206) * patchelf bzip2 sqlite3 * update ubuntu 16.04 * merge 1604/basic.sh -> basic.sh --- images/linux/scripts/installers/1604/basic.sh | 85 ------------------- images/linux/scripts/installers/basic.sh | 19 ++++- images/linux/ubuntu1604.json | 2 +- 3 files changed, 16 insertions(+), 90 deletions(-) delete mode 100644 images/linux/scripts/installers/1604/basic.sh diff --git a/images/linux/scripts/installers/1604/basic.sh b/images/linux/scripts/installers/1604/basic.sh deleted file mode 100644 index cd401714..00000000 --- a/images/linux/scripts/installers/1604/basic.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/bash -################################################################################ -## File: basic.sh -## Desc: Installs basic command line utilities and dev packages -################################################################################ - -# Source the helpers for use with the script -source $HELPER_SCRIPTS/document.sh -source $HELPER_SCRIPTS/apt.sh - -set -e - -common_packages="dnsutils - iproute2 - iputils-ping - libc++-dev - libc++abi-dev - libcurl3 - libicu55 - libunwind8 - locales - openssh-client - tzdata - zstd - lib32z1 - libxkbfile-dev - pkg-config - libsecret-1-dev - libxss1 - libgconf-2-4 - dbus - xvfb - libgbm-dev - libgtk-3-0 - tk - fakeroot - dpkg - rpm - xz-utils - xorriso - zsync - gnupg2 - texinfo" - -cmd_packages="curl - file - ftp - jq - netcat - ssh - parallel - rsync - shellcheck - sudo - telnet - time - unzip - zip - wget - upx - m4 - bison - flex" - -# Install basic command-line utilities -for package in $common_packages $cmd_packages; do - echo "Install $package" - apt-fast install -y --no-install-recommends $package -done - -# 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 $cmd_packages; do - if ! command -v $cmd; then - echo "$cmd was not installed" - exit 1 - fi -done - -# Document what was added to the image -echo "Lastly, documenting what we added to the metadata file" -DocumentInstalledItem "Basic packages:" -for package in $common_packages $cmd_packages; do - DocumentInstalledItemIndent $package -done diff --git a/images/linux/scripts/installers/basic.sh b/images/linux/scripts/installers/basic.sh index cef98a9f..de55d67d 100644 --- a/images/linux/scripts/installers/basic.sh +++ b/images/linux/scripts/installers/basic.sh @@ -38,7 +38,8 @@ common_packages="dnsutils zsync gnupg2 lib32z1 - texinfo" + texinfo + libsqlite3-dev" cmd_packages="curl file @@ -57,7 +58,10 @@ cmd_packages="curl wget m4 bison - flex" + flex + patchelf + bzip2 + sqlite3" if isUbuntu20 ; then echo "Install python2" @@ -65,7 +69,7 @@ if isUbuntu20 ; then fi echo "Install libcurl" -if isUbuntu18 ; then +if isUbuntu16 || isUbuntu18; then libcurelVer="libcurl3" fi @@ -75,12 +79,19 @@ fi apt-get install -y --no-install-recommends $libcurelVer +# install additional packages only for Ubuntu16.04 +if isUbuntu16; then + common_packages="$common_packages + libc++-dev + libc++abi-dev + libicu55" +fi + for package in $common_packages $cmd_packages; do echo "Install $package" apt-get install -y --no-install-recommends $package done - # 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 $cmd_packages; do diff --git a/images/linux/ubuntu1604.json b/images/linux/ubuntu1604.json index 839eeb18..23a4bf88 100644 --- a/images/linux/ubuntu1604.json +++ b/images/linux/ubuntu1604.json @@ -143,7 +143,7 @@ "{{template_dir}}/scripts/installers/azcopy.sh", "{{template_dir}}/scripts/installers/azure-cli.sh", "{{template_dir}}/scripts/installers/azure-devops-cli.sh", - "{{template_dir}}/scripts/installers/1604/basic.sh", + "{{template_dir}}/scripts/installers/basic.sh", "{{template_dir}}/scripts/installers/aliyun-cli.sh", "{{template_dir}}/scripts/installers/aws.sh", "{{template_dir}}/scripts/installers/build-essential.sh",