Skip to content

Commit d19ce41

Browse files
Cache the Gradle zip so release 504s can't fail gradle legs (#2046)
* Cache the pinned Gradle zip for e2e legs Both install-gradle.sh origins are served by github.com releases (services.gradle.org redirects there). On 2026-11-09 05:43-05:47 UTC release downloads returned 504 for longer than curl's ~30 s of retries, and 9 gradle legs of the nightly failed in the install step (run 42568829044). The 9.8.0 legs run on every PR and in the merge queue, where the same window would evict the entry. Restore gradle-<version>-bin.zip from the actions cache before the install step and save it from main on a miss, as #2039 does for vexctl. install-gradle.sh now uses a zip already in place when it matches the pinned sha256, and deletes and re-downloads one that does not. gradle-compatibility.yml restores the same keys and its nightly saves the macOS and Windows zips ci.yml never fetches. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeT4udaLUf9uZoDNXAx * Key the Gradle cache on the pins, restore-only compat Address review: include a hash of install-gradle.sh (which holds the sha256 pins) in the cache key so a fixed pin saves a fresh entry; let gradle-compatibility.yml only restore, keeping ~1 GB of per-OS zips out of the repo cache; print the whole usage header; and unzip with -o so a second run into the same directory reuses the cached zip. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeT4udaLUf9uZoDNXAx --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 891d7a1 commit d19ce41

3 files changed

Lines changed: 76 additions & 14 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1847,6 +1847,25 @@ jobs:
18471847
if [ "$RUNNER_OS" = Windows ]; then launcher="${launcher}.cmd"; fi
18481848
echo "SOCKET_PATCH_MAVEN_E2E_MVN=$launcher" >> "$GITHUB_ENV"
18491849
1850+
- name: Restore the Gradle ${{ matrix.gradle }} distribution
1851+
# Both of install-gradle.sh's origins are served by github.com
1852+
# releases (services.gradle.org redirects there). On 2026-11-09
1853+
# those returned 504 for minutes at a time, longer than curl's
1854+
# ~30 s of retries, and failed 9 gradle legs of the nightly (run
1855+
# 42568829044); the 9.8.0 legs run in the merge queue too. The zip
1856+
# is pinned by sha256, which the script checks on a restored copy
1857+
# as well, so cache it per version. Saved from main only.
1858+
id: gradle-dist-cache
1859+
if: matrix.gradle != ''
1860+
uses: actions/cache/restore@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
1861+
# A miss only means downloading the zip.
1862+
timeout-minutes: 5
1863+
continue-on-error: true
1864+
with:
1865+
path: ${{ runner.temp }}/gradle-${{ matrix.gradle }}-bin.zip
1866+
# The script holds the pins: a changed pin starts a fresh key.
1867+
key: gradle-dist-${{ matrix.gradle }}-${{ runner.os }}-${{ hashFiles('scripts/install-gradle.sh') }}
1868+
18501869
- name: Install Gradle ${{ matrix.gradle }}
18511870
if: matrix.gradle != ''
18521871
shell: bash
@@ -1855,6 +1874,19 @@ jobs:
18551874
# Pinned digest, GitHub-release origin: see the script.
18561875
run: scripts/install-gradle.sh "$GRADLE_VERSION" "$RUNNER_TEMP" >> "$GITHUB_ENV"
18571876

1877+
- name: Save the Gradle ${{ matrix.gradle }} distribution
1878+
if: >-
1879+
matrix.gradle != ''
1880+
&& github.ref == 'refs/heads/main'
1881+
&& steps.gradle-dist-cache.outputs.cache-hit != 'true'
1882+
&& steps.gradle-dist-cache.outcome == 'success'
1883+
uses: actions/cache/save@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
1884+
# Several legs share a version: the first save of a key wins and
1885+
# the others only log a warning, as the action does for any taken key.
1886+
with:
1887+
path: ${{ runner.temp }}/gradle-${{ matrix.gradle }}-bin.zip
1888+
key: ${{ steps.gradle-dist-cache.outputs.cache-primary-key }}
1889+
18581890
- name: Setup .NET SDK
18591891
if: matrix.dotnet != ''
18601892
# Installs next to the runner's preinstalled SDKs; the suite writes

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,19 @@ jobs:
345345
echo "SOCKET_PATCH_MAVEN_E2E_REQUIRED=1"
346346
} >> "$GITHUB_ENV"
347347
348+
- name: Restore the Gradle ${{ matrix.gradle }} distribution
349+
# ci.yml's e2e legs save this pinned zip from main (every version
350+
# on Linux, 8.14.3 on Windows); restoring it keeps a github.com
351+
# release outage from failing these legs. See the matching step
352+
# there. Restore only: saving every OS x version here would add
353+
# ~1 GB of near-duplicate zips to the repo's cache.
354+
uses: actions/cache/restore@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
355+
timeout-minutes: 5
356+
continue-on-error: true
357+
with:
358+
path: ${{ runner.temp }}/gradle-${{ matrix.gradle }}-bin.zip
359+
key: gradle-dist-${{ matrix.gradle }}-${{ runner.os }}-${{ hashFiles('scripts/install-gradle.sh') }}
360+
348361
- name: Install Gradle ${{ matrix.gradle }}
349362
shell: bash
350363
env:

‎scripts/install-gradle.sh‎

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@
99
# alone answering HTTP 500 for ~30 s used to fail a merge-queue leg. It is
1010
# only tried after the release download fails. The sha256 is pinned below
1111
# (from https://gradle.org/release-checksums/), so no checksum fetch can fail
12-
# either; a version without a pin fails closed.
12+
# either; a version without a pin fails closed. A zip already at
13+
# <dir>/gradle-<version>-bin.zip (CI restores one from the actions cache)
14+
# is used without any download when it matches that pin.
1315
#
1416
# Prints (stdout):
1517
# SOCKET_PATCH_GRADLE_E2E_GRADLE=<launcher path>
1618
set -euo pipefail
1719

1820
if [ $# -ne 2 ]; then
19-
sed -n '2,15p' "$0" | sed 's/^# \{0,1\}//' >&2
21+
sed -n '2,17p' "$0" | sed 's/^# \{0,1\}//' >&2
2022
exit 2
2123
fi
2224
VERSION="$1"
@@ -36,26 +38,41 @@ esac
3638
mkdir -p "$DIR"
3739
zip="$DIR/gradle-$VERSION-bin.zip"
3840
file="gradle-$VERSION-bin.zip"
41+
42+
# python, not sha256sum: the macOS runners have only shasum.
43+
verify() {
44+
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"
45+
}
46+
3947
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
48+
if [ -f "$zip" ]; then
49+
if verify; then
50+
echo "install-gradle.sh: using the cached $file" >&2
4651
fetched=1
47-
break
52+
else
53+
rm -f "$zip"
4854
fi
49-
echo "install-gradle.sh: download from $url failed" >&2
50-
done
55+
fi
56+
# --ssl-revoke-best-effort: Windows curl (schannel) otherwise fails when the
57+
# CA's revocation endpoint is unreachable.
58+
if [ -z "$fetched" ]; then
59+
for url in \
60+
"https://github.com/gradle/gradle-distributions/releases/download/v$VERSION/$file" \
61+
"https://services.gradle.org/distributions/$file"; do
62+
if curl -fsSL --retry 5 --retry-all-errors --ssl-revoke-best-effort "$url" -o "$zip"; then
63+
fetched=1
64+
break
65+
fi
66+
echo "install-gradle.sh: download from $url failed" >&2
67+
done
68+
fi
5169
if [ -z "$fetched" ]; then
5270
echo "install-gradle.sh: every origin failed for Gradle $VERSION" >&2
5371
exit 1
5472
fi
5573

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"
74+
verify
75+
unzip -oq "$zip" -d "$DIR"
5976
launcher="$DIR/gradle-$VERSION/bin/gradle"
6077
case "$(uname -s)" in MINGW*|MSYS*|CYGWIN*) launcher="$launcher.bat" ;; esac
6178
echo "SOCKET_PATCH_GRADLE_E2E_GRADLE=$launcher"

0 commit comments

Comments
 (0)