Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import cache from gradle/gradle-build-action@v2 #48

Closed
StefanLobbenmeierObjego opened this issue Feb 16, 2024 · 2 comments
Closed

Import cache from gradle/gradle-build-action@v2 #48

StefanLobbenmeierObjego opened this issue Feb 16, 2024 · 2 comments

Comments

@StefanLobbenmeierObjego
Copy link

StefanLobbenmeierObjego commented Feb 16, 2024

I saw that gradle/gradle-build-action@v2 recommends migrating to gradle/actions/setup-gradle instead. They both have caching, but the first run after changing from the old solution to this one does not have any cache:

Run gradle/actions/setup-gradle@v3
  with:
    gradle-home-cache-cleanup: true
    dependency-graph: generate-and-submit
    cache-disabled: false
    cache-read-only: false
    cache-write-only: false
    cache-overwrite-existing: false
    gradle-home-cache-includes: caches
  notifications
  
    add-job-summary: always
    add-job-summary-as-pr-comment: never
    dependency-graph-continue-on-failure: true
    build-scan-publish: false
    generate-job-summary: true
    gradle-home-cache-strict-match: false
    workflow-job-context: null
    github-token: ***
  env:
    ...
  
Merged default JDK locations into /home/runner/.m2/toolchains.xml
Restore Gradle state from cache
  Gradle User Home cache not found. Will initialize empty.
Preparing cache for cleanup.
Enabling dependency graph generation

I am assuming there are going to be a lot of people migrating over to this action, so being able to read the old cache if no new cache has been created yet would save a lot of CI minutes.

@StefanLobbenmeierObjego
Copy link
Author

There even seems to an error at the end of the first log, that suggests some of the cache keys are the same:

Post job cleanup.
In post-action step
Stopping all Gradle daemons before saving Gradle User Home state
Stopping Gradle daemons for /home/runner/.gradle/wrapper/dists/gradle-8.6-bin/afr5mpiioh[2](https://github.com/objego/objego-calculation-management-service/actions/runs/7932920563/job/21660497437#step:19:2)wthjmwnkmdsd5w/gradle-8.6
/home/runner/.gradle/wrapper/dists/gradle-8.6-bin/afr5mpiioh2wthjmwnkmdsd5w/gradle-8.6/bin/gradle --stop
Stopping Daemon(s)
1 Daemon stopped
Forcing cache cleanup.
/usr/bin/gradle -g /home/runner/.gradle --no-daemon --build-cache --no-scan --quiet -DGITHUB_DEPENDENCY_GRAPH_ENABLED=false noop
Caching Gradle state
  Caching generated-gradle-jars with path '/home/runner/.gradle/caches/8.6/generated-gradle-jars/gradle-api-8.6.jar' and cache key: generated-gradle-jars-724640d9b6d[3](https://github.com/objego/objego-calculation-management-service/actions/runs/7932920563/job/21660497437#step:19:3)8238f67abd00073cebeb
  Caching wrapper-zips with path '/home/runner/.gradle/wrapper/dists/gradle-8.6-bin/afr5mpiioh2wthjmwnkmdsd5w' and cache key: wrapper-zips-61c267d33d913e95c956e860b86f9705
  /usr/bin/tar --posix -cf cache.tzst --exclude cache.tzst -P -C /home/runner/work/objego-calculation-management-service/objego-calculation-management-service --files-from manifest.txt --use-compress-program zstdmt
  /usr/bin/tar --posix -cf cache.tzst --exclude cache.tzst -P -C /home/runner/work/objego-calculation-management-service/objego-calculation-management-service --files-from manifest.txt --use-compress-program zstdmt
  Caching dependencies with path '/home/runner/.gradle/caches/modules-*/files-*/*/*/*/*' and cache key: dependencies-9b1[4](https://github.com/objego/objego-calculation-management-service/actions/runs/7932920563/job/21660497437#step:19:4)[5](https://github.com/objego/objego-calculation-management-service/actions/runs/7932920563/job/21660497437#step:19:5)1a4e045d89359fa[6](https://github.com/objego/objego-calculation-management-service/actions/runs/7932920563/job/21660497437#step:19:6)ee3ff4[7](https://github.com/objego/objego-calculation-management-service/actions/runs/7932920563/job/21660497437#step:19:7)91[8](https://github.com/objego/objego-calculation-management-service/actions/runs/7932920563/job/21660497437#step:19:8)8
  Caching instrumented-jars with path '/home/runner/.gradle/caches/jars-*/*' and cache key: instrumented-jars-f[9](https://github.com/objego/objego-calculation-management-service/actions/runs/7932920563/job/21660497437#step:19:9)f5a6eaf0fc964eadca96300138ac35
  Caching kotlin-dsl with path '/home/runner/.gradle/caches/*/kotlin-dsl/*/*' and cache key: kotlin-dsl-e62d5b61203eb3b9914be59[10](https://github.com/objego/objego-calculation-management-service/actions/runs/7932920563/job/21660497437#step:19:10)ddee903
  /usr/bin/tar --posix -cf cache.tzst --exclude cache.tzst -P -C /home/runner/work/objego-calculation-management-service/objego-calculation-management-service --files-from manifest.txt --use-compress-program zstdmt
  /usr/bin/tar --posix -cf cache.tzst --exclude cache.tzst -P -C /home/runner/work/objego-calculation-management-service/objego-calculation-management-service --files-from manifest.txt --use-compress-program zstdmt
  Failed to save cache entry with path '/home/runner/.gradle/wrapper/dists/gradle-8.6-bin/afr5mpiioh2wthjmwnkmdsd5w' and key: wrapper-zips-61c267d33d913e95c956e860b86f9705: ReserveCacheError: Unable to reserve cache with key wrapper-zips-61c267d33d913e95c956e860b86f9705, another job may be creating this cache. More details: Cache already exists. Scope: refs/heads/main, Key: wrapper-zips-61c267d33d913e95c956e860b86f9705, Version: d871acd3b77b4ac7c2e42910dcb5bfd16a51e427f9d1ee4c97b6ece64a7cfc3c
  Failed to save cache entry with path '/home/runner/.gradle/caches/8.6/generated-gradle-jars/gradle-api-8.6.jar' and key: generated-gradle-jars-724640d9b6d38238f67abd00073cebeb: ReserveCacheError: Unable to reserve cache with key generated-gradle-jars-724640d9b6d38238f67abd00073cebeb, another job may be creating this cache. More details: Cache already exists. Scope: refs/heads/main, Key: generated-gradle-jars-724640d9b6d38238f67abd00073cebeb, Version: ecd2b4eb9591b7a70bde[11](https://github.com/objego/objego-calculation-management-service/actions/runs/7932920563/job/21660497437#step:19:11)f3a65f233adc8494bec77b6a71c1cd626552ec7e54
  Cache Size: ~0 MB (63240 B)
  Cache Size: ~0 MB (77255 B)
  Cache saved successfully
  Cache saved successfully
  /usr/bin/tar --posix -cf cache.tzst --exclude cache.tzst -P -C /home/runner/work/objego-calculation-management-service/objego-calculation-management-service --files-from manifest.txt --use-compress-program zstdmt
  Cache Size: ~261 MB (274050677 B)
  Cache saved successfully
  Caching Gradle User Home with cache key: v9-gradle|Linux|build[2757789f84eafcf9964ee0e93981e97d]-3d45d08e760ab9b68324ee419b3f40ffebaf6b42
  /usr/bin/tar --posix -cf cache.tzst --exclude cache.tzst -P -C /home/runner/work/objego-calculation-management-service/objego-calculation-management-service --files-from manifest.txt --use-compress-program zstdmt
  Cache Size: ~40 MB (4[14](https://github.com/objego/objego-calculation-management-service/actions/runs/7932920563/job/21660497437#step:19:14)76439 B)
  Cache saved successfully
Generating Job Summary
Notice: Submitted dependency-graph-reports/deployment_to_integration-build.json: Dependency results for the repo have been successfully updated.
Completed post-action step

@bigdaz
Copy link
Member

bigdaz commented Feb 16, 2024

The cache protocol has changed with v3.x and the main Gradle User Home cache entry generated by v2.x won't be reused. The initial run with v3 will start with an empty Gradle User Home.

But the extracted cache entries for dependencies etc may have the same cache key, so they won't always be replaced in the cache, even if they are recreated locally. The subsequent runs will reuse these cache entries.

It's important that we can continue to evolve the cache protocol for this action, and occasionally updating to a new version of the action will result in the old cache entries not being reused. At this stage there are no plans to support migration of one cache protocol to another.

@bigdaz bigdaz closed this as completed Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants