Compare commits
	
		
			107 Commits
		
	
	
		
			v3.2.0
			...
			releases/v
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 64a59d5b55 | ||
|   | b388bcadaf | ||
|   | f9ae5e0028 | ||
|   | 34faf3ad7c | ||
|   | 1d114a8000 | ||
|   | 8955114d15 | ||
|   | 3f0eaf4956 | ||
|   | 770b3a8151 | ||
|   | ed5e94a5f5 | ||
|   | 6277f55919 | ||
|   | c30e6dcb11 | ||
|   | 05c9b49ea4 | ||
|   | da311f75a6 | ||
|   | 7a139a9cec | ||
|   | 930f080bad | ||
|   | 56e956426f | ||
|   | 766d8255cd | ||
|   | 686bf424a8 | ||
|   | fb5b333162 | ||
|   | c11ac6c2fe | ||
|   | d5c949690c | ||
|   | 44df5ab77e | ||
|   | 65057ce6fe | ||
|   | 8031e403b4 | ||
|   | c8d01facfc | ||
|   | 81aaae062b | ||
|   | 9d445b2565 | ||
|   | adecab4b4a | ||
|   | 075ad790b0 | ||
|   | b275c83bd6 | ||
|   | 1ddc49105d | ||
|   | 407044787b | ||
|   | 87a7d01109 | ||
|   | 29d6c7aa7f | ||
|   | df53d3c04b | ||
|   | dd740c87de | ||
|   | 0a6e5b052a | ||
|   | a2137c625c | ||
|   | 5a2b5e5714 | ||
|   | 9e9a19bf5f | ||
|   | 84ea3e177d | ||
|   | 00b72c7e02 | ||
|   | 0cc9c1d4e8 | ||
|   | ccf90c02ed | ||
|   | 4f42dc56c1 | ||
|   | b6604364ae | ||
|   | c0cc8dd60a | ||
|   | 91d7bd61be | ||
|   | 5e7f2c1182 | ||
|   | 3d4af52c52 | ||
|   | d91f5bd2fd | ||
|   | 61aa90bfc3 | ||
|   | 0c2d18e609 | ||
|   | 804322aab0 | ||
|   | f426a0deb2 | ||
|   | be72d0432d | ||
|   | 8ecd00a4be | ||
|   | 12a1a354bd | ||
|   | 782b0bd3df | ||
|   | f33ca902b8 | ||
|   | d48d03435b | ||
|   | 6f77edac15 | ||
|   | 6e12d27152 | ||
|   | c346bf01e0 | ||
|   | 593e91a38b | ||
|   | e4c2242eff | ||
|   | 66ef8a0951 | ||
|   | 657c52f11e | ||
|   | 34e917cb7d | ||
|   | ac8fc97c06 | ||
|   | 86712a0733 | ||
|   | d6e98d9302 | ||
|   | a76826ef46 | ||
|   | e02e5113ed | ||
|   | 85ae5bbcea | ||
|   | cce93fb2c7 | ||
|   | e3d8fb0b34 | ||
|   | 020a412c27 | ||
|   | d95c048983 | ||
|   | 706c369cf1 | ||
|   | 11ab7ccfa2 | ||
|   | 4b5f33df54 | ||
|   | 56a0133650 | ||
|   | 19446b165a | ||
|   | 8a88690a20 | ||
|   | 6e2c6a5916 | ||
|   | 2c9fb32186 | ||
|   | 01d96636a0 | ||
|   | 9c5a42a7c9 | ||
|   | a172494938 | ||
|   | f8717682fb | ||
|   | af1210e2a3 | ||
|   | ab0e7714ce | ||
|   | fb4a5dce60 | ||
|   | 71334c58b2 | ||
|   | 888d454557 | ||
|   | dddd7ce07c | ||
|   | abddc4dd44 | ||
|   | 921c58ee44 | ||
|   | 7f45813c72 | ||
|   | 0769f2e443 | ||
|   | 5fe0b944ef | ||
|   | 69b8227b27 | ||
|   | 515d10b4fd | ||
|   | 669e7536d9 | ||
|   | 29dbbce762 | ||
|   | ea5981db97 | 
							
								
								
									
										2
									
								
								.licenses/npm/@actions/cache.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								.licenses/npm/@actions/cache.dep.yml
									
									
									
										generated
									
									
									
								
							| @@ -1,6 +1,6 @@ | ||||
| --- | ||||
| name: "@actions/cache" | ||||
| version: 3.0.6 | ||||
| version: 3.0.5 | ||||
| type: npm | ||||
| summary: | ||||
| homepage: | ||||
|   | ||||
| @@ -27,7 +27,6 @@ See ["Caching dependencies to speed up workflows"](https://docs.github.com/en/ac | ||||
| * Fixed the download stuck problem by introducing a timeout of 1 hour for cache downloads. | ||||
| * Fix zstd not working for windows on gnu tar in issues. | ||||
| * Allowing users to provide a custom timeout as input for aborting download of a cache segment using an environment variable `SEGMENT_DOWNLOAD_TIMEOUT_MINS`. Default is 60 minutes. | ||||
| * Two new actions available for granular control over caches - [restore](restore/action.yml) and [save](save/action.yml) | ||||
|  | ||||
| Refer [here](https://github.com/actions/cache/blob/v2/README.md) for previous versions | ||||
|  | ||||
|   | ||||
| @@ -52,6 +52,3 @@ | ||||
|  | ||||
| ### 3.2.0-beta.1 | ||||
| - Added two new actions - [restore](restore/action.yml) and [save](save/action.yml) for granular control on cache. | ||||
|  | ||||
| ### 3.2.0 | ||||
| - Released the two new actions - [restore](restore/action.yml) and [save](save/action.yml) for granular control on cache | ||||
							
								
								
									
										314
									
								
								dist/restore-only/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										314
									
								
								dist/restore-only/index.js
									
									
									
									
										vendored
									
									
								
							| @@ -1177,10 +1177,6 @@ function getVersion(app) { | ||||
| // Use zstandard if possible to maximize cache performance
 | ||||
| function getCompressionMethod() { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         if (process.platform === 'win32' && !(yield isGnuTarInstalled())) { | ||||
|             // Disable zstd due to bug https://github.com/actions/cache/issues/301
 | ||||
|             return constants_1.CompressionMethod.Gzip; | ||||
|         } | ||||
|         const versionOutput = yield getVersion('zstd'); | ||||
|         const version = semver.clean(versionOutput); | ||||
|         if (!versionOutput.toLowerCase().includes('zstd command line interface')) { | ||||
| @@ -1204,13 +1200,16 @@ function getCacheFileName(compressionMethod) { | ||||
|         : constants_1.CacheFilename.Zstd; | ||||
| } | ||||
| exports.getCacheFileName = getCacheFileName; | ||||
| function isGnuTarInstalled() { | ||||
| function getGnuTarPathOnWindows() { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         if (fs.existsSync(constants_1.GnuTarPathOnWindows)) { | ||||
|             return constants_1.GnuTarPathOnWindows; | ||||
|         } | ||||
|         const versionOutput = yield getVersion('tar'); | ||||
|         return versionOutput.toLowerCase().includes('gnu tar'); | ||||
|         return versionOutput.toLowerCase().includes('gnu tar') ? io.which('tar') : ''; | ||||
|     }); | ||||
| } | ||||
| exports.isGnuTarInstalled = isGnuTarInstalled; | ||||
| exports.getGnuTarPathOnWindows = getGnuTarPathOnWindows; | ||||
| function assertDefined(name, value) { | ||||
|     if (value === undefined) { | ||||
|         throw Error(`Expected ${name} but value was undefiend`); | ||||
| @@ -3433,6 +3432,7 @@ function getCacheEntry(keys, paths, options) { | ||||
|         const resource = `cache?keys=${encodeURIComponent(keys.join(','))}&version=${version}`; | ||||
|         const response = yield requestUtils_1.retryTypedResponse('getCacheEntry', () => __awaiter(this, void 0, void 0, function* () { return httpClient.getJson(getCacheApiUrl(resource)); })); | ||||
|         if (response.statusCode === 204) { | ||||
|             // Cache not found
 | ||||
|             return null; | ||||
|         } | ||||
|         if (!requestUtils_1.isSuccessStatusCode(response.statusCode)) { | ||||
| @@ -3441,6 +3441,7 @@ function getCacheEntry(keys, paths, options) { | ||||
|         const cacheResult = response.result; | ||||
|         const cacheDownloadUrl = cacheResult === null || cacheResult === void 0 ? void 0 : cacheResult.archiveLocation; | ||||
|         if (!cacheDownloadUrl) { | ||||
|             // Cache achiveLocation not found. This should never happen, and hence bail out.
 | ||||
|             throw new Error('Cache not found.'); | ||||
|         } | ||||
|         core.setSecret(cacheDownloadUrl); | ||||
| @@ -38202,21 +38203,19 @@ const path = __importStar(__webpack_require__(622)); | ||||
| const utils = __importStar(__webpack_require__(15)); | ||||
| const constants_1 = __webpack_require__(931); | ||||
| const IS_WINDOWS = process.platform === 'win32'; | ||||
| function getTarPath(args, compressionMethod) { | ||||
| // Returns tar path and type: BSD or GNU
 | ||||
| function getTarPath() { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         switch (process.platform) { | ||||
|             case 'win32': { | ||||
|                 const systemTar = `${process.env['windir']}\\System32\\tar.exe`; | ||||
|                 if (compressionMethod !== constants_1.CompressionMethod.Gzip) { | ||||
|                     // We only use zstandard compression on windows when gnu tar is installed due to
 | ||||
|                     // a bug with compressing large files with bsdtar + zstd
 | ||||
|                     args.push('--force-local'); | ||||
|                 const gnuTar = yield utils.getGnuTarPathOnWindows(); | ||||
|                 const systemTar = constants_1.SystemTarPathOnWindows; | ||||
|                 if (gnuTar) { | ||||
|                     // Use GNUtar as default on windows
 | ||||
|                     return { path: gnuTar, type: constants_1.ArchiveToolType.GNU }; | ||||
|                 } | ||||
|                 else if (fs_1.existsSync(systemTar)) { | ||||
|                     return systemTar; | ||||
|                 } | ||||
|                 else if (yield utils.isGnuTarInstalled()) { | ||||
|                     args.push('--force-local'); | ||||
|                     return { path: systemTar, type: constants_1.ArchiveToolType.BSD }; | ||||
|                 } | ||||
|                 break; | ||||
|             } | ||||
| @@ -38224,25 +38223,92 @@ function getTarPath(args, compressionMethod) { | ||||
|                 const gnuTar = yield io.which('gtar', false); | ||||
|                 if (gnuTar) { | ||||
|                     // fix permission denied errors when extracting BSD tar archive with GNU tar - https://github.com/actions/cache/issues/527
 | ||||
|                     args.push('--delay-directory-restore'); | ||||
|                     return gnuTar; | ||||
|                     return { path: gnuTar, type: constants_1.ArchiveToolType.GNU }; | ||||
|                 } | ||||
|                 else { | ||||
|                     return { | ||||
|                         path: yield io.which('tar', true), | ||||
|                         type: constants_1.ArchiveToolType.BSD | ||||
|                     }; | ||||
|                 } | ||||
|                 break; | ||||
|             } | ||||
|             default: | ||||
|                 break; | ||||
|         } | ||||
|         return yield io.which('tar', true); | ||||
|         // Default assumption is GNU tar is present in path
 | ||||
|         return { | ||||
|             path: yield io.which('tar', true), | ||||
|             type: constants_1.ArchiveToolType.GNU | ||||
|         }; | ||||
|     }); | ||||
| } | ||||
| function execTar(args, compressionMethod, cwd) { | ||||
| // Return arguments for tar as per tarPath, compressionMethod, method type and os
 | ||||
| function getTarArgs(tarPath, compressionMethod, type, archivePath = '') { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         try { | ||||
|             yield exec_1.exec(`"${yield getTarPath(args, compressionMethod)}"`, args, { cwd }); | ||||
|         const args = [`"${tarPath.path}"`]; | ||||
|         const cacheFileName = utils.getCacheFileName(compressionMethod); | ||||
|         const tarFile = 'cache.tar'; | ||||
|         const workingDirectory = getWorkingDirectory(); | ||||
|         // Speficic args for BSD tar on windows for workaround
 | ||||
|         const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD && | ||||
|             compressionMethod !== constants_1.CompressionMethod.Gzip && | ||||
|             IS_WINDOWS; | ||||
|         // Method specific args
 | ||||
|         switch (type) { | ||||
|             case 'create': | ||||
|                 args.push('--posix', '-cf', BSD_TAR_ZSTD | ||||
|                     ? tarFile | ||||
|                     : cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '--exclude', BSD_TAR_ZSTD | ||||
|                     ? tarFile | ||||
|                     : cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P', '-C', workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '--files-from', constants_1.ManifestFilename); | ||||
|                 break; | ||||
|             case 'extract': | ||||
|                 args.push('-xf', BSD_TAR_ZSTD | ||||
|                     ? tarFile | ||||
|                     : archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P', '-C', workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/')); | ||||
|                 break; | ||||
|             case 'list': | ||||
|                 args.push('-tf', BSD_TAR_ZSTD | ||||
|                     ? tarFile | ||||
|                     : archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P'); | ||||
|                 break; | ||||
|         } | ||||
|         catch (error) { | ||||
|             throw new Error(`Tar failed with error: ${error === null || error === void 0 ? void 0 : error.message}`); | ||||
|         // Platform specific args
 | ||||
|         if (tarPath.type === constants_1.ArchiveToolType.GNU) { | ||||
|             switch (process.platform) { | ||||
|                 case 'win32': | ||||
|                     args.push('--force-local'); | ||||
|                     break; | ||||
|                 case 'darwin': | ||||
|                     args.push('--delay-directory-restore'); | ||||
|                     break; | ||||
|             } | ||||
|         } | ||||
|         return args; | ||||
|     }); | ||||
| } | ||||
| // Returns commands to run tar and compression program
 | ||||
| function getCommands(compressionMethod, type, archivePath = '') { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         let args; | ||||
|         const tarPath = yield getTarPath(); | ||||
|         const tarArgs = yield getTarArgs(tarPath, compressionMethod, type, archivePath); | ||||
|         const compressionArgs = type !== 'create' | ||||
|             ? yield getDecompressionProgram(tarPath, compressionMethod, archivePath) | ||||
|             : yield getCompressionProgram(tarPath, compressionMethod); | ||||
|         const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD && | ||||
|             compressionMethod !== constants_1.CompressionMethod.Gzip && | ||||
|             IS_WINDOWS; | ||||
|         if (BSD_TAR_ZSTD && type !== 'create') { | ||||
|             args = [[...compressionArgs].join(' '), [...tarArgs].join(' ')]; | ||||
|         } | ||||
|         else { | ||||
|             args = [[...tarArgs].join(' '), [...compressionArgs].join(' ')]; | ||||
|         } | ||||
|         if (BSD_TAR_ZSTD) { | ||||
|             return args; | ||||
|         } | ||||
|         return [args.join(' ')]; | ||||
|     }); | ||||
| } | ||||
| function getWorkingDirectory() { | ||||
| @@ -38250,91 +38316,116 @@ function getWorkingDirectory() { | ||||
|     return (_a = process.env['GITHUB_WORKSPACE']) !== null && _a !== void 0 ? _a : process.cwd(); | ||||
| } | ||||
| // Common function for extractTar and listTar to get the compression method
 | ||||
| function getCompressionProgram(compressionMethod) { | ||||
|     // -d: Decompress.
 | ||||
|     // unzstd is equivalent to 'zstd -d'
 | ||||
|     // --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.
 | ||||
|     switch (compressionMethod) { | ||||
|         case constants_1.CompressionMethod.Zstd: | ||||
|             return [ | ||||
|                 '--use-compress-program', | ||||
|                 IS_WINDOWS ? 'zstd -d --long=30' : 'unzstd --long=30' | ||||
|             ]; | ||||
|         case constants_1.CompressionMethod.ZstdWithoutLong: | ||||
|             return ['--use-compress-program', IS_WINDOWS ? 'zstd -d' : 'unzstd']; | ||||
|         default: | ||||
|             return ['-z']; | ||||
|     } | ||||
| function getDecompressionProgram(tarPath, compressionMethod, archivePath) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         // -d: Decompress.
 | ||||
|         // unzstd is equivalent to 'zstd -d'
 | ||||
|         // --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 BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD && | ||||
|             compressionMethod !== constants_1.CompressionMethod.Gzip && | ||||
|             IS_WINDOWS; | ||||
|         switch (compressionMethod) { | ||||
|             case constants_1.CompressionMethod.Zstd: | ||||
|                 return BSD_TAR_ZSTD | ||||
|                     ? [ | ||||
|                         'zstd -d --long=30 -o', | ||||
|                         constants_1.TarFilename, | ||||
|                         archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/') | ||||
|                     ] | ||||
|                     : [ | ||||
|                         '--use-compress-program', | ||||
|                         IS_WINDOWS ? '"zstd -d --long=30"' : 'unzstd --long=30' | ||||
|                     ]; | ||||
|             case constants_1.CompressionMethod.ZstdWithoutLong: | ||||
|                 return BSD_TAR_ZSTD | ||||
|                     ? [ | ||||
|                         'zstd -d -o', | ||||
|                         constants_1.TarFilename, | ||||
|                         archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/') | ||||
|                     ] | ||||
|                     : ['--use-compress-program', IS_WINDOWS ? '"zstd -d"' : 'unzstd']; | ||||
|             default: | ||||
|                 return ['-z']; | ||||
|         } | ||||
|     }); | ||||
| } | ||||
| // Used for creating the archive
 | ||||
| // -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores.
 | ||||
| // zstdmt is equivalent to 'zstd -T0'
 | ||||
| // --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.
 | ||||
| // Long range mode is added to zstd in v1.3.2 release, so we will not use --long in older version of zstd.
 | ||||
| function getCompressionProgram(tarPath, compressionMethod) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         const cacheFileName = utils.getCacheFileName(compressionMethod); | ||||
|         const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD && | ||||
|             compressionMethod !== constants_1.CompressionMethod.Gzip && | ||||
|             IS_WINDOWS; | ||||
|         switch (compressionMethod) { | ||||
|             case constants_1.CompressionMethod.Zstd: | ||||
|                 return BSD_TAR_ZSTD | ||||
|                     ? [ | ||||
|                         'zstd -T0 --long=30 -o', | ||||
|                         cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|                         constants_1.TarFilename | ||||
|                     ] | ||||
|                     : [ | ||||
|                         '--use-compress-program', | ||||
|                         IS_WINDOWS ? '"zstd -T0 --long=30"' : 'zstdmt --long=30' | ||||
|                     ]; | ||||
|             case constants_1.CompressionMethod.ZstdWithoutLong: | ||||
|                 return BSD_TAR_ZSTD | ||||
|                     ? [ | ||||
|                         'zstd -T0 -o', | ||||
|                         cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|                         constants_1.TarFilename | ||||
|                     ] | ||||
|                     : ['--use-compress-program', IS_WINDOWS ? '"zstd -T0"' : 'zstdmt']; | ||||
|             default: | ||||
|                 return ['-z']; | ||||
|         } | ||||
|     }); | ||||
| } | ||||
| // Executes all commands as separate processes
 | ||||
| function execCommands(commands, cwd) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         for (const command of commands) { | ||||
|             try { | ||||
|                 yield exec_1.exec(command, undefined, { cwd }); | ||||
|             } | ||||
|             catch (error) { | ||||
|                 throw new Error(`${command.split(' ')[0]} failed with error: ${error === null || error === void 0 ? void 0 : error.message}`); | ||||
|             } | ||||
|         } | ||||
|     }); | ||||
| } | ||||
| // List the contents of a tar
 | ||||
| function listTar(archivePath, compressionMethod) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         const args = [ | ||||
|             ...getCompressionProgram(compressionMethod), | ||||
|             '-tf', | ||||
|             archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|             '-P' | ||||
|         ]; | ||||
|         yield execTar(args, compressionMethod); | ||||
|         const commands = yield getCommands(compressionMethod, 'list', archivePath); | ||||
|         yield execCommands(commands); | ||||
|     }); | ||||
| } | ||||
| exports.listTar = listTar; | ||||
| // Extract a tar
 | ||||
| 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); | ||||
|         const args = [ | ||||
|             ...getCompressionProgram(compressionMethod), | ||||
|             '-xf', | ||||
|             archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|             '-P', | ||||
|             '-C', | ||||
|             workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/') | ||||
|         ]; | ||||
|         yield execTar(args, compressionMethod); | ||||
|         const commands = yield getCommands(compressionMethod, 'extract', archivePath); | ||||
|         yield execCommands(commands); | ||||
|     }); | ||||
| } | ||||
| exports.extractTar = extractTar; | ||||
| // Create a tar
 | ||||
| function createTar(archiveFolder, sourceDirectories, compressionMethod) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         // Write source directories to manifest.txt to avoid command length limits
 | ||||
|         const manifestFilename = 'manifest.txt'; | ||||
|         const cacheFileName = utils.getCacheFileName(compressionMethod); | ||||
|         fs_1.writeFileSync(path.join(archiveFolder, manifestFilename), sourceDirectories.join('\n')); | ||||
|         const workingDirectory = getWorkingDirectory(); | ||||
|         // -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores.
 | ||||
|         // zstdmt is equivalent to 'zstd -T0'
 | ||||
|         // --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.
 | ||||
|         // Long range mode is added to zstd in v1.3.2 release, so we will not use --long in older version of zstd.
 | ||||
|         function getCompressionProgram() { | ||||
|             switch (compressionMethod) { | ||||
|                 case constants_1.CompressionMethod.Zstd: | ||||
|                     return [ | ||||
|                         '--use-compress-program', | ||||
|                         IS_WINDOWS ? 'zstd -T0 --long=30' : 'zstdmt --long=30' | ||||
|                     ]; | ||||
|                 case constants_1.CompressionMethod.ZstdWithoutLong: | ||||
|                     return ['--use-compress-program', IS_WINDOWS ? 'zstd -T0' : 'zstdmt']; | ||||
|                 default: | ||||
|                     return ['-z']; | ||||
|             } | ||||
|         } | ||||
|         const args = [ | ||||
|             '--posix', | ||||
|             ...getCompressionProgram(), | ||||
|             '-cf', | ||||
|             cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|             '--exclude', | ||||
|             cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|             '-P', | ||||
|             '-C', | ||||
|             workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|             '--files-from', | ||||
|             manifestFilename | ||||
|         ]; | ||||
|         yield execTar(args, compressionMethod, archiveFolder); | ||||
|         fs_1.writeFileSync(path.join(archiveFolder, constants_1.ManifestFilename), sourceDirectories.join('\n')); | ||||
|         const commands = yield getCommands(compressionMethod, 'create'); | ||||
|         yield execCommands(commands, archiveFolder); | ||||
|     }); | ||||
| } | ||||
| exports.createTar = createTar; | ||||
| @@ -47084,6 +47175,7 @@ const path = __importStar(__webpack_require__(622)); | ||||
| const utils = __importStar(__webpack_require__(15)); | ||||
| const cacheHttpClient = __importStar(__webpack_require__(114)); | ||||
| const tar_1 = __webpack_require__(434); | ||||
| const constants_1 = __webpack_require__(931); | ||||
| class ValidationError extends Error { | ||||
|     constructor(message) { | ||||
|         super(message); | ||||
| @@ -47145,16 +47237,31 @@ function restoreCache(paths, primaryKey, restoreKeys, options) { | ||||
|         for (const key of keys) { | ||||
|             checkKey(key); | ||||
|         } | ||||
|         const compressionMethod = yield utils.getCompressionMethod(); | ||||
|         let cacheEntry; | ||||
|         let compressionMethod = yield utils.getCompressionMethod(); | ||||
|         let archivePath = ''; | ||||
|         try { | ||||
|             // path are needed to compute version
 | ||||
|             const cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, { | ||||
|             cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, { | ||||
|                 compressionMethod | ||||
|             }); | ||||
|             if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) { | ||||
|                 // Cache not found
 | ||||
|                 return undefined; | ||||
|                 // This is to support the old cache entry created by gzip on windows.
 | ||||
|                 if (process.platform === 'win32' && | ||||
|                     compressionMethod !== constants_1.CompressionMethod.Gzip) { | ||||
|                     compressionMethod = constants_1.CompressionMethod.Gzip; | ||||
|                     cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, { | ||||
|                         compressionMethod | ||||
|                     }); | ||||
|                     if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) { | ||||
|                         return undefined; | ||||
|                     } | ||||
|                     core.debug("Couldn't find cache entry with zstd compression, falling back to gzip compression."); | ||||
|                 } | ||||
|                 else { | ||||
|                     // Cache not found
 | ||||
|                     return undefined; | ||||
|                 } | ||||
|             } | ||||
|             archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); | ||||
|             core.debug(`Archive Path: ${archivePath}`); | ||||
| @@ -53235,6 +53342,11 @@ var CompressionMethod; | ||||
|     CompressionMethod["ZstdWithoutLong"] = "zstd-without-long"; | ||||
|     CompressionMethod["Zstd"] = "zstd"; | ||||
| })(CompressionMethod = exports.CompressionMethod || (exports.CompressionMethod = {})); | ||||
| var ArchiveToolType; | ||||
| (function (ArchiveToolType) { | ||||
|     ArchiveToolType["GNU"] = "gnu"; | ||||
|     ArchiveToolType["BSD"] = "bsd"; | ||||
| })(ArchiveToolType = exports.ArchiveToolType || (exports.ArchiveToolType = {})); | ||||
| // The default number of retry attempts.
 | ||||
| exports.DefaultRetryAttempts = 2; | ||||
| // The default delay in milliseconds between retry attempts.
 | ||||
| @@ -53243,6 +53355,12 @@ exports.DefaultRetryDelay = 5000; | ||||
| // over the socket during this period, the socket is destroyed and the download
 | ||||
| // is aborted.
 | ||||
| exports.SocketTimeout = 5000; | ||||
| // The default path of GNUtar on hosted Windows runners
 | ||||
| exports.GnuTarPathOnWindows = `${process.env['PROGRAMFILES']}\\Git\\usr\\bin\\tar.exe`; | ||||
| // The default path of BSDtar on hosted Windows runners
 | ||||
| exports.SystemTarPathOnWindows = `${process.env['SYSTEMDRIVE']}\\Windows\\System32\\tar.exe`; | ||||
| exports.TarFilename = 'cache.tar'; | ||||
| exports.ManifestFilename = 'manifest.txt'; | ||||
| //# sourceMappingURL=constants.js.map
 | ||||
| 
 | ||||
| /***/ }), | ||||
|   | ||||
							
								
								
									
										314
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										314
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							| @@ -1177,10 +1177,6 @@ function getVersion(app) { | ||||
| // Use zstandard if possible to maximize cache performance
 | ||||
| function getCompressionMethod() { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         if (process.platform === 'win32' && !(yield isGnuTarInstalled())) { | ||||
|             // Disable zstd due to bug https://github.com/actions/cache/issues/301
 | ||||
|             return constants_1.CompressionMethod.Gzip; | ||||
|         } | ||||
|         const versionOutput = yield getVersion('zstd'); | ||||
|         const version = semver.clean(versionOutput); | ||||
|         if (!versionOutput.toLowerCase().includes('zstd command line interface')) { | ||||
| @@ -1204,13 +1200,16 @@ function getCacheFileName(compressionMethod) { | ||||
|         : constants_1.CacheFilename.Zstd; | ||||
| } | ||||
| exports.getCacheFileName = getCacheFileName; | ||||
| function isGnuTarInstalled() { | ||||
| function getGnuTarPathOnWindows() { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         if (fs.existsSync(constants_1.GnuTarPathOnWindows)) { | ||||
|             return constants_1.GnuTarPathOnWindows; | ||||
|         } | ||||
|         const versionOutput = yield getVersion('tar'); | ||||
|         return versionOutput.toLowerCase().includes('gnu tar'); | ||||
|         return versionOutput.toLowerCase().includes('gnu tar') ? io.which('tar') : ''; | ||||
|     }); | ||||
| } | ||||
| exports.isGnuTarInstalled = isGnuTarInstalled; | ||||
| exports.getGnuTarPathOnWindows = getGnuTarPathOnWindows; | ||||
| function assertDefined(name, value) { | ||||
|     if (value === undefined) { | ||||
|         throw Error(`Expected ${name} but value was undefiend`); | ||||
| @@ -3433,6 +3432,7 @@ function getCacheEntry(keys, paths, options) { | ||||
|         const resource = `cache?keys=${encodeURIComponent(keys.join(','))}&version=${version}`; | ||||
|         const response = yield requestUtils_1.retryTypedResponse('getCacheEntry', () => __awaiter(this, void 0, void 0, function* () { return httpClient.getJson(getCacheApiUrl(resource)); })); | ||||
|         if (response.statusCode === 204) { | ||||
|             // Cache not found
 | ||||
|             return null; | ||||
|         } | ||||
|         if (!requestUtils_1.isSuccessStatusCode(response.statusCode)) { | ||||
| @@ -3441,6 +3441,7 @@ function getCacheEntry(keys, paths, options) { | ||||
|         const cacheResult = response.result; | ||||
|         const cacheDownloadUrl = cacheResult === null || cacheResult === void 0 ? void 0 : cacheResult.archiveLocation; | ||||
|         if (!cacheDownloadUrl) { | ||||
|             // Cache achiveLocation not found. This should never happen, and hence bail out.
 | ||||
|             throw new Error('Cache not found.'); | ||||
|         } | ||||
|         core.setSecret(cacheDownloadUrl); | ||||
| @@ -38115,21 +38116,19 @@ const path = __importStar(__webpack_require__(622)); | ||||
| const utils = __importStar(__webpack_require__(15)); | ||||
| const constants_1 = __webpack_require__(931); | ||||
| const IS_WINDOWS = process.platform === 'win32'; | ||||
| function getTarPath(args, compressionMethod) { | ||||
| // Returns tar path and type: BSD or GNU
 | ||||
| function getTarPath() { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         switch (process.platform) { | ||||
|             case 'win32': { | ||||
|                 const systemTar = `${process.env['windir']}\\System32\\tar.exe`; | ||||
|                 if (compressionMethod !== constants_1.CompressionMethod.Gzip) { | ||||
|                     // We only use zstandard compression on windows when gnu tar is installed due to
 | ||||
|                     // a bug with compressing large files with bsdtar + zstd
 | ||||
|                     args.push('--force-local'); | ||||
|                 const gnuTar = yield utils.getGnuTarPathOnWindows(); | ||||
|                 const systemTar = constants_1.SystemTarPathOnWindows; | ||||
|                 if (gnuTar) { | ||||
|                     // Use GNUtar as default on windows
 | ||||
|                     return { path: gnuTar, type: constants_1.ArchiveToolType.GNU }; | ||||
|                 } | ||||
|                 else if (fs_1.existsSync(systemTar)) { | ||||
|                     return systemTar; | ||||
|                 } | ||||
|                 else if (yield utils.isGnuTarInstalled()) { | ||||
|                     args.push('--force-local'); | ||||
|                     return { path: systemTar, type: constants_1.ArchiveToolType.BSD }; | ||||
|                 } | ||||
|                 break; | ||||
|             } | ||||
| @@ -38137,25 +38136,92 @@ function getTarPath(args, compressionMethod) { | ||||
|                 const gnuTar = yield io.which('gtar', false); | ||||
|                 if (gnuTar) { | ||||
|                     // fix permission denied errors when extracting BSD tar archive with GNU tar - https://github.com/actions/cache/issues/527
 | ||||
|                     args.push('--delay-directory-restore'); | ||||
|                     return gnuTar; | ||||
|                     return { path: gnuTar, type: constants_1.ArchiveToolType.GNU }; | ||||
|                 } | ||||
|                 else { | ||||
|                     return { | ||||
|                         path: yield io.which('tar', true), | ||||
|                         type: constants_1.ArchiveToolType.BSD | ||||
|                     }; | ||||
|                 } | ||||
|                 break; | ||||
|             } | ||||
|             default: | ||||
|                 break; | ||||
|         } | ||||
|         return yield io.which('tar', true); | ||||
|         // Default assumption is GNU tar is present in path
 | ||||
|         return { | ||||
|             path: yield io.which('tar', true), | ||||
|             type: constants_1.ArchiveToolType.GNU | ||||
|         }; | ||||
|     }); | ||||
| } | ||||
| function execTar(args, compressionMethod, cwd) { | ||||
| // Return arguments for tar as per tarPath, compressionMethod, method type and os
 | ||||
| function getTarArgs(tarPath, compressionMethod, type, archivePath = '') { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         try { | ||||
|             yield exec_1.exec(`"${yield getTarPath(args, compressionMethod)}"`, args, { cwd }); | ||||
|         const args = [`"${tarPath.path}"`]; | ||||
|         const cacheFileName = utils.getCacheFileName(compressionMethod); | ||||
|         const tarFile = 'cache.tar'; | ||||
|         const workingDirectory = getWorkingDirectory(); | ||||
|         // Speficic args for BSD tar on windows for workaround
 | ||||
|         const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD && | ||||
|             compressionMethod !== constants_1.CompressionMethod.Gzip && | ||||
|             IS_WINDOWS; | ||||
|         // Method specific args
 | ||||
|         switch (type) { | ||||
|             case 'create': | ||||
|                 args.push('--posix', '-cf', BSD_TAR_ZSTD | ||||
|                     ? tarFile | ||||
|                     : cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '--exclude', BSD_TAR_ZSTD | ||||
|                     ? tarFile | ||||
|                     : cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P', '-C', workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '--files-from', constants_1.ManifestFilename); | ||||
|                 break; | ||||
|             case 'extract': | ||||
|                 args.push('-xf', BSD_TAR_ZSTD | ||||
|                     ? tarFile | ||||
|                     : archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P', '-C', workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/')); | ||||
|                 break; | ||||
|             case 'list': | ||||
|                 args.push('-tf', BSD_TAR_ZSTD | ||||
|                     ? tarFile | ||||
|                     : archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P'); | ||||
|                 break; | ||||
|         } | ||||
|         catch (error) { | ||||
|             throw new Error(`Tar failed with error: ${error === null || error === void 0 ? void 0 : error.message}`); | ||||
|         // Platform specific args
 | ||||
|         if (tarPath.type === constants_1.ArchiveToolType.GNU) { | ||||
|             switch (process.platform) { | ||||
|                 case 'win32': | ||||
|                     args.push('--force-local'); | ||||
|                     break; | ||||
|                 case 'darwin': | ||||
|                     args.push('--delay-directory-restore'); | ||||
|                     break; | ||||
|             } | ||||
|         } | ||||
|         return args; | ||||
|     }); | ||||
| } | ||||
| // Returns commands to run tar and compression program
 | ||||
| function getCommands(compressionMethod, type, archivePath = '') { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         let args; | ||||
|         const tarPath = yield getTarPath(); | ||||
|         const tarArgs = yield getTarArgs(tarPath, compressionMethod, type, archivePath); | ||||
|         const compressionArgs = type !== 'create' | ||||
|             ? yield getDecompressionProgram(tarPath, compressionMethod, archivePath) | ||||
|             : yield getCompressionProgram(tarPath, compressionMethod); | ||||
|         const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD && | ||||
|             compressionMethod !== constants_1.CompressionMethod.Gzip && | ||||
|             IS_WINDOWS; | ||||
|         if (BSD_TAR_ZSTD && type !== 'create') { | ||||
|             args = [[...compressionArgs].join(' '), [...tarArgs].join(' ')]; | ||||
|         } | ||||
|         else { | ||||
|             args = [[...tarArgs].join(' '), [...compressionArgs].join(' ')]; | ||||
|         } | ||||
|         if (BSD_TAR_ZSTD) { | ||||
|             return args; | ||||
|         } | ||||
|         return [args.join(' ')]; | ||||
|     }); | ||||
| } | ||||
| function getWorkingDirectory() { | ||||
| @@ -38163,91 +38229,116 @@ function getWorkingDirectory() { | ||||
|     return (_a = process.env['GITHUB_WORKSPACE']) !== null && _a !== void 0 ? _a : process.cwd(); | ||||
| } | ||||
| // Common function for extractTar and listTar to get the compression method
 | ||||
| function getCompressionProgram(compressionMethod) { | ||||
|     // -d: Decompress.
 | ||||
|     // unzstd is equivalent to 'zstd -d'
 | ||||
|     // --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.
 | ||||
|     switch (compressionMethod) { | ||||
|         case constants_1.CompressionMethod.Zstd: | ||||
|             return [ | ||||
|                 '--use-compress-program', | ||||
|                 IS_WINDOWS ? 'zstd -d --long=30' : 'unzstd --long=30' | ||||
|             ]; | ||||
|         case constants_1.CompressionMethod.ZstdWithoutLong: | ||||
|             return ['--use-compress-program', IS_WINDOWS ? 'zstd -d' : 'unzstd']; | ||||
|         default: | ||||
|             return ['-z']; | ||||
|     } | ||||
| function getDecompressionProgram(tarPath, compressionMethod, archivePath) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         // -d: Decompress.
 | ||||
|         // unzstd is equivalent to 'zstd -d'
 | ||||
|         // --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 BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD && | ||||
|             compressionMethod !== constants_1.CompressionMethod.Gzip && | ||||
|             IS_WINDOWS; | ||||
|         switch (compressionMethod) { | ||||
|             case constants_1.CompressionMethod.Zstd: | ||||
|                 return BSD_TAR_ZSTD | ||||
|                     ? [ | ||||
|                         'zstd -d --long=30 -o', | ||||
|                         constants_1.TarFilename, | ||||
|                         archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/') | ||||
|                     ] | ||||
|                     : [ | ||||
|                         '--use-compress-program', | ||||
|                         IS_WINDOWS ? '"zstd -d --long=30"' : 'unzstd --long=30' | ||||
|                     ]; | ||||
|             case constants_1.CompressionMethod.ZstdWithoutLong: | ||||
|                 return BSD_TAR_ZSTD | ||||
|                     ? [ | ||||
|                         'zstd -d -o', | ||||
|                         constants_1.TarFilename, | ||||
|                         archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/') | ||||
|                     ] | ||||
|                     : ['--use-compress-program', IS_WINDOWS ? '"zstd -d"' : 'unzstd']; | ||||
|             default: | ||||
|                 return ['-z']; | ||||
|         } | ||||
|     }); | ||||
| } | ||||
| // Used for creating the archive
 | ||||
| // -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores.
 | ||||
| // zstdmt is equivalent to 'zstd -T0'
 | ||||
| // --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.
 | ||||
| // Long range mode is added to zstd in v1.3.2 release, so we will not use --long in older version of zstd.
 | ||||
| function getCompressionProgram(tarPath, compressionMethod) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         const cacheFileName = utils.getCacheFileName(compressionMethod); | ||||
|         const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD && | ||||
|             compressionMethod !== constants_1.CompressionMethod.Gzip && | ||||
|             IS_WINDOWS; | ||||
|         switch (compressionMethod) { | ||||
|             case constants_1.CompressionMethod.Zstd: | ||||
|                 return BSD_TAR_ZSTD | ||||
|                     ? [ | ||||
|                         'zstd -T0 --long=30 -o', | ||||
|                         cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|                         constants_1.TarFilename | ||||
|                     ] | ||||
|                     : [ | ||||
|                         '--use-compress-program', | ||||
|                         IS_WINDOWS ? '"zstd -T0 --long=30"' : 'zstdmt --long=30' | ||||
|                     ]; | ||||
|             case constants_1.CompressionMethod.ZstdWithoutLong: | ||||
|                 return BSD_TAR_ZSTD | ||||
|                     ? [ | ||||
|                         'zstd -T0 -o', | ||||
|                         cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|                         constants_1.TarFilename | ||||
|                     ] | ||||
|                     : ['--use-compress-program', IS_WINDOWS ? '"zstd -T0"' : 'zstdmt']; | ||||
|             default: | ||||
|                 return ['-z']; | ||||
|         } | ||||
|     }); | ||||
| } | ||||
| // Executes all commands as separate processes
 | ||||
| function execCommands(commands, cwd) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         for (const command of commands) { | ||||
|             try { | ||||
|                 yield exec_1.exec(command, undefined, { cwd }); | ||||
|             } | ||||
|             catch (error) { | ||||
|                 throw new Error(`${command.split(' ')[0]} failed with error: ${error === null || error === void 0 ? void 0 : error.message}`); | ||||
|             } | ||||
|         } | ||||
|     }); | ||||
| } | ||||
| // List the contents of a tar
 | ||||
| function listTar(archivePath, compressionMethod) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         const args = [ | ||||
|             ...getCompressionProgram(compressionMethod), | ||||
|             '-tf', | ||||
|             archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|             '-P' | ||||
|         ]; | ||||
|         yield execTar(args, compressionMethod); | ||||
|         const commands = yield getCommands(compressionMethod, 'list', archivePath); | ||||
|         yield execCommands(commands); | ||||
|     }); | ||||
| } | ||||
| exports.listTar = listTar; | ||||
| // Extract a tar
 | ||||
| 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); | ||||
|         const args = [ | ||||
|             ...getCompressionProgram(compressionMethod), | ||||
|             '-xf', | ||||
|             archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|             '-P', | ||||
|             '-C', | ||||
|             workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/') | ||||
|         ]; | ||||
|         yield execTar(args, compressionMethod); | ||||
|         const commands = yield getCommands(compressionMethod, 'extract', archivePath); | ||||
|         yield execCommands(commands); | ||||
|     }); | ||||
| } | ||||
| exports.extractTar = extractTar; | ||||
| // Create a tar
 | ||||
| function createTar(archiveFolder, sourceDirectories, compressionMethod) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         // Write source directories to manifest.txt to avoid command length limits
 | ||||
|         const manifestFilename = 'manifest.txt'; | ||||
|         const cacheFileName = utils.getCacheFileName(compressionMethod); | ||||
|         fs_1.writeFileSync(path.join(archiveFolder, manifestFilename), sourceDirectories.join('\n')); | ||||
|         const workingDirectory = getWorkingDirectory(); | ||||
|         // -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores.
 | ||||
|         // zstdmt is equivalent to 'zstd -T0'
 | ||||
|         // --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.
 | ||||
|         // Long range mode is added to zstd in v1.3.2 release, so we will not use --long in older version of zstd.
 | ||||
|         function getCompressionProgram() { | ||||
|             switch (compressionMethod) { | ||||
|                 case constants_1.CompressionMethod.Zstd: | ||||
|                     return [ | ||||
|                         '--use-compress-program', | ||||
|                         IS_WINDOWS ? 'zstd -T0 --long=30' : 'zstdmt --long=30' | ||||
|                     ]; | ||||
|                 case constants_1.CompressionMethod.ZstdWithoutLong: | ||||
|                     return ['--use-compress-program', IS_WINDOWS ? 'zstd -T0' : 'zstdmt']; | ||||
|                 default: | ||||
|                     return ['-z']; | ||||
|             } | ||||
|         } | ||||
|         const args = [ | ||||
|             '--posix', | ||||
|             ...getCompressionProgram(), | ||||
|             '-cf', | ||||
|             cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|             '--exclude', | ||||
|             cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|             '-P', | ||||
|             '-C', | ||||
|             workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|             '--files-from', | ||||
|             manifestFilename | ||||
|         ]; | ||||
|         yield execTar(args, compressionMethod, archiveFolder); | ||||
|         fs_1.writeFileSync(path.join(archiveFolder, constants_1.ManifestFilename), sourceDirectories.join('\n')); | ||||
|         const commands = yield getCommands(compressionMethod, 'create'); | ||||
|         yield execCommands(commands, archiveFolder); | ||||
|     }); | ||||
| } | ||||
| exports.createTar = createTar; | ||||
| @@ -47055,6 +47146,7 @@ const path = __importStar(__webpack_require__(622)); | ||||
| const utils = __importStar(__webpack_require__(15)); | ||||
| const cacheHttpClient = __importStar(__webpack_require__(114)); | ||||
| const tar_1 = __webpack_require__(434); | ||||
| const constants_1 = __webpack_require__(931); | ||||
| class ValidationError extends Error { | ||||
|     constructor(message) { | ||||
|         super(message); | ||||
| @@ -47116,16 +47208,31 @@ function restoreCache(paths, primaryKey, restoreKeys, options) { | ||||
|         for (const key of keys) { | ||||
|             checkKey(key); | ||||
|         } | ||||
|         const compressionMethod = yield utils.getCompressionMethod(); | ||||
|         let cacheEntry; | ||||
|         let compressionMethod = yield utils.getCompressionMethod(); | ||||
|         let archivePath = ''; | ||||
|         try { | ||||
|             // path are needed to compute version
 | ||||
|             const cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, { | ||||
|             cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, { | ||||
|                 compressionMethod | ||||
|             }); | ||||
|             if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) { | ||||
|                 // Cache not found
 | ||||
|                 return undefined; | ||||
|                 // This is to support the old cache entry created by gzip on windows.
 | ||||
|                 if (process.platform === 'win32' && | ||||
|                     compressionMethod !== constants_1.CompressionMethod.Gzip) { | ||||
|                     compressionMethod = constants_1.CompressionMethod.Gzip; | ||||
|                     cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, { | ||||
|                         compressionMethod | ||||
|                     }); | ||||
|                     if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) { | ||||
|                         return undefined; | ||||
|                     } | ||||
|                     core.debug("Couldn't find cache entry with zstd compression, falling back to gzip compression."); | ||||
|                 } | ||||
|                 else { | ||||
|                     // Cache not found
 | ||||
|                     return undefined; | ||||
|                 } | ||||
|             } | ||||
|             archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); | ||||
|             core.debug(`Archive Path: ${archivePath}`); | ||||
| @@ -53235,6 +53342,11 @@ var CompressionMethod; | ||||
|     CompressionMethod["ZstdWithoutLong"] = "zstd-without-long"; | ||||
|     CompressionMethod["Zstd"] = "zstd"; | ||||
| })(CompressionMethod = exports.CompressionMethod || (exports.CompressionMethod = {})); | ||||
| var ArchiveToolType; | ||||
| (function (ArchiveToolType) { | ||||
|     ArchiveToolType["GNU"] = "gnu"; | ||||
|     ArchiveToolType["BSD"] = "bsd"; | ||||
| })(ArchiveToolType = exports.ArchiveToolType || (exports.ArchiveToolType = {})); | ||||
| // The default number of retry attempts.
 | ||||
| exports.DefaultRetryAttempts = 2; | ||||
| // The default delay in milliseconds between retry attempts.
 | ||||
| @@ -53243,6 +53355,12 @@ exports.DefaultRetryDelay = 5000; | ||||
| // over the socket during this period, the socket is destroyed and the download
 | ||||
| // is aborted.
 | ||||
| exports.SocketTimeout = 5000; | ||||
| // The default path of GNUtar on hosted Windows runners
 | ||||
| exports.GnuTarPathOnWindows = `${process.env['PROGRAMFILES']}\\Git\\usr\\bin\\tar.exe`; | ||||
| // The default path of BSDtar on hosted Windows runners
 | ||||
| exports.SystemTarPathOnWindows = `${process.env['SYSTEMDRIVE']}\\Windows\\System32\\tar.exe`; | ||||
| exports.TarFilename = 'cache.tar'; | ||||
| exports.ManifestFilename = 'manifest.txt'; | ||||
| //# sourceMappingURL=constants.js.map
 | ||||
| 
 | ||||
| /***/ }), | ||||
|   | ||||
							
								
								
									
										314
									
								
								dist/save-only/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										314
									
								
								dist/save-only/index.js
									
									
									
									
										vendored
									
									
								
							| @@ -1233,10 +1233,6 @@ function getVersion(app) { | ||||
| // Use zstandard if possible to maximize cache performance
 | ||||
| function getCompressionMethod() { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         if (process.platform === 'win32' && !(yield isGnuTarInstalled())) { | ||||
|             // Disable zstd due to bug https://github.com/actions/cache/issues/301
 | ||||
|             return constants_1.CompressionMethod.Gzip; | ||||
|         } | ||||
|         const versionOutput = yield getVersion('zstd'); | ||||
|         const version = semver.clean(versionOutput); | ||||
|         if (!versionOutput.toLowerCase().includes('zstd command line interface')) { | ||||
| @@ -1260,13 +1256,16 @@ function getCacheFileName(compressionMethod) { | ||||
|         : constants_1.CacheFilename.Zstd; | ||||
| } | ||||
| exports.getCacheFileName = getCacheFileName; | ||||
| function isGnuTarInstalled() { | ||||
| function getGnuTarPathOnWindows() { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         if (fs.existsSync(constants_1.GnuTarPathOnWindows)) { | ||||
|             return constants_1.GnuTarPathOnWindows; | ||||
|         } | ||||
|         const versionOutput = yield getVersion('tar'); | ||||
|         return versionOutput.toLowerCase().includes('gnu tar'); | ||||
|         return versionOutput.toLowerCase().includes('gnu tar') ? io.which('tar') : ''; | ||||
|     }); | ||||
| } | ||||
| exports.isGnuTarInstalled = isGnuTarInstalled; | ||||
| exports.getGnuTarPathOnWindows = getGnuTarPathOnWindows; | ||||
| function assertDefined(name, value) { | ||||
|     if (value === undefined) { | ||||
|         throw Error(`Expected ${name} but value was undefiend`); | ||||
| @@ -3489,6 +3488,7 @@ function getCacheEntry(keys, paths, options) { | ||||
|         const resource = `cache?keys=${encodeURIComponent(keys.join(','))}&version=${version}`; | ||||
|         const response = yield requestUtils_1.retryTypedResponse('getCacheEntry', () => __awaiter(this, void 0, void 0, function* () { return httpClient.getJson(getCacheApiUrl(resource)); })); | ||||
|         if (response.statusCode === 204) { | ||||
|             // Cache not found
 | ||||
|             return null; | ||||
|         } | ||||
|         if (!requestUtils_1.isSuccessStatusCode(response.statusCode)) { | ||||
| @@ -3497,6 +3497,7 @@ function getCacheEntry(keys, paths, options) { | ||||
|         const cacheResult = response.result; | ||||
|         const cacheDownloadUrl = cacheResult === null || cacheResult === void 0 ? void 0 : cacheResult.archiveLocation; | ||||
|         if (!cacheDownloadUrl) { | ||||
|             // Cache achiveLocation not found. This should never happen, and hence bail out.
 | ||||
|             throw new Error('Cache not found.'); | ||||
|         } | ||||
|         core.setSecret(cacheDownloadUrl); | ||||
| @@ -38166,21 +38167,19 @@ const path = __importStar(__webpack_require__(622)); | ||||
| const utils = __importStar(__webpack_require__(15)); | ||||
| const constants_1 = __webpack_require__(931); | ||||
| const IS_WINDOWS = process.platform === 'win32'; | ||||
| function getTarPath(args, compressionMethod) { | ||||
| // Returns tar path and type: BSD or GNU
 | ||||
| function getTarPath() { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         switch (process.platform) { | ||||
|             case 'win32': { | ||||
|                 const systemTar = `${process.env['windir']}\\System32\\tar.exe`; | ||||
|                 if (compressionMethod !== constants_1.CompressionMethod.Gzip) { | ||||
|                     // We only use zstandard compression on windows when gnu tar is installed due to
 | ||||
|                     // a bug with compressing large files with bsdtar + zstd
 | ||||
|                     args.push('--force-local'); | ||||
|                 const gnuTar = yield utils.getGnuTarPathOnWindows(); | ||||
|                 const systemTar = constants_1.SystemTarPathOnWindows; | ||||
|                 if (gnuTar) { | ||||
|                     // Use GNUtar as default on windows
 | ||||
|                     return { path: gnuTar, type: constants_1.ArchiveToolType.GNU }; | ||||
|                 } | ||||
|                 else if (fs_1.existsSync(systemTar)) { | ||||
|                     return systemTar; | ||||
|                 } | ||||
|                 else if (yield utils.isGnuTarInstalled()) { | ||||
|                     args.push('--force-local'); | ||||
|                     return { path: systemTar, type: constants_1.ArchiveToolType.BSD }; | ||||
|                 } | ||||
|                 break; | ||||
|             } | ||||
| @@ -38188,25 +38187,92 @@ function getTarPath(args, compressionMethod) { | ||||
|                 const gnuTar = yield io.which('gtar', false); | ||||
|                 if (gnuTar) { | ||||
|                     // fix permission denied errors when extracting BSD tar archive with GNU tar - https://github.com/actions/cache/issues/527
 | ||||
|                     args.push('--delay-directory-restore'); | ||||
|                     return gnuTar; | ||||
|                     return { path: gnuTar, type: constants_1.ArchiveToolType.GNU }; | ||||
|                 } | ||||
|                 else { | ||||
|                     return { | ||||
|                         path: yield io.which('tar', true), | ||||
|                         type: constants_1.ArchiveToolType.BSD | ||||
|                     }; | ||||
|                 } | ||||
|                 break; | ||||
|             } | ||||
|             default: | ||||
|                 break; | ||||
|         } | ||||
|         return yield io.which('tar', true); | ||||
|         // Default assumption is GNU tar is present in path
 | ||||
|         return { | ||||
|             path: yield io.which('tar', true), | ||||
|             type: constants_1.ArchiveToolType.GNU | ||||
|         }; | ||||
|     }); | ||||
| } | ||||
| function execTar(args, compressionMethod, cwd) { | ||||
| // Return arguments for tar as per tarPath, compressionMethod, method type and os
 | ||||
| function getTarArgs(tarPath, compressionMethod, type, archivePath = '') { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         try { | ||||
|             yield exec_1.exec(`"${yield getTarPath(args, compressionMethod)}"`, args, { cwd }); | ||||
|         const args = [`"${tarPath.path}"`]; | ||||
|         const cacheFileName = utils.getCacheFileName(compressionMethod); | ||||
|         const tarFile = 'cache.tar'; | ||||
|         const workingDirectory = getWorkingDirectory(); | ||||
|         // Speficic args for BSD tar on windows for workaround
 | ||||
|         const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD && | ||||
|             compressionMethod !== constants_1.CompressionMethod.Gzip && | ||||
|             IS_WINDOWS; | ||||
|         // Method specific args
 | ||||
|         switch (type) { | ||||
|             case 'create': | ||||
|                 args.push('--posix', '-cf', BSD_TAR_ZSTD | ||||
|                     ? tarFile | ||||
|                     : cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '--exclude', BSD_TAR_ZSTD | ||||
|                     ? tarFile | ||||
|                     : cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P', '-C', workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '--files-from', constants_1.ManifestFilename); | ||||
|                 break; | ||||
|             case 'extract': | ||||
|                 args.push('-xf', BSD_TAR_ZSTD | ||||
|                     ? tarFile | ||||
|                     : archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P', '-C', workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/')); | ||||
|                 break; | ||||
|             case 'list': | ||||
|                 args.push('-tf', BSD_TAR_ZSTD | ||||
|                     ? tarFile | ||||
|                     : archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P'); | ||||
|                 break; | ||||
|         } | ||||
|         catch (error) { | ||||
|             throw new Error(`Tar failed with error: ${error === null || error === void 0 ? void 0 : error.message}`); | ||||
|         // Platform specific args
 | ||||
|         if (tarPath.type === constants_1.ArchiveToolType.GNU) { | ||||
|             switch (process.platform) { | ||||
|                 case 'win32': | ||||
|                     args.push('--force-local'); | ||||
|                     break; | ||||
|                 case 'darwin': | ||||
|                     args.push('--delay-directory-restore'); | ||||
|                     break; | ||||
|             } | ||||
|         } | ||||
|         return args; | ||||
|     }); | ||||
| } | ||||
| // Returns commands to run tar and compression program
 | ||||
| function getCommands(compressionMethod, type, archivePath = '') { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         let args; | ||||
|         const tarPath = yield getTarPath(); | ||||
|         const tarArgs = yield getTarArgs(tarPath, compressionMethod, type, archivePath); | ||||
|         const compressionArgs = type !== 'create' | ||||
|             ? yield getDecompressionProgram(tarPath, compressionMethod, archivePath) | ||||
|             : yield getCompressionProgram(tarPath, compressionMethod); | ||||
|         const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD && | ||||
|             compressionMethod !== constants_1.CompressionMethod.Gzip && | ||||
|             IS_WINDOWS; | ||||
|         if (BSD_TAR_ZSTD && type !== 'create') { | ||||
|             args = [[...compressionArgs].join(' '), [...tarArgs].join(' ')]; | ||||
|         } | ||||
|         else { | ||||
|             args = [[...tarArgs].join(' '), [...compressionArgs].join(' ')]; | ||||
|         } | ||||
|         if (BSD_TAR_ZSTD) { | ||||
|             return args; | ||||
|         } | ||||
|         return [args.join(' ')]; | ||||
|     }); | ||||
| } | ||||
| function getWorkingDirectory() { | ||||
| @@ -38214,91 +38280,116 @@ function getWorkingDirectory() { | ||||
|     return (_a = process.env['GITHUB_WORKSPACE']) !== null && _a !== void 0 ? _a : process.cwd(); | ||||
| } | ||||
| // Common function for extractTar and listTar to get the compression method
 | ||||
| function getCompressionProgram(compressionMethod) { | ||||
|     // -d: Decompress.
 | ||||
|     // unzstd is equivalent to 'zstd -d'
 | ||||
|     // --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.
 | ||||
|     switch (compressionMethod) { | ||||
|         case constants_1.CompressionMethod.Zstd: | ||||
|             return [ | ||||
|                 '--use-compress-program', | ||||
|                 IS_WINDOWS ? 'zstd -d --long=30' : 'unzstd --long=30' | ||||
|             ]; | ||||
|         case constants_1.CompressionMethod.ZstdWithoutLong: | ||||
|             return ['--use-compress-program', IS_WINDOWS ? 'zstd -d' : 'unzstd']; | ||||
|         default: | ||||
|             return ['-z']; | ||||
|     } | ||||
| function getDecompressionProgram(tarPath, compressionMethod, archivePath) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         // -d: Decompress.
 | ||||
|         // unzstd is equivalent to 'zstd -d'
 | ||||
|         // --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 BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD && | ||||
|             compressionMethod !== constants_1.CompressionMethod.Gzip && | ||||
|             IS_WINDOWS; | ||||
|         switch (compressionMethod) { | ||||
|             case constants_1.CompressionMethod.Zstd: | ||||
|                 return BSD_TAR_ZSTD | ||||
|                     ? [ | ||||
|                         'zstd -d --long=30 -o', | ||||
|                         constants_1.TarFilename, | ||||
|                         archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/') | ||||
|                     ] | ||||
|                     : [ | ||||
|                         '--use-compress-program', | ||||
|                         IS_WINDOWS ? '"zstd -d --long=30"' : 'unzstd --long=30' | ||||
|                     ]; | ||||
|             case constants_1.CompressionMethod.ZstdWithoutLong: | ||||
|                 return BSD_TAR_ZSTD | ||||
|                     ? [ | ||||
|                         'zstd -d -o', | ||||
|                         constants_1.TarFilename, | ||||
|                         archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/') | ||||
|                     ] | ||||
|                     : ['--use-compress-program', IS_WINDOWS ? '"zstd -d"' : 'unzstd']; | ||||
|             default: | ||||
|                 return ['-z']; | ||||
|         } | ||||
|     }); | ||||
| } | ||||
| // Used for creating the archive
 | ||||
| // -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores.
 | ||||
| // zstdmt is equivalent to 'zstd -T0'
 | ||||
| // --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.
 | ||||
| // Long range mode is added to zstd in v1.3.2 release, so we will not use --long in older version of zstd.
 | ||||
| function getCompressionProgram(tarPath, compressionMethod) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         const cacheFileName = utils.getCacheFileName(compressionMethod); | ||||
|         const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD && | ||||
|             compressionMethod !== constants_1.CompressionMethod.Gzip && | ||||
|             IS_WINDOWS; | ||||
|         switch (compressionMethod) { | ||||
|             case constants_1.CompressionMethod.Zstd: | ||||
|                 return BSD_TAR_ZSTD | ||||
|                     ? [ | ||||
|                         'zstd -T0 --long=30 -o', | ||||
|                         cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|                         constants_1.TarFilename | ||||
|                     ] | ||||
|                     : [ | ||||
|                         '--use-compress-program', | ||||
|                         IS_WINDOWS ? '"zstd -T0 --long=30"' : 'zstdmt --long=30' | ||||
|                     ]; | ||||
|             case constants_1.CompressionMethod.ZstdWithoutLong: | ||||
|                 return BSD_TAR_ZSTD | ||||
|                     ? [ | ||||
|                         'zstd -T0 -o', | ||||
|                         cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|                         constants_1.TarFilename | ||||
|                     ] | ||||
|                     : ['--use-compress-program', IS_WINDOWS ? '"zstd -T0"' : 'zstdmt']; | ||||
|             default: | ||||
|                 return ['-z']; | ||||
|         } | ||||
|     }); | ||||
| } | ||||
| // Executes all commands as separate processes
 | ||||
| function execCommands(commands, cwd) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         for (const command of commands) { | ||||
|             try { | ||||
|                 yield exec_1.exec(command, undefined, { cwd }); | ||||
|             } | ||||
|             catch (error) { | ||||
|                 throw new Error(`${command.split(' ')[0]} failed with error: ${error === null || error === void 0 ? void 0 : error.message}`); | ||||
|             } | ||||
|         } | ||||
|     }); | ||||
| } | ||||
| // List the contents of a tar
 | ||||
| function listTar(archivePath, compressionMethod) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         const args = [ | ||||
|             ...getCompressionProgram(compressionMethod), | ||||
|             '-tf', | ||||
|             archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|             '-P' | ||||
|         ]; | ||||
|         yield execTar(args, compressionMethod); | ||||
|         const commands = yield getCommands(compressionMethod, 'list', archivePath); | ||||
|         yield execCommands(commands); | ||||
|     }); | ||||
| } | ||||
| exports.listTar = listTar; | ||||
| // Extract a tar
 | ||||
| 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); | ||||
|         const args = [ | ||||
|             ...getCompressionProgram(compressionMethod), | ||||
|             '-xf', | ||||
|             archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|             '-P', | ||||
|             '-C', | ||||
|             workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/') | ||||
|         ]; | ||||
|         yield execTar(args, compressionMethod); | ||||
|         const commands = yield getCommands(compressionMethod, 'extract', archivePath); | ||||
|         yield execCommands(commands); | ||||
|     }); | ||||
| } | ||||
| exports.extractTar = extractTar; | ||||
| // Create a tar
 | ||||
| function createTar(archiveFolder, sourceDirectories, compressionMethod) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         // Write source directories to manifest.txt to avoid command length limits
 | ||||
|         const manifestFilename = 'manifest.txt'; | ||||
|         const cacheFileName = utils.getCacheFileName(compressionMethod); | ||||
|         fs_1.writeFileSync(path.join(archiveFolder, manifestFilename), sourceDirectories.join('\n')); | ||||
|         const workingDirectory = getWorkingDirectory(); | ||||
|         // -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores.
 | ||||
|         // zstdmt is equivalent to 'zstd -T0'
 | ||||
|         // --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.
 | ||||
|         // Long range mode is added to zstd in v1.3.2 release, so we will not use --long in older version of zstd.
 | ||||
|         function getCompressionProgram() { | ||||
|             switch (compressionMethod) { | ||||
|                 case constants_1.CompressionMethod.Zstd: | ||||
|                     return [ | ||||
|                         '--use-compress-program', | ||||
|                         IS_WINDOWS ? 'zstd -T0 --long=30' : 'zstdmt --long=30' | ||||
|                     ]; | ||||
|                 case constants_1.CompressionMethod.ZstdWithoutLong: | ||||
|                     return ['--use-compress-program', IS_WINDOWS ? 'zstd -T0' : 'zstdmt']; | ||||
|                 default: | ||||
|                     return ['-z']; | ||||
|             } | ||||
|         } | ||||
|         const args = [ | ||||
|             '--posix', | ||||
|             ...getCompressionProgram(), | ||||
|             '-cf', | ||||
|             cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|             '--exclude', | ||||
|             cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|             '-P', | ||||
|             '-C', | ||||
|             workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|             '--files-from', | ||||
|             manifestFilename | ||||
|         ]; | ||||
|         yield execTar(args, compressionMethod, archiveFolder); | ||||
|         fs_1.writeFileSync(path.join(archiveFolder, constants_1.ManifestFilename), sourceDirectories.join('\n')); | ||||
|         const commands = yield getCommands(compressionMethod, 'create'); | ||||
|         yield execCommands(commands, archiveFolder); | ||||
|     }); | ||||
| } | ||||
| exports.createTar = createTar; | ||||
| @@ -47197,6 +47288,7 @@ const path = __importStar(__webpack_require__(622)); | ||||
| const utils = __importStar(__webpack_require__(15)); | ||||
| const cacheHttpClient = __importStar(__webpack_require__(114)); | ||||
| const tar_1 = __webpack_require__(434); | ||||
| const constants_1 = __webpack_require__(931); | ||||
| class ValidationError extends Error { | ||||
|     constructor(message) { | ||||
|         super(message); | ||||
| @@ -47258,16 +47350,31 @@ function restoreCache(paths, primaryKey, restoreKeys, options) { | ||||
|         for (const key of keys) { | ||||
|             checkKey(key); | ||||
|         } | ||||
|         const compressionMethod = yield utils.getCompressionMethod(); | ||||
|         let cacheEntry; | ||||
|         let compressionMethod = yield utils.getCompressionMethod(); | ||||
|         let archivePath = ''; | ||||
|         try { | ||||
|             // path are needed to compute version
 | ||||
|             const cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, { | ||||
|             cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, { | ||||
|                 compressionMethod | ||||
|             }); | ||||
|             if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) { | ||||
|                 // Cache not found
 | ||||
|                 return undefined; | ||||
|                 // This is to support the old cache entry created by gzip on windows.
 | ||||
|                 if (process.platform === 'win32' && | ||||
|                     compressionMethod !== constants_1.CompressionMethod.Gzip) { | ||||
|                     compressionMethod = constants_1.CompressionMethod.Gzip; | ||||
|                     cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, { | ||||
|                         compressionMethod | ||||
|                     }); | ||||
|                     if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) { | ||||
|                         return undefined; | ||||
|                     } | ||||
|                     core.debug("Couldn't find cache entry with zstd compression, falling back to gzip compression."); | ||||
|                 } | ||||
|                 else { | ||||
|                     // Cache not found
 | ||||
|                     return undefined; | ||||
|                 } | ||||
|             } | ||||
|             archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); | ||||
|             core.debug(`Archive Path: ${archivePath}`); | ||||
| @@ -53270,6 +53377,11 @@ var CompressionMethod; | ||||
|     CompressionMethod["ZstdWithoutLong"] = "zstd-without-long"; | ||||
|     CompressionMethod["Zstd"] = "zstd"; | ||||
| })(CompressionMethod = exports.CompressionMethod || (exports.CompressionMethod = {})); | ||||
| var ArchiveToolType; | ||||
| (function (ArchiveToolType) { | ||||
|     ArchiveToolType["GNU"] = "gnu"; | ||||
|     ArchiveToolType["BSD"] = "bsd"; | ||||
| })(ArchiveToolType = exports.ArchiveToolType || (exports.ArchiveToolType = {})); | ||||
| // The default number of retry attempts.
 | ||||
| exports.DefaultRetryAttempts = 2; | ||||
| // The default delay in milliseconds between retry attempts.
 | ||||
| @@ -53278,6 +53390,12 @@ exports.DefaultRetryDelay = 5000; | ||||
| // over the socket during this period, the socket is destroyed and the download
 | ||||
| // is aborted.
 | ||||
| exports.SocketTimeout = 5000; | ||||
| // The default path of GNUtar on hosted Windows runners
 | ||||
| exports.GnuTarPathOnWindows = `${process.env['PROGRAMFILES']}\\Git\\usr\\bin\\tar.exe`; | ||||
| // The default path of BSDtar on hosted Windows runners
 | ||||
| exports.SystemTarPathOnWindows = `${process.env['SYSTEMDRIVE']}\\Windows\\System32\\tar.exe`; | ||||
| exports.TarFilename = 'cache.tar'; | ||||
| exports.ManifestFilename = 'manifest.txt'; | ||||
| //# sourceMappingURL=constants.js.map
 | ||||
| 
 | ||||
| /***/ }), | ||||
|   | ||||
							
								
								
									
										314
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										314
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
								
							| @@ -1177,10 +1177,6 @@ function getVersion(app) { | ||||
| // Use zstandard if possible to maximize cache performance
 | ||||
| function getCompressionMethod() { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         if (process.platform === 'win32' && !(yield isGnuTarInstalled())) { | ||||
|             // Disable zstd due to bug https://github.com/actions/cache/issues/301
 | ||||
|             return constants_1.CompressionMethod.Gzip; | ||||
|         } | ||||
|         const versionOutput = yield getVersion('zstd'); | ||||
|         const version = semver.clean(versionOutput); | ||||
|         if (!versionOutput.toLowerCase().includes('zstd command line interface')) { | ||||
| @@ -1204,13 +1200,16 @@ function getCacheFileName(compressionMethod) { | ||||
|         : constants_1.CacheFilename.Zstd; | ||||
| } | ||||
| exports.getCacheFileName = getCacheFileName; | ||||
| function isGnuTarInstalled() { | ||||
| function getGnuTarPathOnWindows() { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         if (fs.existsSync(constants_1.GnuTarPathOnWindows)) { | ||||
|             return constants_1.GnuTarPathOnWindows; | ||||
|         } | ||||
|         const versionOutput = yield getVersion('tar'); | ||||
|         return versionOutput.toLowerCase().includes('gnu tar'); | ||||
|         return versionOutput.toLowerCase().includes('gnu tar') ? io.which('tar') : ''; | ||||
|     }); | ||||
| } | ||||
| exports.isGnuTarInstalled = isGnuTarInstalled; | ||||
| exports.getGnuTarPathOnWindows = getGnuTarPathOnWindows; | ||||
| function assertDefined(name, value) { | ||||
|     if (value === undefined) { | ||||
|         throw Error(`Expected ${name} but value was undefiend`); | ||||
| @@ -3433,6 +3432,7 @@ function getCacheEntry(keys, paths, options) { | ||||
|         const resource = `cache?keys=${encodeURIComponent(keys.join(','))}&version=${version}`; | ||||
|         const response = yield requestUtils_1.retryTypedResponse('getCacheEntry', () => __awaiter(this, void 0, void 0, function* () { return httpClient.getJson(getCacheApiUrl(resource)); })); | ||||
|         if (response.statusCode === 204) { | ||||
|             // Cache not found
 | ||||
|             return null; | ||||
|         } | ||||
|         if (!requestUtils_1.isSuccessStatusCode(response.statusCode)) { | ||||
| @@ -3441,6 +3441,7 @@ function getCacheEntry(keys, paths, options) { | ||||
|         const cacheResult = response.result; | ||||
|         const cacheDownloadUrl = cacheResult === null || cacheResult === void 0 ? void 0 : cacheResult.archiveLocation; | ||||
|         if (!cacheDownloadUrl) { | ||||
|             // Cache achiveLocation not found. This should never happen, and hence bail out.
 | ||||
|             throw new Error('Cache not found.'); | ||||
|         } | ||||
|         core.setSecret(cacheDownloadUrl); | ||||
| @@ -38110,21 +38111,19 @@ const path = __importStar(__webpack_require__(622)); | ||||
| const utils = __importStar(__webpack_require__(15)); | ||||
| const constants_1 = __webpack_require__(931); | ||||
| const IS_WINDOWS = process.platform === 'win32'; | ||||
| function getTarPath(args, compressionMethod) { | ||||
| // Returns tar path and type: BSD or GNU
 | ||||
| function getTarPath() { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         switch (process.platform) { | ||||
|             case 'win32': { | ||||
|                 const systemTar = `${process.env['windir']}\\System32\\tar.exe`; | ||||
|                 if (compressionMethod !== constants_1.CompressionMethod.Gzip) { | ||||
|                     // We only use zstandard compression on windows when gnu tar is installed due to
 | ||||
|                     // a bug with compressing large files with bsdtar + zstd
 | ||||
|                     args.push('--force-local'); | ||||
|                 const gnuTar = yield utils.getGnuTarPathOnWindows(); | ||||
|                 const systemTar = constants_1.SystemTarPathOnWindows; | ||||
|                 if (gnuTar) { | ||||
|                     // Use GNUtar as default on windows
 | ||||
|                     return { path: gnuTar, type: constants_1.ArchiveToolType.GNU }; | ||||
|                 } | ||||
|                 else if (fs_1.existsSync(systemTar)) { | ||||
|                     return systemTar; | ||||
|                 } | ||||
|                 else if (yield utils.isGnuTarInstalled()) { | ||||
|                     args.push('--force-local'); | ||||
|                     return { path: systemTar, type: constants_1.ArchiveToolType.BSD }; | ||||
|                 } | ||||
|                 break; | ||||
|             } | ||||
| @@ -38132,25 +38131,92 @@ function getTarPath(args, compressionMethod) { | ||||
|                 const gnuTar = yield io.which('gtar', false); | ||||
|                 if (gnuTar) { | ||||
|                     // fix permission denied errors when extracting BSD tar archive with GNU tar - https://github.com/actions/cache/issues/527
 | ||||
|                     args.push('--delay-directory-restore'); | ||||
|                     return gnuTar; | ||||
|                     return { path: gnuTar, type: constants_1.ArchiveToolType.GNU }; | ||||
|                 } | ||||
|                 else { | ||||
|                     return { | ||||
|                         path: yield io.which('tar', true), | ||||
|                         type: constants_1.ArchiveToolType.BSD | ||||
|                     }; | ||||
|                 } | ||||
|                 break; | ||||
|             } | ||||
|             default: | ||||
|                 break; | ||||
|         } | ||||
|         return yield io.which('tar', true); | ||||
|         // Default assumption is GNU tar is present in path
 | ||||
|         return { | ||||
|             path: yield io.which('tar', true), | ||||
|             type: constants_1.ArchiveToolType.GNU | ||||
|         }; | ||||
|     }); | ||||
| } | ||||
| function execTar(args, compressionMethod, cwd) { | ||||
| // Return arguments for tar as per tarPath, compressionMethod, method type and os
 | ||||
| function getTarArgs(tarPath, compressionMethod, type, archivePath = '') { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         try { | ||||
|             yield exec_1.exec(`"${yield getTarPath(args, compressionMethod)}"`, args, { cwd }); | ||||
|         const args = [`"${tarPath.path}"`]; | ||||
|         const cacheFileName = utils.getCacheFileName(compressionMethod); | ||||
|         const tarFile = 'cache.tar'; | ||||
|         const workingDirectory = getWorkingDirectory(); | ||||
|         // Speficic args for BSD tar on windows for workaround
 | ||||
|         const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD && | ||||
|             compressionMethod !== constants_1.CompressionMethod.Gzip && | ||||
|             IS_WINDOWS; | ||||
|         // Method specific args
 | ||||
|         switch (type) { | ||||
|             case 'create': | ||||
|                 args.push('--posix', '-cf', BSD_TAR_ZSTD | ||||
|                     ? tarFile | ||||
|                     : cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '--exclude', BSD_TAR_ZSTD | ||||
|                     ? tarFile | ||||
|                     : cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P', '-C', workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '--files-from', constants_1.ManifestFilename); | ||||
|                 break; | ||||
|             case 'extract': | ||||
|                 args.push('-xf', BSD_TAR_ZSTD | ||||
|                     ? tarFile | ||||
|                     : archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P', '-C', workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/')); | ||||
|                 break; | ||||
|             case 'list': | ||||
|                 args.push('-tf', BSD_TAR_ZSTD | ||||
|                     ? tarFile | ||||
|                     : archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P'); | ||||
|                 break; | ||||
|         } | ||||
|         catch (error) { | ||||
|             throw new Error(`Tar failed with error: ${error === null || error === void 0 ? void 0 : error.message}`); | ||||
|         // Platform specific args
 | ||||
|         if (tarPath.type === constants_1.ArchiveToolType.GNU) { | ||||
|             switch (process.platform) { | ||||
|                 case 'win32': | ||||
|                     args.push('--force-local'); | ||||
|                     break; | ||||
|                 case 'darwin': | ||||
|                     args.push('--delay-directory-restore'); | ||||
|                     break; | ||||
|             } | ||||
|         } | ||||
|         return args; | ||||
|     }); | ||||
| } | ||||
| // Returns commands to run tar and compression program
 | ||||
| function getCommands(compressionMethod, type, archivePath = '') { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         let args; | ||||
|         const tarPath = yield getTarPath(); | ||||
|         const tarArgs = yield getTarArgs(tarPath, compressionMethod, type, archivePath); | ||||
|         const compressionArgs = type !== 'create' | ||||
|             ? yield getDecompressionProgram(tarPath, compressionMethod, archivePath) | ||||
|             : yield getCompressionProgram(tarPath, compressionMethod); | ||||
|         const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD && | ||||
|             compressionMethod !== constants_1.CompressionMethod.Gzip && | ||||
|             IS_WINDOWS; | ||||
|         if (BSD_TAR_ZSTD && type !== 'create') { | ||||
|             args = [[...compressionArgs].join(' '), [...tarArgs].join(' ')]; | ||||
|         } | ||||
|         else { | ||||
|             args = [[...tarArgs].join(' '), [...compressionArgs].join(' ')]; | ||||
|         } | ||||
|         if (BSD_TAR_ZSTD) { | ||||
|             return args; | ||||
|         } | ||||
|         return [args.join(' ')]; | ||||
|     }); | ||||
| } | ||||
| function getWorkingDirectory() { | ||||
| @@ -38158,91 +38224,116 @@ function getWorkingDirectory() { | ||||
|     return (_a = process.env['GITHUB_WORKSPACE']) !== null && _a !== void 0 ? _a : process.cwd(); | ||||
| } | ||||
| // Common function for extractTar and listTar to get the compression method
 | ||||
| function getCompressionProgram(compressionMethod) { | ||||
|     // -d: Decompress.
 | ||||
|     // unzstd is equivalent to 'zstd -d'
 | ||||
|     // --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.
 | ||||
|     switch (compressionMethod) { | ||||
|         case constants_1.CompressionMethod.Zstd: | ||||
|             return [ | ||||
|                 '--use-compress-program', | ||||
|                 IS_WINDOWS ? 'zstd -d --long=30' : 'unzstd --long=30' | ||||
|             ]; | ||||
|         case constants_1.CompressionMethod.ZstdWithoutLong: | ||||
|             return ['--use-compress-program', IS_WINDOWS ? 'zstd -d' : 'unzstd']; | ||||
|         default: | ||||
|             return ['-z']; | ||||
|     } | ||||
| function getDecompressionProgram(tarPath, compressionMethod, archivePath) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         // -d: Decompress.
 | ||||
|         // unzstd is equivalent to 'zstd -d'
 | ||||
|         // --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 BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD && | ||||
|             compressionMethod !== constants_1.CompressionMethod.Gzip && | ||||
|             IS_WINDOWS; | ||||
|         switch (compressionMethod) { | ||||
|             case constants_1.CompressionMethod.Zstd: | ||||
|                 return BSD_TAR_ZSTD | ||||
|                     ? [ | ||||
|                         'zstd -d --long=30 -o', | ||||
|                         constants_1.TarFilename, | ||||
|                         archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/') | ||||
|                     ] | ||||
|                     : [ | ||||
|                         '--use-compress-program', | ||||
|                         IS_WINDOWS ? '"zstd -d --long=30"' : 'unzstd --long=30' | ||||
|                     ]; | ||||
|             case constants_1.CompressionMethod.ZstdWithoutLong: | ||||
|                 return BSD_TAR_ZSTD | ||||
|                     ? [ | ||||
|                         'zstd -d -o', | ||||
|                         constants_1.TarFilename, | ||||
|                         archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/') | ||||
|                     ] | ||||
|                     : ['--use-compress-program', IS_WINDOWS ? '"zstd -d"' : 'unzstd']; | ||||
|             default: | ||||
|                 return ['-z']; | ||||
|         } | ||||
|     }); | ||||
| } | ||||
| // Used for creating the archive
 | ||||
| // -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores.
 | ||||
| // zstdmt is equivalent to 'zstd -T0'
 | ||||
| // --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.
 | ||||
| // Long range mode is added to zstd in v1.3.2 release, so we will not use --long in older version of zstd.
 | ||||
| function getCompressionProgram(tarPath, compressionMethod) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         const cacheFileName = utils.getCacheFileName(compressionMethod); | ||||
|         const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD && | ||||
|             compressionMethod !== constants_1.CompressionMethod.Gzip && | ||||
|             IS_WINDOWS; | ||||
|         switch (compressionMethod) { | ||||
|             case constants_1.CompressionMethod.Zstd: | ||||
|                 return BSD_TAR_ZSTD | ||||
|                     ? [ | ||||
|                         'zstd -T0 --long=30 -o', | ||||
|                         cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|                         constants_1.TarFilename | ||||
|                     ] | ||||
|                     : [ | ||||
|                         '--use-compress-program', | ||||
|                         IS_WINDOWS ? '"zstd -T0 --long=30"' : 'zstdmt --long=30' | ||||
|                     ]; | ||||
|             case constants_1.CompressionMethod.ZstdWithoutLong: | ||||
|                 return BSD_TAR_ZSTD | ||||
|                     ? [ | ||||
|                         'zstd -T0 -o', | ||||
|                         cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|                         constants_1.TarFilename | ||||
|                     ] | ||||
|                     : ['--use-compress-program', IS_WINDOWS ? '"zstd -T0"' : 'zstdmt']; | ||||
|             default: | ||||
|                 return ['-z']; | ||||
|         } | ||||
|     }); | ||||
| } | ||||
| // Executes all commands as separate processes
 | ||||
| function execCommands(commands, cwd) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         for (const command of commands) { | ||||
|             try { | ||||
|                 yield exec_1.exec(command, undefined, { cwd }); | ||||
|             } | ||||
|             catch (error) { | ||||
|                 throw new Error(`${command.split(' ')[0]} failed with error: ${error === null || error === void 0 ? void 0 : error.message}`); | ||||
|             } | ||||
|         } | ||||
|     }); | ||||
| } | ||||
| // List the contents of a tar
 | ||||
| function listTar(archivePath, compressionMethod) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         const args = [ | ||||
|             ...getCompressionProgram(compressionMethod), | ||||
|             '-tf', | ||||
|             archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|             '-P' | ||||
|         ]; | ||||
|         yield execTar(args, compressionMethod); | ||||
|         const commands = yield getCommands(compressionMethod, 'list', archivePath); | ||||
|         yield execCommands(commands); | ||||
|     }); | ||||
| } | ||||
| exports.listTar = listTar; | ||||
| // Extract a tar
 | ||||
| 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); | ||||
|         const args = [ | ||||
|             ...getCompressionProgram(compressionMethod), | ||||
|             '-xf', | ||||
|             archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|             '-P', | ||||
|             '-C', | ||||
|             workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/') | ||||
|         ]; | ||||
|         yield execTar(args, compressionMethod); | ||||
|         const commands = yield getCommands(compressionMethod, 'extract', archivePath); | ||||
|         yield execCommands(commands); | ||||
|     }); | ||||
| } | ||||
| exports.extractTar = extractTar; | ||||
| // Create a tar
 | ||||
| function createTar(archiveFolder, sourceDirectories, compressionMethod) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         // Write source directories to manifest.txt to avoid command length limits
 | ||||
|         const manifestFilename = 'manifest.txt'; | ||||
|         const cacheFileName = utils.getCacheFileName(compressionMethod); | ||||
|         fs_1.writeFileSync(path.join(archiveFolder, manifestFilename), sourceDirectories.join('\n')); | ||||
|         const workingDirectory = getWorkingDirectory(); | ||||
|         // -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores.
 | ||||
|         // zstdmt is equivalent to 'zstd -T0'
 | ||||
|         // --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.
 | ||||
|         // Long range mode is added to zstd in v1.3.2 release, so we will not use --long in older version of zstd.
 | ||||
|         function getCompressionProgram() { | ||||
|             switch (compressionMethod) { | ||||
|                 case constants_1.CompressionMethod.Zstd: | ||||
|                     return [ | ||||
|                         '--use-compress-program', | ||||
|                         IS_WINDOWS ? 'zstd -T0 --long=30' : 'zstdmt --long=30' | ||||
|                     ]; | ||||
|                 case constants_1.CompressionMethod.ZstdWithoutLong: | ||||
|                     return ['--use-compress-program', IS_WINDOWS ? 'zstd -T0' : 'zstdmt']; | ||||
|                 default: | ||||
|                     return ['-z']; | ||||
|             } | ||||
|         } | ||||
|         const args = [ | ||||
|             '--posix', | ||||
|             ...getCompressionProgram(), | ||||
|             '-cf', | ||||
|             cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|             '--exclude', | ||||
|             cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|             '-P', | ||||
|             '-C', | ||||
|             workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|             '--files-from', | ||||
|             manifestFilename | ||||
|         ]; | ||||
|         yield execTar(args, compressionMethod, archiveFolder); | ||||
|         fs_1.writeFileSync(path.join(archiveFolder, constants_1.ManifestFilename), sourceDirectories.join('\n')); | ||||
|         const commands = yield getCommands(compressionMethod, 'create'); | ||||
|         yield execCommands(commands, archiveFolder); | ||||
|     }); | ||||
| } | ||||
| exports.createTar = createTar; | ||||
| @@ -47170,6 +47261,7 @@ const path = __importStar(__webpack_require__(622)); | ||||
| const utils = __importStar(__webpack_require__(15)); | ||||
| const cacheHttpClient = __importStar(__webpack_require__(114)); | ||||
| const tar_1 = __webpack_require__(434); | ||||
| const constants_1 = __webpack_require__(931); | ||||
| class ValidationError extends Error { | ||||
|     constructor(message) { | ||||
|         super(message); | ||||
| @@ -47231,16 +47323,31 @@ function restoreCache(paths, primaryKey, restoreKeys, options) { | ||||
|         for (const key of keys) { | ||||
|             checkKey(key); | ||||
|         } | ||||
|         const compressionMethod = yield utils.getCompressionMethod(); | ||||
|         let cacheEntry; | ||||
|         let compressionMethod = yield utils.getCompressionMethod(); | ||||
|         let archivePath = ''; | ||||
|         try { | ||||
|             // path are needed to compute version
 | ||||
|             const cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, { | ||||
|             cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, { | ||||
|                 compressionMethod | ||||
|             }); | ||||
|             if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) { | ||||
|                 // Cache not found
 | ||||
|                 return undefined; | ||||
|                 // This is to support the old cache entry created by gzip on windows.
 | ||||
|                 if (process.platform === 'win32' && | ||||
|                     compressionMethod !== constants_1.CompressionMethod.Gzip) { | ||||
|                     compressionMethod = constants_1.CompressionMethod.Gzip; | ||||
|                     cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, { | ||||
|                         compressionMethod | ||||
|                     }); | ||||
|                     if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) { | ||||
|                         return undefined; | ||||
|                     } | ||||
|                     core.debug("Couldn't find cache entry with zstd compression, falling back to gzip compression."); | ||||
|                 } | ||||
|                 else { | ||||
|                     // Cache not found
 | ||||
|                     return undefined; | ||||
|                 } | ||||
|             } | ||||
|             archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); | ||||
|             core.debug(`Archive Path: ${archivePath}`); | ||||
| @@ -53243,6 +53350,11 @@ var CompressionMethod; | ||||
|     CompressionMethod["ZstdWithoutLong"] = "zstd-without-long"; | ||||
|     CompressionMethod["Zstd"] = "zstd"; | ||||
| })(CompressionMethod = exports.CompressionMethod || (exports.CompressionMethod = {})); | ||||
| var ArchiveToolType; | ||||
| (function (ArchiveToolType) { | ||||
|     ArchiveToolType["GNU"] = "gnu"; | ||||
|     ArchiveToolType["BSD"] = "bsd"; | ||||
| })(ArchiveToolType = exports.ArchiveToolType || (exports.ArchiveToolType = {})); | ||||
| // The default number of retry attempts.
 | ||||
| exports.DefaultRetryAttempts = 2; | ||||
| // The default delay in milliseconds between retry attempts.
 | ||||
| @@ -53251,6 +53363,12 @@ exports.DefaultRetryDelay = 5000; | ||||
| // over the socket during this period, the socket is destroyed and the download
 | ||||
| // is aborted.
 | ||||
| exports.SocketTimeout = 5000; | ||||
| // The default path of GNUtar on hosted Windows runners
 | ||||
| exports.GnuTarPathOnWindows = `${process.env['PROGRAMFILES']}\\Git\\usr\\bin\\tar.exe`; | ||||
| // The default path of BSDtar on hosted Windows runners
 | ||||
| exports.SystemTarPathOnWindows = `${process.env['SYSTEMDRIVE']}\\Windows\\System32\\tar.exe`; | ||||
| exports.TarFilename = 'cache.tar'; | ||||
| exports.ManifestFilename = 'manifest.txt'; | ||||
| //# sourceMappingURL=constants.js.map
 | ||||
| 
 | ||||
| /***/ }), | ||||
|   | ||||
							
								
								
									
										18
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										18
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @@ -1,15 +1,15 @@ | ||||
| { | ||||
|   "name": "cache", | ||||
|   "version": "3.2.0", | ||||
|   "version": "3.2.0-beta.1", | ||||
|   "lockfileVersion": 2, | ||||
|   "requires": true, | ||||
|   "packages": { | ||||
|     "": { | ||||
|       "name": "cache", | ||||
|       "version": "3.2.0", | ||||
|       "version": "3.2.0-beta.1", | ||||
|       "license": "MIT", | ||||
|       "dependencies": { | ||||
|         "@actions/cache": "^3.0.6", | ||||
|         "@actions/cache": "3.1.0-beta.3", | ||||
|         "@actions/core": "^1.10.0", | ||||
|         "@actions/exec": "^1.1.1", | ||||
|         "@actions/io": "^1.1.2" | ||||
| @@ -36,9 +36,9 @@ | ||||
|       } | ||||
|     }, | ||||
|     "node_modules/@actions/cache": { | ||||
|       "version": "3.0.6", | ||||
|       "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.0.6.tgz", | ||||
|       "integrity": "sha512-Tttit+nqmxgb2M5Ufj5p8Lwd+fx329HOTLzxMrY4aaaZqBzqetgWlEfszMyiXfX4cJML+bzLJbyD9rNYt8TJ8g==", | ||||
|       "version": "3.1.0-beta.3", | ||||
|       "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.1.0-beta.3.tgz", | ||||
|       "integrity": "sha512-71S1vd0WKLbC2lAe04pCYqTLBjSa8gURtiqnVBCYAt8QVBjOfwa2D3ESf2m8K2xjUxman/Yimdp7CPJDyFnxZg==", | ||||
|       "dependencies": { | ||||
|         "@actions/core": "^1.10.0", | ||||
|         "@actions/exec": "^1.0.1", | ||||
| @@ -9722,9 +9722,9 @@ | ||||
|   }, | ||||
|   "dependencies": { | ||||
|     "@actions/cache": { | ||||
|       "version": "3.0.6", | ||||
|       "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.0.6.tgz", | ||||
|       "integrity": "sha512-Tttit+nqmxgb2M5Ufj5p8Lwd+fx329HOTLzxMrY4aaaZqBzqetgWlEfszMyiXfX4cJML+bzLJbyD9rNYt8TJ8g==", | ||||
|       "version": "3.1.0-beta.3", | ||||
|       "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.1.0-beta.3.tgz", | ||||
|       "integrity": "sha512-71S1vd0WKLbC2lAe04pCYqTLBjSa8gURtiqnVBCYAt8QVBjOfwa2D3ESf2m8K2xjUxman/Yimdp7CPJDyFnxZg==", | ||||
|       "requires": { | ||||
|         "@actions/core": "^1.10.0", | ||||
|         "@actions/exec": "^1.0.1", | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|   "name": "cache", | ||||
|   "version": "3.2.0", | ||||
|   "version": "3.2.0-beta.1", | ||||
|   "private": true, | ||||
|   "description": "Cache dependencies and build outputs", | ||||
|   "main": "dist/restore/index.js", | ||||
| @@ -23,7 +23,7 @@ | ||||
|   "author": "GitHub", | ||||
|   "license": "MIT", | ||||
|   "dependencies": { | ||||
|     "@actions/cache": "^3.0.6", | ||||
|     "@actions/cache": "3.1.0-beta.3", | ||||
|     "@actions/core": "^1.10.0", | ||||
|     "@actions/exec": "^1.1.1", | ||||
|     "@actions/io": "^1.1.2" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user