Skip to content

Commit 404e5db

Browse files
authored
fix sbt/scala cache key (actions#478)
1 parent 191ba8c commit 404e5db

File tree

5 files changed

+30
-5
lines changed

5 files changed

+30
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ Currently, the following distributions are supported:
116116
The action has a built-in functionality for caching and restoring dependencies. It uses [actions/cache](https://github.com/actions/cache) under hood for caching dependencies but requires less configuration settings. Supported package managers are gradle, maven and sbt. The format of the used cache key is `setup-java-${{ platform }}-${{ packageManager }}-${{ fileHash }}`, where the hash is based on the following files:
117117
- gradle: `**/*.gradle*`, `**/gradle-wrapper.properties`, `buildSrc/**/Versions.kt`, `buildSrc/**/Dependencies.kt`, and `gradle/*.versions.toml`
118118
- maven: `**/pom.xml`
119-
- sbt: all sbt build definition files `**/*.sbt`, `**/project/build.properties`, `**/project/**.{scala,sbt}`
119+
- sbt: all sbt build definition files `**/*.sbt`, `**/project/build.properties`, `**/project/**.scala`, `**/project/**.sbt`
120120

121121
The workflow output `cache-hit` is set to indicate if an exact match was found for the key [as actions/cache does](https://github.com/actions/cache/tree/main#outputs).
122122

__tests__/cache.test.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ describe('dependency cache', () => {
145145
await expect(restore('sbt')).rejects.toThrow(
146146
`No file in ${projectRoot(
147147
workspace
148-
)} matched to [**/*.sbt,**/project/build.properties,**/project/**.{scala,sbt}], make sure you have checked out the target repository`
148+
)} matched to [**/*.sbt,**/project/build.properties,**/project/**.scala,**/project/**.sbt], make sure you have checked out the target repository`
149149
);
150150
});
151151
it('downloads cache', async () => {
@@ -156,6 +156,28 @@ describe('dependency cache', () => {
156156
expect(spyWarning).not.toHaveBeenCalled();
157157
expect(spyInfo).toHaveBeenCalledWith('sbt cache is not found');
158158
});
159+
it('detects scala and sbt changes under **/project/ folder', async () => {
160+
createFile(join(workspace, 'build.sbt'));
161+
createDirectory(join(workspace, 'project'));
162+
createFile(join(workspace, 'project/DependenciesV1.scala'));
163+
164+
await restore('sbt');
165+
const firstCall = spySaveState.mock.calls.toString();
166+
167+
spySaveState.mockClear();
168+
await restore('sbt');
169+
const secondCall = spySaveState.mock.calls.toString();
170+
171+
// Make sure multiple restores produce the same cache
172+
expect(firstCall).toBe(secondCall);
173+
174+
spySaveState.mockClear();
175+
createFile(join(workspace, 'project/DependenciesV2.scala'));
176+
await restore('sbt');
177+
const thirdCall = spySaveState.mock.calls.toString();
178+
179+
expect(firstCall).not.toBe(thirdCall);
180+
});
159181
});
160182
});
161183
describe('save', () => {

dist/cleanup/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68416,7 +68416,8 @@ const supportedPackageManager = [
6841668416
pattern: [
6841768417
'**/*.sbt',
6841868418
'**/project/build.properties',
68419-
'**/project/**.{scala,sbt}'
68419+
'**/project/**.scala',
68420+
'**/project/**.sbt'
6842068421
]
6842168422
}
6842268423
];

dist/setup/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103621,7 +103621,8 @@ const supportedPackageManager = [
103621103621
pattern: [
103622103622
'**/*.sbt',
103623103623
'**/project/build.properties',
103624-
'**/project/**.{scala,sbt}'
103624+
'**/project/**.scala',
103625+
'**/project/**.sbt'
103625103626
]
103626103627
}
103627103628
];

src/cache.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ const supportedPackageManager: PackageManager[] = [
5656
pattern: [
5757
'**/*.sbt',
5858
'**/project/build.properties',
59-
'**/project/**.{scala,sbt}'
59+
'**/project/**.scala',
60+
'**/project/**.sbt'
6061
]
6162
}
6263
];

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy