Update node_modules

This commit is contained in:
crazy-max 2020-03-10 20:09:37 +00:00
parent 61f0b011eb
commit 5de4fb0015
6 changed files with 57 additions and 50 deletions

View File

@ -6,7 +6,7 @@ export declare class RetryHelper {
private minSeconds; private minSeconds;
private maxSeconds; private maxSeconds;
constructor(maxAttempts: number, minSeconds: number, maxSeconds: number); constructor(maxAttempts: number, minSeconds: number, maxSeconds: number);
execute<T>(action: () => Promise<T>): Promise<T>; execute<T>(action: () => Promise<T>, isRetryable?: (e: Error) => boolean): Promise<T>;
private getSleepAmount; private getSleepAmount;
private sleep; private sleep;
} }

View File

@ -32,7 +32,7 @@ class RetryHelper {
throw new Error('min seconds should be less than or equal to max seconds'); throw new Error('min seconds should be less than or equal to max seconds');
} }
} }
execute(action) { execute(action, isRetryable) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let attempt = 1; let attempt = 1;
while (attempt < this.maxAttempts) { while (attempt < this.maxAttempts) {
@ -41,6 +41,9 @@ class RetryHelper {
return yield action(); return yield action();
} }
catch (err) { catch (err) {
if (isRetryable && !isRetryable(err)) {
throw err;
}
core.info(err.message); core.info(err.message);
} }
// Sleep // Sleep

View File

@ -1 +1 @@
{"version":3,"file":"retry-helper.js","sourceRoot":"","sources":["../src/retry-helper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,oDAAqC;AAErC;;GAEG;AACH,MAAa,WAAW;IAKtB,YAAY,WAAmB,EAAE,UAAkB,EAAE,UAAkB;QACrE,IAAI,WAAW,GAAG,CAAC,EAAE;YACnB,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAA;SACrE;QAED,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;QACxC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;QACxC,IAAI,IAAI,CAAC,UAA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,CAAA;IACH,CAAC;IAEa,KAAK,CAAC,OAAe;;YACjC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC,CAAC,CAAA;QACpE,CAAC;KAAA;CACF;AAxDD,kCAwDC"}

View File

@ -42,31 +42,6 @@ class HTTPError extends Error {
exports.HTTPError = HTTPError; exports.HTTPError = HTTPError;
const IS_WINDOWS = process.platform === 'win32'; const IS_WINDOWS = process.platform === 'win32';
const userAgent = 'actions/tool-cache'; const userAgent = 'actions/tool-cache';
// On load grab temp directory and cache directory and remove them from env (currently don't want to expose this)
let tempDirectory = process.env['RUNNER_TEMP'] || '';
let cacheRoot = process.env['RUNNER_TOOL_CACHE'] || '';
// If directories not found, place them in common temp locations
if (!tempDirectory || !cacheRoot) {
let baseLocation;
if (IS_WINDOWS) {
// On windows use the USERPROFILE env variable
baseLocation = process.env['USERPROFILE'] || 'C:\\';
}
else {
if (process.platform === 'darwin') {
baseLocation = '/Users';
}
else {
baseLocation = '/home';
}
}
if (!tempDirectory) {
tempDirectory = path.join(baseLocation, 'actions', 'temp');
}
if (!cacheRoot) {
cacheRoot = path.join(baseLocation, 'actions', 'cache');
}
}
/** /**
* Download a tool from an url and stream it into a file * Download a tool from an url and stream it into a file
* *
@ -76,15 +51,28 @@ if (!tempDirectory || !cacheRoot) {
*/ */
function downloadTool(url, dest) { function downloadTool(url, dest) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
dest = dest || path.join(tempDirectory, v4_1.default()); dest = dest || path.join(_getTempDirectory(), v4_1.default());
yield io.mkdirP(path.dirname(dest)); yield io.mkdirP(path.dirname(dest));
core.debug(`Downloading ${url}`); core.debug(`Downloading ${url}`);
core.debug(`Destination ${dest}`); core.debug(`Destination ${dest}`);
const maxAttempts = 3; const maxAttempts = 3;
const minSeconds = getGlobal('TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS', 10); const minSeconds = _getGlobal('TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS', 10);
const maxSeconds = getGlobal('TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS', 20); const maxSeconds = _getGlobal('TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS', 20);
const retryHelper = new retry_helper_1.RetryHelper(maxAttempts, minSeconds, maxSeconds); const retryHelper = new retry_helper_1.RetryHelper(maxAttempts, minSeconds, maxSeconds);
return yield retryHelper.execute(() => __awaiter(this, void 0, void 0, function* () { return yield downloadToolAttempt(url, dest || ''); })); return yield retryHelper.execute(() => __awaiter(this, void 0, void 0, function* () {
return yield downloadToolAttempt(url, dest || '');
}), (err) => {
if (err instanceof HTTPError && err.httpStatusCode) {
// Don't retry anything less than 500, except 408 Request Timeout and 429 Too Many Requests
if (err.httpStatusCode < 500 &&
err.httpStatusCode !== 408 &&
err.httpStatusCode !== 429) {
return false;
}
}
// Otherwise retry
return true;
});
}); });
} }
exports.downloadTool = downloadTool; exports.downloadTool = downloadTool;
@ -105,7 +93,7 @@ function downloadToolAttempt(url, dest) {
} }
// Download the response body // Download the response body
const pipeline = util.promisify(stream.pipeline); const pipeline = util.promisify(stream.pipeline);
const responseMessageFactory = getGlobal('TEST_DOWNLOAD_TOOL_RESPONSE_MESSAGE_FACTORY', () => response.message); const responseMessageFactory = _getGlobal('TEST_DOWNLOAD_TOOL_RESPONSE_MESSAGE_FACTORY', () => response.message);
const readStream = responseMessageFactory(); const readStream = responseMessageFactory();
let succeeded = false; let succeeded = false;
try { try {
@ -388,7 +376,7 @@ function find(toolName, versionSpec, arch) {
let toolPath = ''; let toolPath = '';
if (versionSpec) { if (versionSpec) {
versionSpec = semver.clean(versionSpec) || ''; versionSpec = semver.clean(versionSpec) || '';
const cachePath = path.join(cacheRoot, toolName, versionSpec, arch); const cachePath = path.join(_getCacheDirectory(), toolName, versionSpec, arch);
core.debug(`checking cache: ${cachePath}`); core.debug(`checking cache: ${cachePath}`);
if (fs.existsSync(cachePath) && fs.existsSync(`${cachePath}.complete`)) { if (fs.existsSync(cachePath) && fs.existsSync(`${cachePath}.complete`)) {
core.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`); core.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`);
@ -410,7 +398,7 @@ exports.find = find;
function findAllVersions(toolName, arch) { function findAllVersions(toolName, arch) {
const versions = []; const versions = [];
arch = arch || os.arch(); arch = arch || os.arch();
const toolPath = path.join(cacheRoot, toolName); const toolPath = path.join(_getCacheDirectory(), toolName);
if (fs.existsSync(toolPath)) { if (fs.existsSync(toolPath)) {
const children = fs.readdirSync(toolPath); const children = fs.readdirSync(toolPath);
for (const child of children) { for (const child of children) {
@ -429,7 +417,7 @@ function _createExtractFolder(dest) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (!dest) { if (!dest) {
// create a temp dir // create a temp dir
dest = path.join(tempDirectory, v4_1.default()); dest = path.join(_getTempDirectory(), v4_1.default());
} }
yield io.mkdirP(dest); yield io.mkdirP(dest);
return dest; return dest;
@ -437,7 +425,7 @@ function _createExtractFolder(dest) {
} }
function _createToolPath(tool, version, arch) { function _createToolPath(tool, version, arch) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const folderPath = path.join(cacheRoot, tool, semver.clean(version) || version, arch || ''); const folderPath = path.join(_getCacheDirectory(), tool, semver.clean(version) || version, arch || '');
core.debug(`destination ${folderPath}`); core.debug(`destination ${folderPath}`);
const markerPath = `${folderPath}.complete`; const markerPath = `${folderPath}.complete`;
yield io.rmRF(folderPath); yield io.rmRF(folderPath);
@ -447,7 +435,7 @@ function _createToolPath(tool, version, arch) {
}); });
} }
function _completeToolPath(tool, version, arch) { function _completeToolPath(tool, version, arch) {
const folderPath = path.join(cacheRoot, tool, semver.clean(version) || version, arch || ''); const folderPath = path.join(_getCacheDirectory(), tool, semver.clean(version) || version, arch || '');
const markerPath = `${folderPath}.complete`; const markerPath = `${folderPath}.complete`;
fs.writeFileSync(markerPath, ''); fs.writeFileSync(markerPath, '');
core.debug('finished caching tool'); core.debug('finished caching tool');
@ -484,10 +472,26 @@ function _evaluateVersions(versions, versionSpec) {
} }
return version; return version;
} }
/**
* Gets RUNNER_TOOL_CACHE
*/
function _getCacheDirectory() {
const cacheDirectory = process.env['RUNNER_TOOL_CACHE'] || '';
assert_1.ok(cacheDirectory, 'Expected RUNNER_TOOL_CACHE to be defined');
return cacheDirectory;
}
/**
* Gets RUNNER_TEMP
*/
function _getTempDirectory() {
const tempDirectory = process.env['RUNNER_TEMP'] || '';
assert_1.ok(tempDirectory, 'Expected RUNNER_TEMP to be defined');
return tempDirectory;
}
/** /**
* Gets a global variable * Gets a global variable
*/ */
function getGlobal(key, defaultValue) { function _getGlobal(key, defaultValue) {
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
const value = global[key]; const value = global[key];
/* eslint-enable @typescript-eslint/no-explicit-any */ /* eslint-enable @typescript-eslint/no-explicit-any */

File diff suppressed because one or more lines are too long

View File

@ -1,32 +1,32 @@
{ {
"_args": [ "_args": [
[ [
"@actions/tool-cache@1.3.2", "@actions/tool-cache@1.3.3",
"/home/runner/work/ghaction-upx/ghaction-upx" "/home/runner/work/ghaction-upx/ghaction-upx"
] ]
], ],
"_from": "@actions/tool-cache@1.3.2", "_from": "@actions/tool-cache@1.3.3",
"_id": "@actions/tool-cache@1.3.2", "_id": "@actions/tool-cache@1.3.3",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-6lNI29W6fc6dEA+l4aSEGWpS3DZJmgvRu8nZWaLc1LoHlEiosHydVroFgdxvBolcWJ776TnNleRG71+DSdr1aA==", "_integrity": "sha512-AFVyTLcIxusDVI1gMhbZW8m/On7YNJG+xYaxorV+qic+f7lO7h37aT2mfzxqAq7mwHxtP1YlVFNrXe9QDf/bPg==",
"_location": "/@actions/tool-cache", "_location": "/@actions/tool-cache",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "version", "type": "version",
"registry": true, "registry": true,
"raw": "@actions/tool-cache@1.3.2", "raw": "@actions/tool-cache@1.3.3",
"name": "@actions/tool-cache", "name": "@actions/tool-cache",
"escapedName": "@actions%2ftool-cache", "escapedName": "@actions%2ftool-cache",
"scope": "@actions", "scope": "@actions",
"rawSpec": "1.3.2", "rawSpec": "1.3.3",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "1.3.2" "fetchSpec": "1.3.3"
}, },
"_requiredBy": [ "_requiredBy": [
"/" "/"
], ],
"_resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-1.3.2.tgz", "_resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-1.3.3.tgz",
"_spec": "1.3.2", "_spec": "1.3.3",
"_where": "/home/runner/work/ghaction-upx/ghaction-upx", "_where": "/home/runner/work/ghaction-upx/ghaction-upx",
"bugs": { "bugs": {
"url": "https://github.com/actions/toolkit/issues" "url": "https://github.com/actions/toolkit/issues"
@ -77,5 +77,5 @@
"tsc": "tsc" "tsc": "tsc"
}, },
"types": "lib/tool-cache.d.ts", "types": "lib/tool-cache.d.ts",
"version": "1.3.2" "version": "1.3.3"
} }