Bump @actions/cache to 5.1.0, log cache write denied (#746)

* Bump @actions/cache to 5.1.0, log cache write denied

* Add cache save failure test case

* Update dist

* Resolve high-severity audit issues
This commit is contained in:
Jason Ginchereau
2026-06-22 08:33:08 -10:00
committed by GitHub
parent dc3262dda8
commit 4406a635cd
18 changed files with 44364 additions and 67770 deletions

View File

@@ -3,6 +3,7 @@ import * as core from '@actions/core';
import fs from 'node:fs';
import {run} from '../src/cache-save';
import {getNuGetFolderPath} from '../src/cache-utils';
import {State} from '../src/constants';
jest.mock('@actions/cache');
jest.mock('@actions/core');
@@ -84,4 +85,22 @@ describe('cache-save tests', () => {
expect(jest.mocked(core.getState)).toHaveBeenCalledTimes(2);
expect(jest.mocked(cache.saveCache)).toHaveBeenCalled();
});
it('does not fail and traces when saveCache returns -1', async () => {
jest.mocked(core.getBooleanInput).mockReturnValue(true);
jest.mocked(core.getState).mockImplementation(s => s);
jest.mocked(fs.existsSync).mockReturnValue(true);
jest.mocked(cache.saveCache).mockResolvedValue(-1);
await run();
expect(jest.mocked(core.setFailed)).not.toHaveBeenCalled();
expect(jest.mocked(cache.saveCache)).toHaveBeenCalled();
expect(jest.mocked(core.debug)).toHaveBeenCalledWith(
`Cache was not saved for the key: ${State.CachePrimaryKey}`
);
expect(jest.mocked(core.info)).not.toHaveBeenCalledWith(
`Cache saved with the key: ${State.CachePrimaryKey}`
);
});
});