Skip to content

Commit f973c76

Browse files
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] <[email protected]> * update dist Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Sergey Vilgelm <[email protected]>
1 parent ac76264 commit f973c76

File tree

4 files changed

+64
-34
lines changed

4 files changed

+64
-34
lines changed

dist/post_run/index.js

+28-13
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,12 @@ exports.restoreCache = restoreCache;
133133
* @returns number returns cacheId if the cache was saved successfully and throws an error if save fails
134134
*/
135135
function saveCache(paths, key, options) {
136+
var _a, _b, _c, _d, _e;
136137
return __awaiter(this, void 0, void 0, function* () {
137138
checkPaths(paths);
138139
checkKey(key);
139140
const compressionMethod = yield utils.getCompressionMethod();
140-
core.debug('Reserving Cache');
141-
const cacheId = yield cacheHttpClient.reserveCache(key, paths, {
142-
compressionMethod
143-
});
144-
if (cacheId === -1) {
145-
throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache.`);
146-
}
147-
core.debug(`Cache ID: ${cacheId}`);
141+
let cacheId = null;
148142
const cachePaths = yield utils.resolvePaths(paths);
149143
core.debug('Cache Paths:');
150144
core.debug(`${JSON.stringify(cachePaths)}`);
@@ -159,9 +153,24 @@ function saveCache(paths, key, options) {
159153
const fileSizeLimit = 10 * 1024 * 1024 * 1024; // 10GB per repo limit
160154
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
161155
core.debug(`File Size: ${archiveFileSize}`);
162-
if (archiveFileSize > fileSizeLimit) {
156+
// For GHES, this check will take place in ReserveCache API with enterprise file size limit
157+
if (archiveFileSize > fileSizeLimit && !utils.isGhes()) {
163158
throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`);
164159
}
160+
core.debug('Reserving Cache');
161+
const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, {
162+
compressionMethod,
163+
cacheSize: archiveFileSize
164+
});
165+
if ((_a = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.result) === null || _a === void 0 ? void 0 : _a.cacheId) {
166+
cacheId = (_b = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.result) === null || _b === void 0 ? void 0 : _b.cacheId;
167+
}
168+
else if ((reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.statusCode) === 400) {
169+
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.`);
170+
}
171+
else {
172+
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}`);
173+
}
165174
core.debug(`Saving Cache (ID: ${cacheId})`);
166175
yield cacheHttpClient.saveCache(cacheId, archivePath, options);
167176
}
@@ -295,18 +304,18 @@ function downloadCache(archiveLocation, archivePath, options) {
295304
exports.downloadCache = downloadCache;
296305
// Reserve Cache
297306
function reserveCache(key, paths, options) {
298-
var _a, _b;
299307
return __awaiter(this, void 0, void 0, function* () {
300308
const httpClient = createHttpClient();
301309
const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod);
302310
const reserveCacheRequest = {
303311
key,
304-
version
312+
version,
313+
cacheSize: options === null || options === void 0 ? void 0 : options.cacheSize
305314
};
306315
const response = yield requestUtils_1.retryTypedResponse('reserveCache', () => __awaiter(this, void 0, void 0, function* () {
307316
return httpClient.postJson(getCacheApiUrl('caches'), reserveCacheRequest);
308317
}));
309-
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;
318+
return response;
310319
});
311320
}
312321
exports.reserveCache = reserveCache;
@@ -575,6 +584,11 @@ function assertDefined(name, value) {
575584
return value;
576585
}
577586
exports.assertDefined = assertDefined;
587+
function isGhes() {
588+
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
589+
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
590+
}
591+
exports.isGhes = isGhes;
578592
//# sourceMappingURL=cacheUtils.js.map
579593

580594
/***/ }),
@@ -954,7 +968,8 @@ function retryTypedResponse(name, method, maxAttempts = constants_1.DefaultRetry
954968
return {
955969
statusCode: error.statusCode,
956970
result: null,
957-
headers: {}
971+
headers: {},
972+
error
958973
};
959974
}
960975
else {

dist/run/index.js

+28-13
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,12 @@ exports.restoreCache = restoreCache;
133133
* @returns number returns cacheId if the cache was saved successfully and throws an error if save fails
134134
*/
135135
function saveCache(paths, key, options) {
136+
var _a, _b, _c, _d, _e;
136137
return __awaiter(this, void 0, void 0, function* () {
137138
checkPaths(paths);
138139
checkKey(key);
139140
const compressionMethod = yield utils.getCompressionMethod();
140-
core.debug('Reserving Cache');
141-
const cacheId = yield cacheHttpClient.reserveCache(key, paths, {
142-
compressionMethod
143-
});
144-
if (cacheId === -1) {
145-
throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache.`);
146-
}
147-
core.debug(`Cache ID: ${cacheId}`);
141+
let cacheId = null;
148142
const cachePaths = yield utils.resolvePaths(paths);
149143
core.debug('Cache Paths:');
150144
core.debug(`${JSON.stringify(cachePaths)}`);
@@ -159,9 +153,24 @@ function saveCache(paths, key, options) {
159153
const fileSizeLimit = 10 * 1024 * 1024 * 1024; // 10GB per repo limit
160154
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
161155
core.debug(`File Size: ${archiveFileSize}`);
162-
if (archiveFileSize > fileSizeLimit) {
156+
// For GHES, this check will take place in ReserveCache API with enterprise file size limit
157+
if (archiveFileSize > fileSizeLimit && !utils.isGhes()) {
163158
throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`);
164159
}
160+
core.debug('Reserving Cache');
161+
const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, {
162+
compressionMethod,
163+
cacheSize: archiveFileSize
164+
});
165+
if ((_a = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.result) === null || _a === void 0 ? void 0 : _a.cacheId) {
166+
cacheId = (_b = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.result) === null || _b === void 0 ? void 0 : _b.cacheId;
167+
}
168+
else if ((reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.statusCode) === 400) {
169+
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.`);
170+
}
171+
else {
172+
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}`);
173+
}
165174
core.debug(`Saving Cache (ID: ${cacheId})`);
166175
yield cacheHttpClient.saveCache(cacheId, archivePath, options);
167176
}
@@ -295,18 +304,18 @@ function downloadCache(archiveLocation, archivePath, options) {
295304
exports.downloadCache = downloadCache;
296305
// Reserve Cache
297306
function reserveCache(key, paths, options) {
298-
var _a, _b;
299307
return __awaiter(this, void 0, void 0, function* () {
300308
const httpClient = createHttpClient();
301309
const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod);
302310
const reserveCacheRequest = {
303311
key,
304-
version
312+
version,
313+
cacheSize: options === null || options === void 0 ? void 0 : options.cacheSize
305314
};
306315
const response = yield requestUtils_1.retryTypedResponse('reserveCache', () => __awaiter(this, void 0, void 0, function* () {
307316
return httpClient.postJson(getCacheApiUrl('caches'), reserveCacheRequest);
308317
}));
309-
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;
318+
return response;
310319
});
311320
}
312321
exports.reserveCache = reserveCache;
@@ -575,6 +584,11 @@ function assertDefined(name, value) {
575584
return value;
576585
}
577586
exports.assertDefined = assertDefined;
587+
function isGhes() {
588+
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
589+
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
590+
}
591+
exports.isGhes = isGhes;
578592
//# sourceMappingURL=cacheUtils.js.map
579593

580594
/***/ }),
@@ -954,7 +968,8 @@ function retryTypedResponse(name, method, maxAttempts = constants_1.DefaultRetry
954968
return {
955969
statusCode: error.statusCode,
956970
result: null,
957-
headers: {}
971+
headers: {},
972+
error
958973
};
959974
}
960975
else {

package-lock.json

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"author": "golangci",
2525
"license": "MIT",
2626
"dependencies": {
27-
"@actions/cache": "^2.0.0",
27+
"@actions/cache": "^2.0.2",
2828
"@actions/core": "^1.6.0",
2929
"@actions/exec": "^1.1.1",
3030
"@actions/github": "^5.0.1",

0 commit comments

Comments
 (0)