Skip to content

Commit dc6dd8e

Browse files
committed
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
1 parent 81edc40 commit dc6dd8e

3 files changed

Lines changed: 10 additions & 19 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1863,7 +1863,8 @@ jobs:
18631863
continue-on-error: true
18641864
with:
18651865
path: ${{ runner.temp }}/gradle-${{ matrix.gradle }}-bin.zip
1866-
key: gradle-dist-${{ matrix.gradle }}-${{ runner.os }}
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') }}
18671868

18681869
- name: Install Gradle ${{ matrix.gradle }}
18691870
if: matrix.gradle != ''

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

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -346,16 +346,17 @@ jobs:
346346
} >> "$GITHUB_ENV"
347347
348348
- name: Restore the Gradle ${{ matrix.gradle }} distribution
349-
# ci.yml's e2e legs save this pinned zip from main; restoring it
350-
# keeps a github.com release outage from failing these legs. See
351-
# the matching step there.
352-
id: gradle-dist-cache
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.
353354
uses: actions/cache/restore@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
354355
timeout-minutes: 5
355356
continue-on-error: true
356357
with:
357358
path: ${{ runner.temp }}/gradle-${{ matrix.gradle }}-bin.zip
358-
key: gradle-dist-${{ matrix.gradle }}-${{ runner.os }}
359+
key: gradle-dist-${{ matrix.gradle }}-${{ runner.os }}-${{ hashFiles('scripts/install-gradle.sh') }}
359360

360361
- name: Install Gradle ${{ matrix.gradle }}
361362
shell: bash
@@ -364,17 +365,6 @@ jobs:
364365
# Pinned digest, GitHub-release origin: see the script.
365366
run: scripts/install-gradle.sh "$GRADLE_VERSION" "$RUNNER_TEMP" >> "$GITHUB_ENV"
366367

367-
- name: Save the Gradle ${{ matrix.gradle }} distribution
368-
# The nightly saves the macOS and Windows zips ci.yml never fetches.
369-
if: >-
370-
github.ref == 'refs/heads/main'
371-
&& steps.gradle-dist-cache.outputs.cache-hit != 'true'
372-
&& steps.gradle-dist-cache.outcome == 'success'
373-
uses: actions/cache/save@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
374-
with:
375-
path: ${{ runner.temp }}/gradle-${{ matrix.gradle }}-bin.zip
376-
key: ${{ steps.gradle-dist-cache.outputs.cache-primary-key }}
377-
378368
- name: Run the ${{ matrix.mode }} suites
379369
shell: bash
380370
env:

‎scripts/install-gradle.sh‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
set -euo pipefail
1919

2020
if [ $# -ne 2 ]; then
21-
sed -n '2,15p' "$0" | sed 's/^# \{0,1\}//' >&2
21+
sed -n '2,17p' "$0" | sed 's/^# \{0,1\}//' >&2
2222
exit 2
2323
fi
2424
VERSION="$1"
@@ -72,7 +72,7 @@ if [ -z "$fetched" ]; then
7272
fi
7373

7474
verify
75-
unzip -q "$zip" -d "$DIR"
75+
unzip -oq "$zip" -d "$DIR"
7676
launcher="$DIR/gradle-$VERSION/bin/gradle"
7777
case "$(uname -s)" in MINGW*|MSYS*|CYGWIN*) launcher="$launcher.bat" ;; esac
7878
echo "SOCKET_PATCH_GRADLE_E2E_GRADLE=$launcher"

0 commit comments

Comments
 (0)