mirror of
https://code.forgejo.org/actions/cache.git
synced 2025-04-21 00:03:58 +08:00
Add unit tests for save (#98)
* Clean up args and arrange imports * Arrange args in restore tests * Add unit tests for save * Use const instead of let (linting)
This commit is contained in:
parent
c0584c42d1
commit
8d14a2150b
5 changed files with 390 additions and 44 deletions
|
@ -19,7 +19,7 @@ async function run(): Promise<void> {
|
|||
);
|
||||
}
|
||||
|
||||
let cachePath = utils.resolvePath(
|
||||
const cachePath = utils.resolvePath(
|
||||
core.getInput(Inputs.Path, { required: true })
|
||||
);
|
||||
core.debug(`Cache Path: ${cachePath}`);
|
||||
|
@ -67,7 +67,7 @@ async function run(): Promise<void> {
|
|||
return;
|
||||
}
|
||||
|
||||
let archivePath = path.join(
|
||||
const archivePath = path.join(
|
||||
await utils.createTempDirectory(),
|
||||
"cache.tgz"
|
||||
);
|
||||
|
@ -90,15 +90,17 @@ async function run(): Promise<void> {
|
|||
|
||||
// http://man7.org/linux/man-pages/man1/tar.1.html
|
||||
// tar [-options] <name of the tar archive> [files or directories which to add into archive]
|
||||
const args = ["-xz"];
|
||||
|
||||
const IS_WINDOWS = process.platform === "win32";
|
||||
if (IS_WINDOWS) {
|
||||
args.push("--force-local");
|
||||
archivePath = archivePath.replace(/\\/g, "/");
|
||||
cachePath = cachePath.replace(/\\/g, "/");
|
||||
}
|
||||
args.push(...["-f", archivePath, "-C", cachePath]);
|
||||
const args = IS_WINDOWS
|
||||
? [
|
||||
"-xz",
|
||||
"--force-local",
|
||||
"-f",
|
||||
archivePath.replace(/\\/g, "/"),
|
||||
"-C",
|
||||
cachePath.replace(/\\/g, "/")
|
||||
]
|
||||
: ["-xz", "-f", archivePath, "-C", cachePath];
|
||||
|
||||
const tarPath = await io.which("tar", true);
|
||||
core.debug(`Tar Path: ${tarPath}`);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue