Skip to content

Commit 1a7d892

Browse files
committed
Install Gradle without services.gradle.org
The merge-queue run for #1108 (37834367420) was evicted when the ubuntu Gradle 6.9.4 e2e leg's install step got HTTP 500 from services.gradle.org six times in 31 s. That host only redirects: the zip lives on the gradle/gradle-distributions GitHub release, and the .sha256 is a second request to the same flaky redirector. scripts/install-gradle.sh now fetches the zip from the GitHub release (services.gradle.org only as a fallback) and checks it against a sha256 pinned in the script, taken from gradle.org/release-checksums. A version with no pinned digest fails closed. The e2e legs and gradle-compatibility.yml share the script. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01148r6VxiJnnFAx13nVn4Sa
1 parent 1fb6d1e commit 1a7d892

3 files changed

Lines changed: 68 additions & 21 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,15 +1526,8 @@ jobs:
15261526
shell: bash
15271527
env:
15281528
GRADLE_VERSION: ${{ matrix.gradle }}
1529-
run: |
1530-
url="https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip"
1531-
curl -fsSL --retry 5 --retry-all-errors --ssl-revoke-best-effort "$url" -o "$RUNNER_TEMP/gradle.zip"
1532-
curl -fsSL --retry 5 --retry-all-errors --ssl-revoke-best-effort "$url.sha256" -o "$RUNNER_TEMP/gradle.sha256"
1533-
python -c 'import hashlib, pathlib, os; p=pathlib.Path(os.environ["RUNNER_TEMP"]); assert hashlib.sha256((p/"gradle.zip").read_bytes()).hexdigest() == (p/"gradle.sha256").read_text().strip()'
1534-
unzip -q "$RUNNER_TEMP/gradle.zip" -d "$RUNNER_TEMP"
1535-
launcher="$RUNNER_TEMP/gradle-${GRADLE_VERSION}/bin/gradle"
1536-
if [ "$RUNNER_OS" = Windows ]; then launcher="${launcher}.bat"; fi
1537-
echo "SOCKET_PATCH_GRADLE_E2E_GRADLE=$launcher" >> "$GITHUB_ENV"
1529+
# Pinned digest, GitHub-release origin: see the script.
1530+
run: scripts/install-gradle.sh "$GRADLE_VERSION" "$RUNNER_TEMP" >> "$GITHUB_ENV"
15381531

15391532
- name: Setup .NET SDK
15401533
if: matrix.dotnet != ''

‎.github/workflows/gradle-compatibility.yml‎

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ name: Gradle patch compatibility
2121
#
2222
# 9.8.0 is the current release on services.gradle.org (re-checked
2323
# 2026-10-02; bump it here and in ci.yml together when a newer 9.x ships).
24-
# 7.6.6 is the last 7.x. Every distribution is sha256-checked against
25-
# services.gradle.org before use.
24+
# 7.6.6 is the last 7.x. scripts/install-gradle.sh pins every
25+
# distribution's sha256; add the new version's digest there too.
2626
#
2727
# Each mode runs its suites' `#[ignore]` tests by name prefix (the contract
2828
# scripts/ci-e2e-bundle.py --check enforces): agent = e2e_gradle_discovery_build
@@ -44,6 +44,7 @@ on:
4444
paths:
4545
- '.github/workflows/gradle-compatibility.yml'
4646
- 'scripts/ci-e2e-bundle.py'
47+
- 'scripts/install-gradle.sh'
4748
- 'Cargo.lock'
4849
- 'Cargo.toml'
4950
- 'crates/*/Cargo.toml'
@@ -277,16 +278,8 @@ jobs:
277278
shell: bash
278279
env:
279280
GRADLE_VERSION: ${{ matrix.gradle }}
280-
run: |
281-
# Download flags: see the Maven step above.
282-
url="https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip"
283-
curl -fsSL --retry 5 --retry-all-errors --ssl-revoke-best-effort "$url" -o "$RUNNER_TEMP/gradle.zip"
284-
curl -fsSL --retry 5 --retry-all-errors --ssl-revoke-best-effort "$url.sha256" -o "$RUNNER_TEMP/gradle.sha256"
285-
python -c 'import hashlib, pathlib, os; p=pathlib.Path(os.environ["RUNNER_TEMP"]); assert hashlib.sha256((p/"gradle.zip").read_bytes()).hexdigest() == (p/"gradle.sha256").read_text().strip()'
286-
unzip -q "$RUNNER_TEMP/gradle.zip" -d "$RUNNER_TEMP"
287-
launcher="$RUNNER_TEMP/gradle-${GRADLE_VERSION}/bin/gradle"
288-
if [ "$RUNNER_OS" = Windows ]; then launcher="${launcher}.bat"; fi
289-
echo "SOCKET_PATCH_GRADLE_E2E_GRADLE=$launcher" >> "$GITHUB_ENV"
281+
# Pinned digest, GitHub-release origin: see the script.
282+
run: scripts/install-gradle.sh "$GRADLE_VERSION" "$RUNNER_TEMP" >> "$GITHUB_ENV"
290283

291284
- name: Run the ${{ matrix.mode }} suites
292285
shell: bash

‎scripts/install-gradle.sh‎

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env bash
2+
# Install one pinned Gradle distribution for the real-Gradle suites, then
3+
# print the variable a CI step appends to $GITHUB_ENV.
4+
#
5+
# scripts/install-gradle.sh <version> <dir>
6+
#
7+
# The zip comes straight from the gradle/gradle-distributions GitHub
8+
# release, the host services.gradle.org redirects to anyway; the redirector
9+
# alone answering HTTP 500 for ~30 s used to fail a merge-queue leg. It is
10+
# only tried after the release download fails. The sha256 is pinned below
11+
# (from https://gradle.org/release-checksums/), so no checksum fetch can fail
12+
# either; a version without a pin fails closed.
13+
#
14+
# Prints (stdout):
15+
# SOCKET_PATCH_GRADLE_E2E_GRADLE=<launcher path>
16+
set -euo pipefail
17+
18+
if [ $# -ne 2 ]; then
19+
sed -n '2,15p' "$0" | sed 's/^# \{0,1\}//' >&2
20+
exit 2
21+
fi
22+
VERSION="$1"
23+
DIR="$2"
24+
25+
case "$VERSION" in
26+
6.9.4) sha=3e240228538de9f18772a574e99a0ba959e83d6ef351014381acd9631781389a ;;
27+
7.6.6) sha=673d9776f303bc7048fc3329d232d6ebf1051b07893bd9d11616fad9a8673be0 ;;
28+
8.14.3) sha=bd71102213493060956ec229d946beee57158dbd89d0e62b91bca0fa2c5f3531 ;;
29+
9.8.0) sha=bafd5ce9cfaea0fbccfdc8439a1ac42fbd4cd9c89dc9a988228d8a2639a58e6c ;;
30+
*)
31+
echo "install-gradle.sh: no pinned sha256 for Gradle $VERSION; add it from https://gradle.org/release-checksums/" >&2
32+
exit 1
33+
;;
34+
esac
35+
36+
mkdir -p "$DIR"
37+
zip="$DIR/gradle-$VERSION-bin.zip"
38+
file="gradle-$VERSION-bin.zip"
39+
fetched=""
40+
# --ssl-revoke-best-effort: Windows curl (schannel) otherwise fails when the
41+
# CA's revocation endpoint is unreachable.
42+
for url in \
43+
"https://github.com/gradle/gradle-distributions/releases/download/v$VERSION/$file" \
44+
"https://services.gradle.org/distributions/$file"; do
45+
if curl -fsSL --retry 5 --retry-all-errors --ssl-revoke-best-effort "$url" -o "$zip"; then
46+
fetched=1
47+
break
48+
fi
49+
echo "install-gradle.sh: download from $url failed" >&2
50+
done
51+
if [ -z "$fetched" ]; then
52+
echo "install-gradle.sh: every origin failed for Gradle $VERSION" >&2
53+
exit 1
54+
fi
55+
56+
# python, not sha256sum: the macOS runners have only shasum.
57+
python -c 'import hashlib, sys; d = hashlib.sha256(open(sys.argv[1], "rb").read()).hexdigest(); sys.exit(0 if d == sys.argv[2] else "sha256 mismatch: got " + d)' "$zip" "$sha"
58+
unzip -q "$zip" -d "$DIR"
59+
launcher="$DIR/gradle-$VERSION/bin/gradle"
60+
case "$(uname -s)" in MINGW*|MSYS*|CYGWIN*) launcher="$launcher.bat" ;; esac
61+
echo "SOCKET_PATCH_GRADLE_E2E_GRADLE=$launcher"

0 commit comments

Comments
 (0)