1
0
Fork 0
mirror of https://code.forgejo.org/actions/cache.git synced 2025-05-02 00:09:54 +02:00

Allow for multiple line-delimited paths to cache

This commit is contained in:
Ethan Dennis 2020-03-04 16:02:51 -08:00
parent 826785142a
commit 84cead4a82
No known key found for this signature in database
GPG key ID: 32E74B75DB4065DD
8 changed files with 116 additions and 58 deletions

View file

@ -9,6 +9,12 @@ beforeAll(() => {
jest.spyOn(io, "which").mockImplementation(tool => {
return Promise.resolve(tool);
});
process.env["GITHUB_WORKSPACE"] = process.cwd();
});
afterAll(() => {
process.env["GITHUB_WORKSPACE"] = undefined;
});
test("extract tar", async () => {
@ -16,10 +22,11 @@ test("extract tar", async () => {
const execMock = jest.spyOn(exec, "exec");
const archivePath = "cache.tar";
const targetDirectory = "~/.npm/cache";
await tar.extractTar(archivePath, targetDirectory);
const workspace = process.env["GITHUB_WORKSPACE"];
expect(mkdirMock).toHaveBeenCalledWith(targetDirectory);
await tar.extractTar(archivePath);
expect(mkdirMock).toHaveBeenCalledWith(workspace);
const IS_WINDOWS = process.platform === "win32";
const tarPath = IS_WINDOWS
@ -30,8 +37,9 @@ test("extract tar", async () => {
"-xz",
"-f",
archivePath,
"-P",
"-C",
targetDirectory
workspace
]);
});
@ -39,8 +47,10 @@ test("create tar", async () => {
const execMock = jest.spyOn(exec, "exec");
const archivePath = "cache.tar";
const sourceDirectory = "~/.npm/cache";
await tar.createTar(archivePath, sourceDirectory);
const workspace = process.env["GITHUB_WORKSPACE"];
const sourceDirectories = ["~/.npm/cache", `${workspace}/dist`];
await tar.createTar(archivePath, sourceDirectories);
const IS_WINDOWS = process.platform === "win32";
const tarPath = IS_WINDOWS
@ -52,7 +62,7 @@ test("create tar", async () => {
"-f",
archivePath,
"-C",
sourceDirectory,
"."
workspace,
sourceDirectories.join(" ")
]);
});