@actions/cache 5.0.4 → 6.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/lib/cache.d.ts +2 -1
- package/lib/cache.js +30 -72
- package/lib/cache.js.map +1 -1
- package/lib/generated/google/protobuf/timestamp.js +21 -24
- package/lib/generated/google/protobuf/timestamp.js.map +1 -1
- package/lib/generated/google/protobuf/wrappers.js +74 -77
- package/lib/generated/google/protobuf/wrappers.js.map +1 -1
- package/lib/generated/results/api/v1/cache.d.ts +1 -1
- package/lib/generated/results/api/v1/cache.js +73 -76
- package/lib/generated/results/api/v1/cache.js.map +1 -1
- package/lib/generated/results/api/v1/cache.twirp-client.d.ts +1 -1
- package/lib/generated/results/api/v1/cache.twirp-client.js +15 -20
- package/lib/generated/results/api/v1/cache.twirp-client.js.map +1 -1
- package/lib/generated/results/entities/v1/cachemetadata.d.ts +1 -1
- package/lib/generated/results/entities/v1/cachemetadata.js +16 -19
- package/lib/generated/results/entities/v1/cachemetadata.js.map +1 -1
- package/lib/generated/results/entities/v1/cachescope.js +13 -16
- package/lib/generated/results/entities/v1/cachescope.js.map +1 -1
- package/lib/internal/cacheHttpClient.d.ts +2 -2
- package/lib/internal/cacheHttpClient.js +36 -75
- package/lib/internal/cacheHttpClient.js.map +1 -1
- package/lib/internal/cacheUtils.d.ts +1 -1
- package/lib/internal/cacheUtils.js +27 -72
- package/lib/internal/cacheUtils.js.map +1 -1
- package/lib/internal/config.js +3 -8
- package/lib/internal/config.js.map +1 -1
- package/lib/internal/constants.js +14 -17
- package/lib/internal/constants.js.map +1 -1
- package/lib/internal/contracts.d.ts +37 -0
- package/lib/internal/contracts.js +2 -0
- package/lib/internal/contracts.js.map +1 -0
- package/lib/internal/downloadUtils.d.ts +1 -1
- package/lib/internal/downloadUtils.js +23 -64
- package/lib/internal/downloadUtils.js.map +1 -1
- package/lib/internal/requestUtils.d.ts +1 -1
- package/lib/internal/requestUtils.js +16 -57
- package/lib/internal/requestUtils.js.map +1 -1
- package/lib/internal/shared/cacheTwirpClient.d.ts +1 -1
- package/lib/internal/shared/cacheTwirpClient.js +36 -39
- package/lib/internal/shared/cacheTwirpClient.js.map +1 -1
- package/lib/internal/shared/errors.js +7 -17
- package/lib/internal/shared/errors.js.map +1 -1
- package/lib/internal/shared/package-version.cjs +7 -0
- package/lib/internal/shared/user-agent.js +3 -7
- package/lib/internal/shared/user-agent.js.map +1 -1
- package/lib/internal/shared/util.js +7 -11
- package/lib/internal/shared/util.js.map +1 -1
- package/lib/internal/tar.d.ts +1 -1
- package/lib/internal/tar.js +36 -74
- package/lib/internal/tar.js.map +1 -1
- package/lib/internal/uploadUtils.d.ts +1 -1
- package/lib/internal/uploadUtils.js +7 -45
- package/lib/internal/uploadUtils.js.map +1 -1
- package/lib/options.js +3 -40
- package/lib/options.js.map +1 -1
- package/package.json +20 -15
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,17 +7,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
8
|
});
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const cache_twirp_client_1 = require("../../generated/results/api/v1/cache.twirp-client");
|
|
21
|
-
const util_1 = require("./util");
|
|
10
|
+
import { info, debug, warning } from '@actions/core';
|
|
11
|
+
import { getUserAgentString } from './user-agent.js';
|
|
12
|
+
import { NetworkError, RateLimitError, UsageError } from './errors.js';
|
|
13
|
+
import { getCacheServiceURL } from '../config.js';
|
|
14
|
+
import { getRuntimeToken } from '../cacheUtils.js';
|
|
15
|
+
import { BearerCredentialHandler } from '@actions/http-client/lib/auth';
|
|
16
|
+
import { HttpClient, HttpCodes } from '@actions/http-client';
|
|
17
|
+
import { CacheServiceClientJSON } from '../../generated/results/api/v1/cache.twirp-client.js';
|
|
18
|
+
import { maskSecretUrls } from './util.js';
|
|
22
19
|
/**
|
|
23
20
|
* This class is a wrapper around the CacheServiceClientJSON class generated by Twirp.
|
|
24
21
|
*
|
|
@@ -31,8 +28,8 @@ class CacheServiceClient {
|
|
|
31
28
|
this.maxAttempts = 5;
|
|
32
29
|
this.baseRetryIntervalMilliseconds = 3000;
|
|
33
30
|
this.retryMultiplier = 1.5;
|
|
34
|
-
const token =
|
|
35
|
-
this.baseUrl =
|
|
31
|
+
const token = getRuntimeToken();
|
|
32
|
+
this.baseUrl = getCacheServiceURL();
|
|
36
33
|
if (maxAttempts) {
|
|
37
34
|
this.maxAttempts = maxAttempts;
|
|
38
35
|
}
|
|
@@ -42,8 +39,8 @@ class CacheServiceClient {
|
|
|
42
39
|
if (retryMultiplier) {
|
|
43
40
|
this.retryMultiplier = retryMultiplier;
|
|
44
41
|
}
|
|
45
|
-
this.httpClient = new
|
|
46
|
-
new
|
|
42
|
+
this.httpClient = new HttpClient(userAgent, [
|
|
43
|
+
new BearerCredentialHandler(token)
|
|
47
44
|
]);
|
|
48
45
|
}
|
|
49
46
|
// This function satisfies the Rpc interface. It is compatible with the JSON
|
|
@@ -51,7 +48,7 @@ class CacheServiceClient {
|
|
|
51
48
|
request(service, method, contentType, data) {
|
|
52
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53
50
|
const url = new URL(`/twirp/${service}/${method}`, this.baseUrl).href;
|
|
54
|
-
|
|
51
|
+
debug(`[Request] ${method} ${url}`);
|
|
55
52
|
const headers = {
|
|
56
53
|
'Content-Type': contentType
|
|
57
54
|
};
|
|
@@ -75,47 +72,47 @@ class CacheServiceClient {
|
|
|
75
72
|
const response = yield operation();
|
|
76
73
|
const statusCode = response.message.statusCode;
|
|
77
74
|
rawBody = yield response.readBody();
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
debug(`[Response] - ${response.message.statusCode}`);
|
|
76
|
+
debug(`Headers: ${JSON.stringify(response.message.headers, null, 2)}`);
|
|
80
77
|
const body = JSON.parse(rawBody);
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
maskSecretUrls(body);
|
|
79
|
+
debug(`Body: ${JSON.stringify(body, null, 2)}`);
|
|
83
80
|
if (this.isSuccessStatusCode(statusCode)) {
|
|
84
81
|
return { response, body };
|
|
85
82
|
}
|
|
86
83
|
isRetryable = this.isRetryableHttpStatusCode(statusCode);
|
|
87
84
|
errorMessage = `Failed request: (${statusCode}) ${response.message.statusMessage}`;
|
|
88
85
|
if (body.msg) {
|
|
89
|
-
if (
|
|
90
|
-
throw new
|
|
86
|
+
if (UsageError.isUsageErrorMessage(body.msg)) {
|
|
87
|
+
throw new UsageError();
|
|
91
88
|
}
|
|
92
89
|
errorMessage = `${errorMessage}: ${body.msg}`;
|
|
93
90
|
}
|
|
94
91
|
// Handle rate limiting - don't retry, just warn and exit
|
|
95
92
|
// For more info, see https://docs.github.com/en/actions/reference/limits
|
|
96
|
-
if (statusCode ===
|
|
93
|
+
if (statusCode === HttpCodes.TooManyRequests) {
|
|
97
94
|
const retryAfterHeader = response.message.headers['retry-after'];
|
|
98
95
|
if (retryAfterHeader) {
|
|
99
96
|
const parsedSeconds = parseInt(retryAfterHeader, 10);
|
|
100
97
|
if (!isNaN(parsedSeconds) && parsedSeconds > 0) {
|
|
101
|
-
|
|
98
|
+
warning(`You've hit a rate limit, your rate limit will reset in ${parsedSeconds} seconds`);
|
|
102
99
|
}
|
|
103
100
|
}
|
|
104
|
-
throw new
|
|
101
|
+
throw new RateLimitError(`Rate limited: ${errorMessage}`);
|
|
105
102
|
}
|
|
106
103
|
}
|
|
107
104
|
catch (error) {
|
|
108
105
|
if (error instanceof SyntaxError) {
|
|
109
|
-
|
|
106
|
+
debug(`Raw Body: ${rawBody}`);
|
|
110
107
|
}
|
|
111
|
-
if (error instanceof
|
|
108
|
+
if (error instanceof UsageError) {
|
|
112
109
|
throw error;
|
|
113
110
|
}
|
|
114
|
-
if (error instanceof
|
|
111
|
+
if (error instanceof RateLimitError) {
|
|
115
112
|
throw error;
|
|
116
113
|
}
|
|
117
|
-
if (
|
|
118
|
-
throw new
|
|
114
|
+
if (NetworkError.isNetworkErrorCode(error === null || error === void 0 ? void 0 : error.code)) {
|
|
115
|
+
throw new NetworkError(error === null || error === void 0 ? void 0 : error.code);
|
|
119
116
|
}
|
|
120
117
|
isRetryable = true;
|
|
121
118
|
errorMessage = error.message;
|
|
@@ -127,7 +124,7 @@ class CacheServiceClient {
|
|
|
127
124
|
throw new Error(`Failed to make request after ${this.maxAttempts} attempts: ${errorMessage}`);
|
|
128
125
|
}
|
|
129
126
|
const retryTimeMilliseconds = this.getExponentialRetryTimeMilliseconds(attempt);
|
|
130
|
-
|
|
127
|
+
info(`Attempt ${attempt + 1} of ${this.maxAttempts} failed with error: ${errorMessage}. Retrying request in ${retryTimeMilliseconds} ms...`);
|
|
131
128
|
yield this.sleep(retryTimeMilliseconds);
|
|
132
129
|
attempt++;
|
|
133
130
|
}
|
|
@@ -143,10 +140,10 @@ class CacheServiceClient {
|
|
|
143
140
|
if (!statusCode)
|
|
144
141
|
return false;
|
|
145
142
|
const retryableStatusCodes = [
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
143
|
+
HttpCodes.BadGateway,
|
|
144
|
+
HttpCodes.GatewayTimeout,
|
|
145
|
+
HttpCodes.InternalServerError,
|
|
146
|
+
HttpCodes.ServiceUnavailable
|
|
150
147
|
];
|
|
151
148
|
return retryableStatusCodes.includes(statusCode);
|
|
152
149
|
}
|
|
@@ -168,8 +165,8 @@ class CacheServiceClient {
|
|
|
168
165
|
return Math.trunc(Math.random() * (maxTime - minTime) + minTime);
|
|
169
166
|
}
|
|
170
167
|
}
|
|
171
|
-
function internalCacheTwirpClient(options) {
|
|
172
|
-
const client = new CacheServiceClient(
|
|
173
|
-
return new
|
|
168
|
+
export function internalCacheTwirpClient(options) {
|
|
169
|
+
const client = new CacheServiceClient(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);
|
|
170
|
+
return new CacheServiceClientJSON(client);
|
|
174
171
|
}
|
|
175
172
|
//# sourceMappingURL=cacheTwirpClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cacheTwirpClient.js","sourceRoot":"","sources":["../../../src/internal/shared/cacheTwirpClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cacheTwirpClient.js","sourceRoot":"","sources":["../../../src/internal/shared/cacheTwirpClient.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAC,MAAM,eAAe,CAAA;AAClD,OAAO,EAAC,kBAAkB,EAAC,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAC,YAAY,EAAE,cAAc,EAAE,UAAU,EAAC,MAAM,aAAa,CAAA;AACpE,OAAO,EAAC,kBAAkB,EAAC,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAC,eAAe,EAAC,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAC,uBAAuB,EAAC,MAAM,+BAA+B,CAAA;AACrE,OAAO,EAAC,UAAU,EAAsB,SAAS,EAAC,MAAM,sBAAsB,CAAA;AAC9E,OAAO,EAAC,sBAAsB,EAAC,MAAM,sDAAsD,CAAA;AAC3F,OAAO,EAAC,cAAc,EAAC,MAAM,WAAW,CAAA;AAYxC;;;;;;GAMG;AACH,MAAM,kBAAkB;IAOtB,YACE,SAAiB,EACjB,WAAoB,EACpB,6BAAsC,EACtC,eAAwB;QARlB,gBAAW,GAAG,CAAC,CAAA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AY,CAAC,CAAC,CAAA;QAClE,CAAC;KAAA;IAED,mCAAmC,CAAC,OAAe;QACjD,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAA;QACzD,CAAC;QAED,IAAI,OAAO,KAAK,CAAC,EAAE,CAAC;YAClB,OAAO,IAAI,CAAC,6BAA6B,CAAA;QAC3C,CAAC;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,MAAM,UAAU,wBAAwB,CAAC,OAIxC;IACC,MAAM,MAAM,GAAG,IAAI,kBAAkB,CACnC,kBAAkB,EAAE,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,sBAAsB,CAAC,MAAM,CAAC,CAAA;AAC3C,CAAC"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RateLimitError = exports.UsageError = exports.NetworkError = exports.GHESNotSupportedError = exports.CacheNotFoundError = exports.InvalidResponseError = exports.FilesNotFoundError = void 0;
|
|
4
|
-
class FilesNotFoundError extends Error {
|
|
1
|
+
export class FilesNotFoundError extends Error {
|
|
5
2
|
constructor(files = []) {
|
|
6
3
|
let message = 'No files were found to upload';
|
|
7
4
|
if (files.length > 0) {
|
|
@@ -12,29 +9,25 @@ class FilesNotFoundError extends Error {
|
|
|
12
9
|
this.name = 'FilesNotFoundError';
|
|
13
10
|
}
|
|
14
11
|
}
|
|
15
|
-
|
|
16
|
-
class InvalidResponseError extends Error {
|
|
12
|
+
export class InvalidResponseError extends Error {
|
|
17
13
|
constructor(message) {
|
|
18
14
|
super(message);
|
|
19
15
|
this.name = 'InvalidResponseError';
|
|
20
16
|
}
|
|
21
17
|
}
|
|
22
|
-
|
|
23
|
-
class CacheNotFoundError extends Error {
|
|
18
|
+
export class CacheNotFoundError extends Error {
|
|
24
19
|
constructor(message = 'Cache not found') {
|
|
25
20
|
super(message);
|
|
26
21
|
this.name = 'CacheNotFoundError';
|
|
27
22
|
}
|
|
28
23
|
}
|
|
29
|
-
|
|
30
|
-
class GHESNotSupportedError extends Error {
|
|
24
|
+
export class GHESNotSupportedError extends Error {
|
|
31
25
|
constructor(message = '@actions/cache v4.1.4+, actions/cache/save@v4+ and actions/cache/restore@v4+ are not currently supported on GHES.') {
|
|
32
26
|
super(message);
|
|
33
27
|
this.name = 'GHESNotSupportedError';
|
|
34
28
|
}
|
|
35
29
|
}
|
|
36
|
-
|
|
37
|
-
class NetworkError extends Error {
|
|
30
|
+
export class NetworkError extends Error {
|
|
38
31
|
constructor(code) {
|
|
39
32
|
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
33
|
super(message);
|
|
@@ -42,7 +35,6 @@ class NetworkError extends Error {
|
|
|
42
35
|
this.name = 'NetworkError';
|
|
43
36
|
}
|
|
44
37
|
}
|
|
45
|
-
exports.NetworkError = NetworkError;
|
|
46
38
|
NetworkError.isNetworkErrorCode = (code) => {
|
|
47
39
|
if (!code)
|
|
48
40
|
return false;
|
|
@@ -54,24 +46,22 @@ NetworkError.isNetworkErrorCode = (code) => {
|
|
|
54
46
|
'EHOSTUNREACH'
|
|
55
47
|
].includes(code);
|
|
56
48
|
};
|
|
57
|
-
class UsageError extends Error {
|
|
49
|
+
export class UsageError extends Error {
|
|
58
50
|
constructor() {
|
|
59
51
|
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
52
|
super(message);
|
|
61
53
|
this.name = 'UsageError';
|
|
62
54
|
}
|
|
63
55
|
}
|
|
64
|
-
exports.UsageError = UsageError;
|
|
65
56
|
UsageError.isUsageErrorMessage = (msg) => {
|
|
66
57
|
if (!msg)
|
|
67
58
|
return false;
|
|
68
59
|
return msg.includes('insufficient usage');
|
|
69
60
|
};
|
|
70
|
-
class RateLimitError extends Error {
|
|
61
|
+
export class RateLimitError extends Error {
|
|
71
62
|
constructor(message) {
|
|
72
63
|
super(message);
|
|
73
64
|
this.name = 'RateLimitError';
|
|
74
65
|
}
|
|
75
66
|
}
|
|
76
|
-
exports.RateLimitError = RateLimitError;
|
|
77
67
|
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/internal/shared/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/internal/shared/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAG3C,YAAY,QAAkB,EAAE;QAC9B,IAAI,OAAO,GAAG,+BAA+B,CAAA;QAC7C,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrB,OAAO,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAA;QACpC,CAAC;QAED,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,I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AI,CAAC,GAAG;QAAE,OAAO,KAAK,CAAA;IACtB,OAAO,GAAG,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAA;AAC3C,CAAC,CAAA;AAGH,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAA;IAC9B,CAAC;CACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// This file exists as a CommonJS module to read the version from package.json.
|
|
2
|
+
// In an ESM package, using `require()` directly in .ts files requires disabling
|
|
3
|
+
// ESLint rules and doesn't work reliably across all Node.js versions.
|
|
4
|
+
// By keeping this as a .cjs file, we can use require() naturally and export
|
|
5
|
+
// the version for the ESM modules to import.
|
|
6
|
+
const packageJson = require('../../../package.json')
|
|
7
|
+
module.exports = { version: packageJson.version }
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getUserAgentString = getUserAgentString;
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
|
|
5
|
-
const packageJson = require('../../../package.json');
|
|
1
|
+
import { version } from './package-version.cjs';
|
|
6
2
|
/**
|
|
7
3
|
* 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
4
|
*/
|
|
9
|
-
function getUserAgentString() {
|
|
10
|
-
return `@actions/cache-${
|
|
5
|
+
export function getUserAgentString() {
|
|
6
|
+
return `@actions/cache-${version}`;
|
|
11
7
|
}
|
|
12
8
|
//# sourceMappingURL=user-agent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-agent.js","sourceRoot":"","sources":["../../../src/internal/shared/user-agent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"user-agent.js","sourceRoot":"","sources":["../../../src/internal/shared/user-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,uBAAuB,CAAA;AAE7C;;GAEG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,kBAAkB,OAAO,EAAE,CAAA;AACpC,CAAC"}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.maskSigUrl = maskSigUrl;
|
|
4
|
-
exports.maskSecretUrls = maskSecretUrls;
|
|
5
|
-
const core_1 = require("@actions/core");
|
|
1
|
+
import { debug, setSecret } from '@actions/core';
|
|
6
2
|
/**
|
|
7
3
|
* Masks the `sig` parameter in a URL and sets it as a secret.
|
|
8
4
|
*
|
|
@@ -20,19 +16,19 @@ const core_1 = require("@actions/core");
|
|
|
20
16
|
* maskSigUrl('https://example.blob.core.windows.net/container/file.txt?sig=abc123&se=2023-01-01');
|
|
21
17
|
* ```
|
|
22
18
|
*/
|
|
23
|
-
function maskSigUrl(url) {
|
|
19
|
+
export function maskSigUrl(url) {
|
|
24
20
|
if (!url)
|
|
25
21
|
return;
|
|
26
22
|
try {
|
|
27
23
|
const parsedUrl = new URL(url);
|
|
28
24
|
const signature = parsedUrl.searchParams.get('sig');
|
|
29
25
|
if (signature) {
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
setSecret(signature);
|
|
27
|
+
setSecret(encodeURIComponent(signature));
|
|
32
28
|
}
|
|
33
29
|
}
|
|
34
30
|
catch (error) {
|
|
35
|
-
|
|
31
|
+
debug(`Failed to parse URL: ${url} ${error instanceof Error ? error.message : String(error)}`);
|
|
36
32
|
}
|
|
37
33
|
}
|
|
38
34
|
/**
|
|
@@ -56,9 +52,9 @@ function maskSigUrl(url) {
|
|
|
56
52
|
* maskSecretUrls(responseBody);
|
|
57
53
|
* ```
|
|
58
54
|
*/
|
|
59
|
-
function maskSecretUrls(body) {
|
|
55
|
+
export function maskSecretUrls(body) {
|
|
60
56
|
if (typeof body !== 'object' || body === null) {
|
|
61
|
-
|
|
57
|
+
debug('body is not an object or is null');
|
|
62
58
|
return;
|
|
63
59
|
}
|
|
64
60
|
if ('signed_upload_url' in body &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../../src/internal/shared/util.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../../src/internal/shared/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,SAAS,EAAC,MAAM,eAAe,CAAA;AAE9C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,IAAI,CAAC,GAAG;QAAE,OAAM;IAChB,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;QAC9B,MAAM,SAAS,GAAG,SAAS,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QACnD,IAAI,SAAS,EAAE,CAAC;YACd,SAAS,CAAC,SAAS,CAAC,CAAA;YACpB,SAAS,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,CAAA;QAC1C,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,KAAK,CACH,wBAAwB,GAAG,IACzB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CACvD,EAAE,CACH,CAAA;IACH,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,cAAc,CAAC,IAAoC;IACjE,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAC9C,KAAK,CAAC,kCAAkC,CAAC,CAAA;QACzC,OAAM;IACR,CAAC;IACD,IACE,mBAAmB,IAAI,IAAI;QAC3B,OAAO,IAAI,CAAC,iBAAiB,KAAK,QAAQ,EAC1C,CAAC;QACD,UAAU,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;IACpC,CAAC;IACD,IACE,qBAAqB,IAAI,IAAI;QAC7B,OAAO,IAAI,CAAC,mBAAmB,KAAK,QAAQ,EAC5C,CAAC;QACD,UAAU,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAA;IACtC,CAAC;AACH,CAAC"}
|
package/lib/internal/tar.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CompressionMethod } from './constants';
|
|
1
|
+
import { CompressionMethod } from './constants.js';
|
|
2
2
|
export declare function listTar(archivePath: string, compressionMethod: CompressionMethod): Promise<void>;
|
|
3
3
|
export declare function extractTar(archivePath: string, compressionMethod: CompressionMethod): Promise<void>;
|
|
4
4
|
export declare function createTar(archiveFolder: string, sourceDirectories: string[], compressionMethod: CompressionMethod): Promise<void>;
|
package/lib/internal/tar.js
CHANGED
|
@@ -1,37 +1,3 @@
|
|
|
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 () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -41,16 +7,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
41
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
8
|
});
|
|
43
9
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const fs_1 = require("fs");
|
|
51
|
-
const path = __importStar(require("path"));
|
|
52
|
-
const utils = __importStar(require("./cacheUtils"));
|
|
53
|
-
const constants_1 = require("./constants");
|
|
10
|
+
import { exec } from '@actions/exec';
|
|
11
|
+
import * as io from '@actions/io';
|
|
12
|
+
import { existsSync, writeFileSync } from 'fs';
|
|
13
|
+
import * as path from 'path';
|
|
14
|
+
import * as utils from './cacheUtils.js';
|
|
15
|
+
import { CompressionMethod, SystemTarPathOnWindows, ArchiveToolType, TarFilename, ManifestFilename } from './constants.js';
|
|
54
16
|
const IS_WINDOWS = process.platform === 'win32';
|
|
55
17
|
// Returns tar path and type: BSD or GNU
|
|
56
18
|
function getTarPath() {
|
|
@@ -58,13 +20,13 @@ function getTarPath() {
|
|
|
58
20
|
switch (process.platform) {
|
|
59
21
|
case 'win32': {
|
|
60
22
|
const gnuTar = yield utils.getGnuTarPathOnWindows();
|
|
61
|
-
const systemTar =
|
|
23
|
+
const systemTar = SystemTarPathOnWindows;
|
|
62
24
|
if (gnuTar) {
|
|
63
25
|
// Use GNUtar as default on windows
|
|
64
|
-
return { path: gnuTar, type:
|
|
26
|
+
return { path: gnuTar, type: ArchiveToolType.GNU };
|
|
65
27
|
}
|
|
66
|
-
else if (
|
|
67
|
-
return { path: systemTar, type:
|
|
28
|
+
else if (existsSync(systemTar)) {
|
|
29
|
+
return { path: systemTar, type: ArchiveToolType.BSD };
|
|
68
30
|
}
|
|
69
31
|
break;
|
|
70
32
|
}
|
|
@@ -72,12 +34,12 @@ function getTarPath() {
|
|
|
72
34
|
const gnuTar = yield io.which('gtar', false);
|
|
73
35
|
if (gnuTar) {
|
|
74
36
|
// fix permission denied errors when extracting BSD tar archive with GNU tar - https://github.com/actions/cache/issues/527
|
|
75
|
-
return { path: gnuTar, type:
|
|
37
|
+
return { path: gnuTar, type: ArchiveToolType.GNU };
|
|
76
38
|
}
|
|
77
39
|
else {
|
|
78
40
|
return {
|
|
79
41
|
path: yield io.which('tar', true),
|
|
80
|
-
type:
|
|
42
|
+
type: ArchiveToolType.BSD
|
|
81
43
|
};
|
|
82
44
|
}
|
|
83
45
|
}
|
|
@@ -87,7 +49,7 @@ function getTarPath() {
|
|
|
87
49
|
// Default assumption is GNU tar is present in path
|
|
88
50
|
return {
|
|
89
51
|
path: yield io.which('tar', true),
|
|
90
|
-
type:
|
|
52
|
+
type: ArchiveToolType.GNU
|
|
91
53
|
};
|
|
92
54
|
});
|
|
93
55
|
}
|
|
@@ -99,8 +61,8 @@ function getTarArgs(tarPath_1, compressionMethod_1, type_1) {
|
|
|
99
61
|
const tarFile = 'cache.tar';
|
|
100
62
|
const workingDirectory = getWorkingDirectory();
|
|
101
63
|
// Speficic args for BSD tar on windows for workaround
|
|
102
|
-
const BSD_TAR_ZSTD = tarPath.type ===
|
|
103
|
-
compressionMethod !==
|
|
64
|
+
const BSD_TAR_ZSTD = tarPath.type === ArchiveToolType.BSD &&
|
|
65
|
+
compressionMethod !== CompressionMethod.Gzip &&
|
|
104
66
|
IS_WINDOWS;
|
|
105
67
|
// Method specific args
|
|
106
68
|
switch (type) {
|
|
@@ -109,7 +71,7 @@ function getTarArgs(tarPath_1, compressionMethod_1, type_1) {
|
|
|
109
71
|
? tarFile
|
|
110
72
|
: cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '--exclude', BSD_TAR_ZSTD
|
|
111
73
|
? tarFile
|
|
112
|
-
: cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P', '-C', workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '--files-from',
|
|
74
|
+
: cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P', '-C', workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '--files-from', ManifestFilename);
|
|
113
75
|
break;
|
|
114
76
|
case 'extract':
|
|
115
77
|
args.push('-xf', BSD_TAR_ZSTD
|
|
@@ -123,7 +85,7 @@ function getTarArgs(tarPath_1, compressionMethod_1, type_1) {
|
|
|
123
85
|
break;
|
|
124
86
|
}
|
|
125
87
|
// Platform specific args
|
|
126
|
-
if (tarPath.type ===
|
|
88
|
+
if (tarPath.type === ArchiveToolType.GNU) {
|
|
127
89
|
switch (process.platform) {
|
|
128
90
|
case 'win32':
|
|
129
91
|
args.push('--force-local');
|
|
@@ -145,8 +107,8 @@ function getCommands(compressionMethod_1, type_1) {
|
|
|
145
107
|
const compressionArgs = type !== 'create'
|
|
146
108
|
? yield getDecompressionProgram(tarPath, compressionMethod, archivePath)
|
|
147
109
|
: yield getCompressionProgram(tarPath, compressionMethod);
|
|
148
|
-
const BSD_TAR_ZSTD = tarPath.type ===
|
|
149
|
-
compressionMethod !==
|
|
110
|
+
const BSD_TAR_ZSTD = tarPath.type === ArchiveToolType.BSD &&
|
|
111
|
+
compressionMethod !== CompressionMethod.Gzip &&
|
|
150
112
|
IS_WINDOWS;
|
|
151
113
|
if (BSD_TAR_ZSTD && type !== 'create') {
|
|
152
114
|
args = [[...compressionArgs].join(' '), [...tarArgs].join(' ')];
|
|
@@ -171,26 +133,26 @@ function getDecompressionProgram(tarPath, compressionMethod, archivePath) {
|
|
|
171
133
|
// unzstd is equivalent to 'zstd -d'
|
|
172
134
|
// --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
|
|
173
135
|
// Using 30 here because we also support 32-bit self-hosted runners.
|
|
174
|
-
const BSD_TAR_ZSTD = tarPath.type ===
|
|
175
|
-
compressionMethod !==
|
|
136
|
+
const BSD_TAR_ZSTD = tarPath.type === ArchiveToolType.BSD &&
|
|
137
|
+
compressionMethod !== CompressionMethod.Gzip &&
|
|
176
138
|
IS_WINDOWS;
|
|
177
139
|
switch (compressionMethod) {
|
|
178
|
-
case
|
|
140
|
+
case CompressionMethod.Zstd:
|
|
179
141
|
return BSD_TAR_ZSTD
|
|
180
142
|
? [
|
|
181
143
|
'zstd -d --long=30 --force -o',
|
|
182
|
-
|
|
144
|
+
TarFilename,
|
|
183
145
|
archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/')
|
|
184
146
|
]
|
|
185
147
|
: [
|
|
186
148
|
'--use-compress-program',
|
|
187
149
|
IS_WINDOWS ? '"zstd -d --long=30"' : 'unzstd --long=30'
|
|
188
150
|
];
|
|
189
|
-
case
|
|
151
|
+
case CompressionMethod.ZstdWithoutLong:
|
|
190
152
|
return BSD_TAR_ZSTD
|
|
191
153
|
? [
|
|
192
154
|
'zstd -d --force -o',
|
|
193
|
-
|
|
155
|
+
TarFilename,
|
|
194
156
|
archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/')
|
|
195
157
|
]
|
|
196
158
|
: ['--use-compress-program', IS_WINDOWS ? '"zstd -d"' : 'unzstd'];
|
|
@@ -208,27 +170,27 @@ function getDecompressionProgram(tarPath, compressionMethod, archivePath) {
|
|
|
208
170
|
function getCompressionProgram(tarPath, compressionMethod) {
|
|
209
171
|
return __awaiter(this, void 0, void 0, function* () {
|
|
210
172
|
const cacheFileName = utils.getCacheFileName(compressionMethod);
|
|
211
|
-
const BSD_TAR_ZSTD = tarPath.type ===
|
|
212
|
-
compressionMethod !==
|
|
173
|
+
const BSD_TAR_ZSTD = tarPath.type === ArchiveToolType.BSD &&
|
|
174
|
+
compressionMethod !== CompressionMethod.Gzip &&
|
|
213
175
|
IS_WINDOWS;
|
|
214
176
|
switch (compressionMethod) {
|
|
215
|
-
case
|
|
177
|
+
case CompressionMethod.Zstd:
|
|
216
178
|
return BSD_TAR_ZSTD
|
|
217
179
|
? [
|
|
218
180
|
'zstd -T0 --long=30 --force -o',
|
|
219
181
|
cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
|
220
|
-
|
|
182
|
+
TarFilename
|
|
221
183
|
]
|
|
222
184
|
: [
|
|
223
185
|
'--use-compress-program',
|
|
224
186
|
IS_WINDOWS ? '"zstd -T0 --long=30"' : 'zstdmt --long=30'
|
|
225
187
|
];
|
|
226
|
-
case
|
|
188
|
+
case CompressionMethod.ZstdWithoutLong:
|
|
227
189
|
return BSD_TAR_ZSTD
|
|
228
190
|
? [
|
|
229
191
|
'zstd -T0 --force -o',
|
|
230
192
|
cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
|
231
|
-
|
|
193
|
+
TarFilename
|
|
232
194
|
]
|
|
233
195
|
: ['--use-compress-program', IS_WINDOWS ? '"zstd -T0"' : 'zstdmt'];
|
|
234
196
|
default:
|
|
@@ -241,7 +203,7 @@ function execCommands(commands, cwd) {
|
|
|
241
203
|
return __awaiter(this, void 0, void 0, function* () {
|
|
242
204
|
for (const command of commands) {
|
|
243
205
|
try {
|
|
244
|
-
yield
|
|
206
|
+
yield exec(command, undefined, {
|
|
245
207
|
cwd,
|
|
246
208
|
env: Object.assign(Object.assign({}, process.env), { MSYS: 'winsymlinks:nativestrict' })
|
|
247
209
|
});
|
|
@@ -253,14 +215,14 @@ function execCommands(commands, cwd) {
|
|
|
253
215
|
});
|
|
254
216
|
}
|
|
255
217
|
// List the contents of a tar
|
|
256
|
-
function listTar(archivePath, compressionMethod) {
|
|
218
|
+
export function listTar(archivePath, compressionMethod) {
|
|
257
219
|
return __awaiter(this, void 0, void 0, function* () {
|
|
258
220
|
const commands = yield getCommands(compressionMethod, 'list', archivePath);
|
|
259
221
|
yield execCommands(commands);
|
|
260
222
|
});
|
|
261
223
|
}
|
|
262
224
|
// Extract a tar
|
|
263
|
-
function extractTar(archivePath, compressionMethod) {
|
|
225
|
+
export function extractTar(archivePath, compressionMethod) {
|
|
264
226
|
return __awaiter(this, void 0, void 0, function* () {
|
|
265
227
|
// Create directory to extract tar into
|
|
266
228
|
const workingDirectory = getWorkingDirectory();
|
|
@@ -270,10 +232,10 @@ function extractTar(archivePath, compressionMethod) {
|
|
|
270
232
|
});
|
|
271
233
|
}
|
|
272
234
|
// Create a tar
|
|
273
|
-
function createTar(archiveFolder, sourceDirectories, compressionMethod) {
|
|
235
|
+
export function createTar(archiveFolder, sourceDirectories, compressionMethod) {
|
|
274
236
|
return __awaiter(this, void 0, void 0, function* () {
|
|
275
237
|
// Write source directories to manifest.txt to avoid command length limits
|
|
276
|
-
|
|
238
|
+
writeFileSync(path.join(archiveFolder, ManifestFilename), sourceDirectories.join('\n'));
|
|
277
239
|
const commands = yield getCommands(compressionMethod, 'create');
|
|
278
240
|
yield execCommands(commands, archiveFolder);
|
|
279
241
|
});
|