build(deps): bump @actions/cache from 2.0.0 to 2.0.2 (#447)

* build(deps): bump @actions/cache from 2.0.0 to 2.0.2

Bumps [@actions/cache](https://github.com/actions/toolkit/tree/HEAD/packages/cache) from 2.0.0 to 2.0.2.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/cache/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/cache)

---
updated-dependencies:
- dependency-name: "@actions/cache"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* update dist

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Sergey Vilgelm <sergey@vilgelm.com>
This commit is contained in:
dependabot[bot] 2022-04-18 06:46:26 -07:00 committed by GitHub
parent ac76264da2
commit f973c7630e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 64 additions and 34 deletions

View File

@ -133,18 +133,12 @@ exports.restoreCache = restoreCache;
* @returns number returns cacheId if the cache was saved successfully and throws an error if save fails * @returns number returns cacheId if the cache was saved successfully and throws an error if save fails
*/ */
function saveCache(paths, key, options) { function saveCache(paths, key, options) {
var _a, _b, _c, _d, _e;
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
checkPaths(paths); checkPaths(paths);
checkKey(key); checkKey(key);
const compressionMethod = yield utils.getCompressionMethod(); const compressionMethod = yield utils.getCompressionMethod();
core.debug('Reserving Cache'); let cacheId = null;
const cacheId = yield cacheHttpClient.reserveCache(key, paths, {
compressionMethod
});
if (cacheId === -1) {
throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache.`);
}
core.debug(`Cache ID: ${cacheId}`);
const cachePaths = yield utils.resolvePaths(paths); const cachePaths = yield utils.resolvePaths(paths);
core.debug('Cache Paths:'); core.debug('Cache Paths:');
core.debug(`${JSON.stringify(cachePaths)}`); core.debug(`${JSON.stringify(cachePaths)}`);
@ -159,9 +153,24 @@ function saveCache(paths, key, options) {
const fileSizeLimit = 10 * 1024 * 1024 * 1024; // 10GB per repo limit const fileSizeLimit = 10 * 1024 * 1024 * 1024; // 10GB per repo limit
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
core.debug(`File Size: ${archiveFileSize}`); core.debug(`File Size: ${archiveFileSize}`);
if (archiveFileSize > fileSizeLimit) { // For GHES, this check will take place in ReserveCache API with enterprise file size limit
if (archiveFileSize > fileSizeLimit && !utils.isGhes()) {
throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`); throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`);
} }
core.debug('Reserving Cache');
const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, {
compressionMethod,
cacheSize: archiveFileSize
});
if ((_a = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.result) === null || _a === void 0 ? void 0 : _a.cacheId) {
cacheId = (_b = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.result) === null || _b === void 0 ? void 0 : _b.cacheId;
}
else if ((reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.statusCode) === 400) {
throw new Error((_d = (_c = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.error) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : `Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the data cap limit, not saving cache.`);
}
else {
throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache. More details: ${(_e = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.error) === null || _e === void 0 ? void 0 : _e.message}`);
}
core.debug(`Saving Cache (ID: ${cacheId})`); core.debug(`Saving Cache (ID: ${cacheId})`);
yield cacheHttpClient.saveCache(cacheId, archivePath, options); yield cacheHttpClient.saveCache(cacheId, archivePath, options);
} }
@ -295,18 +304,18 @@ function downloadCache(archiveLocation, archivePath, options) {
exports.downloadCache = downloadCache; exports.downloadCache = downloadCache;
// Reserve Cache // Reserve Cache
function reserveCache(key, paths, options) { function reserveCache(key, paths, options) {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const httpClient = createHttpClient(); const httpClient = createHttpClient();
const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod); const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod);
const reserveCacheRequest = { const reserveCacheRequest = {
key, key,
version version,
cacheSize: options === null || options === void 0 ? void 0 : options.cacheSize
}; };
const response = yield requestUtils_1.retryTypedResponse('reserveCache', () => __awaiter(this, void 0, void 0, function* () { const response = yield requestUtils_1.retryTypedResponse('reserveCache', () => __awaiter(this, void 0, void 0, function* () {
return httpClient.postJson(getCacheApiUrl('caches'), reserveCacheRequest); return httpClient.postJson(getCacheApiUrl('caches'), reserveCacheRequest);
})); }));
return (_b = (_a = response === null || response === void 0 ? void 0 : response.result) === null || _a === void 0 ? void 0 : _a.cacheId) !== null && _b !== void 0 ? _b : -1; return response;
}); });
} }
exports.reserveCache = reserveCache; exports.reserveCache = reserveCache;
@ -575,6 +584,11 @@ function assertDefined(name, value) {
return value; return value;
} }
exports.assertDefined = assertDefined; exports.assertDefined = assertDefined;
function isGhes() {
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
}
exports.isGhes = isGhes;
//# sourceMappingURL=cacheUtils.js.map //# sourceMappingURL=cacheUtils.js.map
/***/ }), /***/ }),
@ -954,7 +968,8 @@ function retryTypedResponse(name, method, maxAttempts = constants_1.DefaultRetry
return { return {
statusCode: error.statusCode, statusCode: error.statusCode,
result: null, result: null,
headers: {} headers: {},
error
}; };
} }
else { else {

41
dist/run/index.js vendored
View File

@ -133,18 +133,12 @@ exports.restoreCache = restoreCache;
* @returns number returns cacheId if the cache was saved successfully and throws an error if save fails * @returns number returns cacheId if the cache was saved successfully and throws an error if save fails
*/ */
function saveCache(paths, key, options) { function saveCache(paths, key, options) {
var _a, _b, _c, _d, _e;
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
checkPaths(paths); checkPaths(paths);
checkKey(key); checkKey(key);
const compressionMethod = yield utils.getCompressionMethod(); const compressionMethod = yield utils.getCompressionMethod();
core.debug('Reserving Cache'); let cacheId = null;
const cacheId = yield cacheHttpClient.reserveCache(key, paths, {
compressionMethod
});
if (cacheId === -1) {
throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache.`);
}
core.debug(`Cache ID: ${cacheId}`);
const cachePaths = yield utils.resolvePaths(paths); const cachePaths = yield utils.resolvePaths(paths);
core.debug('Cache Paths:'); core.debug('Cache Paths:');
core.debug(`${JSON.stringify(cachePaths)}`); core.debug(`${JSON.stringify(cachePaths)}`);
@ -159,9 +153,24 @@ function saveCache(paths, key, options) {
const fileSizeLimit = 10 * 1024 * 1024 * 1024; // 10GB per repo limit const fileSizeLimit = 10 * 1024 * 1024 * 1024; // 10GB per repo limit
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
core.debug(`File Size: ${archiveFileSize}`); core.debug(`File Size: ${archiveFileSize}`);
if (archiveFileSize > fileSizeLimit) { // For GHES, this check will take place in ReserveCache API with enterprise file size limit
if (archiveFileSize > fileSizeLimit && !utils.isGhes()) {
throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`); throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`);
} }
core.debug('Reserving Cache');
const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, {
compressionMethod,
cacheSize: archiveFileSize
});
if ((_a = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.result) === null || _a === void 0 ? void 0 : _a.cacheId) {
cacheId = (_b = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.result) === null || _b === void 0 ? void 0 : _b.cacheId;
}
else if ((reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.statusCode) === 400) {
throw new Error((_d = (_c = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.error) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : `Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the data cap limit, not saving cache.`);
}
else {
throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache. More details: ${(_e = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.error) === null || _e === void 0 ? void 0 : _e.message}`);
}
core.debug(`Saving Cache (ID: ${cacheId})`); core.debug(`Saving Cache (ID: ${cacheId})`);
yield cacheHttpClient.saveCache(cacheId, archivePath, options); yield cacheHttpClient.saveCache(cacheId, archivePath, options);
} }
@ -295,18 +304,18 @@ function downloadCache(archiveLocation, archivePath, options) {
exports.downloadCache = downloadCache; exports.downloadCache = downloadCache;
// Reserve Cache // Reserve Cache
function reserveCache(key, paths, options) { function reserveCache(key, paths, options) {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const httpClient = createHttpClient(); const httpClient = createHttpClient();
const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod); const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod);
const reserveCacheRequest = { const reserveCacheRequest = {
key, key,
version version,
cacheSize: options === null || options === void 0 ? void 0 : options.cacheSize
}; };
const response = yield requestUtils_1.retryTypedResponse('reserveCache', () => __awaiter(this, void 0, void 0, function* () { const response = yield requestUtils_1.retryTypedResponse('reserveCache', () => __awaiter(this, void 0, void 0, function* () {
return httpClient.postJson(getCacheApiUrl('caches'), reserveCacheRequest); return httpClient.postJson(getCacheApiUrl('caches'), reserveCacheRequest);
})); }));
return (_b = (_a = response === null || response === void 0 ? void 0 : response.result) === null || _a === void 0 ? void 0 : _a.cacheId) !== null && _b !== void 0 ? _b : -1; return response;
}); });
} }
exports.reserveCache = reserveCache; exports.reserveCache = reserveCache;
@ -575,6 +584,11 @@ function assertDefined(name, value) {
return value; return value;
} }
exports.assertDefined = assertDefined; exports.assertDefined = assertDefined;
function isGhes() {
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
}
exports.isGhes = isGhes;
//# sourceMappingURL=cacheUtils.js.map //# sourceMappingURL=cacheUtils.js.map
/***/ }), /***/ }),
@ -954,7 +968,8 @@ function retryTypedResponse(name, method, maxAttempts = constants_1.DefaultRetry
return { return {
statusCode: error.statusCode, statusCode: error.statusCode,
result: null, result: null,
headers: {} headers: {},
error
}; };
} }
else { else {

14
package-lock.json generated
View File

@ -9,7 +9,7 @@
"version": "3.1.0", "version": "3.1.0",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/cache": "^2.0.0", "@actions/cache": "^2.0.2",
"@actions/core": "^1.6.0", "@actions/core": "^1.6.0",
"@actions/exec": "^1.1.1", "@actions/exec": "^1.1.1",
"@actions/github": "^5.0.1", "@actions/github": "^5.0.1",
@ -32,9 +32,9 @@
} }
}, },
"node_modules/@actions/cache": { "node_modules/@actions/cache": {
"version": "2.0.0", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-2.0.0.tgz", "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-2.0.2.tgz",
"integrity": "sha512-d7n8ul6HjWX6oDrNEPoqn8ZvqyyDhp9Uek6WOxALyxGVsXU+8+ND+viD3UfrXVWfs/GQiqI5Eq4cOozZj0yRFQ==", "integrity": "sha512-K1DCaW/OtHj5mV7hI7HEXiceX3rM4Nc0iG2hfYsrkEy6GiOeqlCC/LyICrBZIRDM6+vSrS12tg1ORl4hghomBA==",
"dependencies": { "dependencies": {
"@actions/core": "^1.2.6", "@actions/core": "^1.2.6",
"@actions/exec": "^1.0.1", "@actions/exec": "^1.0.1",
@ -3009,9 +3009,9 @@
}, },
"dependencies": { "dependencies": {
"@actions/cache": { "@actions/cache": {
"version": "2.0.0", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-2.0.0.tgz", "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-2.0.2.tgz",
"integrity": "sha512-d7n8ul6HjWX6oDrNEPoqn8ZvqyyDhp9Uek6WOxALyxGVsXU+8+ND+viD3UfrXVWfs/GQiqI5Eq4cOozZj0yRFQ==", "integrity": "sha512-K1DCaW/OtHj5mV7hI7HEXiceX3rM4Nc0iG2hfYsrkEy6GiOeqlCC/LyICrBZIRDM6+vSrS12tg1ORl4hghomBA==",
"requires": { "requires": {
"@actions/core": "^1.2.6", "@actions/core": "^1.2.6",
"@actions/exec": "^1.0.1", "@actions/exec": "^1.0.1",

View File

@ -24,7 +24,7 @@
"author": "golangci", "author": "golangci",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/cache": "^2.0.0", "@actions/cache": "^2.0.2",
"@actions/core": "^1.6.0", "@actions/core": "^1.6.0",
"@actions/exec": "^1.1.1", "@actions/exec": "^1.1.1",
"@actions/github": "^5.0.1", "@actions/github": "^5.0.1",