Unverified Commit 09f46b2d authored by Daz DeBoer's avatar Daz DeBoer
Browse files

Update to @actions/cache v2.0.0

parent d7b4f42a
Loading
Loading
Loading
Loading
+7 −7
Changes for package-lock.json: 7 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@
      "hasInstallScript": true,
      "license": "MIT",
      "dependencies": {
        "@actions/cache": "1.0.10",
        "@actions/cache": "2.0.0",
        "@actions/core": "1.6.0",
        "@actions/exec": "1.1.1",
        "@actions/github": "5.0.0",
@@ -38,9 +38,9 @@
      }
    },
    "node_modules/@actions/cache": {
      "version": "1.0.10",
      "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-1.0.10.tgz",
      "integrity": "sha512-8l9A54RXsPHbHs4Tu0DGqTyE5cguvq3xO9H0ohbLa5zbL2Z4dh9lxnjQn2xojsPQr4WnEVgbaVZpc1tlhehQGw==",
      "version": "2.0.0",
      "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-2.0.0.tgz",
      "integrity": "sha512-d7n8ul6HjWX6oDrNEPoqn8ZvqyyDhp9Uek6WOxALyxGVsXU+8+ND+viD3UfrXVWfs/GQiqI5Eq4cOozZj0yRFQ==",
      "dependencies": {
        "@actions/core": "^1.2.6",
        "@actions/exec": "^1.0.1",
@@ -7093,9 +7093,9 @@
  },
  "dependencies": {
    "@actions/cache": {
      "version": "1.0.10",
      "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-1.0.10.tgz",
      "integrity": "sha512-8l9A54RXsPHbHs4Tu0DGqTyE5cguvq3xO9H0ohbLa5zbL2Z4dh9lxnjQn2xojsPQr4WnEVgbaVZpc1tlhehQGw==",
      "version": "2.0.0",
      "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-2.0.0.tgz",
      "integrity": "sha512-d7n8ul6HjWX6oDrNEPoqn8ZvqyyDhp9Uek6WOxALyxGVsXU+8+ND+viD3UfrXVWfs/GQiqI5Eq4cOozZj0yRFQ==",
      "requires": {
        "@actions/core": "^1.2.6",
        "@actions/exec": "^1.0.1",
+1 −1
Changes for package.json: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@
  ],
  "license": "MIT",
  "dependencies": {
    "@actions/cache": "1.0.10",
    "@actions/cache": "2.0.0",
    "@actions/core": "1.6.0",
    "@actions/exec": "1.1.1",
    "@actions/github": "5.0.0",
−108

File deleted.

+95
Changes for patches/@actions+cache+2.0.0.patch: 95 added lines, 0 removed lines.
Original line number Diff line number Diff line
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 dd31592..cbe378a 100644
--- a/node_modules/@actions/cache/lib/cache.js
+++ b/node_modules/@actions/cache/lib/cache.js
@@ -37,6 +37,13 @@ class ReserveCacheError extends Error {
     }
 }
 exports.ReserveCacheError = ReserveCacheError;
+class CacheEntry {
+    constructor(key, size) {
+        this.key = key;
+        this.size = size;
+    }
+}
+exports.CacheEntry = CacheEntry;
 function checkPaths(paths) {
     if (!paths || paths.length === 0) {
         throw new ValidationError(`Path Validation Error: At least one directory or file path is required`);
@@ -93,6 +100,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 +108,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 +122,7 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
                 core.debug(`Failed to delete archive: ${error}`);
             }
         }
-        return cacheEntry.cacheKey;
+        return restoredEntry;
     });
 }
 exports.restoreCache = restoreCache;
@@ -144,6 +153,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()) {
@@ -151,6 +161,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}`);
             if (archiveFileSize > fileSizeLimit) {
                 throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`);
@@ -167,7 +178,7 @@ function saveCache(paths, key, options) {
                 core.debug(`Failed to delete archive: ${error}`);
             }
         }
-        return cacheId;
+        return savedEntry;
     });
 }
 exports.saveCache = saveCache;