Skip to content

Commit d7f26a4

Browse files
authored
ci: deflake bazelisk installation (#7258) (#7266)
Download Bazelisk directly from its GitHub releases. Use a retry loop to deal with flakes. Also install for the 32-bit builds, currently unused, but I think the consistency is worth the couple of seconds added to these builds.
1 parent 1092cbe commit d7f26a4

File tree

3 files changed

+52
-11
lines changed

3 files changed

+52
-11
lines changed

ci/kokoro/windows/build-32.bat

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,20 @@
1212
@REM See the License for the specific language governing permissions and
1313
@REM limitations under the License.
1414

15-
REM Change PATH to use chocolatey's version of Bazel
16-
set PATH=C:\ProgramData\chocolatey\bin;%PATH%
15+
REM Install Bazelisk.
16+
@echo %date% %time%
17+
@cd github\google-cloud-cpp
18+
@powershell -exec bypass ci\kokoro\windows\install-bazelisk.ps1
19+
@if NOT ERRORLEVEL 0 exit /b 1
20+
21+
REM Change PATH to install the Bazelisk version we just installed
22+
@set PATH=C:\bin;%PATH%
1723

1824
REM Configure the environment to use MSVC 2019 and then switch to PowerShell.
1925
call "c:\Program Files (x86)\Microsoft Visual Studio\%MSVC_VERSION%\Community\VC\Auxiliary\Build\vcvars32.bat"
2026

2127
REM The remaining of the build script is implemented in PowerShell.
22-
echo %date% %time%
23-
cd github\google-cloud-cpp
28+
@echo %date% %time%
2429
powershell -exec bypass ci\kokoro\windows\build.ps1
2530
if %errorlevel% neq 0 exit /b %errorlevel%
2631

ci/kokoro/windows/build.bat

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,22 @@
1212
@REM See the License for the specific language governing permissions and
1313
@REM limitations under the License.
1414

15-
REM Install Bazelisk using Chocolatey.
16-
choco install --no-progress -y bazelisk
15+
REM Install Bazelisk.
16+
@echo %date% %time%
17+
@cd github\google-cloud-cpp
18+
@powershell -exec bypass ci\kokoro\windows\install-bazelisk.ps1
19+
@if NOT ERRORLEVEL 0 exit /b 1
1720

18-
REM Change PATH to use chocolatey's version of Bazel
19-
set PATH=C:\ProgramData\chocolatey\bin;%PATH%
21+
REM Change PATH to install the Bazelisk version we just installed
22+
@set PATH=C:\bin;%PATH%
2023

2124
REM Configure the environment to use MSVC %MSVC_VERSION% and then switch to PowerShell.
2225
call "c:\Program Files (x86)\Microsoft Visual Studio\%MSVC_VERSION%\Community\VC\Auxiliary\Build\vcvars64.bat"
2326

2427
REM The remaining of the build script is implemented in PowerShell.
25-
echo %date% %time%
26-
cd github\google-cloud-cpp
28+
@echo %date% %time%
2729
powershell -exec bypass ci\kokoro\windows\build.ps1
28-
if %errorlevel% neq 0 exit /b %errorlevel%
30+
if NOT ERRORLEVEL 0 exit /b 1
2931

3032
@echo DONE "============================================="
3133
@echo %date% %time%
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env powershell
2+
#
3+
# Copyright 2021 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# Stop on errors. This is similar to `set -e` on Unix shells.
18+
$ErrorActionPreference = "Stop"
19+
20+
New-Item -ItemType Directory -Force -Path "C:\bin"
21+
22+
ForEach($_ in (30, 60, 120, 240, 0)) {
23+
Write-Host -ForegroundColor Yellow "Downloading bazelisk.exe to C:\Windows"
24+
try {
25+
(New-Object System.Net.WebClient).Downloadfile('https://github.com/bazelbuild/bazelisk/releases/download/v1.10.1/bazelisk-windows-amd64.exe', 'C:\bin\bazelisk.exe');
26+
Write-Host -ForegroundColor Green "bazelisk successfully downloaded"
27+
Exit 0
28+
} catch {
29+
}
30+
Start-Sleep -Seconds $_
31+
}
32+
33+
Write-Host -ForegroundColor Red "bazelisk download failed"
34+
Exit 1

0 commit comments

Comments
 (0)