Loading __tests__/tar.test.ts +10 −7 Changes for __tests__/tar.test.ts: 10 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ jest.mock("@actions/exec"); jest.mock("@actions/io"); const IS_WINDOWS = process.platform === "win32"; const IS_64OS = process.platform != "win32" || process.arch === "x64"; function getTempDir(): string { return path.join(__dirname, "_temp", "tar"); Loading Loading @@ -46,12 +47,13 @@ test("zstd extract tar", async () => { const tarPath = IS_WINDOWS ? `${process.env["windir"]}\\System32\\tar.exe` : "tar"; const zstdOptions = IS_64OS ? "zstd -d --long=31" : "zstd -d --long=30"; expect(execMock).toHaveBeenCalledTimes(1); expect(execMock).toHaveBeenCalledWith( `${tarPath}`, `"${tarPath}"`, [ "--use-compress-program", "zstd -d", zstdOptions, "-xf", IS_WINDOWS ? archivePath.replace(/\\/g, "/") : archivePath, "-P", Loading @@ -78,7 +80,7 @@ test("gzip extract tar", async () => { : "tar"; expect(execMock).toHaveBeenCalledTimes(1); expect(execMock).toHaveBeenCalledWith( `${tarPath}`, `"${tarPath}"`, [ "-z", "-xf", Loading Loading @@ -107,7 +109,7 @@ test("gzip extract GNU tar on windows", async () => { expect(isGnuMock).toHaveBeenCalledTimes(1); expect(execMock).toHaveBeenCalledTimes(1); expect(execMock).toHaveBeenCalledWith( `tar`, `"tar"`, [ "-z", "-xf", Loading Loading @@ -140,13 +142,14 @@ test("zstd create tar", async () => { const tarPath = IS_WINDOWS ? `${process.env["windir"]}\\System32\\tar.exe` : "tar"; const zstdOptions = IS_64OS ? "zstd -T0 --long=31" : "zstd -T0 --long=30"; expect(execMock).toHaveBeenCalledTimes(1); expect(execMock).toHaveBeenCalledWith( `${tarPath}`, `"${tarPath}"`, [ "--use-compress-program", "zstd -T0", zstdOptions, "-cf", IS_WINDOWS ? CacheFilename.Zstd.replace(/\\/g, "/") Loading Loading @@ -184,7 +187,7 @@ test("gzip create tar", async () => { expect(execMock).toHaveBeenCalledTimes(1); expect(execMock).toHaveBeenCalledWith( `${tarPath}`, `"${tarPath}"`, [ "-z", "-cf", Loading dist/restore/index.js +20 −9 Changes for dist/restore/index.js: 20 added lines, 9 removed lines. Original line number Diff line number Diff line Loading @@ -2237,10 +2237,9 @@ function createHttpClient() { return new http_client_1.HttpClient("actions/cache", [bearerCredentialHandler], getRequestOptions()); } function getCacheVersion(compressionMethod) { const components = [core.getInput(constants_1.Inputs.Path, { required: true })].concat(compressionMethod == constants_1.CompressionMethod.Zstd ? [compressionMethod] : []); // Add salt to cache version to support breaking changes in cache entry const components = [core.getInput(constants_1.Inputs.Path, { required: true })].concat(compressionMethod == constants_1.CompressionMethod.Zstd ? [compressionMethod, versionSalt] : versionSalt); components.push(versionSalt); return crypto .createHash("sha256") .update(components.join("|")) Loading Loading @@ -3320,7 +3319,7 @@ function unlinkFile(path) { return util.promisify(fs.unlink)(path); } exports.unlinkFile = unlinkFile; function checkVersion(app) { function getVersion(app) { return __awaiter(this, void 0, void 0, function* () { core.debug(`Checking ${app} --version`); let versionOutput = ""; Loading @@ -3344,7 +3343,7 @@ function checkVersion(app) { } function getCompressionMethod() { return __awaiter(this, void 0, void 0, function* () { const versionOutput = yield checkVersion("zstd"); const versionOutput = yield getVersion("zstd"); return versionOutput.toLowerCase().includes("zstd command line interface") ? constants_1.CompressionMethod.Zstd : constants_1.CompressionMethod.Gzip; Loading @@ -3359,7 +3358,7 @@ function getCacheFileName(compressionMethod) { exports.getCacheFileName = getCacheFileName; function useGnuTar() { return __awaiter(this, void 0, void 0, function* () { const versionOutput = yield checkVersion("tar"); const versionOutput = yield getVersion("tar"); return versionOutput.toLowerCase().includes("gnu tar"); }); } Loading Loading @@ -5068,7 +5067,7 @@ function execTar(args, cwd) { var _a; return __awaiter(this, void 0, void 0, function* () { try { yield exec_1.exec(`${yield getTarPath(args)}`, args, { cwd: cwd }); yield exec_1.exec(`"${yield getTarPath(args)}"`, args, { cwd: cwd }); } catch (error) { throw new Error(`Tar failed with error: ${(_a = error) === null || _a === void 0 ? void 0 : _a.message}`); Loading @@ -5079,14 +5078,22 @@ function getWorkingDirectory() { var _a; 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) { return __awaiter(this, void 0, void 0, function* () { // Create directory to extract tar into const workingDirectory = getWorkingDirectory(); yield io.mkdirP(workingDirectory); // --d: Decompress. // --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit. const args = [ ...(compressionMethod == constants_1.CompressionMethod.Zstd ? ["--use-compress-program", "zstd -d"] ? [ "--use-compress-program", isOS64() ? "zstd -d --long=31" : "zstd -d --long=30" ] : ["-z"]), "-xf", archivePath.replace(new RegExp("\\" + path.sep, "g"), "/"), Loading @@ -5105,10 +5112,14 @@ function createTar(archiveFolder, sourceDirectories, compressionMethod) { const cacheFileName = utils.getCacheFileName(compressionMethod); 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. // --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit. const workingDirectory = getWorkingDirectory(); const args = [ ...(compressionMethod == constants_1.CompressionMethod.Zstd ? ["--use-compress-program", "zstd -T0"] ? [ "--use-compress-program", isOS64() ? "zstd -T0 --long=31" : "zstd -T0 --long=30" ] : ["-z"]), "-cf", cacheFileName.replace(new RegExp("\\" + path.sep, "g"), "/"), Loading dist/save/index.js +20 −9 Changes for dist/save/index.js: 20 added lines, 9 removed lines. Original line number Diff line number Diff line Loading @@ -2237,10 +2237,9 @@ function createHttpClient() { return new http_client_1.HttpClient("actions/cache", [bearerCredentialHandler], getRequestOptions()); } function getCacheVersion(compressionMethod) { const components = [core.getInput(constants_1.Inputs.Path, { required: true })].concat(compressionMethod == constants_1.CompressionMethod.Zstd ? [compressionMethod] : []); // Add salt to cache version to support breaking changes in cache entry const components = [core.getInput(constants_1.Inputs.Path, { required: true })].concat(compressionMethod == constants_1.CompressionMethod.Zstd ? [compressionMethod, versionSalt] : versionSalt); components.push(versionSalt); return crypto .createHash("sha256") .update(components.join("|")) Loading Loading @@ -3320,7 +3319,7 @@ function unlinkFile(path) { return util.promisify(fs.unlink)(path); } exports.unlinkFile = unlinkFile; function checkVersion(app) { function getVersion(app) { return __awaiter(this, void 0, void 0, function* () { core.debug(`Checking ${app} --version`); let versionOutput = ""; Loading @@ -3344,7 +3343,7 @@ function checkVersion(app) { } function getCompressionMethod() { return __awaiter(this, void 0, void 0, function* () { const versionOutput = yield checkVersion("zstd"); const versionOutput = yield getVersion("zstd"); return versionOutput.toLowerCase().includes("zstd command line interface") ? constants_1.CompressionMethod.Zstd : constants_1.CompressionMethod.Gzip; Loading @@ -3359,7 +3358,7 @@ function getCacheFileName(compressionMethod) { exports.getCacheFileName = getCacheFileName; function useGnuTar() { return __awaiter(this, void 0, void 0, function* () { const versionOutput = yield checkVersion("tar"); const versionOutput = yield getVersion("tar"); return versionOutput.toLowerCase().includes("gnu tar"); }); } Loading Loading @@ -5045,7 +5044,7 @@ function execTar(args, cwd) { var _a; return __awaiter(this, void 0, void 0, function* () { try { yield exec_1.exec(`${yield getTarPath(args)}`, args, { cwd: cwd }); yield exec_1.exec(`"${yield getTarPath(args)}"`, args, { cwd: cwd }); } catch (error) { throw new Error(`Tar failed with error: ${(_a = error) === null || _a === void 0 ? void 0 : _a.message}`); Loading @@ -5056,14 +5055,22 @@ function getWorkingDirectory() { var _a; 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) { return __awaiter(this, void 0, void 0, function* () { // Create directory to extract tar into const workingDirectory = getWorkingDirectory(); yield io.mkdirP(workingDirectory); // --d: Decompress. // --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit. const args = [ ...(compressionMethod == constants_1.CompressionMethod.Zstd ? ["--use-compress-program", "zstd -d"] ? [ "--use-compress-program", isOS64() ? "zstd -d --long=31" : "zstd -d --long=30" ] : ["-z"]), "-xf", archivePath.replace(new RegExp("\\" + path.sep, "g"), "/"), Loading @@ -5082,10 +5089,14 @@ function createTar(archiveFolder, sourceDirectories, compressionMethod) { const cacheFileName = utils.getCacheFileName(compressionMethod); 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. // --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit. const workingDirectory = getWorkingDirectory(); const args = [ ...(compressionMethod == constants_1.CompressionMethod.Zstd ? ["--use-compress-program", "zstd -T0"] ? [ "--use-compress-program", isOS64() ? "zstd -T0 --long=31" : "zstd -T0 --long=30" ] : ["-z"]), "-cf", cacheFileName.replace(new RegExp("\\" + path.sep, "g"), "/"), Loading src/cacheHttpClient.ts +4 −4 Changes for src/cacheHttpClient.ts: 4 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -86,13 +86,13 @@ function createHttpClient(): HttpClient { } export function getCacheVersion(compressionMethod?: CompressionMethod): string { // Add salt to cache version to support breaking changes in cache entry const components = [core.getInput(Inputs.Path, { required: true })].concat( compressionMethod == CompressionMethod.Zstd ? [compressionMethod, versionSalt] : versionSalt compressionMethod == CompressionMethod.Zstd ? [compressionMethod] : [] ); // Add salt to cache version to support breaking changes in cache entry components.push(versionSalt); return crypto .createHash("sha256") .update(components.join("|")) Loading src/tar.ts +16 −3 Changes for src/tar.ts: 16 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ async function getTarPath(args: string[]): Promise<string> { async function execTar(args: string[], cwd?: string): Promise<void> { try { await exec(`${await getTarPath(args)}`, args, { cwd: cwd }); await exec(`"${await getTarPath(args)}"`, args, { cwd: cwd }); } catch (error) { throw new Error(`Tar failed with error: ${error?.message}`); } Loading @@ -32,6 +32,10 @@ function getWorkingDirectory(): string { return process.env["GITHUB_WORKSPACE"] ?? process.cwd(); } function isOS64(): boolean { return process.platform != "win32" || process.arch === "x64"; } export async function extractTar( archivePath: string, compressionMethod: CompressionMethod Loading @@ -39,9 +43,14 @@ export async function extractTar( // Create directory to extract tar into const workingDirectory = getWorkingDirectory(); await io.mkdirP(workingDirectory); // --d: Decompress. // --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit. const args = [ ...(compressionMethod == CompressionMethod.Zstd ? ["--use-compress-program", "zstd -d"] ? [ "--use-compress-program", isOS64() ? "zstd -d --long=31" : "zstd -d --long=30" ] : ["-z"]), "-xf", archivePath.replace(new RegExp("\\" + path.sep, "g"), "/"), Loading @@ -65,10 +74,14 @@ export async function createTar( sourceDirectories.join("\n") ); // -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. const workingDirectory = getWorkingDirectory(); const args = [ ...(compressionMethod == CompressionMethod.Zstd ? ["--use-compress-program", "zstd -T0"] ? [ "--use-compress-program", isOS64() ? "zstd -T0 --long=31" : "zstd -T0 --long=30" ] : ["-z"]), "-cf", cacheFileName.replace(new RegExp("\\" + path.sep, "g"), "/"), Loading Loading
__tests__/tar.test.ts +10 −7 Changes for __tests__/tar.test.ts: 10 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ jest.mock("@actions/exec"); jest.mock("@actions/io"); const IS_WINDOWS = process.platform === "win32"; const IS_64OS = process.platform != "win32" || process.arch === "x64"; function getTempDir(): string { return path.join(__dirname, "_temp", "tar"); Loading Loading @@ -46,12 +47,13 @@ test("zstd extract tar", async () => { const tarPath = IS_WINDOWS ? `${process.env["windir"]}\\System32\\tar.exe` : "tar"; const zstdOptions = IS_64OS ? "zstd -d --long=31" : "zstd -d --long=30"; expect(execMock).toHaveBeenCalledTimes(1); expect(execMock).toHaveBeenCalledWith( `${tarPath}`, `"${tarPath}"`, [ "--use-compress-program", "zstd -d", zstdOptions, "-xf", IS_WINDOWS ? archivePath.replace(/\\/g, "/") : archivePath, "-P", Loading @@ -78,7 +80,7 @@ test("gzip extract tar", async () => { : "tar"; expect(execMock).toHaveBeenCalledTimes(1); expect(execMock).toHaveBeenCalledWith( `${tarPath}`, `"${tarPath}"`, [ "-z", "-xf", Loading Loading @@ -107,7 +109,7 @@ test("gzip extract GNU tar on windows", async () => { expect(isGnuMock).toHaveBeenCalledTimes(1); expect(execMock).toHaveBeenCalledTimes(1); expect(execMock).toHaveBeenCalledWith( `tar`, `"tar"`, [ "-z", "-xf", Loading Loading @@ -140,13 +142,14 @@ test("zstd create tar", async () => { const tarPath = IS_WINDOWS ? `${process.env["windir"]}\\System32\\tar.exe` : "tar"; const zstdOptions = IS_64OS ? "zstd -T0 --long=31" : "zstd -T0 --long=30"; expect(execMock).toHaveBeenCalledTimes(1); expect(execMock).toHaveBeenCalledWith( `${tarPath}`, `"${tarPath}"`, [ "--use-compress-program", "zstd -T0", zstdOptions, "-cf", IS_WINDOWS ? CacheFilename.Zstd.replace(/\\/g, "/") Loading Loading @@ -184,7 +187,7 @@ test("gzip create tar", async () => { expect(execMock).toHaveBeenCalledTimes(1); expect(execMock).toHaveBeenCalledWith( `${tarPath}`, `"${tarPath}"`, [ "-z", "-cf", Loading
dist/restore/index.js +20 −9 Changes for dist/restore/index.js: 20 added lines, 9 removed lines. Original line number Diff line number Diff line Loading @@ -2237,10 +2237,9 @@ function createHttpClient() { return new http_client_1.HttpClient("actions/cache", [bearerCredentialHandler], getRequestOptions()); } function getCacheVersion(compressionMethod) { const components = [core.getInput(constants_1.Inputs.Path, { required: true })].concat(compressionMethod == constants_1.CompressionMethod.Zstd ? [compressionMethod] : []); // Add salt to cache version to support breaking changes in cache entry const components = [core.getInput(constants_1.Inputs.Path, { required: true })].concat(compressionMethod == constants_1.CompressionMethod.Zstd ? [compressionMethod, versionSalt] : versionSalt); components.push(versionSalt); return crypto .createHash("sha256") .update(components.join("|")) Loading Loading @@ -3320,7 +3319,7 @@ function unlinkFile(path) { return util.promisify(fs.unlink)(path); } exports.unlinkFile = unlinkFile; function checkVersion(app) { function getVersion(app) { return __awaiter(this, void 0, void 0, function* () { core.debug(`Checking ${app} --version`); let versionOutput = ""; Loading @@ -3344,7 +3343,7 @@ function checkVersion(app) { } function getCompressionMethod() { return __awaiter(this, void 0, void 0, function* () { const versionOutput = yield checkVersion("zstd"); const versionOutput = yield getVersion("zstd"); return versionOutput.toLowerCase().includes("zstd command line interface") ? constants_1.CompressionMethod.Zstd : constants_1.CompressionMethod.Gzip; Loading @@ -3359,7 +3358,7 @@ function getCacheFileName(compressionMethod) { exports.getCacheFileName = getCacheFileName; function useGnuTar() { return __awaiter(this, void 0, void 0, function* () { const versionOutput = yield checkVersion("tar"); const versionOutput = yield getVersion("tar"); return versionOutput.toLowerCase().includes("gnu tar"); }); } Loading Loading @@ -5068,7 +5067,7 @@ function execTar(args, cwd) { var _a; return __awaiter(this, void 0, void 0, function* () { try { yield exec_1.exec(`${yield getTarPath(args)}`, args, { cwd: cwd }); yield exec_1.exec(`"${yield getTarPath(args)}"`, args, { cwd: cwd }); } catch (error) { throw new Error(`Tar failed with error: ${(_a = error) === null || _a === void 0 ? void 0 : _a.message}`); Loading @@ -5079,14 +5078,22 @@ function getWorkingDirectory() { var _a; 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) { return __awaiter(this, void 0, void 0, function* () { // Create directory to extract tar into const workingDirectory = getWorkingDirectory(); yield io.mkdirP(workingDirectory); // --d: Decompress. // --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit. const args = [ ...(compressionMethod == constants_1.CompressionMethod.Zstd ? ["--use-compress-program", "zstd -d"] ? [ "--use-compress-program", isOS64() ? "zstd -d --long=31" : "zstd -d --long=30" ] : ["-z"]), "-xf", archivePath.replace(new RegExp("\\" + path.sep, "g"), "/"), Loading @@ -5105,10 +5112,14 @@ function createTar(archiveFolder, sourceDirectories, compressionMethod) { const cacheFileName = utils.getCacheFileName(compressionMethod); 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. // --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit. const workingDirectory = getWorkingDirectory(); const args = [ ...(compressionMethod == constants_1.CompressionMethod.Zstd ? ["--use-compress-program", "zstd -T0"] ? [ "--use-compress-program", isOS64() ? "zstd -T0 --long=31" : "zstd -T0 --long=30" ] : ["-z"]), "-cf", cacheFileName.replace(new RegExp("\\" + path.sep, "g"), "/"), Loading
dist/save/index.js +20 −9 Changes for dist/save/index.js: 20 added lines, 9 removed lines. Original line number Diff line number Diff line Loading @@ -2237,10 +2237,9 @@ function createHttpClient() { return new http_client_1.HttpClient("actions/cache", [bearerCredentialHandler], getRequestOptions()); } function getCacheVersion(compressionMethod) { const components = [core.getInput(constants_1.Inputs.Path, { required: true })].concat(compressionMethod == constants_1.CompressionMethod.Zstd ? [compressionMethod] : []); // Add salt to cache version to support breaking changes in cache entry const components = [core.getInput(constants_1.Inputs.Path, { required: true })].concat(compressionMethod == constants_1.CompressionMethod.Zstd ? [compressionMethod, versionSalt] : versionSalt); components.push(versionSalt); return crypto .createHash("sha256") .update(components.join("|")) Loading Loading @@ -3320,7 +3319,7 @@ function unlinkFile(path) { return util.promisify(fs.unlink)(path); } exports.unlinkFile = unlinkFile; function checkVersion(app) { function getVersion(app) { return __awaiter(this, void 0, void 0, function* () { core.debug(`Checking ${app} --version`); let versionOutput = ""; Loading @@ -3344,7 +3343,7 @@ function checkVersion(app) { } function getCompressionMethod() { return __awaiter(this, void 0, void 0, function* () { const versionOutput = yield checkVersion("zstd"); const versionOutput = yield getVersion("zstd"); return versionOutput.toLowerCase().includes("zstd command line interface") ? constants_1.CompressionMethod.Zstd : constants_1.CompressionMethod.Gzip; Loading @@ -3359,7 +3358,7 @@ function getCacheFileName(compressionMethod) { exports.getCacheFileName = getCacheFileName; function useGnuTar() { return __awaiter(this, void 0, void 0, function* () { const versionOutput = yield checkVersion("tar"); const versionOutput = yield getVersion("tar"); return versionOutput.toLowerCase().includes("gnu tar"); }); } Loading Loading @@ -5045,7 +5044,7 @@ function execTar(args, cwd) { var _a; return __awaiter(this, void 0, void 0, function* () { try { yield exec_1.exec(`${yield getTarPath(args)}`, args, { cwd: cwd }); yield exec_1.exec(`"${yield getTarPath(args)}"`, args, { cwd: cwd }); } catch (error) { throw new Error(`Tar failed with error: ${(_a = error) === null || _a === void 0 ? void 0 : _a.message}`); Loading @@ -5056,14 +5055,22 @@ function getWorkingDirectory() { var _a; 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) { return __awaiter(this, void 0, void 0, function* () { // Create directory to extract tar into const workingDirectory = getWorkingDirectory(); yield io.mkdirP(workingDirectory); // --d: Decompress. // --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit. const args = [ ...(compressionMethod == constants_1.CompressionMethod.Zstd ? ["--use-compress-program", "zstd -d"] ? [ "--use-compress-program", isOS64() ? "zstd -d --long=31" : "zstd -d --long=30" ] : ["-z"]), "-xf", archivePath.replace(new RegExp("\\" + path.sep, "g"), "/"), Loading @@ -5082,10 +5089,14 @@ function createTar(archiveFolder, sourceDirectories, compressionMethod) { const cacheFileName = utils.getCacheFileName(compressionMethod); 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. // --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit. const workingDirectory = getWorkingDirectory(); const args = [ ...(compressionMethod == constants_1.CompressionMethod.Zstd ? ["--use-compress-program", "zstd -T0"] ? [ "--use-compress-program", isOS64() ? "zstd -T0 --long=31" : "zstd -T0 --long=30" ] : ["-z"]), "-cf", cacheFileName.replace(new RegExp("\\" + path.sep, "g"), "/"), Loading
src/cacheHttpClient.ts +4 −4 Changes for src/cacheHttpClient.ts: 4 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -86,13 +86,13 @@ function createHttpClient(): HttpClient { } export function getCacheVersion(compressionMethod?: CompressionMethod): string { // Add salt to cache version to support breaking changes in cache entry const components = [core.getInput(Inputs.Path, { required: true })].concat( compressionMethod == CompressionMethod.Zstd ? [compressionMethod, versionSalt] : versionSalt compressionMethod == CompressionMethod.Zstd ? [compressionMethod] : [] ); // Add salt to cache version to support breaking changes in cache entry components.push(versionSalt); return crypto .createHash("sha256") .update(components.join("|")) Loading
src/tar.ts +16 −3 Changes for src/tar.ts: 16 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ async function getTarPath(args: string[]): Promise<string> { async function execTar(args: string[], cwd?: string): Promise<void> { try { await exec(`${await getTarPath(args)}`, args, { cwd: cwd }); await exec(`"${await getTarPath(args)}"`, args, { cwd: cwd }); } catch (error) { throw new Error(`Tar failed with error: ${error?.message}`); } Loading @@ -32,6 +32,10 @@ function getWorkingDirectory(): string { return process.env["GITHUB_WORKSPACE"] ?? process.cwd(); } function isOS64(): boolean { return process.platform != "win32" || process.arch === "x64"; } export async function extractTar( archivePath: string, compressionMethod: CompressionMethod Loading @@ -39,9 +43,14 @@ export async function extractTar( // Create directory to extract tar into const workingDirectory = getWorkingDirectory(); await io.mkdirP(workingDirectory); // --d: Decompress. // --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit. const args = [ ...(compressionMethod == CompressionMethod.Zstd ? ["--use-compress-program", "zstd -d"] ? [ "--use-compress-program", isOS64() ? "zstd -d --long=31" : "zstd -d --long=30" ] : ["-z"]), "-xf", archivePath.replace(new RegExp("\\" + path.sep, "g"), "/"), Loading @@ -65,10 +74,14 @@ export async function createTar( sourceDirectories.join("\n") ); // -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. const workingDirectory = getWorkingDirectory(); const args = [ ...(compressionMethod == CompressionMethod.Zstd ? ["--use-compress-program", "zstd -T0"] ? [ "--use-compress-program", isOS64() ? "zstd -T0 --long=31" : "zstd -T0 --long=30" ] : ["-z"]), "-cf", cacheFileName.replace(new RegExp("\\" + path.sep, "g"), "/"), Loading