From 5a2acbc6f0d775b70570ce19a3453e251c77a390 Mon Sep 17 00:00:00 2001 From: Maxim Lobanov Date: Thu, 5 Mar 2020 10:30:24 +0300 Subject: [PATCH] Add Bazelisk support to Linux and Windows (#490) * added bazelisk * moved bazelisk installation to bazel * changed Validate-Bazel.ps1 * removed Install-Bazelisk.ps1 * changed bazel and bazelisk version output * fixed Validate-Bazel.ps1 * removed the extra "$" character --- images/linux/scripts/installers/bazel.sh | 15 +++++++++-- images/linux/ubuntu1604.json | 2 +- images/linux/ubuntu1804.json | 2 +- images/win/Windows2016-Azure.json | 24 +++++++++--------- .../win/scripts/Installers/Install-Bazel.ps1 | 6 +++-- .../win/scripts/Installers/Validate-Bazel.ps1 | 25 +++++++++++++++++-- 6 files changed, 54 insertions(+), 20 deletions(-) diff --git a/images/linux/scripts/installers/bazel.sh b/images/linux/scripts/installers/bazel.sh index fcc8f03dd..d6649fcee 100644 --- a/images/linux/scripts/installers/bazel.sh +++ b/images/linux/scripts/installers/bazel.sh @@ -1,7 +1,7 @@ #!/bin/bash ################################################################################ ## File: bazel.sh -## Desc: Installs bazel +## Desc: Installs Bazel and Bazelisk (A user-friendly launcher for Bazel) ################################################################################ # Source the helpers for use with the script @@ -13,6 +13,9 @@ echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | apt-get update -y apt-get install -y bazel +# Install bazelisk +npm install -g @bazel/bazelisk + # 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 ! command -v bazel; then @@ -20,6 +23,14 @@ if ! command -v bazel; then exit 1 fi +if ! command -v bazelisk; then + echo "Bazelisk was not installed" + exit 1 +fi + # Document what was added to the image +bazelisk_version = $(bazelisk version | grep "Bazelisk version:" | cut -d ":" -f 2) + echo "Lastly, documenting what we added to the metadata file" -DocumentInstalledItem "Bazel ($(bazel version))" +DocumentInstalledItem "Bazel ($(bazel --version))" +DocumentInstalledItem "Bazelisk ($bazelisk_version)" diff --git a/images/linux/ubuntu1604.json b/images/linux/ubuntu1604.json index 62700c4b9..5317804de 100644 --- a/images/linux/ubuntu1604.json +++ b/images/linux/ubuntu1604.json @@ -123,7 +123,6 @@ "{{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/bazel.sh", "{{template_dir}}/scripts/installers/1604/basic.sh", "{{template_dir}}/scripts/installers/aws.sh", "{{template_dir}}/scripts/installers/build-essential.sh", @@ -153,6 +152,7 @@ "{{template_dir}}/scripts/installers/mono.sh", "{{template_dir}}/scripts/installers/mysql.sh", "{{template_dir}}/scripts/installers/nodejs.sh", + "{{template_dir}}/scripts/installers/bazel.sh", "{{template_dir}}/scripts/installers/phantomjs.sh", "{{template_dir}}/scripts/installers/1604/php.sh", "{{template_dir}}/scripts/installers/pollinate.sh", diff --git a/images/linux/ubuntu1804.json b/images/linux/ubuntu1804.json index d825cc858..121a11090 100644 --- a/images/linux/ubuntu1804.json +++ b/images/linux/ubuntu1804.json @@ -126,7 +126,6 @@ "{{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/bazel.sh", "{{template_dir}}/scripts/installers/1804/basic.sh", "{{template_dir}}/scripts/installers/aws.sh", "{{template_dir}}/scripts/installers/build-essential.sh", @@ -156,6 +155,7 @@ "{{template_dir}}/scripts/installers/mono.sh", "{{template_dir}}/scripts/installers/mysql.sh", "{{template_dir}}/scripts/installers/nodejs.sh", + "{{template_dir}}/scripts/installers/bazel.sh", "{{template_dir}}/scripts/installers/phantomjs.sh", "{{template_dir}}/scripts/installers/1804/php.sh", "{{template_dir}}/scripts/installers/pollinate.sh", diff --git a/images/win/Windows2016-Azure.json b/images/win/Windows2016-Azure.json index f5632891c..c1db38b6d 100644 --- a/images/win/Windows2016-Azure.json +++ b/images/win/Windows2016-Azure.json @@ -277,6 +277,12 @@ "{{ template_dir }}/scripts/Installers/Install-NodeLts.ps1" ] }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Install-Bazel.ps1" + ] + }, { "type": "powershell", "scripts":[ @@ -576,12 +582,6 @@ "{{ template_dir }}/scripts/Installers/Install-Kind.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Install-Bazel.ps1" - ] - }, { "type": "windows-restart", "restart_timeout": "30m" @@ -717,6 +717,12 @@ "{{ template_dir }}/scripts/Installers/Validate-NodeLts.ps1" ] }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Validate-Bazel.ps1" + ] + }, { "type": "powershell", "scripts":[ @@ -861,12 +867,6 @@ "{{ template_dir }}/scripts/Installers/Validate-Kind.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-Bazel.ps1" - ] - }, { "type": "file", "source": "C:\\InstalledSoftware.md", diff --git a/images/win/scripts/Installers/Install-Bazel.ps1 b/images/win/scripts/Installers/Install-Bazel.ps1 index 1973c06f6..fb14a856b 100644 --- a/images/win/scripts/Installers/Install-Bazel.ps1 +++ b/images/win/scripts/Installers/Install-Bazel.ps1 @@ -1,6 +1,8 @@ ################################################################################ ## File: Install-Bazel.ps1 -## Desc: Install Bazel +## Desc: Install Bazel and Bazelisk (A user-friendly launcher for Bazel) ################################################################################ -choco install bazel -y \ No newline at end of file +choco install bazel -y + +npm install -g @bazel/bazelisk \ No newline at end of file diff --git a/images/win/scripts/Installers/Validate-Bazel.ps1 b/images/win/scripts/Installers/Validate-Bazel.ps1 index 71af7df72..3fc0e3d69 100644 --- a/images/win/scripts/Installers/Validate-Bazel.ps1 +++ b/images/win/scripts/Installers/Validate-Bazel.ps1 @@ -1,6 +1,6 @@ ################################################################################ ## File: Validate-Bazel.ps1 -## Desc: Validate Bazel +## Desc: Validate Bazel and Bazelisk (A user-friendly launcher for Bazel) ################################################################################ if (Get-Command -Name 'bazel') @@ -13,11 +13,32 @@ else exit 1 } -# Adding description of the software to Markdown +if (Get-Command -Name 'bazelisk') +{ + Write-Host "bazelisk on path" +} +else +{ + Write-Host 'bazelisk is not on path' + exit 1 +} + +# Adding description of Bazel to Markdown $SoftwareName = "bazel" $Description = @" _Version:_ $(bazel --version)
"@ +Add-SoftwareDetailsToMarkdown -SoftwareName $SoftwareName -DescriptionMarkdown $Description + +# Adding description of Bazelisk to Markdown +$bazelisk_version = (bazelisk version | Select-String "Bazelisk version:").Split(":")[1] + +$SoftwareName = "bazelisk" + +$Description = @" +_Version:_ $bazelisk_version
+"@ + Add-SoftwareDetailsToMarkdown -SoftwareName $SoftwareName -DescriptionMarkdown $Description \ No newline at end of file