@@ -1148,6 +1148,11 @@ function assertDefined(name, value) {
1148
1148
return value;
1149
1149
}
1150
1150
exports.assertDefined = assertDefined;
1151
+ function isGhes() {
1152
+ const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
1153
+ return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
1154
+ }
1155
+ exports.isGhes = isGhes;
1151
1156
//# sourceMappingURL=cacheUtils.js.map
1152
1157
1153
1158
/***/ }),
@@ -3806,18 +3811,18 @@ function downloadCache(archiveLocation, archivePath, options) {
3806
3811
exports.downloadCache = downloadCache;
3807
3812
// Reserve Cache
3808
3813
function reserveCache(key, paths, options) {
3809
- var _a, _b;
3810
3814
return __awaiter(this, void 0, void 0, function* () {
3811
3815
const httpClient = createHttpClient();
3812
3816
const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod);
3813
3817
const reserveCacheRequest = {
3814
3818
key,
3815
- version
3819
+ version,
3820
+ cacheSize: options === null || options === void 0 ? void 0 : options.cacheSize
3816
3821
};
3817
3822
const response = yield requestUtils_1.retryTypedResponse('reserveCache', () => __awaiter(this, void 0, void 0, function* () {
3818
3823
return httpClient.postJson(getCacheApiUrl('caches'), reserveCacheRequest);
3819
3824
}));
3820
- 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 ;
3825
+ return response;
3821
3826
});
3822
3827
}
3823
3828
exports.reserveCache = reserveCache;
@@ -41528,18 +41533,12 @@ exports.restoreCache = restoreCache;
41528
41533
* @returns number returns cacheId if the cache was saved successfully and throws an error if save fails
41529
41534
*/
41530
41535
function saveCache(paths, key, options) {
41536
+ var _a, _b, _c, _d, _e;
41531
41537
return __awaiter(this, void 0, void 0, function* () {
41532
41538
checkPaths(paths);
41533
41539
checkKey(key);
41534
41540
const compressionMethod = yield utils.getCompressionMethod();
41535
- core.debug('Reserving Cache');
41536
- const cacheId = yield cacheHttpClient.reserveCache(key, paths, {
41537
- compressionMethod
41538
- });
41539
- if (cacheId === -1) {
41540
- throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache.`);
41541
- }
41542
- core.debug(`Cache ID: ${cacheId}`);
41541
+ let cacheId = null;
41543
41542
const cachePaths = yield utils.resolvePaths(paths);
41544
41543
core.debug('Cache Paths:');
41545
41544
core.debug(`${JSON.stringify(cachePaths)}`);
@@ -41554,9 +41553,24 @@ function saveCache(paths, key, options) {
41554
41553
const fileSizeLimit = 10 * 1024 * 1024 * 1024; // 10GB per repo limit
41555
41554
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
41556
41555
core.debug(`File Size: ${archiveFileSize}`);
41557
- if (archiveFileSize > fileSizeLimit) {
41556
+ // For GHES, this check will take place in ReserveCache API with enterprise file size limit
41557
+ if (archiveFileSize > fileSizeLimit && !utils.isGhes()) {
41558
41558
throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`);
41559
41559
}
41560
+ core.debug('Reserving Cache');
41561
+ const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, {
41562
+ compressionMethod,
41563
+ cacheSize: archiveFileSize
41564
+ });
41565
+ if ((_a = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.result) === null || _a === void 0 ? void 0 : _a.cacheId) {
41566
+ cacheId = (_b = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.result) === null || _b === void 0 ? void 0 : _b.cacheId;
41567
+ }
41568
+ else if ((reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.statusCode) === 400) {
41569
+ 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.`);
41570
+ }
41571
+ else {
41572
+ 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}`);
41573
+ }
41560
41574
core.debug(`Saving Cache (ID: ${cacheId})`);
41561
41575
yield cacheHttpClient.saveCache(cacheId, archivePath, options);
41562
41576
}
@@ -50335,7 +50349,8 @@ function retryTypedResponse(name, method, maxAttempts = constants_1.DefaultRetry
50335
50349
return {
50336
50350
statusCode: error.statusCode,
50337
50351
result: null,
50338
- headers: {}
50352
+ headers: {},
50353
+ error
50339
50354
};
50340
50355
}
50341
50356
else {
0 commit comments