@actions/cache 3.2.4 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -2
- package/lib/cache.d.ts +2 -2
- package/lib/cache.js +222 -7
- package/lib/cache.js.map +1 -1
- package/lib/generated/google/protobuf/timestamp.d.ts +158 -0
- package/lib/generated/google/protobuf/timestamp.js +136 -0
- package/lib/generated/google/protobuf/timestamp.js.map +1 -0
- package/lib/generated/google/protobuf/wrappers.d.ts +307 -0
- package/lib/generated/google/protobuf/wrappers.js +614 -0
- package/lib/generated/google/protobuf/wrappers.js.map +1 -0
- package/lib/generated/results/api/v1/cache.d.ts +378 -0
- package/lib/generated/results/api/v1/cache.js +730 -0
- package/lib/generated/results/api/v1/cache.js.map +1 -0
- package/lib/generated/results/api/v1/cache.twirp.d.ts +53 -0
- package/lib/generated/results/api/v1/cache.twirp.js +602 -0
- package/lib/generated/results/api/v1/cache.twirp.js.map +1 -0
- package/lib/generated/results/entities/v1/cacheentry.d.ts +71 -0
- package/lib/generated/results/entities/v1/cacheentry.js +106 -0
- package/lib/generated/results/entities/v1/cacheentry.js.map +1 -0
- package/lib/generated/results/entities/v1/cachemetadata.d.ts +35 -0
- package/lib/generated/results/entities/v1/cachemetadata.js +64 -0
- package/lib/generated/results/entities/v1/cachemetadata.js.map +1 -0
- package/lib/generated/results/entities/v1/cachescope.d.ts +34 -0
- package/lib/generated/results/entities/v1/cachescope.js +63 -0
- package/lib/generated/results/entities/v1/cachescope.js.map +1 -0
- package/lib/internal/cacheHttpClient.d.ts +1 -3
- package/lib/internal/cacheHttpClient.js +30 -36
- package/lib/internal/cacheHttpClient.js.map +1 -1
- package/lib/internal/cacheUtils.d.ts +2 -1
- package/lib/internal/cacheUtils.js +28 -10
- package/lib/internal/cacheUtils.js.map +1 -1
- package/lib/internal/config.d.ts +3 -0
- package/lib/internal/config.js +37 -0
- package/lib/internal/config.js.map +1 -0
- package/lib/internal/constants.d.ts +1 -0
- package/lib/internal/constants.js +2 -1
- package/lib/internal/constants.js.map +1 -1
- package/lib/internal/shared/cacheTwirpClient.d.ts +6 -0
- package/lib/internal/shared/cacheTwirpClient.js +160 -0
- package/lib/internal/shared/cacheTwirpClient.js.map +1 -0
- package/lib/internal/shared/errors.d.ts +22 -0
- package/lib/internal/shared/errors.js +70 -0
- package/lib/internal/shared/errors.js.map +1 -0
- package/lib/internal/shared/user-agent.d.ts +4 -0
- package/lib/internal/shared/user-agent.js +13 -0
- package/lib/internal/shared/user-agent.js.map +1 -0
- package/lib/internal/uploadUtils.d.ts +60 -0
- package/lib/internal/uploadUtils.js +167 -0
- package/lib/internal/uploadUtils.js.map +1 -0
- package/lib/options.d.ts +12 -0
- package/lib/options.js +17 -0
- package/lib/options.js.map +1 -1
- package/package.json +5 -5
|
@@ -39,17 +39,18 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
|
39
39
|
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.
|
|
42
|
+
exports.getRuntimeToken = exports.getCacheVersion = exports.assertDefined = exports.getGnuTarPathOnWindows = exports.getCacheFileName = exports.getCompressionMethod = exports.unlinkFile = exports.resolvePaths = exports.getArchiveFileSizeInBytes = exports.createTempDirectory = void 0;
|
|
43
43
|
const core = __importStar(require("@actions/core"));
|
|
44
44
|
const exec = __importStar(require("@actions/exec"));
|
|
45
45
|
const glob = __importStar(require("@actions/glob"));
|
|
46
46
|
const io = __importStar(require("@actions/io"));
|
|
47
|
+
const crypto = __importStar(require("crypto"));
|
|
47
48
|
const fs = __importStar(require("fs"));
|
|
48
49
|
const path = __importStar(require("path"));
|
|
49
50
|
const semver = __importStar(require("semver"));
|
|
50
51
|
const util = __importStar(require("util"));
|
|
51
|
-
const uuid_1 = require("uuid");
|
|
52
52
|
const constants_1 = require("./constants");
|
|
53
|
+
const versionSalt = '1.0';
|
|
53
54
|
// From https://github.com/actions/toolkit/blob/main/packages/tool-cache/src/tool-cache.ts#L23
|
|
54
55
|
function createTempDirectory() {
|
|
55
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -71,7 +72,7 @@ function createTempDirectory() {
|
|
|
71
72
|
}
|
|
72
73
|
tempDirectory = path.join(baseLocation, 'actions', 'temp');
|
|
73
74
|
}
|
|
74
|
-
const dest = path.join(tempDirectory,
|
|
75
|
+
const dest = path.join(tempDirectory, crypto.randomUUID());
|
|
75
76
|
yield io.mkdirP(dest);
|
|
76
77
|
return dest;
|
|
77
78
|
});
|
|
@@ -187,12 +188,29 @@ function assertDefined(name, value) {
|
|
|
187
188
|
return value;
|
|
188
189
|
}
|
|
189
190
|
exports.assertDefined = assertDefined;
|
|
190
|
-
function
|
|
191
|
-
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
191
|
+
function getCacheVersion(paths, compressionMethod, enableCrossOsArchive = false) {
|
|
192
|
+
// don't pass changes upstream
|
|
193
|
+
const components = paths.slice();
|
|
194
|
+
// Add compression method to cache version to restore
|
|
195
|
+
// compressed cache as per compression method
|
|
196
|
+
if (compressionMethod) {
|
|
197
|
+
components.push(compressionMethod);
|
|
198
|
+
}
|
|
199
|
+
// Only check for windows platforms if enableCrossOsArchive is false
|
|
200
|
+
if (process.platform === 'win32' && !enableCrossOsArchive) {
|
|
201
|
+
components.push('windows-only');
|
|
202
|
+
}
|
|
203
|
+
// Add salt to cache version to support breaking changes in cache entry
|
|
204
|
+
components.push(versionSalt);
|
|
205
|
+
return crypto.createHash('sha256').update(components.join('|')).digest('hex');
|
|
206
|
+
}
|
|
207
|
+
exports.getCacheVersion = getCacheVersion;
|
|
208
|
+
function getRuntimeToken() {
|
|
209
|
+
const token = process.env['ACTIONS_RUNTIME_TOKEN'];
|
|
210
|
+
if (!token) {
|
|
211
|
+
throw new Error('Unable to get the ACTIONS_RUNTIME_TOKEN env variable');
|
|
212
|
+
}
|
|
213
|
+
return token;
|
|
196
214
|
}
|
|
197
|
-
exports.
|
|
215
|
+
exports.getRuntimeToken = getRuntimeToken;
|
|
198
216
|
//# sourceMappingURL=cacheUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cacheUtils.js","sourceRoot":"","sources":["../../src/internal/cacheUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAqC;AACrC,oDAAqC;AACrC,oDAAqC;AACrC,gDAAiC;AACjC,uCAAwB;AACxB,2CAA4B;AAC5B,+CAAgC;AAChC,2CAA4B;AAC5B
|
|
1
|
+
{"version":3,"file":"cacheUtils.js","sourceRoot":"","sources":["../../src/internal/cacheUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAqC;AACrC,oDAAqC;AACrC,oDAAqC;AACrC,gDAAiC;AACjC,+CAAgC;AAChC,uCAAwB;AACxB,2CAA4B;AAC5B,+CAAgC;AAChC,2CAA4B;AAC5B,2CAIoB;AAEpB,MAAM,WAAW,GAAG,KAAK,CAAA;AAEzB,8FAA8F;AAC9F,SAAsB,mBAAmB;;QACvC,MAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAA;QAE/C,IAAI,aAAa,GAAW,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,EAAE,CAAA;QAE5D,IAAI,CAAC,aAAa,EAAE;YAClB,IAAI,YAAoB,CAAA;YACxB,IAAI,UAAU,EAAE;gBACd,8CAA8C;gBAC9C,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,MAAM,CAAA;aACpD;iBAAM;gBACL,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE;oBACjC,YAAY,GAAG,QAAQ,CAAA;iBACxB;qBAAM;oBACL,YAAY,GAAG,O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;IAEhC,qDAAqD;IACrD,6CAA6C;IAC7C,IAAI,iBAAiB,EAAE;QACrB,UAAU,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;KACnC;IAED,oEAAoE;IACpE,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,IAAI,CAAC,oBAAoB,EAAE;QACzD,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;KAChC;IAED,uEAAuE;IACvE,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IAE5B,OAAO,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC/E,CAAC;AAvBD,0CAuBC;AAED,SAAgB,eAAe;IAC7B,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAA;IAClD,IAAI,CAAC,KAAK,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAA;KACxE;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAND,0CAMC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCacheServiceURL = exports.getCacheServiceVersion = exports.isGhes = void 0;
|
|
4
|
+
function isGhes() {
|
|
5
|
+
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
|
|
6
|
+
const hostname = ghUrl.hostname.trimEnd().toUpperCase();
|
|
7
|
+
const isGitHubHost = hostname === 'GITHUB.COM';
|
|
8
|
+
const isGheHost = hostname.endsWith('.GHE.COM');
|
|
9
|
+
const isLocalHost = hostname.endsWith('.LOCALHOST');
|
|
10
|
+
return !isGitHubHost && !isGheHost && !isLocalHost;
|
|
11
|
+
}
|
|
12
|
+
exports.isGhes = isGhes;
|
|
13
|
+
function getCacheServiceVersion() {
|
|
14
|
+
// Cache service v2 is not supported on GHES. We will default to
|
|
15
|
+
// cache service v1 even if the feature flag was enabled by user.
|
|
16
|
+
if (isGhes())
|
|
17
|
+
return 'v1';
|
|
18
|
+
return process.env['ACTIONS_CACHE_SERVICE_V2'] ? 'v2' : 'v1';
|
|
19
|
+
}
|
|
20
|
+
exports.getCacheServiceVersion = getCacheServiceVersion;
|
|
21
|
+
function getCacheServiceURL() {
|
|
22
|
+
const version = getCacheServiceVersion();
|
|
23
|
+
// Based on the version of the cache service, we will determine which
|
|
24
|
+
// URL to use.
|
|
25
|
+
switch (version) {
|
|
26
|
+
case 'v1':
|
|
27
|
+
return (process.env['ACTIONS_CACHE_URL'] ||
|
|
28
|
+
process.env['ACTIONS_RESULTS_URL'] ||
|
|
29
|
+
'');
|
|
30
|
+
case 'v2':
|
|
31
|
+
return process.env['ACTIONS_RESULTS_URL'] || '';
|
|
32
|
+
default:
|
|
33
|
+
throw new Error(`Unsupported cache service version: ${version}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.getCacheServiceURL = getCacheServiceURL;
|
|
37
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/internal/config.ts"],"names":[],"mappings":";;;AAAA,SAAgB,MAAM;IACpB,MAAM,KAAK,GAAG,IAAI,GAAG,CACnB,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,oBAAoB,CACzD,CAAA;IAED,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,WAAW,EAAE,CAAA;IACvD,MAAM,YAAY,GAAG,QAAQ,KAAK,YAAY,CAAA;IAC9C,MAAM,SAAS,GAAG,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAA;IAC/C,MAAM,WAAW,GAAG,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAA;IAEnD,OAAO,CAAC,YAAY,IAAI,CAAC,SAAS,IAAI,CAAC,WAAW,CAAA;AACpD,CAAC;AAXD,wBAWC;AAED,SAAgB,sBAAsB;IACpC,gEAAgE;IAChE,iEAAiE;IACjE,IAAI,MAAM,EAAE;QAAE,OAAO,IAAI,CAAA;IAEzB,OAAO,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAA;AAC9D,CAAC;AAND,wDAMC;AAED,SAAgB,kBAAkB;IAChC,MAAM,OAAO,GAAG,sBAAsB,EAAE,CAAA;IAExC,qEAAqE;IACrE,cAAc;IACd,QAAQ,OAAO,EAAE;QACf,KAAK,IAAI;YACP,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;gBAChC,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC;gBAClC,EAAE,CACH,CAAA;QACH,KAAK,IAAI;YACP,OAAO,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,IAAI,EAAE,CAAA;QACjD;YACE,MAAM,IAAI,KAAK,CAAC,sCAAsC,OAAO,EAAE,CAAC,CAAA;KACnE;AACH,CAAC;AAjBD,gDAiBC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ManifestFilename = exports.TarFilename = exports.SystemTarPathOnWindows = exports.GnuTarPathOnWindows = exports.SocketTimeout = exports.DefaultRetryDelay = exports.DefaultRetryAttempts = exports.ArchiveToolType = exports.CompressionMethod = exports.CacheFilename = void 0;
|
|
3
|
+
exports.CacheFileSizeLimit = exports.ManifestFilename = exports.TarFilename = exports.SystemTarPathOnWindows = exports.GnuTarPathOnWindows = exports.SocketTimeout = exports.DefaultRetryDelay = exports.DefaultRetryAttempts = exports.ArchiveToolType = exports.CompressionMethod = exports.CacheFilename = void 0;
|
|
4
4
|
var CacheFilename;
|
|
5
5
|
(function (CacheFilename) {
|
|
6
6
|
CacheFilename["Gzip"] = "cache.tgz";
|
|
@@ -33,4 +33,5 @@ exports.GnuTarPathOnWindows = `${process.env['PROGRAMFILES']}\\Git\\usr\\bin\\ta
|
|
|
33
33
|
exports.SystemTarPathOnWindows = `${process.env['SYSTEMDRIVE']}\\Windows\\System32\\tar.exe`;
|
|
34
34
|
exports.TarFilename = 'cache.tar';
|
|
35
35
|
exports.ManifestFilename = 'manifest.txt';
|
|
36
|
+
exports.CacheFileSizeLimit = 10 * Math.pow(1024, 3); // 10GiB per repository
|
|
36
37
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/internal/constants.ts"],"names":[],"mappings":";;;AAAA,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,mCAAkB,CAAA;IAClB,oCAAmB,CAAA;AACrB,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB;AAED,IAAY,iBAMX;AAND,WAAY,iBAAiB;IAC3B,kCAAa,CAAA;IACb,+CAA+C;IAC/C,6EAA6E;IAC7E,0DAAqC,CAAA;IACrC,kCAAa,CAAA;AACf,CAAC,EANW,iBAAiB,iCAAjB,iBAAiB,QAM5B;AAED,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,8BAAW,CAAA;IACX,8BAAW,CAAA;AACb,CAAC,EAHW,eAAe,+BAAf,eAAe,QAG1B;AAED,wCAAwC;AAC3B,QAAA,oBAAoB,GAAG,CAAC,CAAA;AAErC,4DAA4D;AAC/C,QAAA,iBAAiB,GAAG,IAAI,CAAA;AAErC,6EAA6E;AAC7E,+EAA+E;AAC/E,cAAc;AACD,QAAA,aAAa,GAAG,IAAI,CAAA;AAEjC,uDAAuD;AAC1C,QAAA,mBAAmB,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,0BAA0B,CAAA;AAE3F,uDAAuD;AAC1C,QAAA,sBAAsB,GAAG,GAAG,OAAO,CAAC,G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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.internalCacheTwirpClient = void 0;
|
|
13
|
+
const core_1 = require("@actions/core");
|
|
14
|
+
const user_agent_1 = require("./user-agent");
|
|
15
|
+
const errors_1 = require("./errors");
|
|
16
|
+
const config_1 = require("../config");
|
|
17
|
+
const cacheUtils_1 = require("../cacheUtils");
|
|
18
|
+
const auth_1 = require("@actions/http-client/lib/auth");
|
|
19
|
+
const http_client_1 = require("@actions/http-client");
|
|
20
|
+
const cache_twirp_1 = require("../../generated/results/api/v1/cache.twirp");
|
|
21
|
+
/**
|
|
22
|
+
* This class is a wrapper around the CacheServiceClientJSON class generated by Twirp.
|
|
23
|
+
*
|
|
24
|
+
* It adds retry logic to the request method, which is not present in the generated client.
|
|
25
|
+
*
|
|
26
|
+
* This class is used to interact with cache service v2.
|
|
27
|
+
*/
|
|
28
|
+
class CacheServiceClient {
|
|
29
|
+
constructor(userAgent, maxAttempts, baseRetryIntervalMilliseconds, retryMultiplier) {
|
|
30
|
+
this.maxAttempts = 5;
|
|
31
|
+
this.baseRetryIntervalMilliseconds = 3000;
|
|
32
|
+
this.retryMultiplier = 1.5;
|
|
33
|
+
const token = (0, cacheUtils_1.getRuntimeToken)();
|
|
34
|
+
this.baseUrl = (0, config_1.getCacheServiceURL)();
|
|
35
|
+
if (maxAttempts) {
|
|
36
|
+
this.maxAttempts = maxAttempts;
|
|
37
|
+
}
|
|
38
|
+
if (baseRetryIntervalMilliseconds) {
|
|
39
|
+
this.baseRetryIntervalMilliseconds = baseRetryIntervalMilliseconds;
|
|
40
|
+
}
|
|
41
|
+
if (retryMultiplier) {
|
|
42
|
+
this.retryMultiplier = retryMultiplier;
|
|
43
|
+
}
|
|
44
|
+
this.httpClient = new http_client_1.HttpClient(userAgent, [
|
|
45
|
+
new auth_1.BearerCredentialHandler(token)
|
|
46
|
+
]);
|
|
47
|
+
}
|
|
48
|
+
// This function satisfies the Rpc interface. It is compatible with the JSON
|
|
49
|
+
// JSON generated client.
|
|
50
|
+
request(service, method, contentType, data) {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
const url = new URL(`/twirp/${service}/${method}`, this.baseUrl).href;
|
|
53
|
+
(0, core_1.debug)(`[Request] ${method} ${url}`);
|
|
54
|
+
const headers = {
|
|
55
|
+
'Content-Type': contentType
|
|
56
|
+
};
|
|
57
|
+
try {
|
|
58
|
+
const { body } = yield this.retryableRequest(() => __awaiter(this, void 0, void 0, function* () { return this.httpClient.post(url, JSON.stringify(data), headers); }));
|
|
59
|
+
return body;
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
throw new Error(`Failed to ${method}: ${error.message}`);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
retryableRequest(operation) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
let attempt = 0;
|
|
69
|
+
let errorMessage = '';
|
|
70
|
+
let rawBody = '';
|
|
71
|
+
while (attempt < this.maxAttempts) {
|
|
72
|
+
let isRetryable = false;
|
|
73
|
+
try {
|
|
74
|
+
const response = yield operation();
|
|
75
|
+
const statusCode = response.message.statusCode;
|
|
76
|
+
rawBody = yield response.readBody();
|
|
77
|
+
(0, core_1.debug)(`[Response] - ${response.message.statusCode}`);
|
|
78
|
+
(0, core_1.debug)(`Headers: ${JSON.stringify(response.message.headers, null, 2)}`);
|
|
79
|
+
const body = JSON.parse(rawBody);
|
|
80
|
+
(0, core_1.debug)(`Body: ${JSON.stringify(body, null, 2)}`);
|
|
81
|
+
if (this.isSuccessStatusCode(statusCode)) {
|
|
82
|
+
return { response, body };
|
|
83
|
+
}
|
|
84
|
+
isRetryable = this.isRetryableHttpStatusCode(statusCode);
|
|
85
|
+
errorMessage = `Failed request: (${statusCode}) ${response.message.statusMessage}`;
|
|
86
|
+
if (body.msg) {
|
|
87
|
+
if (errors_1.UsageError.isUsageErrorMessage(body.msg)) {
|
|
88
|
+
throw new errors_1.UsageError();
|
|
89
|
+
}
|
|
90
|
+
errorMessage = `${errorMessage}: ${body.msg}`;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
if (error instanceof SyntaxError) {
|
|
95
|
+
(0, core_1.debug)(`Raw Body: ${rawBody}`);
|
|
96
|
+
}
|
|
97
|
+
if (error instanceof errors_1.UsageError) {
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
100
|
+
if (errors_1.NetworkError.isNetworkErrorCode(error === null || error === void 0 ? void 0 : error.code)) {
|
|
101
|
+
throw new errors_1.NetworkError(error === null || error === void 0 ? void 0 : error.code);
|
|
102
|
+
}
|
|
103
|
+
isRetryable = true;
|
|
104
|
+
errorMessage = error.message;
|
|
105
|
+
}
|
|
106
|
+
if (!isRetryable) {
|
|
107
|
+
throw new Error(`Received non-retryable error: ${errorMessage}`);
|
|
108
|
+
}
|
|
109
|
+
if (attempt + 1 === this.maxAttempts) {
|
|
110
|
+
throw new Error(`Failed to make request after ${this.maxAttempts} attempts: ${errorMessage}`);
|
|
111
|
+
}
|
|
112
|
+
const retryTimeMilliseconds = this.getExponentialRetryTimeMilliseconds(attempt);
|
|
113
|
+
(0, core_1.info)(`Attempt ${attempt + 1} of ${this.maxAttempts} failed with error: ${errorMessage}. Retrying request in ${retryTimeMilliseconds} ms...`);
|
|
114
|
+
yield this.sleep(retryTimeMilliseconds);
|
|
115
|
+
attempt++;
|
|
116
|
+
}
|
|
117
|
+
throw new Error(`Request failed`);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
isSuccessStatusCode(statusCode) {
|
|
121
|
+
if (!statusCode)
|
|
122
|
+
return false;
|
|
123
|
+
return statusCode >= 200 && statusCode < 300;
|
|
124
|
+
}
|
|
125
|
+
isRetryableHttpStatusCode(statusCode) {
|
|
126
|
+
if (!statusCode)
|
|
127
|
+
return false;
|
|
128
|
+
const retryableStatusCodes = [
|
|
129
|
+
http_client_1.HttpCodes.BadGateway,
|
|
130
|
+
http_client_1.HttpCodes.GatewayTimeout,
|
|
131
|
+
http_client_1.HttpCodes.InternalServerError,
|
|
132
|
+
http_client_1.HttpCodes.ServiceUnavailable,
|
|
133
|
+
http_client_1.HttpCodes.TooManyRequests
|
|
134
|
+
];
|
|
135
|
+
return retryableStatusCodes.includes(statusCode);
|
|
136
|
+
}
|
|
137
|
+
sleep(milliseconds) {
|
|
138
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
139
|
+
return new Promise(resolve => setTimeout(resolve, milliseconds));
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
getExponentialRetryTimeMilliseconds(attempt) {
|
|
143
|
+
if (attempt < 0) {
|
|
144
|
+
throw new Error('attempt should be a positive integer');
|
|
145
|
+
}
|
|
146
|
+
if (attempt === 0) {
|
|
147
|
+
return this.baseRetryIntervalMilliseconds;
|
|
148
|
+
}
|
|
149
|
+
const minTime = this.baseRetryIntervalMilliseconds * Math.pow(this.retryMultiplier, attempt);
|
|
150
|
+
const maxTime = minTime * this.retryMultiplier;
|
|
151
|
+
// returns a random number between minTime and maxTime (exclusive)
|
|
152
|
+
return Math.trunc(Math.random() * (maxTime - minTime) + minTime);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function internalCacheTwirpClient(options) {
|
|
156
|
+
const client = new CacheServiceClient((0, user_agent_1.getUserAgentString)(), options === null || options === void 0 ? void 0 : options.maxAttempts, options === null || options === void 0 ? void 0 : options.retryIntervalMs, options === null || options === void 0 ? void 0 : options.retryMultiplier);
|
|
157
|
+
return new cache_twirp_1.CacheServiceClientJSON(client);
|
|
158
|
+
}
|
|
159
|
+
exports.internalCacheTwirpClient = internalCacheTwirpClient;
|
|
160
|
+
//# sourceMappingURL=cacheTwirpClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cacheTwirpClient.js","sourceRoot":"","sources":["../../../src/internal/shared/cacheTwirpClient.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAyC;AACzC,6CAA+C;AAC/C,qCAAiD;AACjD,sCAA4C;AAC5C,8CAA6C;AAC7C,wDAAqE;AACrE,sDAA8E;AAC9E,4EAAiF;AAYjF;;;;;;GAMG;AACH,MAAM,kBAAkB;IAOtB,YACE,SAAiB,EACjB,WAAoB,EACpB,6BAAsC,EACtC,eAAwB;QARlB,gBAAW,GAAG,CAAC,CAAA;QACf,kCAA6B,GAAG,IAAI,CAAA;QACpC,oBAAe,GAAG,GAAG,CAAA;QAQ3B,MAAM,KAAK,GAAG,IAAA,4BAAe,GAAE,CAAA;QAC/B,IAAI,CAAC,OAAO,GAAG,IAAA,2BAAkB,GAAE,CAAA;QACnC,IAAI,WAAW,EAAE;YACf,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;SAC/B;QACD,IAAI,6BAA6B,EAAE;YACjC,IAAI,CAAC,6BAA6B,GAAG,6BAA6B,CAAA;SACnE;QACD,IAAI,eAAe,EAAE;YACnB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAA;SACvC;QAED,IAAI,CAAC,UAAU,GAAG,IAAI,wBAAU,CAAC,SAAS,EAAE;YAC1C,IAAI,8BAAuB,CAAC,KAAK,CAAC;SACnC,CAAC,CAAA;IACJ,CAAC;IAED,4EAA4E;IAC5E,yBAAyB;IACnB,OAAO,CACX,OAAe,EACf,MAA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OAAO,GAAG,CAAC,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAA;SACxD;QAED,IAAI,OAAO,KAAK,CAAC,EAAE;YACjB,OAAO,IAAI,CAAC,6BAA6B,CAAA;SAC1C;QAED,MAAM,OAAO,GACX,IAAI,CAAC,6BAA6B,GAAG,SAAA,IAAI,CAAC,eAAe,EAAI,OAAO,CAAA,CAAA;QACtE,MAAM,OAAO,GAAG,OAAO,GAAG,IAAI,CAAC,eAAe,CAAA;QAE9C,kEAAkE;QAClE,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC,CAAA;IAClE,CAAC;CACF;AAED,SAAgB,wBAAwB,CAAC,OAIxC;IACC,MAAM,MAAM,GAAG,IAAI,kBAAkB,CACnC,IAAA,+BAAkB,GAAE,EACpB,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EACpB,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,eAAe,EACxB,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,eAAe,CACzB,CAAA;IACD,OAAO,IAAI,oCAAsB,CAAC,MAAM,CAAC,CAAA;AAC3C,CAAC;AAZD,4DAYC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare class FilesNotFoundError extends Error {
|
|
2
|
+
files: string[];
|
|
3
|
+
constructor(files?: string[]);
|
|
4
|
+
}
|
|
5
|
+
export declare class InvalidResponseError extends Error {
|
|
6
|
+
constructor(message: string);
|
|
7
|
+
}
|
|
8
|
+
export declare class CacheNotFoundError extends Error {
|
|
9
|
+
constructor(message?: string);
|
|
10
|
+
}
|
|
11
|
+
export declare class GHESNotSupportedError extends Error {
|
|
12
|
+
constructor(message?: string);
|
|
13
|
+
}
|
|
14
|
+
export declare class NetworkError extends Error {
|
|
15
|
+
code: string;
|
|
16
|
+
constructor(code: string);
|
|
17
|
+
static isNetworkErrorCode: (code?: string) => boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare class UsageError extends Error {
|
|
20
|
+
constructor();
|
|
21
|
+
static isUsageErrorMessage: (msg?: string) => boolean;
|
|
22
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UsageError = exports.NetworkError = exports.GHESNotSupportedError = exports.CacheNotFoundError = exports.InvalidResponseError = exports.FilesNotFoundError = void 0;
|
|
4
|
+
class FilesNotFoundError extends Error {
|
|
5
|
+
constructor(files = []) {
|
|
6
|
+
let message = 'No files were found to upload';
|
|
7
|
+
if (files.length > 0) {
|
|
8
|
+
message += `: ${files.join(', ')}`;
|
|
9
|
+
}
|
|
10
|
+
super(message);
|
|
11
|
+
this.files = files;
|
|
12
|
+
this.name = 'FilesNotFoundError';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.FilesNotFoundError = FilesNotFoundError;
|
|
16
|
+
class InvalidResponseError extends Error {
|
|
17
|
+
constructor(message) {
|
|
18
|
+
super(message);
|
|
19
|
+
this.name = 'InvalidResponseError';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.InvalidResponseError = InvalidResponseError;
|
|
23
|
+
class CacheNotFoundError extends Error {
|
|
24
|
+
constructor(message = 'Cache not found') {
|
|
25
|
+
super(message);
|
|
26
|
+
this.name = 'CacheNotFoundError';
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.CacheNotFoundError = CacheNotFoundError;
|
|
30
|
+
class GHESNotSupportedError extends Error {
|
|
31
|
+
constructor(message = '@actions/cache v4.1.4+, actions/cache/save@v4+ and actions/cache/restore@v4+ are not currently supported on GHES.') {
|
|
32
|
+
super(message);
|
|
33
|
+
this.name = 'GHESNotSupportedError';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.GHESNotSupportedError = GHESNotSupportedError;
|
|
37
|
+
class NetworkError extends Error {
|
|
38
|
+
constructor(code) {
|
|
39
|
+
const message = `Unable to make request: ${code}\nIf you are using self-hosted runners, please make sure your runner has access to all GitHub endpoints: https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/about-self-hosted-runners#communication-between-self-hosted-runners-and-github`;
|
|
40
|
+
super(message);
|
|
41
|
+
this.code = code;
|
|
42
|
+
this.name = 'NetworkError';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.NetworkError = NetworkError;
|
|
46
|
+
NetworkError.isNetworkErrorCode = (code) => {
|
|
47
|
+
if (!code)
|
|
48
|
+
return false;
|
|
49
|
+
return [
|
|
50
|
+
'ECONNRESET',
|
|
51
|
+
'ENOTFOUND',
|
|
52
|
+
'ETIMEDOUT',
|
|
53
|
+
'ECONNREFUSED',
|
|
54
|
+
'EHOSTUNREACH'
|
|
55
|
+
].includes(code);
|
|
56
|
+
};
|
|
57
|
+
class UsageError extends Error {
|
|
58
|
+
constructor() {
|
|
59
|
+
const message = `Cache storage quota has been hit. Unable to upload any new cache entries. Usage is recalculated every 6-12 hours.\nMore info on storage limits: https://docs.github.com/en/billing/managing-billing-for-github-actions/about-billing-for-github-actions#calculating-minute-and-storage-spending`;
|
|
60
|
+
super(message);
|
|
61
|
+
this.name = 'UsageError';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.UsageError = UsageError;
|
|
65
|
+
UsageError.isUsageErrorMessage = (msg) => {
|
|
66
|
+
if (!msg)
|
|
67
|
+
return false;
|
|
68
|
+
return msg.includes('insufficient usage');
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/internal/shared/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,kBAAmB,SAAQ,KAAK;IAG3C,YAAY,QAAkB,EAAE;QAC9B,IAAI,OAAO,GAAG,+BAA+B,CAAA;Q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,CAAA;AAClB,CAAC,CAAA;AAGH,MAAa,UAAW,SAAQ,KAAK;IACnC;QACE,MAAM,OAAO,GAAG,iSAAiS,CAAA;QACjT,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,YAAY,CAAA;IAC1B,CAAC;;AALH,gCAWC;AAJQ,8BAAmB,GAAG,CAAC,GAAY,EAAW,EAAE;IACrD,IAAI,CAAC,GAAG;QAAE,OAAO,KAAK,CAAA;IACtB,OAAO,GAAG,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAA;AAC3C,CAAC,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getUserAgentString = void 0;
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
|
|
5
|
+
const packageJson = require('../../../package.json');
|
|
6
|
+
/**
|
|
7
|
+
* Ensure that this User Agent String is used in all HTTP calls so that we can monitor telemetry between different versions of this package
|
|
8
|
+
*/
|
|
9
|
+
function getUserAgentString() {
|
|
10
|
+
return `@actions/cache-${packageJson.version}`;
|
|
11
|
+
}
|
|
12
|
+
exports.getUserAgentString = getUserAgentString;
|
|
13
|
+
//# sourceMappingURL=user-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-agent.js","sourceRoot":"","sources":["../../../src/internal/shared/user-agent.ts"],"names":[],"mappings":";;;AAAA,qGAAqG;AACrG,MAAM,WAAW,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAA;AAEpD;;GAEG;AACH,SAAgB,kBAAkB;IAChC,OAAO,kBAAkB,WAAW,CAAC,OAAO,EAAE,CAAA;AAChD,CAAC;AAFD,gDAEC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { BlobUploadCommonResponse } from '@azure/storage-blob';
|
|
2
|
+
import { TransferProgressEvent } from '@azure/ms-rest-js';
|
|
3
|
+
import { UploadOptions } from '../options';
|
|
4
|
+
/**
|
|
5
|
+
* Class for tracking the upload state and displaying stats.
|
|
6
|
+
*/
|
|
7
|
+
export declare class UploadProgress {
|
|
8
|
+
contentLength: number;
|
|
9
|
+
sentBytes: number;
|
|
10
|
+
startTime: number;
|
|
11
|
+
displayedComplete: boolean;
|
|
12
|
+
timeoutHandle?: ReturnType<typeof setTimeout>;
|
|
13
|
+
constructor(contentLength: number);
|
|
14
|
+
/**
|
|
15
|
+
* Sets the number of bytes sent
|
|
16
|
+
*
|
|
17
|
+
* @param sentBytes the number of bytes sent
|
|
18
|
+
*/
|
|
19
|
+
setSentBytes(sentBytes: number): void;
|
|
20
|
+
/**
|
|
21
|
+
* Returns the total number of bytes transferred.
|
|
22
|
+
*/
|
|
23
|
+
getTransferredBytes(): number;
|
|
24
|
+
/**
|
|
25
|
+
* Returns true if the upload is complete.
|
|
26
|
+
*/
|
|
27
|
+
isDone(): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Prints the current upload stats. Once the upload completes, this will print one
|
|
30
|
+
* last line and then stop.
|
|
31
|
+
*/
|
|
32
|
+
display(): void;
|
|
33
|
+
/**
|
|
34
|
+
* Returns a function used to handle TransferProgressEvents.
|
|
35
|
+
*/
|
|
36
|
+
onProgress(): (progress: TransferProgressEvent) => void;
|
|
37
|
+
/**
|
|
38
|
+
* Starts the timer that displays the stats.
|
|
39
|
+
*
|
|
40
|
+
* @param delayInMs the delay between each write
|
|
41
|
+
*/
|
|
42
|
+
startDisplayTimer(delayInMs?: number): void;
|
|
43
|
+
/**
|
|
44
|
+
* Stops the timer that displays the stats. As this typically indicates the upload
|
|
45
|
+
* is complete, this will display one last line, unless the last line has already
|
|
46
|
+
* been written.
|
|
47
|
+
*/
|
|
48
|
+
stopDisplayTimer(): void;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Uploads a cache archive directly to Azure Blob Storage using the Azure SDK.
|
|
52
|
+
* This function will display progress information to the console. Concurrency of the
|
|
53
|
+
* upload is determined by the calling functions.
|
|
54
|
+
*
|
|
55
|
+
* @param signedUploadURL
|
|
56
|
+
* @param archivePath
|
|
57
|
+
* @param options
|
|
58
|
+
* @returns
|
|
59
|
+
*/
|
|
60
|
+
export declare function uploadCacheArchiveSDK(signedUploadURL: string, archivePath: string, options?: UploadOptions): Promise<BlobUploadCommonResponse>;
|