gradle-build-action/patches/@actions+cache+3.1.4.patch

115 lines
5.7 KiB
Diff
Raw Normal View History

2022-03-28 15:58:41 -04:00
diff --git a/node_modules/@actions/cache/lib/cache.d.ts b/node_modules/@actions/cache/lib/cache.d.ts
2023-02-06 17:04:55 -05:00
index 4658366..b796e58 100644
2022-03-28 15:58:41 -04:00
--- a/node_modules/@actions/cache/lib/cache.d.ts
+++ b/node_modules/@actions/cache/lib/cache.d.ts
2023-02-06 17:04:55 -05:00
@@ -21,7 +21,7 @@ export declare function isFeatureAvailable(): boolean;
* @param enableCrossOsArchive an optional boolean enabled to restore on windows any cache created on any platform
2022-03-28 15:58:41 -04:00
* @returns string returns the key for the cache hit, otherwise returns undefined
*/
2023-02-06 17:04:55 -05:00
-export declare function restoreCache(paths: string[], primaryKey: string, restoreKeys?: string[], options?: DownloadOptions, enableCrossOsArchive?: boolean): Promise<string | undefined>;
+export declare function restoreCache(paths: string[], primaryKey: string, restoreKeys?: string[], options?: DownloadOptions, enableCrossOsArchive?: boolean): Promise<CacheEntry | undefined>;
2022-03-28 15:58:41 -04:00
/**
* Saves a list of files with the specified key
*
2023-02-06 17:04:55 -05:00
@@ -31,4 +31,12 @@ export declare function restoreCache(paths: string[], primaryKey: string, restor
2022-03-28 15:58:41 -04:00
* @param options cache upload options
* @returns number returns cacheId if the cache was saved successfully and throws an error if save fails
*/
2023-02-06 17:04:55 -05:00
-export declare function saveCache(paths: string[], key: string, options?: UploadOptions, enableCrossOsArchive?: boolean): Promise<number>;
+export declare function saveCache(paths: string[], key: string, options?: UploadOptions, enableCrossOsArchive?: boolean): Promise<CacheEntry>;
2022-03-28 15:58:41 -04:00
+
+// PATCHED: Add `CacheEntry` as return type for save/restore functions
+// This allows us to track and report on cache entry sizes.
+export declare class CacheEntry {
+ key: string;
+ size?: number;
+ constructor(key: string, size?: number);
+}
diff --git a/node_modules/@actions/cache/lib/cache.js b/node_modules/@actions/cache/lib/cache.js
2023-02-06 17:04:55 -05:00
index 0fa9df3..5f0b173 100644
2022-03-28 15:58:41 -04:00
--- a/node_modules/@actions/cache/lib/cache.js
+++ b/node_modules/@actions/cache/lib/cache.js
2023-02-06 17:04:55 -05:00
@@ -97,26 +97,18 @@ function restoreCache(paths, primaryKey, restoreKeys, options, enableCrossOsArch
}
archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod));
core.debug(`Archive Path: ${archivePath}`);
+ const restoredEntry = new CacheEntry(cacheEntry.cacheKey);
2022-03-28 15:58:41 -04:00
// Download the cache from the cache entry
yield cacheHttpClient.downloadCache(cacheEntry.archiveLocation, archivePath, options);
if (core.isDebug()) {
2022-03-28 15:58:41 -04:00
yield tar_1.listTar(archivePath, compressionMethod);
}
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
+ restoredEntry.size = archiveFileSize;
core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`);
yield tar_1.extractTar(archivePath, compressionMethod);
core.info('Cache restored successfully');
- return cacheEntry.cacheKey;
- }
- catch (error) {
- const typedError = error;
- if (typedError.name === ValidationError.name) {
- throw error;
- }
- else {
- // Supress all non-validation cache related errors because caching should be optional
- core.warning(`Failed to restore: ${error.message}`);
- }
+ return restoredEntry;
2022-03-28 15:58:41 -04:00
}
finally {
// Try to delete the archive to save space
2023-02-06 17:04:55 -05:00
@@ -156,6 +148,7 @@ function saveCache(paths, key, options, enableCrossOsArchive = false) {
2022-03-28 15:58:41 -04:00
const archiveFolder = yield utils.createTempDirectory();
const archivePath = path.join(archiveFolder, utils.getCacheFileName(compressionMethod));
core.debug(`Archive Path: ${archivePath}`);
+ const savedEntry = new CacheEntry(key);
try {
yield tar_1.createTar(archiveFolder, cachePaths, compressionMethod);
if (core.isDebug()) {
2023-02-06 17:04:55 -05:00
@@ -163,6 +156,7 @@ function saveCache(paths, key, options, enableCrossOsArchive = false) {
2022-03-28 15:58:41 -04:00
}
const fileSizeLimit = 10 * 1024 * 1024 * 1024; // 10GB per repo limit
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
+ savedEntry.size = archiveFileSize;
core.debug(`File Size: ${archiveFileSize}`);
// For GHES, this check will take place in ReserveCache API with enterprise file size limit
if (archiveFileSize > fileSizeLimit && !utils.isGhes()) {
2023-02-06 17:04:55 -05:00
@@ -186,18 +180,6 @@ function saveCache(paths, key, options, enableCrossOsArchive = false) {
core.debug(`Saving Cache (ID: ${cacheId})`);
yield cacheHttpClient.saveCache(cacheId, archivePath, options);
}
- catch (error) {
- const typedError = error;
- if (typedError.name === ValidationError.name) {
- throw error;
- }
- else if (typedError.name === ReserveCacheError.name) {
- core.info(`Failed to save: ${typedError.message}`);
- }
- else {
- core.warning(`Failed to save: ${typedError.message}`);
- }
- }
finally {
// Try to delete the archive to save space
try {
2023-02-06 17:04:55 -05:00
@@ -207,8 +189,15 @@ function saveCache(paths, key, options, enableCrossOsArchive = false) {
2022-03-28 15:58:41 -04:00
core.debug(`Failed to delete archive: ${error}`);
}
}
- return cacheId;
+ return savedEntry;
});
}
exports.saveCache = saveCache;
+class CacheEntry {
+ constructor(key, size) {
+ this.key = key;
+ this.size = size;
+ }
+}
+exports.CacheEntry = CacheEntry;
//# sourceMappingURL=cache.js.map
\ No newline at end of file