From 1fb171821f1eedeccccea5f731d7bc6630520caa Mon Sep 17 00:00:00 2001 From: Alex Abashev Date: Tue, 20 Oct 2026 14:32:07 +0300 Subject: [PATCH] Cache Gradle's downloads in CI Six of the last 120 CI runs lost a job to a download, and every re-run passed. On 2026-10-19 Maven Central reset the connection on three runners and failed DNS on a fourth while they resolved dependencies, and on 2026-10-03 and 2026-10-19 services.gradle.org failed DNS and then timed out on macos-15-intel while the wrapper fetched Gradle. No JDK or GraalVM download failed. gradle/actions/setup-gradle, at the SHA dependency-submission.yml already pins, now runs in every job: it restores the dependencies and the wrapper's distribution from the Actions cache and saves them after builds of the default branch, while pull requests only read. Three paths stay out: the local build cache; the IntelliJ IDE the plugin's tests start, an 852 MB zip that is slower to restore than to download and a third of the repository's 10 GB; and the transforms directory, where that zip is unpacked to 2.1 GB and cannot be left out alone. Leaving paths out needs the default, proprietary cache provider, which is vendored in the action and free for public repositories. JDK downloads are not cached: none has failed, and setup-graalvm finds a cached GraalVM only by its exact version, which would mean pinning versions by hand in two workflows. --- .github/workflows/ci.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 07dd75c81..89192e3b8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,6 +33,23 @@ jobs: java-version: '21' problem-matcher: true + # Gradle's downloads come from the Actions cache rather than the network: the wrapper's distribution + # (services.gradle.org timed out and failed DNS on macos-15-intel, twice in a month) and the + # dependencies (Maven Central reset the connection on three runners and failed DNS on a fourth, all + # on 2026-10-19). Only builds of the default branch write the cache; pull requests read it. Two + # things stay out: the local build cache, left out on purpose for now, and the IDE the IntelliJ + # plugin's tests start, whose 852 MB zip and the 2.1 GB it unpacks to under transforms would take + # longer to restore than to download and fill much of the repository's 10 GB. Leaving paths out is a + # feature of the default, proprietary cache provider, bundled in the action and free for public + # repositories; the open-source one has none. + - name: Cache Gradle's downloads + uses: gradle/actions/setup-gradle@3f5f9adaf7d9fecd50b5935e54106014257a94e6 # v6.4.0 + with: + gradle-home-cache-excludes: | + caches/build-cache-1 + caches/modules-2/files-2.1/com.jetbrains.intellij.idea + caches/*/transforms + - name: Build run: ./gradlew test @@ -104,6 +121,15 @@ jobs: java-version: '21' problem-matcher: false + # The same cache as in `build`. + - name: Cache Gradle's downloads + uses: gradle/actions/setup-gradle@3f5f9adaf7d9fecd50b5935e54106014257a94e6 # v6.4.0 + with: + gradle-home-cache-excludes: | + caches/build-cache-1 + caches/modules-2/files-2.1/com.jetbrains.intellij.idea + caches/*/transforms + - name: Explain the extra Gradle arguments if: ${{ matrix.gradle_args != '' }} env: @@ -180,6 +206,15 @@ jobs: distribution: 'graalvm-community' github-token: ${{ secrets.GITHUB_TOKEN }} + # The same cache as in `build`. + - name: Cache Gradle's downloads + uses: gradle/actions/setup-gradle@3f5f9adaf7d9fecd50b5935e54106014257a94e6 # v6.4.0 + with: + gradle-home-cache-excludes: | + caches/build-cache-1 + caches/modules-2/files-2.1/com.jetbrains.intellij.idea + caches/*/transforms + - name: Compile the native image run: ./gradlew -PnativeImage=true :open-java-format-native:nativeCompile env: