Skip to content

Commit 5407bf6

Browse files
Merge pull request #448 from IvanZosimov/CacheLibVersionUpdate
Add support for the @actions/cache library 3.0.0
2 parents ab6deb3 + 41b9110 commit 5407bf6

File tree

9 files changed

+1781
-68
lines changed

9 files changed

+1781
-68
lines changed

.licenses/npm/@actions/cache.dep.yml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.licenses/npm/@actions/http-client-1.0.11.dep.yml

+32
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.licenses/npm/@actions/http-client-2.0.1.dep.yml

+32
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

__tests__/cache-save.test.ts

+53
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,59 @@ describe('run', () => {
212212
);
213213
expect(setFailedSpy).not.toHaveBeenCalled();
214214
});
215+
216+
it('saves with -1 cacheId , should not fail workflow', async () => {
217+
inputs['cache'] = 'poetry';
218+
getStateSpy.mockImplementation((name: string) => {
219+
if (name === State.STATE_CACHE_PRIMARY_KEY) {
220+
return poetryLockHash;
221+
} else if (name === State.CACHE_PATHS) {
222+
return JSON.stringify([__dirname]);
223+
} else {
224+
return requirementsHash;
225+
}
226+
});
227+
228+
saveCacheSpy.mockImplementation(() => {
229+
return -1;
230+
});
231+
232+
await run();
233+
234+
expect(getInputSpy).toHaveBeenCalled();
235+
expect(getStateSpy).toHaveBeenCalledTimes(3);
236+
expect(infoSpy).not.toHaveBeenCalled();
237+
expect(saveCacheSpy).toHaveBeenCalled();
238+
expect(infoSpy).not.toHaveBeenLastCalledWith(
239+
`Cache saved with the key: ${poetryLockHash}`
240+
);
241+
expect(setFailedSpy).not.toHaveBeenCalled();
242+
});
243+
244+
it('saves with error from toolkit, should fail workflow', async () => {
245+
inputs['cache'] = 'npm';
246+
getStateSpy.mockImplementation((name: string) => {
247+
if (name === State.STATE_CACHE_PRIMARY_KEY) {
248+
return poetryLockHash;
249+
} else if (name === State.CACHE_PATHS) {
250+
return JSON.stringify([__dirname]);
251+
} else {
252+
return requirementsHash;
253+
}
254+
});
255+
256+
saveCacheSpy.mockImplementation(() => {
257+
throw new cache.ValidationError('Validation failed');
258+
});
259+
260+
await run();
261+
262+
expect(getInputSpy).toHaveBeenCalled();
263+
expect(getStateSpy).toHaveBeenCalledTimes(3);
264+
expect(infoSpy).not.toHaveBeenCalledWith();
265+
expect(saveCacheSpy).toHaveBeenCalled();
266+
expect(setFailedSpy).toHaveBeenCalled();
267+
});
215268
});
216269

217270
afterEach(() => {

0 commit comments

Comments
 (0)