mirror of
https://gitea.com/actions/setup-java.git
synced 2025-04-06 15:29:37 +00:00
Add SBT in cache managers. (#302)
This commit is contained in:
@ -118,6 +118,23 @@ describe('dependency cache', () => {
|
||||
expect(spyInfo).toBeCalledWith('gradle cache is not found');
|
||||
});
|
||||
});
|
||||
describe('for sbt', () => {
|
||||
it('throws error if no build.sbt found', async () => {
|
||||
await expect(restore('sbt')).rejects.toThrowError(
|
||||
`No file in ${projectRoot(
|
||||
workspace
|
||||
)} matched to [**/*.sbt,**/project/build.properties,**/project/**.{scala,sbt}], make sure you have checked out the target repository`
|
||||
);
|
||||
});
|
||||
it('downloads cache', async () => {
|
||||
createFile(join(workspace, 'build.sbt'));
|
||||
|
||||
await restore('sbt');
|
||||
expect(spyCacheRestore).toBeCalled();
|
||||
expect(spyWarning).not.toBeCalled();
|
||||
expect(spyInfo).toBeCalledWith('sbt cache is not found');
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('save', () => {
|
||||
let spyCacheSave: jest.SpyInstance<
|
||||
@ -194,6 +211,30 @@ describe('dependency cache', () => {
|
||||
expect(spyInfo).toBeCalledWith(expect.stringMatching(/^Cache saved with the key:.*/));
|
||||
});
|
||||
});
|
||||
describe('for sbt', () => {
|
||||
it('uploads cache even if no build.sbt found', async () => {
|
||||
createStateForMissingBuildFile();
|
||||
await save('sbt');
|
||||
expect(spyCacheSave).toBeCalled();
|
||||
expect(spyWarning).not.toBeCalled();
|
||||
});
|
||||
it('does not upload cache if no restore run before', async () => {
|
||||
createFile(join(workspace, 'build.sbt'));
|
||||
|
||||
await save('sbt');
|
||||
expect(spyCacheSave).not.toBeCalled();
|
||||
expect(spyWarning).toBeCalledWith('Error retrieving key from state.');
|
||||
});
|
||||
it('uploads cache', async () => {
|
||||
createFile(join(workspace, 'build.sbt'));
|
||||
createStateForSuccessfulRestore();
|
||||
|
||||
await save('sbt');
|
||||
expect(spyCacheSave).toBeCalled();
|
||||
expect(spyWarning).not.toBeCalled();
|
||||
expect(spyInfo).toBeCalledWith(expect.stringMatching(/^Cache saved with the key:.*/));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
1
__tests__/cache/sbt/.gitignore
vendored
Normal file
1
__tests__/cache/sbt/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
target/
|
3
__tests__/cache/sbt/build.sbt
vendored
Normal file
3
__tests__/cache/sbt/build.sbt
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
ThisBuild / scalaVersion := "2.12.15"
|
||||
|
||||
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.2"
|
1
__tests__/cache/sbt/project/build.properties
vendored
Normal file
1
__tests__/cache/sbt/project/build.properties
vendored
Normal file
@ -0,0 +1 @@
|
||||
sbt.version=1.6.2
|
Reference in New Issue
Block a user