mirror of
https://github.com/gradle/actions
synced 2024-11-27 20:02:19 +00:00
113 lines
5.1 KiB
Diff
113 lines
5.1 KiB
Diff
diff --git a/node_modules/@actions/cache/lib/cache.d.ts b/node_modules/@actions/cache/lib/cache.d.ts
|
|
index 4658366..b796e58 100644
|
|
--- a/node_modules/@actions/cache/lib/cache.d.ts
|
|
+++ b/node_modules/@actions/cache/lib/cache.d.ts
|
|
@@ -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
|
|
* @returns string returns the key for the cache hit, otherwise returns undefined
|
|
*/
|
|
-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>;
|
|
/**
|
|
* Saves a list of files with the specified key
|
|
*
|
|
@@ -31,4 +31,12 @@ export declare function restoreCache(paths: string[], primaryKey: string, restor
|
|
* @param options cache upload options
|
|
* @returns number returns cacheId if the cache was saved successfully and throws an error if save fails
|
|
*/
|
|
-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>;
|
|
+
|
|
+// 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
|
|
index 9d636aa..a176bd7 100644
|
|
--- a/node_modules/@actions/cache/lib/cache.js
|
|
+++ b/node_modules/@actions/cache/lib/cache.js
|
|
@@ -127,18 +127,21 @@ function restoreCache(paths, primaryKey, restoreKeys, options, enableCrossOsArch
|
|
core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`);
|
|
yield (0, 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}`);
|
|
- }
|
|
+
|
|
+ // PATCHED - Return more inforamtion about restored entry
|
|
+ return new CacheEntry(cacheEntry.cacheKey, archiveFileSize);;
|
|
}
|
|
+ // PATCHED - propagate errors
|
|
+ // 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}`);
|
|
+ // }
|
|
+ // }
|
|
finally {
|
|
// Try to delete the archive to save space
|
|
try {
|
|
@@ -206,19 +209,23 @@ function saveCache(paths, key, options, enableCrossOsArchive = false) {
|
|
}
|
|
core.debug(`Saving Cache (ID: ${cacheId})`);
|
|
yield cacheHttpClient.saveCache(cacheId, archivePath, options);
|
|
+
|
|
+ // PATCHED - Return more inforamtion about saved entry
|
|
+ return new CacheEntry(key, archiveFileSize);
|
|
}
|
|
- 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}`);
|
|
- }
|
|
- }
|
|
+ // PATCHED - propagate errors
|
|
+ // 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 {
|
|
@@ -232,4 +239,11 @@ function saveCache(paths, key, options, enableCrossOsArchive = false) {
|
|
});
|
|
}
|
|
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
|