setup-java icon indicating copy to clipboard operation
setup-java copied to clipboard

Avoid `sbt` cache being invalidated for a library that is only incrementing its own version

Open rtyley opened this issue 2 years ago • 1 comments

Description: While working on guardian/gha-scala-library-release-workflow I noticed that no matter how many times I ran the workflow, actions/setup-java would always report sbt cache is not found, even if there had been no substantial change in the project - simply that the version number in version.sbt (the file used by sbt/sbt-release) had been incremented (as in https://github.com/guardian/play-secret-rotation/commit/b2152325baf80f57e7c510fe03ccda5596c139d6).

This meant that turning on cache: sbt would actually slow the workflow considerably, as it would never benefit from the cache being present, and would always have to save it, which could take 2-3 minutes - even though it can't take advantage of the data it's saving.

As such, it would be great to exclude version.sbt files from the cache hash key.

Background: cache: sbt was originally introduced with https://github.com/actions/setup-java/pull/302 - cc @fmeriaux 🙇‍♂️

Check list:

  • [ ] Mark if documentation changes are required.
  • [ ] Mark if tests were added or updated to cover the changes.

rtyley avatar Dec 06 '23 17:12 rtyley

Interesting, perhaps it would be a good idea to have an action parameter that allows you to complete the pattern by default?

This would give us finer control over the specifics of our projects.

fmeriaux avatar Dec 07 '23 07:12 fmeriaux