mirror of
https://code.forgejo.org/actions/cache.git
synced 2024-11-09 03:33:40 -05:00
Use 30 as the long distance matching window to support both 32-bit and 64-bit OS
This commit is contained in:
parent
a5d9a3b1a6
commit
75cd46ec0c
5 changed files with 17 additions and 42 deletions
|
@ -12,7 +12,6 @@ jest.mock("@actions/exec");
|
||||||
jest.mock("@actions/io");
|
jest.mock("@actions/io");
|
||||||
|
|
||||||
const IS_WINDOWS = process.platform === "win32";
|
const IS_WINDOWS = process.platform === "win32";
|
||||||
const IS_64OS = process.platform != "win32" || process.arch === "x64";
|
|
||||||
|
|
||||||
function getTempDir(): string {
|
function getTempDir(): string {
|
||||||
return path.join(__dirname, "_temp", "tar");
|
return path.join(__dirname, "_temp", "tar");
|
||||||
|
@ -47,13 +46,12 @@ test("zstd extract tar", async () => {
|
||||||
const tarPath = IS_WINDOWS
|
const tarPath = IS_WINDOWS
|
||||||
? `${process.env["windir"]}\\System32\\tar.exe`
|
? `${process.env["windir"]}\\System32\\tar.exe`
|
||||||
: "tar";
|
: "tar";
|
||||||
const zstdOptions = IS_64OS ? "zstd -d --long=31" : "zstd -d --long=30";
|
|
||||||
expect(execMock).toHaveBeenCalledTimes(1);
|
expect(execMock).toHaveBeenCalledTimes(1);
|
||||||
expect(execMock).toHaveBeenCalledWith(
|
expect(execMock).toHaveBeenCalledWith(
|
||||||
`"${tarPath}"`,
|
`"${tarPath}"`,
|
||||||
[
|
[
|
||||||
"--use-compress-program",
|
"--use-compress-program",
|
||||||
zstdOptions,
|
"zstd -d --long=30",
|
||||||
"-xf",
|
"-xf",
|
||||||
IS_WINDOWS ? archivePath.replace(/\\/g, "/") : archivePath,
|
IS_WINDOWS ? archivePath.replace(/\\/g, "/") : archivePath,
|
||||||
"-P",
|
"-P",
|
||||||
|
@ -142,14 +140,13 @@ test("zstd create tar", async () => {
|
||||||
const tarPath = IS_WINDOWS
|
const tarPath = IS_WINDOWS
|
||||||
? `${process.env["windir"]}\\System32\\tar.exe`
|
? `${process.env["windir"]}\\System32\\tar.exe`
|
||||||
: "tar";
|
: "tar";
|
||||||
const zstdOptions = IS_64OS ? "zstd -T0 --long=31" : "zstd -T0 --long=30";
|
|
||||||
|
|
||||||
expect(execMock).toHaveBeenCalledTimes(1);
|
expect(execMock).toHaveBeenCalledTimes(1);
|
||||||
expect(execMock).toHaveBeenCalledWith(
|
expect(execMock).toHaveBeenCalledWith(
|
||||||
`"${tarPath}"`,
|
`"${tarPath}"`,
|
||||||
[
|
[
|
||||||
"--use-compress-program",
|
"--use-compress-program",
|
||||||
zstdOptions,
|
"zstd -T0 --long=30",
|
||||||
"-cf",
|
"-cf",
|
||||||
IS_WINDOWS
|
IS_WINDOWS
|
||||||
? CacheFilename.Zstd.replace(/\\/g, "/")
|
? CacheFilename.Zstd.replace(/\\/g, "/")
|
||||||
|
|
15
dist/restore/index.js
vendored
15
dist/restore/index.js
vendored
|
@ -5078,9 +5078,6 @@ function getWorkingDirectory() {
|
||||||
var _a;
|
var _a;
|
||||||
return _a = process.env["GITHUB_WORKSPACE"], (_a !== null && _a !== void 0 ? _a : process.cwd());
|
return _a = process.env["GITHUB_WORKSPACE"], (_a !== null && _a !== void 0 ? _a : process.cwd());
|
||||||
}
|
}
|
||||||
function isOS64() {
|
|
||||||
return process.platform != "win32" || process.arch === "x64";
|
|
||||||
}
|
|
||||||
function extractTar(archivePath, compressionMethod) {
|
function extractTar(archivePath, compressionMethod) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
// Create directory to extract tar into
|
// Create directory to extract tar into
|
||||||
|
@ -5088,12 +5085,10 @@ function extractTar(archivePath, compressionMethod) {
|
||||||
yield io.mkdirP(workingDirectory);
|
yield io.mkdirP(workingDirectory);
|
||||||
// --d: Decompress.
|
// --d: Decompress.
|
||||||
// --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
|
// --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
|
||||||
|
// Using 30 here because we also support 32-bit self-hosted runners.
|
||||||
const args = [
|
const args = [
|
||||||
...(compressionMethod == constants_1.CompressionMethod.Zstd
|
...(compressionMethod == constants_1.CompressionMethod.Zstd
|
||||||
? [
|
? ["--use-compress-program", "zstd -d --long=30"]
|
||||||
"--use-compress-program",
|
|
||||||
isOS64() ? "zstd -d --long=31" : "zstd -d --long=30"
|
|
||||||
]
|
|
||||||
: ["-z"]),
|
: ["-z"]),
|
||||||
"-xf",
|
"-xf",
|
||||||
archivePath.replace(new RegExp("\\" + path.sep, "g"), "/"),
|
archivePath.replace(new RegExp("\\" + path.sep, "g"), "/"),
|
||||||
|
@ -5113,13 +5108,11 @@ function createTar(archiveFolder, sourceDirectories, compressionMethod) {
|
||||||
fs_1.writeFileSync(path.join(archiveFolder, manifestFilename), sourceDirectories.join("\n"));
|
fs_1.writeFileSync(path.join(archiveFolder, manifestFilename), sourceDirectories.join("\n"));
|
||||||
// -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores.
|
// -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores.
|
||||||
// --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
|
// --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
|
||||||
|
// Using 30 here because we also support 32-bit self-hosted runners.
|
||||||
const workingDirectory = getWorkingDirectory();
|
const workingDirectory = getWorkingDirectory();
|
||||||
const args = [
|
const args = [
|
||||||
...(compressionMethod == constants_1.CompressionMethod.Zstd
|
...(compressionMethod == constants_1.CompressionMethod.Zstd
|
||||||
? [
|
? ["--use-compress-program", "zstd -T0 --long=30"]
|
||||||
"--use-compress-program",
|
|
||||||
isOS64() ? "zstd -T0 --long=31" : "zstd -T0 --long=30"
|
|
||||||
]
|
|
||||||
: ["-z"]),
|
: ["-z"]),
|
||||||
"-cf",
|
"-cf",
|
||||||
cacheFileName.replace(new RegExp("\\" + path.sep, "g"), "/"),
|
cacheFileName.replace(new RegExp("\\" + path.sep, "g"), "/"),
|
||||||
|
|
15
dist/save/index.js
vendored
15
dist/save/index.js
vendored
|
@ -5055,9 +5055,6 @@ function getWorkingDirectory() {
|
||||||
var _a;
|
var _a;
|
||||||
return _a = process.env["GITHUB_WORKSPACE"], (_a !== null && _a !== void 0 ? _a : process.cwd());
|
return _a = process.env["GITHUB_WORKSPACE"], (_a !== null && _a !== void 0 ? _a : process.cwd());
|
||||||
}
|
}
|
||||||
function isOS64() {
|
|
||||||
return process.platform != "win32" || process.arch === "x64";
|
|
||||||
}
|
|
||||||
function extractTar(archivePath, compressionMethod) {
|
function extractTar(archivePath, compressionMethod) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
// Create directory to extract tar into
|
// Create directory to extract tar into
|
||||||
|
@ -5065,12 +5062,10 @@ function extractTar(archivePath, compressionMethod) {
|
||||||
yield io.mkdirP(workingDirectory);
|
yield io.mkdirP(workingDirectory);
|
||||||
// --d: Decompress.
|
// --d: Decompress.
|
||||||
// --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
|
// --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
|
||||||
|
// Using 30 here because we also support 32-bit self-hosted runners.
|
||||||
const args = [
|
const args = [
|
||||||
...(compressionMethod == constants_1.CompressionMethod.Zstd
|
...(compressionMethod == constants_1.CompressionMethod.Zstd
|
||||||
? [
|
? ["--use-compress-program", "zstd -d --long=30"]
|
||||||
"--use-compress-program",
|
|
||||||
isOS64() ? "zstd -d --long=31" : "zstd -d --long=30"
|
|
||||||
]
|
|
||||||
: ["-z"]),
|
: ["-z"]),
|
||||||
"-xf",
|
"-xf",
|
||||||
archivePath.replace(new RegExp("\\" + path.sep, "g"), "/"),
|
archivePath.replace(new RegExp("\\" + path.sep, "g"), "/"),
|
||||||
|
@ -5090,13 +5085,11 @@ function createTar(archiveFolder, sourceDirectories, compressionMethod) {
|
||||||
fs_1.writeFileSync(path.join(archiveFolder, manifestFilename), sourceDirectories.join("\n"));
|
fs_1.writeFileSync(path.join(archiveFolder, manifestFilename), sourceDirectories.join("\n"));
|
||||||
// -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores.
|
// -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores.
|
||||||
// --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
|
// --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
|
||||||
|
// Using 30 here because we also support 32-bit self-hosted runners.
|
||||||
const workingDirectory = getWorkingDirectory();
|
const workingDirectory = getWorkingDirectory();
|
||||||
const args = [
|
const args = [
|
||||||
...(compressionMethod == constants_1.CompressionMethod.Zstd
|
...(compressionMethod == constants_1.CompressionMethod.Zstd
|
||||||
? [
|
? ["--use-compress-program", "zstd -T0 --long=30"]
|
||||||
"--use-compress-program",
|
|
||||||
isOS64() ? "zstd -T0 --long=31" : "zstd -T0 --long=30"
|
|
||||||
]
|
|
||||||
: ["-z"]),
|
: ["-z"]),
|
||||||
"-cf",
|
"-cf",
|
||||||
cacheFileName.replace(new RegExp("\\" + path.sep, "g"), "/"),
|
cacheFileName.replace(new RegExp("\\" + path.sep, "g"), "/"),
|
||||||
|
|
16
src/tar.ts
16
src/tar.ts
|
@ -32,10 +32,6 @@ function getWorkingDirectory(): string {
|
||||||
return process.env["GITHUB_WORKSPACE"] ?? process.cwd();
|
return process.env["GITHUB_WORKSPACE"] ?? process.cwd();
|
||||||
}
|
}
|
||||||
|
|
||||||
function isOS64(): boolean {
|
|
||||||
return process.platform != "win32" || process.arch === "x64";
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function extractTar(
|
export async function extractTar(
|
||||||
archivePath: string,
|
archivePath: string,
|
||||||
compressionMethod: CompressionMethod
|
compressionMethod: CompressionMethod
|
||||||
|
@ -45,12 +41,10 @@ export async function extractTar(
|
||||||
await io.mkdirP(workingDirectory);
|
await io.mkdirP(workingDirectory);
|
||||||
// --d: Decompress.
|
// --d: Decompress.
|
||||||
// --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
|
// --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
|
||||||
|
// Using 30 here because we also support 32-bit self-hosted runners.
|
||||||
const args = [
|
const args = [
|
||||||
...(compressionMethod == CompressionMethod.Zstd
|
...(compressionMethod == CompressionMethod.Zstd
|
||||||
? [
|
? ["--use-compress-program", "zstd -d --long=30"]
|
||||||
"--use-compress-program",
|
|
||||||
isOS64() ? "zstd -d --long=31" : "zstd -d --long=30"
|
|
||||||
]
|
|
||||||
: ["-z"]),
|
: ["-z"]),
|
||||||
"-xf",
|
"-xf",
|
||||||
archivePath.replace(new RegExp("\\" + path.sep, "g"), "/"),
|
archivePath.replace(new RegExp("\\" + path.sep, "g"), "/"),
|
||||||
|
@ -75,13 +69,11 @@ export async function createTar(
|
||||||
);
|
);
|
||||||
// -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores.
|
// -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores.
|
||||||
// --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
|
// --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
|
||||||
|
// Using 30 here because we also support 32-bit self-hosted runners.
|
||||||
const workingDirectory = getWorkingDirectory();
|
const workingDirectory = getWorkingDirectory();
|
||||||
const args = [
|
const args = [
|
||||||
...(compressionMethod == CompressionMethod.Zstd
|
...(compressionMethod == CompressionMethod.Zstd
|
||||||
? [
|
? ["--use-compress-program", "zstd -T0 --long=30"]
|
||||||
"--use-compress-program",
|
|
||||||
isOS64() ? "zstd -T0 --long=31" : "zstd -T0 --long=30"
|
|
||||||
]
|
|
||||||
: ["-z"]),
|
: ["-z"]),
|
||||||
"-cf",
|
"-cf",
|
||||||
cacheFileName.replace(new RegExp("\\" + path.sep, "g"), "/"),
|
cacheFileName.replace(new RegExp("\\" + path.sep, "g"), "/"),
|
||||||
|
|
Loading…
Reference in a new issue