Skip to content

Commit 842deab

Browse files
authored
Avoid sbt cache being invalidated for a library that is only incrementing 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
1 parent 16ef37f commit 842deab

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/cache.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ const supportedPackageManager: PackageManager[] = [
5858
'**/*.sbt',
5959
'**/project/build.properties',
6060
'**/project/**.scala',
61-
'**/project/**.sbt'
61+
'**/project/**.sbt',
62+
'!**/version.sbt' // releasing a new version of a library project shouldn't invalidate the entire sbt cache
6263
]
6364
}
6465
];

0 commit comments

Comments
 (0)