Skip to content

Commit f56f4fa

Browse files
prontclaude
andauthored
chore(ci): remove Chocolatey from Windows bootstrap (#25254)
* chore(ci): remove Chocolatey from Windows bootstrap Install protoc directly from the upstream GitHub release (matching the pinned version used on Linux/macOS in scripts/environment/install-protoc.sh) instead of going through Chocolatey. GNU make is already on the default PATH of the windows-2025 runner image via C:\mingw64\bin, so no extra install step is needed for it. This eliminates the recurring "Chocolatey installed 0/0 packages" failures caused by Chocolatey CDN blips, and pins the Windows build to the same protoc version used on Linux/macOS. Verified on the ci-sandbox repo: - protoc resolves to $RUNNER_TEMP\protoc\bin\protoc.exe -> libprotoc 3.21.12 - make resolves to C:\mingw64\bin\make.exe -> GNU Make 4.4.1 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore(ci): share install-protoc.sh across platforms Extend the existing Linux/macOS protoc installer with MINGW/MSYS platform detection and .exe handling, and have bootstrap-windows-2025.ps1 delegate to it via Git Bash. This replaces the inline PowerShell download introduced earlier and makes all three platforms pin the same protoc version from the same upstream source. Also adds curl --retry 5 --retry-delay 10 --retry-all-errors so transient download blips are retried without extra scaffolding. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore(ci): drop curl --retry-all-errors for focal compatibility The ghcr.io/cross-rs/* base images used by scripts/cross/Dockerfile are Ubuntu 20.04 focal, which ships curl 7.68.x. --retry-all-errors was added in curl 7.71.0, so it would be rejected as an unknown option and break cross-target builds that run install-protoc.sh inside those images. Plain --retry 5 --retry-delay 10 still handles the transport-level retries that cover the CDN blips we care about. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent c0cdf20 commit f56f4fa

2 files changed

Lines changed: 39 additions & 40 deletions

File tree

scripts/environment/bootstrap-windows-2025.ps1

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,6 @@
22
$ErrorActionPreference = "Stop"
33
Set-StrictMode -Version Latest
44

5-
# Helper function to install choco packages with exponential backoff retry
6-
function Install-ChocoPackage {
7-
param(
8-
[string]$Package,
9-
[int]$MaxRetries = 5
10-
)
11-
12-
for ($attempt = 1; $attempt -le $MaxRetries; $attempt++) {
13-
choco install $Package --execution-timeout=7200 -y
14-
# Both `choco install` and `choco list` can exit 0 even on 5xx errors
15-
# from the feed, so verify install by matching a "name|version" line
16-
# in the list output. --limit-output strips headers/warnings.
17-
if ((choco list --limit-output -e $Package) -match "^$([regex]::Escape($Package))\|") {
18-
return
19-
}
20-
21-
if ($attempt -lt $MaxRetries) {
22-
$delay = 5 * [math]::Pow(2, $attempt) # Exponential: 10, 20, 40, 80 seconds
23-
Write-Host "choco install $Package failed (attempt $attempt of $MaxRetries). Retrying in $delay seconds..."
24-
Start-Sleep -Seconds $delay
25-
} else {
26-
throw "choco install $Package failed after $MaxRetries attempts"
27-
}
28-
}
29-
}
30-
315
# Set up our Cargo path so we can do Rust-y things.
326
echo "$HOME\.cargo\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
337

@@ -37,9 +11,19 @@ if ($env:RELEASE_BUILDER -ne "true") {
3711
bash scripts/environment/prepare.sh --modules=rustup
3812
}
3913

40-
# Install Chocolatey packages with exponential backoff retry
41-
Install-ChocoPackage "make"
42-
Install-ChocoPackage "protoc"
14+
# Install protoc via the shared cross-platform script. It pins the same version
15+
# used on Linux/macOS and downloads directly from the upstream GitHub release,
16+
# so we avoid the recurring Chocolatey CDN failures.
17+
$ProtocInstallDir = Join-Path $env:RUNNER_TEMP "protoc-bin"
18+
bash scripts/environment/install-protoc.sh "$ProtocInstallDir"
19+
if ($LASTEXITCODE -ne 0) {
20+
throw "install-protoc.sh failed with exit code $LASTEXITCODE"
21+
}
22+
echo "$ProtocInstallDir" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
23+
24+
# GNU make is already on PATH on the windows-2025 runner image via the
25+
# pre-installed MinGW toolchain at C:\mingw64\bin, so no extra install is
26+
# needed here.
4327

4428
# Set a specific override path for libclang.
4529
echo "LIBCLANG_PATH=$( (gcm clang).source -replace "clang.exe" )" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append

scripts/environment/install-protoc.sh

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,12 @@ trap 'rm -rf "${TMP_DIR?}"' EXIT
2323
get_platform() {
2424
local os
2525
os=$(uname)
26-
if [[ "${os}" == "Darwin" ]]; then
27-
echo "osx"
28-
elif [[ "${os}" == "Linux" ]]; then
29-
echo "linux"
30-
else
31-
>&2 echo "unsupported os: ${os}" && exit 1
32-
fi
26+
case "${os}" in
27+
Darwin) echo "osx" ;;
28+
Linux) echo "linux" ;;
29+
MINGW*|MSYS*|CYGWIN*) echo "win64" ;;
30+
*) >&2 echo "unsupported os: ${os}" && exit 1 ;;
31+
esac
3332
}
3433

3534
get_arch() {
@@ -47,20 +46,36 @@ get_arch() {
4746
fi
4847
}
4948

49+
get_bin_name() {
50+
if [[ "$(get_platform)" == "win64" ]]; then
51+
echo "protoc.exe"
52+
else
53+
echo "protoc"
54+
fi
55+
}
56+
5057
install_protoc() {
5158
local version=$1
5259
local install_path=$2
5360

5461
local base_url="https://github.com/protocolbuffers/protobuf/releases/download"
5562
local url
56-
url="${base_url}/v${version}/protoc-${version}-$(get_platform)-$(get_arch).zip"
63+
if [[ "$(get_platform)" == "win64" ]]; then
64+
# Windows release assets are named without an explicit arch suffix.
65+
url="${base_url}/v${version}/protoc-${version}-win64.zip"
66+
else
67+
url="${base_url}/v${version}/protoc-${version}-$(get_platform)-$(get_arch).zip"
68+
fi
5769
local download_path="${TMP_DIR}/protoc.zip"
5870

5971
echo "Downloading ${url}"
60-
curl -fsSL "${url}" -o "${download_path}"
72+
# Stay compatible with the curl shipped by Ubuntu 20.04 focal (7.68.x) used
73+
# in the ghcr.io/cross-rs/* base images: --retry-all-errors was only added
74+
# in curl 7.71.0, so rely on the transport-level retry that --retry covers.
75+
curl --retry 5 --retry-delay 10 -fsSL "${url}" -o "${download_path}"
6176

6277
unzip -qq "${download_path}" -d "${TMP_DIR}"
63-
mv -f -v "${TMP_DIR}/bin/protoc" "${install_path}"
78+
mv -f -v "${TMP_DIR}/bin/$(get_bin_name)" "${install_path}"
6479
}
6580

66-
install_protoc "21.12" "${INSTALL_PATH}/protoc"
81+
install_protoc "21.12" "${INSTALL_PATH}/$(get_bin_name)"

0 commit comments

Comments
 (0)