mirror of
https://github.com/gradle/gradle-build-action
synced 2024-12-17 22:02:17 +00:00
116ac10f81
Production deps: - Bump @actions/tool-cache from 1.7.2 to 2.0.1 - Bump @actions/http-client from 1.0.11 to 2.0.1 - Bump @actions/github from 5.0.1 to 5.0.3 - Bump @actions/cache from 2.0.2 to 2.0.4 Dev deps: - Bump eslint from 8.14.0 to 8.15.0 - Bump eslint-plugin-jest from 26.2.0 to 26.2.2 - Bump jest from 27.5.1 to 28.1.0 - Bump ts-jst from 27.1.4 to 28.0.2
90 lines
4.4 KiB
Diff
90 lines
4.4 KiB
Diff
diff --git a/node_modules/@actions/cache/lib/cache.d.ts b/node_modules/@actions/cache/lib/cache.d.ts
|
|
index 16b20f7..aea77ba 100644
|
|
--- a/node_modules/@actions/cache/lib/cache.d.ts
|
|
+++ b/node_modules/@actions/cache/lib/cache.d.ts
|
|
@@ -20,7 +20,7 @@ export declare function isFeatureAvailable(): boolean;
|
|
* @param downloadOptions cache download options
|
|
* @returns string returns the key for the cache hit, otherwise returns undefined
|
|
*/
|
|
-export declare function restoreCache(paths: string[], primaryKey: string, restoreKeys?: string[], options?: DownloadOptions): Promise<string | undefined>;
|
|
+export declare function restoreCache(paths: string[], primaryKey: string, restoreKeys?: string[], options?: DownloadOptions): Promise<CacheEntry | undefined>;
|
|
/**
|
|
* Saves a list of files with the specified key
|
|
*
|
|
@@ -29,4 +29,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): Promise<number>;
|
|
+export declare function saveCache(paths: string[], key: string, options?: UploadOptions): 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 0b5a2a8..757ad88 100644
|
|
--- a/node_modules/@actions/cache/lib/cache.js
|
|
+++ b/node_modules/@actions/cache/lib/cache.js
|
|
@@ -93,6 +93,7 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
|
|
}
|
|
const archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod));
|
|
core.debug(`Archive Path: ${archivePath}`);
|
|
+ const restoredEntry = new CacheEntry(cacheEntry.cacheKey);
|
|
try {
|
|
// Download the cache from the cache entry
|
|
yield cacheHttpClient.downloadCache(cacheEntry.archiveLocation, archivePath, options);
|
|
@@ -100,6 +101,7 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
|
|
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');
|
|
@@ -113,7 +115,7 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
|
|
core.debug(`Failed to delete archive: ${error}`);
|
|
}
|
|
}
|
|
- return cacheEntry.cacheKey;
|
|
+ return restoredEntry;
|
|
});
|
|
}
|
|
exports.restoreCache = restoreCache;
|
|
@@ -138,6 +140,7 @@ function saveCache(paths, key, options) {
|
|
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()) {
|
|
@@ -145,6 +148,7 @@ function saveCache(paths, key, options) {
|
|
}
|
|
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()) {
|
|
@@ -176,8 +180,15 @@ function saveCache(paths, key, options) {
|
|
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
|