Skip to content

Commit

Permalink
Avoid sbt cache being invalidated for a library that is only incremen…
Browse files Browse the repository at this point in the history
…ting it's own version

While working on https://github.com/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 `version.sbt` (the file used by https://github.com/sbt/sbt-release) had the version number in it incremented (as in guardian/play-secret-rotation@b215232).

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 orginally introduced with #302
  • Loading branch information
rtyley authored Dec 6, 2023
1 parent 16ef37f commit 842deab
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ const supportedPackageManager: PackageManager[] = [
'**/*.sbt',
'**/project/build.properties',
'**/project/**.scala',
'**/project/**.sbt'
'**/project/**.sbt',
'!**/version.sbt' // releasing a new version of a library project shouldn't invalidate the entire sbt cache
]
}
];
Expand Down

0 comments on commit 842deab

Please sign in to comment.