gradle / actions

A collection of GitHub Actions to accelerate your Gradle Builds on GitHub
https://github.com/marketplace/actions/build-with-gradle
MIT License
148 stars 39 forks source link

Gradle itself is not cached #362

Closed hanneskaeufler closed 1 day ago

hanneskaeufler commented 2 weeks ago

Observed behaviour

Gradle 8.10 is downloaded for every single CI job

Expected behaviour

Gradle is cached and not downloaded from the internet every time

Details

While this certainly is against my assumption, I'm not sure whether this is a feature request or a bug. I'm using gradle/actions/setup-gradle@v3 and recently upgraded to gradle/actions/setup-gradle@v4.0.1, same behaviour

Gradle test logs:

Run ./gradlew testCodeCoverageReport
Downloading https://services.gradle.org/distributions/gradle-8.10-bin.zip
.............10%.............20%.............30%.............40%.............50%.............60%.............70%.............80%.............90%.............100%
Welcome to Gradle 8.10!
Here are the highlights of this release:
 - Support for Java 23
 - Faster configuration cache
 - Better configuration cache reports
For more details see https://docs.gradle.org/8.10/release-notes.html
Starting a Gradle Daemon (subsequent builds will be faster)

Cache action logs:

Run gradle/actions/setup-gradle@v3
  with:
    cache-read-only: true
    add-job-summary-as-pr-comment: on-failure
    cache-encryption-key: ***
    cache-disabled: false
    cache-write-only: false
    cache-overwrite-existing: false
    gradle-home-cache-includes: caches
  notifications

    gradle-home-cache-cleanup: false
    add-job-summary: always
    dependency-graph: disabled
    dependency-graph-continue-on-failure: true
    build-scan-publish: false
    validate-wrappers: false
    generate-job-summary: true
    gradle-home-cache-strict-match: false
    workflow-job-context: null
    github-token: ***
  env:
    aws-region: eu-central-1
    java-version: [2](XXX#step:4:2)1
    JAVA_HOME: /opt/actions-runner/_work/_tool/Java_Temurin-Hotspot_jdk/21.0.4-7.0.LTS/x64
    JAVA_HOME_21_X64: /opt/actions-runner/_work/_tool/Java_Temurin-Hotspot_jdk/21.0.4-7.0.LTS/x64
Merged default JDK locations into /home/ec2-user/.m2/toolchains.xml
Restore Gradle state from cache
  Received 0 of 179680919 (0.0%), 0.0 MBs/sec
  Received 4194[3](XXX#step:4:3)04 of 179680919 (2.3%), 2.0 MBs/sec
  Received 29360128 of 179680919 (16.3%), 9.3 MBs/sec
  Received [4](XXX#step:4:4)1943040 of 179680919 (23.3%), 10.0 MBs/sec
  Received [5](XXX#step:4:5)4525952 of 179680919 (30.3%), 10.4 MBs/sec
  Received 8388[6](XXX#step:4:6)080 of 179680919 (46.7%), 13.3 MBs/sec
  Received 83886080 of 1[7](XXX#step:4:7)9680919 (46.7%), 11.4 MBs/sec
  Received 109051904 of 1796[8](XXX#step:4:8)0919 (60.7%), 13.0 MBs/sec
  Received 130023424 of 17[9](XXX#step:4:9)680919 (72.4%), 13.8 MBs/sec
  Received 138412032 of 179680919 (77.0%), 13.2 MBs/sec
  Received 167772160 of 179680919 (93.4%), 14.5 MBs/sec
  Received 176160768 of 179680919 (98.0%), 14.0 MBs/sec
  Cache Size: ~171 MB (179680919 B)
  /usr/bin/tar -xf /opt/actions-runner/_work/_temp/b7eb797c-5397-4892-9078-f28047468688/cache.tzst -P -C /opt/actions-runner/_work/XXX --use-compress-program unzstd
  Received 179680919 of 179680919 ([10](XXX#step:4:10)0.0%), 13.2 MBs/sec
  Cache restored successfully
  Restored Gradle User Home from cache key: gradle-home-v1|Linux|test[3beed8b027db7880bb219b74c2544332]-96dd0c4a1a4f8e1080642c829e22e4c15beff5a4
  Received 0 of 136835072 (0.0%), 0.0 MBs/sec
  Received 0 of 658769602 (0.0%), 0.0 MBs/sec
  Received 0 of 39793105 (0.0%), 0.0 MBs/sec
  Received 0 of 134895155 (0.0%), 0.0 MBs/sec
  Received 0 of 41050001 (0.0%), 0.0 MBs/sec
  Received 0 of 46716789 (0.0%), 0.0 MBs/sec
  Cache Size: ~0 MB (165998 B)
  Received 165998 of 165998 (100.0%), 0.2 MBs/sec
  Received 0 of 623364 (0.0%), 0.0 MBs/sec
  /usr/bin/tar -xf /opt/actions-runner/_work/_temp/b560c586-9848-437f-84fd-8c092e5c6605/cache.tzst -P -C /opt/actions-runner/_work/XXX --use-compress-program unzstd
  Cache restored successfully
  Restored instrumented-jars with key gradle-instrumented-jars-v1-324d103900f0478f12a72c3a64d03a83 to /home/ec2-user/.gradle/caches/jars-*/*/
  Cache Size: ~1 MB (623364 B)
  /usr/bin/tar -xf /opt/actions-runner/_work/_temp/09d0af1c-47a8-4a53-b1fc-a745e3614324/cache.tzst -P -C /opt/actions-runner/_work/XXX --use-compress-program unzstd
  Cache restored successfully
  Restored groovy-dsl with key gradle-groovy-dsl-v1-809ccf809ff9745e05b6e4bfedd8882b to /home/ec2-user/.gradle/caches/*/groovy-dsl/*/
  Received 8388608 of 136835072 (6.1%), 4.0 MBs/sec
  Received 4194304 of 658769602 (0.6%), 2.0 MBs/sec
  Received 0 of 39793105 (0.0%), 0.0 MBs/sec
  Received 0 of 134895155 (0.0%), 0.0 MBs/sec
  Received 0 of 41050001 (0.0%), 0.0 MBs/sec
  Received 0 of 46716789 (0.0%), 0.0 MBs/sec
  Received 623364 of 623364 (100.0%), 0.3 MBs/sec
  Received 20971520 of 136835072 (15.3%), 6.6 MBs/sec
  Received 12582912 of 658769602 (1.9%), 4.0 MBs/sec
  Received 8388608 of 39793105 (21.1%), 2.6 MBs/sec
  Received 12582912 of 134895155 (9.3%), 4.0 MBs/sec
  Received 12582912 of 41050001 (30.7%), 4.0 MBs/sec
  Received 12582912 of 46716789 (26.9%), 4.0 MBs/sec
  Received 41943040 of 136835072 (30.7%), 9.9 MBs/sec
  Received 20971520 of 658769602 (3.2%), 5.0 MBs/sec
  Received 18821585 of 39793105 (47.3%), 4.5 MBs/sec
  Received 16777216 of 134895155 (12.4%), 4.0 MBs/sec
  Received 29360128 of 41050001 (71.5%), 7.0 MBs/sec
  Received 20971520 of 46716789 (44.9%), 5.0 MBs/sec
  Cache Size: ~39 MB (41050001 B)
  /usr/bin/tar -xf /opt/actions-runner/_work/_temp/a996d796-3fe8-49bc-a839-58cb64aa5c5c/cache.tzst -P -C /opt/actions-runner/_work/XXX --use-compress-program unzstd
  Received 50331648 of 136835072 (36.8%), 9.5 MBs/sec
  Received 46137344 of 658769602 (7.0%), 8.8 MBs/sec
  Received 35598801 of 39793105 (89.5%), 6.7 MBs/sec
  Received 37748736 of 134895155 (28.0%), 7.2 MBs/sec
  Received 41050001 of 41050001 (100.0%), 7.8 MBs/sec
  Received 34133877 of 46716789 (73.1%), 6.5 MBs/sec
  Cache Size: ~38 MB (39793105 B)
  Cache restored successfully
  Restored generated-gradle-jars with key gradle-generated-gradle-jars-v1-8b02b97fb417a75a34543e345c4e56f3 to /home/ec2-user/.gradle/caches/8.8/generated-gradle-jars/gradle-api-8.8.jar
  /usr/bin/tar -xf /opt/actions-runner/_work/_temp/8ad486bd-ab76-4815-9b6a-7b451599e9cb/cache.tzst -P -C /opt/actions-runner/_work/XXX --use-compress-program unzstd
  Received 71303168 of 136835072 (52.1%), [11](XXX#step:4:11).3 MBs/sec
  Received 46137344 of 658769602 (7.0%), 7.3 MBs/sec
  Received 39793105 of 39793105 (100.0%), 6.3 MBs/sec
  Received 54525952 of 134895155 (40.4%), 8.6 MBs/sec
  Received 38328181 of 46716789 (82.0%), 6.1 MBs/sec
  Cache Size: ~45 MB (46716789 B)
  Cache restored successfully
  Restored generated-gradle-jars with key gradle-generated-gradle-jars-v1-26cfecc158c44513d188405a5d2d0d9c to /home/ec2-user/.gradle/caches/8.9/generated-gradle-jars/gradle-api-8.9.jar
  /usr/bin/tar -xf /opt/actions-runner/_work/_temp/55ce3383-ccc3-4f3f-8e52-cf2d073f92cd/cache.tzst -P -C /opt/actions-runner/_work/XXX --use-compress-program unzstd
  Received 75497472 of 136835072 (55.2%), 10.2 MBs/sec
  Received 58720256 of 658769602 (8.9%), 8.0 MBs/sec
  Received 58720256 of 134895155 (43.5%), 8.0 MBs/sec
  Received 46716789 of 46716789 (100.0%), 6.4 MBs/sec
  Received 100663296 of 136835072 (73.6%), [12](XXX#step:4:12).0 MBs/sec
  Received 79691776 of 658769602 (12.1%), 9.5 MBs/sec
  Received 7[13](XXX#step:4:13)03168 of 134895155 (52.9%), 8.5 MBs/sec
  Cache restored successfully
  Restored transforms with key gradle-transforms-v1-0812ba636c0f[14](XXX#step:4:14)1cd55243145b0c4731 to /home/ec2-user/.gradle/caches/transforms-4/*/
  /home/ec2-user/.gradle/caches/*/transforms/*/
  Received 121634816 of 136835072 (88.9%), 12.8 MBs/sec
  Received 96468992 of 658769602 (14.6%), 10.2 MBs/sec
  Received 83886080 of 134895[15](XXX#step:4:15)5 (62.2%), 8.9 MBs/sec
  Received 124252160 of 136835072 (90.8%), 11.8 MBs/sec
  Received 104857600 of 658769602 (15.9%), 10.0 MBs/sec
  Received 104857600 of 134895155 (77.7%), 10.0 MBs/sec
  Cache Size: ~130 MB (136835072 B)
  /usr/bin/tar -xf /opt/actions-runner/_work/_temp/4707b6be-0ef3-4a5a-85b9-938875855118/cache.tzst -P -C /opt/actions-runner/_work/XXX --use-compress-program unzstd
  Received 136835072 of 136835072 (100.0%), 11.8 MBs/sec
  Received 130023424 of 658769602 (19.7%), 11.3 MBs/sec
  Received 109729331 of 134895155 (81.3%), 9.5 MBs/sec
  Cache restored successfully
  Restored wrapper-zips with key gradle-wrapper-zips-v1-9b12742562b89ad80b153fd0e40e926d to /home/ec2-user/.gradle/wrapper/dists/gradle-8.8-bin/dl7vupf4psengwqhwktix4v1
  Received 146800640 of 658769602 (22.3%), 11.7 MBs/sec
  Received 122312243 of 134895155 (90.7%), 9.7 MBs/sec
  Cache Size: ~129 MB (134895155 B)
  /usr/bin/tar -xf /opt/actions-runner/_work/_temp/088ba319-e171-4c93-81b0-ac1e76f5ebcf/cache.tzst -P -C /opt/actions-runner/_work/XXX --use-compress-program unzstd
  Received 171966464 of 658769602 (26.1%), 12.6 MBs/sec
  Received 134895155 of 134895155 (100.0%), 9.9 MBs/sec
  Cache restored successfully
  Restored wrapper-zips with key gradle-wrapper-zips-v1-df6ecc383658ce44d9cbac4d1bfd12bf to /home/ec2-user/.gradle/wrapper/dists/gradle-8.9-bin/90cnw93cvbtalezasaz0blq0a
  Received 180355072 of 658769602 (27.4%), 12.3 MBs/sec
  Received 209715200 of 658769602 (31.8%), 13.3 MBs/sec
  Received 218103808 of 658769602 (33.1%), 13.0 MBs/sec
  Received 234881024 of 658769602 (35.7%), 13.2 MBs/sec
  Received 268435456 of 658769602 (40.7%), 14.2 MBs/sec
  Received 268435456 of 658769602 (40.7%), 13.5 MBs/sec
  Received 289406976 of 658769602 (43.9%), 13.8 MBs/sec
  Received 314572800 of 658769602 (47.8%), 14.3 MBs/sec
  Received 3313500[16](XXX#step:4:16) of 658769602 (50.3%), 14.3 MBs/sec
  Received 343932928 of 658769602 (52.2%), 14.2 MBs/sec
  Received 377487360 of 658769602 (57.3%), 15.0 MBs/sec
  Received 394264576 of 658769602 (59.8%), 15.0 MBs/sec
  Received 406847488 of 658769602 (61.8%), 14.9 MBs/sec
  Received 423624704 of 658769602 (64.3%), 14.9 MBs/sec
  Received 448790528 of 658769602 (68.1%), 15.3 MBs/sec
  Received 469762048 of 658769602 (71.3%), 15.4 MBs/sec
  Received 482344960 of 658769602 (73.2%), 15.3 MBs/sec
  Received 499122[17](XXX#step:4:17)6 of 658769602 (75.8%), 15.3 MBs/sec
  Received 515899392 of 658769602 (78.3%), 15.4 MBs/sec
  Received 541065216 of 658769602 (82.1%), 15.6 MBs/sec
  Received 553648128 of 658769602 (84.0%), 15.5 MBs/sec
  Received 574619648 of 658769602 (87.2%), 15.6 MBs/sec
  Received 591396864 of 658769602 (89.8%), 15.7 MBs/sec
  Received 612368384 of 658769602 (93.0%), 15.8 MBs/sec
  Received 624951296 of 658769602 (94.9%), 15.7 MBs/sec
  Received 641992386 of 658769602 (97.5%), 15.7 MBs/sec
  Received 654575298 of 658769602 (99.4%), 15.6 MBs/sec
  Cache Size: ~628 MB (658769602 B)
  /usr/bin/tar -xf /opt/actions-runner/_work/_temp/a056261b-6dff-406b-a543-5d34564f0a38/cache.tzst -P -C /opt/actions-runner/_work/XXX --use-compress-program unzstd
  Received 658769602 of 658769602 (100.0%), 15.3 MBs/sec
  Cache restored successfully
  Restored dependencies with key gradle-dependencies-v1-bfacfdccc69c1c3074d1d3fcf70[18](XXX#step:4:18)e3e to /home/ec2-user/.gradle/caches/modules-*/files-*/*/*/*/*
  Received 0 of 2629969 (0.0%), 0.0 MBs/sec
  Cache Size: ~3 MB (2629969 B)
  /usr/bin/tar -xf /opt/actions-runner/_work/_temp/b0d9590c-0a92-44c8-b6e3-773b96f3cef6/cache.tzst -P -C /opt/actions-runner/_work/XXX --use-compress-program unzstd
  Cache restored successfully
  Restored configuration-cache with key gradle-configuration-cache-v1-5a5492bcb09981d9ee95a8455a1b1a9e275a2d5a[24](XXX#step:4:24)c274a49b2b3cb99f6f2cc6 to /opt/actions-runner/_work/XXX/.gradle/configuration-cache
bigdaz commented 2 weeks ago

Thanks for the report. A few things in your logs stand out.

cache-read-only: true
...
Restored wrapper-zips with key gradle-wrapper-zips-v1-9b12742562b89ad80b153fd0e40e926d to /home/ec2-user/.gradle/wrapper/dists/gradle-8.8-bin/dl7vupf4psengwqhwktix4v1
...
Restored wrapper-zips with key gradle-wrapper-zips-v1-df6ecc383658ce44d9cbac4d1bfd12bf to /home/ec2-user/.gradle/wrapper/dists/gradle-8.9-bin/90cnw93cvbtalezasaz0blq0a

The cache-read-only setting is likely because you are running this job from a branch other than main: see here for an explanation. With v4 you should have a link to this doc in the generated Job Summary.

Then we see that wrappers for Gradle 8.8 and Gradle 8.9 are restored, but not Gradle 8.10. So the most likely explanation is that the Job is restoring a cache entry written from a Job that didn't run Gradle 8.10.

If you are sure that isn't the case, then we could investigate whether there is a bug in the action that fails to restore Gradle 8.10 in particular,

hanneskaeufler commented 2 weeks ago

Thanks for the input! I did based on your assessment actually double check a couple of things and notice that not all of our jobs got upgrade to @v4.0.1, some were accidentally left back at @v3. So I fixed that and will monitor some more. Also activated the job summary to get a better look at that.

Then we see that wrappers for Gradle 8.8 and Gradle 8.9 are restored, but not Gradle 8.10.

Are those "wrapper zips" containing the full gradle installation? I had a brief look at my local gradle cache and couldn't really understand where gradle itself is located.

bigdaz commented 1 week ago

Also activated the job summary to get a better look at that.

Did you have this disabled for some reason? Or was it not enabled by default?

Are those "wrapper zips" containing the full gradle installation? I had a brief look at my local gradle cache and couldn't really understand where gradle itself is located.

Yes, if you execute using the Gradle wrapper (./gradlew ...) then the Gradle distribution will be downloaded and stored in the Gradle User Home at ~/.gradle/wrapper/dists. This is the recommended approach to execute Gradle.

bigdaz commented 1 day ago

@hanneskaeufler I'm going to close this issue, as there's no evidence that Gradle wrappers or installations are not being cache correctly. Feel free to comment here if you continue to experience issues and we can investigate further.