@actions/cache 3.3.0 → 4.0.1
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 +205 -0
- package/lib/generated/results/api/v1/cache.js +388 -0
- package/lib/generated/results/api/v1/cache.js.map +1 -0
- package/lib/generated/results/api/v1/cache.twirp-client.d.ts +24 -0
- package/lib/generated/results/api/v1/cache.twirp-client.js +68 -0
- package/lib/generated/results/api/v1/cache.twirp-client.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 +26 -8
- 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 +2 -1
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
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_client_1 = require("../../generated/results/api/v1/cache.twirp-client");
|
|
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_client_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,0FAAwF;AAYxF;;;;;;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,IAA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A;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;QAC7C,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;YACpB,OAAO,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAA;SACnC;QAED,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAA;IAClC,CAAC;CACF;AAbD,gDAaC;AAED,MAAa,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAA;IACpC,CAAC;CACF;AALD,oDAKC;AAED,MAAa,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAO,GAAG,iBAAiB;QACrC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAA;IAClC,CAAC;CACF;AALD,gDAKC;AAED,MAAa,qBAAsB,SAAQ,KAAK;IAC9C,YACE,OAAO,GAAG,mHAAmH;QAE7H,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAA;IACrC,CAAC;CACF;AAPD,sDAOC;AAED,MAAa,YAAa,SAAQ,KAAK;IAGrC,YAAY,IAAY;QACtB,MAAM,OAAO,GAAG,2BAA2B,IAAI,kRAAkR,CAAA;QACjU,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,IAAI,GAAG,cAAc,CAAA;IAC5B,CAAC;;AARH,oCAoBC;AAVQ,+BAAkB,GAAG,CAAC,IAAa,EAAW,EAAE;IACrD,IAAI,CAAC,IAAI;QAAE,OAAO,KAAK,CAAA;IACvB,OAAO;QACL,YAAY;QACZ,WAAW;QACX,WAAW;QACX,cAAc;QACd,cAAc;KACf,CAAC,QAAQ,CAAC,IAAI,CAAC,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>;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.uploadCacheArchiveSDK = exports.UploadProgress = void 0;
|
|
36
|
+
const core = __importStar(require("@actions/core"));
|
|
37
|
+
const storage_blob_1 = require("@azure/storage-blob");
|
|
38
|
+
const errors_1 = require("./shared/errors");
|
|
39
|
+
/**
|
|
40
|
+
* Class for tracking the upload state and displaying stats.
|
|
41
|
+
*/
|
|
42
|
+
class UploadProgress {
|
|
43
|
+
constructor(contentLength) {
|
|
44
|
+
this.contentLength = contentLength;
|
|
45
|
+
this.sentBytes = 0;
|
|
46
|
+
this.displayedComplete = false;
|
|
47
|
+
this.startTime = Date.now();
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Sets the number of bytes sent
|
|
51
|
+
*
|
|
52
|
+
* @param sentBytes the number of bytes sent
|
|
53
|
+
*/
|
|
54
|
+
setSentBytes(sentBytes) {
|
|
55
|
+
this.sentBytes = sentBytes;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Returns the total number of bytes transferred.
|
|
59
|
+
*/
|
|
60
|
+
getTransferredBytes() {
|
|
61
|
+
return this.sentBytes;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Returns true if the upload is complete.
|
|
65
|
+
*/
|
|
66
|
+
isDone() {
|
|
67
|
+
return this.getTransferredBytes() === this.contentLength;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Prints the current upload stats. Once the upload completes, this will print one
|
|
71
|
+
* last line and then stop.
|
|
72
|
+
*/
|
|
73
|
+
display() {
|
|
74
|
+
if (this.displayedComplete) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const transferredBytes = this.sentBytes;
|
|
78
|
+
const percentage = (100 * (transferredBytes / this.contentLength)).toFixed(1);
|
|
79
|
+
const elapsedTime = Date.now() - this.startTime;
|
|
80
|
+
const uploadSpeed = (transferredBytes /
|
|
81
|
+
(1024 * 1024) /
|
|
82
|
+
(elapsedTime / 1000)).toFixed(1);
|
|
83
|
+
core.info(`Sent ${transferredBytes} of ${this.contentLength} (${percentage}%), ${uploadSpeed} MBs/sec`);
|
|
84
|
+
if (this.isDone()) {
|
|
85
|
+
this.displayedComplete = true;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Returns a function used to handle TransferProgressEvents.
|
|
90
|
+
*/
|
|
91
|
+
onProgress() {
|
|
92
|
+
return (progress) => {
|
|
93
|
+
this.setSentBytes(progress.loadedBytes);
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Starts the timer that displays the stats.
|
|
98
|
+
*
|
|
99
|
+
* @param delayInMs the delay between each write
|
|
100
|
+
*/
|
|
101
|
+
startDisplayTimer(delayInMs = 1000) {
|
|
102
|
+
const displayCallback = () => {
|
|
103
|
+
this.display();
|
|
104
|
+
if (!this.isDone()) {
|
|
105
|
+
this.timeoutHandle = setTimeout(displayCallback, delayInMs);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
this.timeoutHandle = setTimeout(displayCallback, delayInMs);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Stops the timer that displays the stats. As this typically indicates the upload
|
|
112
|
+
* is complete, this will display one last line, unless the last line has already
|
|
113
|
+
* been written.
|
|
114
|
+
*/
|
|
115
|
+
stopDisplayTimer() {
|
|
116
|
+
if (this.timeoutHandle) {
|
|
117
|
+
clearTimeout(this.timeoutHandle);
|
|
118
|
+
this.timeoutHandle = undefined;
|
|
119
|
+
}
|
|
120
|
+
this.display();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
exports.UploadProgress = UploadProgress;
|
|
124
|
+
/**
|
|
125
|
+
* Uploads a cache archive directly to Azure Blob Storage using the Azure SDK.
|
|
126
|
+
* This function will display progress information to the console. Concurrency of the
|
|
127
|
+
* upload is determined by the calling functions.
|
|
128
|
+
*
|
|
129
|
+
* @param signedUploadURL
|
|
130
|
+
* @param archivePath
|
|
131
|
+
* @param options
|
|
132
|
+
* @returns
|
|
133
|
+
*/
|
|
134
|
+
function uploadCacheArchiveSDK(signedUploadURL, archivePath, options) {
|
|
135
|
+
var _a;
|
|
136
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
137
|
+
const blobClient = new storage_blob_1.BlobClient(signedUploadURL);
|
|
138
|
+
const blockBlobClient = blobClient.getBlockBlobClient();
|
|
139
|
+
const uploadProgress = new UploadProgress((_a = options === null || options === void 0 ? void 0 : options.archiveSizeBytes) !== null && _a !== void 0 ? _a : 0);
|
|
140
|
+
// Specify data transfer options
|
|
141
|
+
const uploadOptions = {
|
|
142
|
+
blockSize: options === null || options === void 0 ? void 0 : options.uploadChunkSize,
|
|
143
|
+
concurrency: options === null || options === void 0 ? void 0 : options.uploadConcurrency,
|
|
144
|
+
maxSingleShotSize: 128 * 1024 * 1024,
|
|
145
|
+
onProgress: uploadProgress.onProgress()
|
|
146
|
+
};
|
|
147
|
+
try {
|
|
148
|
+
uploadProgress.startDisplayTimer();
|
|
149
|
+
core.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`);
|
|
150
|
+
const response = yield blockBlobClient.uploadFile(archivePath, uploadOptions);
|
|
151
|
+
// TODO: better management of non-retryable errors
|
|
152
|
+
if (response._response.status >= 400) {
|
|
153
|
+
throw new errors_1.InvalidResponseError(`uploadCacheArchiveSDK: upload failed with status code ${response._response.status}`);
|
|
154
|
+
}
|
|
155
|
+
return response;
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
core.warning(`uploadCacheArchiveSDK: internal error uploading cache archive: ${error.message}`);
|
|
159
|
+
throw error;
|
|
160
|
+
}
|
|
161
|
+
finally {
|
|
162
|
+
uploadProgress.stopDisplayTimer();
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
exports.uploadCacheArchiveSDK = uploadCacheArchiveSDK;
|
|
167
|
+
//# sourceMappingURL=uploadUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uploadUtils.js","sourceRoot":"","sources":["../../src/internal/uploadUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAqC;AACrC,sDAK4B;AAE5B,4CAAoD;AAGpD;;GAEG;AACH,MAAa,cAAc;IAOzB,YAAY,aAAqB;QAC/B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;QAClC,IAAI,CAAC,SAAS,GAAG,CAAC,CAAA;QAClB,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAA;QAC9B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;IAC7B,CAAC;IAED;;;;OAIG;IACH,YAAY,CAAC,SAAiB;QAC5B,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AAU,CAC/C,WAAW,EACX,aAAa,CACd,CAAA;YAED,kDAAkD;YAClD,IAAI,QAAQ,CAAC,SAAS,CAAC,MAAM,IAAI,GAAG,EAAE;gBACpC,MAAM,IAAI,6BAAoB,CAC5B,yDAAyD,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,CACrF,CAAA;aACF;YAED,OAAO,QAAQ,CAAA;SAChB;QAAC,OAAO,KAAK,EAAE;YACd,IAAI,CAAC,OAAO,CACV,kEAAkE,KAAK,CAAC,OAAO,EAAE,CAClF,CAAA;YACD,MAAM,KAAK,CAAA;SACZ;gBAAS;YACR,cAAc,CAAC,gBAAgB,EAAE,CAAA;SAClC;;CACF;AA7CD,sDA6CC"}
|
package/lib/options.d.ts
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
* Options to control cache upload
|
|
3
3
|
*/
|
|
4
4
|
export interface UploadOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Indicates whether to use the Azure Blob SDK to download caches
|
|
7
|
+
* that are stored on Azure Blob Storage to improve reliability and
|
|
8
|
+
* performance
|
|
9
|
+
*
|
|
10
|
+
* @default false
|
|
11
|
+
*/
|
|
12
|
+
useAzureSdk?: boolean;
|
|
5
13
|
/**
|
|
6
14
|
* Number of parallel cache upload
|
|
7
15
|
*
|
|
@@ -14,6 +22,10 @@ export interface UploadOptions {
|
|
|
14
22
|
* @default 32MB
|
|
15
23
|
*/
|
|
16
24
|
uploadChunkSize?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Archive size in bytes
|
|
27
|
+
*/
|
|
28
|
+
archiveSizeBytes?: number;
|
|
17
29
|
}
|
|
18
30
|
/**
|
|
19
31
|
* Options to control cache download
|
package/lib/options.js
CHANGED
|
@@ -31,11 +31,16 @@ const core = __importStar(require("@actions/core"));
|
|
|
31
31
|
* @param copy the original upload options
|
|
32
32
|
*/
|
|
33
33
|
function getUploadOptions(copy) {
|
|
34
|
+
// Defaults if not overriden
|
|
34
35
|
const result = {
|
|
36
|
+
useAzureSdk: false,
|
|
35
37
|
uploadConcurrency: 4,
|
|
36
38
|
uploadChunkSize: 32 * 1024 * 1024
|
|
37
39
|
};
|
|
38
40
|
if (copy) {
|
|
41
|
+
if (typeof copy.useAzureSdk === 'boolean') {
|
|
42
|
+
result.useAzureSdk = copy.useAzureSdk;
|
|
43
|
+
}
|
|
39
44
|
if (typeof copy.uploadConcurrency === 'number') {
|
|
40
45
|
result.uploadConcurrency = copy.uploadConcurrency;
|
|
41
46
|
}
|
|
@@ -43,6 +48,18 @@ function getUploadOptions(copy) {
|
|
|
43
48
|
result.uploadChunkSize = copy.uploadChunkSize;
|
|
44
49
|
}
|
|
45
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Add env var overrides
|
|
53
|
+
*/
|
|
54
|
+
// Cap the uploadConcurrency at 32
|
|
55
|
+
result.uploadConcurrency = !isNaN(Number(process.env['CACHE_UPLOAD_CONCURRENCY']))
|
|
56
|
+
? Math.min(32, Number(process.env['CACHE_UPLOAD_CONCURRENCY']))
|
|
57
|
+
: result.uploadConcurrency;
|
|
58
|
+
// Cap the uploadChunkSize at 128MiB
|
|
59
|
+
result.uploadChunkSize = !isNaN(Number(process.env['CACHE_UPLOAD_CHUNK_SIZE']))
|
|
60
|
+
? Math.min(128 * 1024 * 1024, Number(process.env['CACHE_UPLOAD_CHUNK_SIZE']) * 1024 * 1024)
|
|
61
|
+
: result.uploadChunkSize;
|
|
62
|
+
core.debug(`Use Azure SDK: ${result.useAzureSdk}`);
|
|
46
63
|
core.debug(`Upload concurrency: ${result.uploadConcurrency}`);
|
|
47
64
|
core.debug(`Upload chunk size: ${result.uploadChunkSize}`);
|
|
48
65
|
return result;
|
package/lib/options.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAqC;
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot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AU,KAAK,SAAS,EAAE;YACxC,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAA;SACpC;KACF;IACD,MAAM,0BAA0B,GAC9B,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAA;IAE9C,IACE,0BAA0B;QAC1B,CAAC,KAAK,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC;QAC1C,QAAQ,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC,EAC5C;QACA,MAAM,CAAC,kBAAkB,GAAG,MAAM,CAAC,0BAA0B,CAAC,GAAG,EAAE,GAAG,IAAI,CAAA;KAC3E;IACD,IAAI,CAAC,KAAK,CAAC,kBAAkB,MAAM,CAAC,WAAW,EAAE,CAAC,CAAA;IAClD,IAAI,CAAC,KAAK,CAAC,yBAAyB,MAAM,CAAC,mBAAmB,EAAE,CAAC,CAAA;IACjE,IAAI,CAAC,KAAK,CAAC,yBAAyB,MAAM,CAAC,WAAW,EAAE,CAAC,CAAA;IACzD,IAAI,CAAC,KAAK,CACR,gDAAgD,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,EAAE,CAC/F,CAAA;IACD,IAAI,CAAC,KAAK,CAAC,kCAAkC,MAAM,CAAC,kBAAkB,EAAE,CAAC,CAAA;IACzE,IAAI,CAAC,KAAK,CAAC,gBAAgB,MAAM,CAAC,UAAU,EAAE,CAAC,CAAA;IAE/C,OAAO,MAAM,CAAA;AACf,CAAC;AAvDD,gDAuDC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@actions/cache",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"preview": true,
|
|
5
5
|
"description": "Actions cache lib",
|
|
6
6
|
"keywords": [
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"@azure/abort-controller": "^1.1.0",
|
|
46
46
|
"@azure/ms-rest-js": "^2.6.0",
|
|
47
47
|
"@azure/storage-blob": "^12.13.0",
|
|
48
|
+
"@protobuf-ts/plugin": "^2.9.4",
|
|
48
49
|
"semver": "^6.3.1"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|