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

Allow cache entries to be reused on different runner operating systems #27

Open
hfhbd opened this issue Jan 17, 2023 · 4 comments
Open
Labels
enhancement New feature or request

Comments

@hfhbd
Copy link
Contributor

hfhbd commented Jan 17, 2023

GitHub Actions/Cache supports enableCrossOsArchive to reuse the same cache from different operating systems. This is very handy for matrix builds using multiple OS to further reduce the CI time (and costs).

https://github.com/actions/cache/blob/main/tips-and-workarounds.md#cross-os-cache

@bigdaz bigdaz changed the title Support enableCrossOsArchive cache Allow cache entries to be reused on different runner operating systems Feb 18, 2023
@bigdaz
Copy link
Member

bigdaz commented Feb 18, 2023

Thanks for the report. To make this work, we'd need to do the following:

  1. Identify which parts of Gradle User Home can be safely reused across operating systems. For example, downloaded jars are likely to be compatible, compiled build scrips may not be.
  2. All cache keys currently embed RUNNER_OS value at the lowest level. This would have to be removed for non-shareable caches. Perhaps it could be removed in general since OS entries are implicitly separate without enableCrossOsArchive.
  3. For sharable entries, pass enableCrossOsArchive: true on these calls to save and restore the cache.

PRs welcome!

@bigdaz bigdaz added the enhancement New feature or request label Feb 18, 2023
@bigdaz bigdaz transferred this issue from gradle/gradle-build-action Feb 9, 2024
@bigdaz
Copy link
Member

bigdaz commented Apr 8, 2024

I took a look and found another snag: since the paths to Gradle User Home are different on Linux vs Windows, just passing enableCrossOsArchive: true when saving and restoring isn't enough. Any files to be shared would need to be first moved to an OS agnostic location before calling saveCache or restoreCache. Without this, the entry pattern values are different, and the entries won't be shared.

@hfhbd
Copy link
Contributor Author

hfhbd commented Jul 22, 2024

Given that with the latest version we also take the arch as key and not all dependencies/caches (like Kotlin MPP) supports multi OS out of the box, I think we can close this issue.

@bigdaz
Copy link
Member

bigdaz commented Jul 22, 2024

I think this might still be useful for entries extracted from Gradle User Home. For example, we extract the dependency jars into a separate entry that can be reused even as other parts of Gradle User Home change.

Some of these extracted entries are not inherently tied to OS/arch and should/could be reusable between different OSes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants