mirror of
https://github.com/actions/cache.git
synced 2025-04-19 02:26:45 +00:00
Cache multiple paths and add glob pattern support (#212)
* Allow for multiple line-delimited paths to cache * Add initial minimatch support * Use @actions/glob for pattern matching * Cache multiple entries using --files-from tar input remove known failing test Quote tar paths Add salt to test cache Try reading input files from manifest bump salt Run test on macos more testing Run caching tests on 3 platforms Run tests on self-hosted Apparently cant reference hosted runners by name Bump salt wait for some time after save more timing out smarter waiting Cache in tmp dir that won't be deleted Use child_process instead of actions/exec Revert tempDir hack bump salt more logging More console logging Use filepath to with cacheHttpClient Test cache restoration Revert temp dir hack debug logging clean up cache.yml testing Bump salt change debug output build actions * unit test coverage for caching multiple dirs * Ensure there's a locateable test folder at homedir * Clean up code * Version cache with all inputs * Unit test getCacheVersion * Include keys in getCacheEntry request * Clean import orders * Use fs promises in actionUtils tests * Update import order for to fix linter errors * Fix remaining linter error * Remove platform-specific test code * Add lerna example for caching multiple dirs * Lerna example updated to v2 Co-Authored-By: Josh Gross <joshmgross@github.com> Co-authored-by: Josh Gross <joshmgross@github.com>
This commit is contained in:
parent
22d71e33ad
commit
eb78578266
16 changed files with 4820 additions and 160 deletions
|
@ -14,10 +14,6 @@ jest.mock("../src/tar");
|
|||
jest.mock("../src/utils/actionUtils");
|
||||
|
||||
beforeAll(() => {
|
||||
jest.spyOn(actionUtils, "resolvePath").mockImplementation(filePath => {
|
||||
return path.resolve(filePath);
|
||||
});
|
||||
|
||||
jest.spyOn(actionUtils, "isExactKeyMatch").mockImplementation(
|
||||
(key, cacheResult) => {
|
||||
const actualUtils = jest.requireActual("../src/utils/actionUtils");
|
||||
|
@ -60,7 +56,8 @@ test("restore with invalid event outputs warning", async () => {
|
|||
test("restore with no path should fail", async () => {
|
||||
const failedMock = jest.spyOn(core, "setFailed");
|
||||
await run();
|
||||
expect(failedMock).toHaveBeenCalledWith(
|
||||
// this input isn't necessary for restore b/c tarball contains entries relative to workspace
|
||||
expect(failedMock).not.toHaveBeenCalledWith(
|
||||
"Input required and not supplied: path"
|
||||
);
|
||||
});
|
||||
|
@ -202,7 +199,6 @@ test("restore with restore keys and no cache found", async () => {
|
|||
|
||||
test("restore with cache found", async () => {
|
||||
const key = "node-test";
|
||||
const cachePath = path.resolve("node_modules");
|
||||
testUtils.setInputs({
|
||||
path: "node_modules",
|
||||
key
|
||||
|
@ -257,7 +253,7 @@ test("restore with cache found", async () => {
|
|||
expect(getArchiveFileSizeMock).toHaveBeenCalledWith(archivePath);
|
||||
|
||||
expect(extractTarMock).toHaveBeenCalledTimes(1);
|
||||
expect(extractTarMock).toHaveBeenCalledWith(archivePath, cachePath);
|
||||
expect(extractTarMock).toHaveBeenCalledWith(archivePath);
|
||||
|
||||
expect(unlinkFileMock).toHaveBeenCalledTimes(1);
|
||||
expect(unlinkFileMock).toHaveBeenCalledWith(archivePath);
|
||||
|
@ -271,7 +267,6 @@ test("restore with cache found", async () => {
|
|||
|
||||
test("restore with a pull request event and cache found", async () => {
|
||||
const key = "node-test";
|
||||
const cachePath = path.resolve("node_modules");
|
||||
testUtils.setInputs({
|
||||
path: "node_modules",
|
||||
key
|
||||
|
@ -328,7 +323,7 @@ test("restore with a pull request event and cache found", async () => {
|
|||
expect(infoMock).toHaveBeenCalledWith(`Cache Size: ~60 MB (62915000 B)`);
|
||||
|
||||
expect(extractTarMock).toHaveBeenCalledTimes(1);
|
||||
expect(extractTarMock).toHaveBeenCalledWith(archivePath, cachePath);
|
||||
expect(extractTarMock).toHaveBeenCalledWith(archivePath);
|
||||
|
||||
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
|
||||
expect(setCacheHitOutputMock).toHaveBeenCalledWith(true);
|
||||
|
@ -340,7 +335,6 @@ test("restore with a pull request event and cache found", async () => {
|
|||
test("restore with cache found for restore key", async () => {
|
||||
const key = "node-test";
|
||||
const restoreKey = "node-";
|
||||
const cachePath = path.resolve("node_modules");
|
||||
testUtils.setInputs({
|
||||
path: "node_modules",
|
||||
key,
|
||||
|
@ -396,7 +390,7 @@ test("restore with cache found for restore key", async () => {
|
|||
expect(infoMock).toHaveBeenCalledWith(`Cache Size: ~0 MB (142 B)`);
|
||||
|
||||
expect(extractTarMock).toHaveBeenCalledTimes(1);
|
||||
expect(extractTarMock).toHaveBeenCalledWith(archivePath, cachePath);
|
||||
expect(extractTarMock).toHaveBeenCalledWith(archivePath);
|
||||
|
||||
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
|
||||
expect(setCacheHitOutputMock).toHaveBeenCalledWith(false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue