mirror of
https://gitea.com/actions/cache.git
synced 2025-11-11 03:16:25 +08:00
Compare commits
3 Commits
2893d426fc
...
53d0c08d51
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
53d0c08d51 | ||
|
|
8e13e3de7e | ||
|
|
892a8188be |
186
dist/restore-only/index.js
vendored
186
dist/restore-only/index.js
vendored
@@ -5898,11 +5898,9 @@ const path = __importStar(__nccwpck_require__(1017));
|
||||
const utils = __importStar(__nccwpck_require__(3310));
|
||||
const cacheHttpClient = __importStar(__nccwpck_require__(2370));
|
||||
const cacheTwirpClient = __importStar(__nccwpck_require__(5726));
|
||||
const downloadUtils_1 = __nccwpck_require__(318);
|
||||
const config_1 = __nccwpck_require__(6490);
|
||||
const tar_1 = __nccwpck_require__(9099);
|
||||
const constants_1 = __nccwpck_require__(4010);
|
||||
const upload_cache_1 = __nccwpck_require__(302);
|
||||
class ValidationError extends Error {
|
||||
constructor(message) {
|
||||
super(message);
|
||||
@@ -6052,6 +6050,8 @@ function restoreCacheV1(paths, primaryKey, restoreKeys, options, enableCrossOsAr
|
||||
*/
|
||||
function restoreCacheV2(paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// Override UploadOptions to force the use of Azure
|
||||
options = Object.assign(Object.assign({}, options), { useAzureSdk: true });
|
||||
restoreKeys = restoreKeys || [];
|
||||
const keys = [primaryKey, ...restoreKeys];
|
||||
core.debug('Resolved Keys:');
|
||||
@@ -6084,10 +6084,7 @@ function restoreCacheV2(paths, primaryKey, restoreKeys, options, enableCrossOsAr
|
||||
archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod));
|
||||
core.debug(`Archive path: ${archivePath}`);
|
||||
core.debug(`Starting download of archive to: ${archivePath}`);
|
||||
yield (0, downloadUtils_1.downloadCacheStorageSDK)(response.signedDownloadUrl, archivePath, options ||
|
||||
{
|
||||
timeoutInMs: 30000
|
||||
});
|
||||
yield cacheHttpClient.downloadCache(response.signedDownloadUrl, archivePath, options);
|
||||
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||||
core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`);
|
||||
if (core.isDebug()) {
|
||||
@@ -6196,7 +6193,7 @@ function saveCacheV1(paths, key, options, enableCrossOsArchive = false) {
|
||||
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})`);
|
||||
yield cacheHttpClient.saveCache(cacheId, archivePath, options);
|
||||
yield cacheHttpClient.saveCache(cacheId, archivePath, '', options);
|
||||
}
|
||||
catch (error) {
|
||||
const typedError = error;
|
||||
@@ -6233,6 +6230,8 @@ function saveCacheV1(paths, key, options, enableCrossOsArchive = false) {
|
||||
*/
|
||||
function saveCacheV2(paths, key, options, enableCrossOsArchive = false) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// Override UploadOptions to force the use of Azure
|
||||
options = Object.assign(Object.assign({}, options), { useAzureSdk: true });
|
||||
const compressionMethod = yield utils.getCompressionMethod();
|
||||
const twirpClient = cacheTwirpClient.internalCacheTwirpClient();
|
||||
let cacheId = -1;
|
||||
@@ -6267,8 +6266,7 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) {
|
||||
throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache.`);
|
||||
}
|
||||
core.debug(`Attempting to upload cache located at: ${archivePath}`);
|
||||
const uploadResponse = yield (0, upload_cache_1.uploadCacheFile)(response.signedUploadUrl, archivePath);
|
||||
core.debug(`Download response status: ${uploadResponse._response.status}`);
|
||||
yield cacheHttpClient.saveCache(cacheId, archivePath, response.signedUploadUrl, options);
|
||||
const finalizeRequest = {
|
||||
key,
|
||||
version,
|
||||
@@ -8052,71 +8050,6 @@ exports.CacheScope = new CacheScope$Type();
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 302:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.uploadCacheFile = void 0;
|
||||
const core = __importStar(__nccwpck_require__(4850));
|
||||
const storage_blob_1 = __nccwpck_require__(3864);
|
||||
const errors_1 = __nccwpck_require__(6333);
|
||||
function uploadCacheFile(signedUploadURL, archivePath) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// Specify data transfer options
|
||||
const uploadOptions = {
|
||||
blockSize: 4 * 1024 * 1024,
|
||||
concurrency: 4,
|
||||
maxSingleShotSize: 8 * 1024 * 1024 // 8 MiB initial transfer size
|
||||
};
|
||||
const blobClient = new storage_blob_1.BlobClient(signedUploadURL);
|
||||
const blockBlobClient = blobClient.getBlockBlobClient();
|
||||
core.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`);
|
||||
const resp = yield blockBlobClient.uploadFile(archivePath, uploadOptions);
|
||||
if (resp._response.status >= 400) {
|
||||
throw new errors_1.InvalidResponseError(`Upload failed with status code ${resp._response.status}`);
|
||||
}
|
||||
return resp;
|
||||
});
|
||||
}
|
||||
exports.uploadCacheFile = uploadCacheFile;
|
||||
//# sourceMappingURL=upload-cache.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 2370:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
@@ -8162,6 +8095,7 @@ const auth_1 = __nccwpck_require__(7231);
|
||||
const fs = __importStar(__nccwpck_require__(7147));
|
||||
const url_1 = __nccwpck_require__(7310);
|
||||
const utils = __importStar(__nccwpck_require__(3310));
|
||||
const uploadUtils_1 = __nccwpck_require__(1157);
|
||||
const downloadUtils_1 = __nccwpck_require__(318);
|
||||
const options_1 = __nccwpck_require__(7190);
|
||||
const requestUtils_1 = __nccwpck_require__(7865);
|
||||
@@ -8348,20 +8282,30 @@ function commitCache(httpClient, cacheId, filesize) {
|
||||
}));
|
||||
});
|
||||
}
|
||||
function saveCache(cacheId, archivePath, options) {
|
||||
function saveCache(cacheId, archivePath, signedUploadURL, options) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const httpClient = createHttpClient();
|
||||
core.debug('Upload cache');
|
||||
yield uploadFile(httpClient, cacheId, archivePath, options);
|
||||
// Commit Cache
|
||||
core.debug('Commiting cache');
|
||||
const cacheSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||||
core.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`);
|
||||
const commitCacheResponse = yield commitCache(httpClient, cacheId, cacheSize);
|
||||
if (!(0, requestUtils_1.isSuccessStatusCode)(commitCacheResponse.statusCode)) {
|
||||
throw new Error(`Cache service responded with ${commitCacheResponse.statusCode} during commit cache.`);
|
||||
const uploadOptions = (0, options_1.getUploadOptions)(options);
|
||||
if (uploadOptions.useAzureSdk) {
|
||||
// Use Azure storage SDK to upload caches directly to Azure
|
||||
if (!signedUploadURL) {
|
||||
throw new Error('Azure Storage SDK can only be used when a signed URL is provided.');
|
||||
}
|
||||
yield (0, uploadUtils_1.uploadCacheArchiveSDK)(signedUploadURL, archivePath, options);
|
||||
}
|
||||
else {
|
||||
const httpClient = createHttpClient();
|
||||
core.debug('Upload cache');
|
||||
yield uploadFile(httpClient, cacheId, archivePath, options);
|
||||
// Commit Cache
|
||||
core.debug('Commiting cache');
|
||||
const cacheSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||||
core.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`);
|
||||
const commitCacheResponse = yield commitCache(httpClient, cacheId, cacheSize);
|
||||
if (!(0, requestUtils_1.isSuccessStatusCode)(commitCacheResponse.statusCode)) {
|
||||
throw new Error(`Cache service responded with ${commitCacheResponse.statusCode} during commit cache.`);
|
||||
}
|
||||
core.info('Cache saved successfully');
|
||||
}
|
||||
core.info('Cache saved successfully');
|
||||
});
|
||||
}
|
||||
exports.saveCache = saveCache;
|
||||
@@ -9752,6 +9696,71 @@ exports.createTar = createTar;
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 1157:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.uploadCacheArchiveSDK = void 0;
|
||||
const core = __importStar(__nccwpck_require__(4850));
|
||||
const storage_blob_1 = __nccwpck_require__(3864);
|
||||
const errors_1 = __nccwpck_require__(6333);
|
||||
function uploadCacheArchiveSDK(signedUploadURL, archivePath, options) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// Specify data transfer options
|
||||
const uploadOptions = {
|
||||
blockSize: options === null || options === void 0 ? void 0 : options.uploadChunkSize,
|
||||
concurrency: options === null || options === void 0 ? void 0 : options.uploadConcurrency,
|
||||
maxSingleShotSize: 128 * 1024 * 1024 // 128 MiB initial transfer size
|
||||
};
|
||||
const blobClient = new storage_blob_1.BlobClient(signedUploadURL);
|
||||
const blockBlobClient = blobClient.getBlockBlobClient();
|
||||
core.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`);
|
||||
const resp = yield blockBlobClient.uploadFile(archivePath, uploadOptions);
|
||||
if (resp._response.status >= 400) {
|
||||
throw new errors_1.InvalidResponseError(`Upload failed with status code ${resp._response.status}`);
|
||||
}
|
||||
return resp;
|
||||
});
|
||||
}
|
||||
exports.uploadCacheArchiveSDK = uploadCacheArchiveSDK;
|
||||
//# sourceMappingURL=uploadUtils.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 7190:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
@@ -9790,10 +9799,14 @@ const core = __importStar(__nccwpck_require__(4850));
|
||||
*/
|
||||
function getUploadOptions(copy) {
|
||||
const result = {
|
||||
useAzureSdk: false,
|
||||
uploadConcurrency: 4,
|
||||
uploadChunkSize: 32 * 1024 * 1024
|
||||
};
|
||||
if (copy) {
|
||||
if (typeof copy.useAzureSdk === 'boolean') {
|
||||
result.useAzureSdk = copy.useAzureSdk;
|
||||
}
|
||||
if (typeof copy.uploadConcurrency === 'number') {
|
||||
result.uploadConcurrency = copy.uploadConcurrency;
|
||||
}
|
||||
@@ -9801,6 +9814,7 @@ function getUploadOptions(copy) {
|
||||
result.uploadChunkSize = copy.uploadChunkSize;
|
||||
}
|
||||
}
|
||||
core.debug(`Use Azure SDK: ${result.useAzureSdk}`);
|
||||
core.debug(`Upload concurrency: ${result.uploadConcurrency}`);
|
||||
core.debug(`Upload chunk size: ${result.uploadChunkSize}`);
|
||||
return result;
|
||||
|
||||
186
dist/restore/index.js
vendored
186
dist/restore/index.js
vendored
@@ -5898,11 +5898,9 @@ const path = __importStar(__nccwpck_require__(1017));
|
||||
const utils = __importStar(__nccwpck_require__(3310));
|
||||
const cacheHttpClient = __importStar(__nccwpck_require__(2370));
|
||||
const cacheTwirpClient = __importStar(__nccwpck_require__(5726));
|
||||
const downloadUtils_1 = __nccwpck_require__(318);
|
||||
const config_1 = __nccwpck_require__(6490);
|
||||
const tar_1 = __nccwpck_require__(9099);
|
||||
const constants_1 = __nccwpck_require__(4010);
|
||||
const upload_cache_1 = __nccwpck_require__(302);
|
||||
class ValidationError extends Error {
|
||||
constructor(message) {
|
||||
super(message);
|
||||
@@ -6052,6 +6050,8 @@ function restoreCacheV1(paths, primaryKey, restoreKeys, options, enableCrossOsAr
|
||||
*/
|
||||
function restoreCacheV2(paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// Override UploadOptions to force the use of Azure
|
||||
options = Object.assign(Object.assign({}, options), { useAzureSdk: true });
|
||||
restoreKeys = restoreKeys || [];
|
||||
const keys = [primaryKey, ...restoreKeys];
|
||||
core.debug('Resolved Keys:');
|
||||
@@ -6084,10 +6084,7 @@ function restoreCacheV2(paths, primaryKey, restoreKeys, options, enableCrossOsAr
|
||||
archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod));
|
||||
core.debug(`Archive path: ${archivePath}`);
|
||||
core.debug(`Starting download of archive to: ${archivePath}`);
|
||||
yield (0, downloadUtils_1.downloadCacheStorageSDK)(response.signedDownloadUrl, archivePath, options ||
|
||||
{
|
||||
timeoutInMs: 30000
|
||||
});
|
||||
yield cacheHttpClient.downloadCache(response.signedDownloadUrl, archivePath, options);
|
||||
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||||
core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`);
|
||||
if (core.isDebug()) {
|
||||
@@ -6196,7 +6193,7 @@ function saveCacheV1(paths, key, options, enableCrossOsArchive = false) {
|
||||
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})`);
|
||||
yield cacheHttpClient.saveCache(cacheId, archivePath, options);
|
||||
yield cacheHttpClient.saveCache(cacheId, archivePath, '', options);
|
||||
}
|
||||
catch (error) {
|
||||
const typedError = error;
|
||||
@@ -6233,6 +6230,8 @@ function saveCacheV1(paths, key, options, enableCrossOsArchive = false) {
|
||||
*/
|
||||
function saveCacheV2(paths, key, options, enableCrossOsArchive = false) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// Override UploadOptions to force the use of Azure
|
||||
options = Object.assign(Object.assign({}, options), { useAzureSdk: true });
|
||||
const compressionMethod = yield utils.getCompressionMethod();
|
||||
const twirpClient = cacheTwirpClient.internalCacheTwirpClient();
|
||||
let cacheId = -1;
|
||||
@@ -6267,8 +6266,7 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) {
|
||||
throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache.`);
|
||||
}
|
||||
core.debug(`Attempting to upload cache located at: ${archivePath}`);
|
||||
const uploadResponse = yield (0, upload_cache_1.uploadCacheFile)(response.signedUploadUrl, archivePath);
|
||||
core.debug(`Download response status: ${uploadResponse._response.status}`);
|
||||
yield cacheHttpClient.saveCache(cacheId, archivePath, response.signedUploadUrl, options);
|
||||
const finalizeRequest = {
|
||||
key,
|
||||
version,
|
||||
@@ -8052,71 +8050,6 @@ exports.CacheScope = new CacheScope$Type();
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 302:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.uploadCacheFile = void 0;
|
||||
const core = __importStar(__nccwpck_require__(4850));
|
||||
const storage_blob_1 = __nccwpck_require__(3864);
|
||||
const errors_1 = __nccwpck_require__(6333);
|
||||
function uploadCacheFile(signedUploadURL, archivePath) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// Specify data transfer options
|
||||
const uploadOptions = {
|
||||
blockSize: 4 * 1024 * 1024,
|
||||
concurrency: 4,
|
||||
maxSingleShotSize: 8 * 1024 * 1024 // 8 MiB initial transfer size
|
||||
};
|
||||
const blobClient = new storage_blob_1.BlobClient(signedUploadURL);
|
||||
const blockBlobClient = blobClient.getBlockBlobClient();
|
||||
core.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`);
|
||||
const resp = yield blockBlobClient.uploadFile(archivePath, uploadOptions);
|
||||
if (resp._response.status >= 400) {
|
||||
throw new errors_1.InvalidResponseError(`Upload failed with status code ${resp._response.status}`);
|
||||
}
|
||||
return resp;
|
||||
});
|
||||
}
|
||||
exports.uploadCacheFile = uploadCacheFile;
|
||||
//# sourceMappingURL=upload-cache.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 2370:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
@@ -8162,6 +8095,7 @@ const auth_1 = __nccwpck_require__(7231);
|
||||
const fs = __importStar(__nccwpck_require__(7147));
|
||||
const url_1 = __nccwpck_require__(7310);
|
||||
const utils = __importStar(__nccwpck_require__(3310));
|
||||
const uploadUtils_1 = __nccwpck_require__(1157);
|
||||
const downloadUtils_1 = __nccwpck_require__(318);
|
||||
const options_1 = __nccwpck_require__(7190);
|
||||
const requestUtils_1 = __nccwpck_require__(7865);
|
||||
@@ -8348,20 +8282,30 @@ function commitCache(httpClient, cacheId, filesize) {
|
||||
}));
|
||||
});
|
||||
}
|
||||
function saveCache(cacheId, archivePath, options) {
|
||||
function saveCache(cacheId, archivePath, signedUploadURL, options) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const httpClient = createHttpClient();
|
||||
core.debug('Upload cache');
|
||||
yield uploadFile(httpClient, cacheId, archivePath, options);
|
||||
// Commit Cache
|
||||
core.debug('Commiting cache');
|
||||
const cacheSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||||
core.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`);
|
||||
const commitCacheResponse = yield commitCache(httpClient, cacheId, cacheSize);
|
||||
if (!(0, requestUtils_1.isSuccessStatusCode)(commitCacheResponse.statusCode)) {
|
||||
throw new Error(`Cache service responded with ${commitCacheResponse.statusCode} during commit cache.`);
|
||||
const uploadOptions = (0, options_1.getUploadOptions)(options);
|
||||
if (uploadOptions.useAzureSdk) {
|
||||
// Use Azure storage SDK to upload caches directly to Azure
|
||||
if (!signedUploadURL) {
|
||||
throw new Error('Azure Storage SDK can only be used when a signed URL is provided.');
|
||||
}
|
||||
yield (0, uploadUtils_1.uploadCacheArchiveSDK)(signedUploadURL, archivePath, options);
|
||||
}
|
||||
else {
|
||||
const httpClient = createHttpClient();
|
||||
core.debug('Upload cache');
|
||||
yield uploadFile(httpClient, cacheId, archivePath, options);
|
||||
// Commit Cache
|
||||
core.debug('Commiting cache');
|
||||
const cacheSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||||
core.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`);
|
||||
const commitCacheResponse = yield commitCache(httpClient, cacheId, cacheSize);
|
||||
if (!(0, requestUtils_1.isSuccessStatusCode)(commitCacheResponse.statusCode)) {
|
||||
throw new Error(`Cache service responded with ${commitCacheResponse.statusCode} during commit cache.`);
|
||||
}
|
||||
core.info('Cache saved successfully');
|
||||
}
|
||||
core.info('Cache saved successfully');
|
||||
});
|
||||
}
|
||||
exports.saveCache = saveCache;
|
||||
@@ -9752,6 +9696,71 @@ exports.createTar = createTar;
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 1157:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.uploadCacheArchiveSDK = void 0;
|
||||
const core = __importStar(__nccwpck_require__(4850));
|
||||
const storage_blob_1 = __nccwpck_require__(3864);
|
||||
const errors_1 = __nccwpck_require__(6333);
|
||||
function uploadCacheArchiveSDK(signedUploadURL, archivePath, options) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// Specify data transfer options
|
||||
const uploadOptions = {
|
||||
blockSize: options === null || options === void 0 ? void 0 : options.uploadChunkSize,
|
||||
concurrency: options === null || options === void 0 ? void 0 : options.uploadConcurrency,
|
||||
maxSingleShotSize: 128 * 1024 * 1024 // 128 MiB initial transfer size
|
||||
};
|
||||
const blobClient = new storage_blob_1.BlobClient(signedUploadURL);
|
||||
const blockBlobClient = blobClient.getBlockBlobClient();
|
||||
core.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`);
|
||||
const resp = yield blockBlobClient.uploadFile(archivePath, uploadOptions);
|
||||
if (resp._response.status >= 400) {
|
||||
throw new errors_1.InvalidResponseError(`Upload failed with status code ${resp._response.status}`);
|
||||
}
|
||||
return resp;
|
||||
});
|
||||
}
|
||||
exports.uploadCacheArchiveSDK = uploadCacheArchiveSDK;
|
||||
//# sourceMappingURL=uploadUtils.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 7190:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
@@ -9790,10 +9799,14 @@ const core = __importStar(__nccwpck_require__(4850));
|
||||
*/
|
||||
function getUploadOptions(copy) {
|
||||
const result = {
|
||||
useAzureSdk: false,
|
||||
uploadConcurrency: 4,
|
||||
uploadChunkSize: 32 * 1024 * 1024
|
||||
};
|
||||
if (copy) {
|
||||
if (typeof copy.useAzureSdk === 'boolean') {
|
||||
result.useAzureSdk = copy.useAzureSdk;
|
||||
}
|
||||
if (typeof copy.uploadConcurrency === 'number') {
|
||||
result.uploadConcurrency = copy.uploadConcurrency;
|
||||
}
|
||||
@@ -9801,6 +9814,7 @@ function getUploadOptions(copy) {
|
||||
result.uploadChunkSize = copy.uploadChunkSize;
|
||||
}
|
||||
}
|
||||
core.debug(`Use Azure SDK: ${result.useAzureSdk}`);
|
||||
core.debug(`Upload concurrency: ${result.uploadConcurrency}`);
|
||||
core.debug(`Upload chunk size: ${result.uploadChunkSize}`);
|
||||
return result;
|
||||
|
||||
186
dist/save-only/index.js
vendored
186
dist/save-only/index.js
vendored
@@ -5898,11 +5898,9 @@ const path = __importStar(__nccwpck_require__(1017));
|
||||
const utils = __importStar(__nccwpck_require__(3310));
|
||||
const cacheHttpClient = __importStar(__nccwpck_require__(2370));
|
||||
const cacheTwirpClient = __importStar(__nccwpck_require__(5726));
|
||||
const downloadUtils_1 = __nccwpck_require__(318);
|
||||
const config_1 = __nccwpck_require__(6490);
|
||||
const tar_1 = __nccwpck_require__(9099);
|
||||
const constants_1 = __nccwpck_require__(4010);
|
||||
const upload_cache_1 = __nccwpck_require__(302);
|
||||
class ValidationError extends Error {
|
||||
constructor(message) {
|
||||
super(message);
|
||||
@@ -6052,6 +6050,8 @@ function restoreCacheV1(paths, primaryKey, restoreKeys, options, enableCrossOsAr
|
||||
*/
|
||||
function restoreCacheV2(paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// Override UploadOptions to force the use of Azure
|
||||
options = Object.assign(Object.assign({}, options), { useAzureSdk: true });
|
||||
restoreKeys = restoreKeys || [];
|
||||
const keys = [primaryKey, ...restoreKeys];
|
||||
core.debug('Resolved Keys:');
|
||||
@@ -6084,10 +6084,7 @@ function restoreCacheV2(paths, primaryKey, restoreKeys, options, enableCrossOsAr
|
||||
archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod));
|
||||
core.debug(`Archive path: ${archivePath}`);
|
||||
core.debug(`Starting download of archive to: ${archivePath}`);
|
||||
yield (0, downloadUtils_1.downloadCacheStorageSDK)(response.signedDownloadUrl, archivePath, options ||
|
||||
{
|
||||
timeoutInMs: 30000
|
||||
});
|
||||
yield cacheHttpClient.downloadCache(response.signedDownloadUrl, archivePath, options);
|
||||
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||||
core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`);
|
||||
if (core.isDebug()) {
|
||||
@@ -6196,7 +6193,7 @@ function saveCacheV1(paths, key, options, enableCrossOsArchive = false) {
|
||||
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})`);
|
||||
yield cacheHttpClient.saveCache(cacheId, archivePath, options);
|
||||
yield cacheHttpClient.saveCache(cacheId, archivePath, '', options);
|
||||
}
|
||||
catch (error) {
|
||||
const typedError = error;
|
||||
@@ -6233,6 +6230,8 @@ function saveCacheV1(paths, key, options, enableCrossOsArchive = false) {
|
||||
*/
|
||||
function saveCacheV2(paths, key, options, enableCrossOsArchive = false) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// Override UploadOptions to force the use of Azure
|
||||
options = Object.assign(Object.assign({}, options), { useAzureSdk: true });
|
||||
const compressionMethod = yield utils.getCompressionMethod();
|
||||
const twirpClient = cacheTwirpClient.internalCacheTwirpClient();
|
||||
let cacheId = -1;
|
||||
@@ -6267,8 +6266,7 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) {
|
||||
throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache.`);
|
||||
}
|
||||
core.debug(`Attempting to upload cache located at: ${archivePath}`);
|
||||
const uploadResponse = yield (0, upload_cache_1.uploadCacheFile)(response.signedUploadUrl, archivePath);
|
||||
core.debug(`Download response status: ${uploadResponse._response.status}`);
|
||||
yield cacheHttpClient.saveCache(cacheId, archivePath, response.signedUploadUrl, options);
|
||||
const finalizeRequest = {
|
||||
key,
|
||||
version,
|
||||
@@ -8052,71 +8050,6 @@ exports.CacheScope = new CacheScope$Type();
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 302:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.uploadCacheFile = void 0;
|
||||
const core = __importStar(__nccwpck_require__(4850));
|
||||
const storage_blob_1 = __nccwpck_require__(3864);
|
||||
const errors_1 = __nccwpck_require__(6333);
|
||||
function uploadCacheFile(signedUploadURL, archivePath) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// Specify data transfer options
|
||||
const uploadOptions = {
|
||||
blockSize: 4 * 1024 * 1024,
|
||||
concurrency: 4,
|
||||
maxSingleShotSize: 8 * 1024 * 1024 // 8 MiB initial transfer size
|
||||
};
|
||||
const blobClient = new storage_blob_1.BlobClient(signedUploadURL);
|
||||
const blockBlobClient = blobClient.getBlockBlobClient();
|
||||
core.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`);
|
||||
const resp = yield blockBlobClient.uploadFile(archivePath, uploadOptions);
|
||||
if (resp._response.status >= 400) {
|
||||
throw new errors_1.InvalidResponseError(`Upload failed with status code ${resp._response.status}`);
|
||||
}
|
||||
return resp;
|
||||
});
|
||||
}
|
||||
exports.uploadCacheFile = uploadCacheFile;
|
||||
//# sourceMappingURL=upload-cache.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 2370:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
@@ -8162,6 +8095,7 @@ const auth_1 = __nccwpck_require__(7231);
|
||||
const fs = __importStar(__nccwpck_require__(7147));
|
||||
const url_1 = __nccwpck_require__(7310);
|
||||
const utils = __importStar(__nccwpck_require__(3310));
|
||||
const uploadUtils_1 = __nccwpck_require__(1157);
|
||||
const downloadUtils_1 = __nccwpck_require__(318);
|
||||
const options_1 = __nccwpck_require__(7190);
|
||||
const requestUtils_1 = __nccwpck_require__(7865);
|
||||
@@ -8348,20 +8282,30 @@ function commitCache(httpClient, cacheId, filesize) {
|
||||
}));
|
||||
});
|
||||
}
|
||||
function saveCache(cacheId, archivePath, options) {
|
||||
function saveCache(cacheId, archivePath, signedUploadURL, options) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const httpClient = createHttpClient();
|
||||
core.debug('Upload cache');
|
||||
yield uploadFile(httpClient, cacheId, archivePath, options);
|
||||
// Commit Cache
|
||||
core.debug('Commiting cache');
|
||||
const cacheSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||||
core.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`);
|
||||
const commitCacheResponse = yield commitCache(httpClient, cacheId, cacheSize);
|
||||
if (!(0, requestUtils_1.isSuccessStatusCode)(commitCacheResponse.statusCode)) {
|
||||
throw new Error(`Cache service responded with ${commitCacheResponse.statusCode} during commit cache.`);
|
||||
const uploadOptions = (0, options_1.getUploadOptions)(options);
|
||||
if (uploadOptions.useAzureSdk) {
|
||||
// Use Azure storage SDK to upload caches directly to Azure
|
||||
if (!signedUploadURL) {
|
||||
throw new Error('Azure Storage SDK can only be used when a signed URL is provided.');
|
||||
}
|
||||
yield (0, uploadUtils_1.uploadCacheArchiveSDK)(signedUploadURL, archivePath, options);
|
||||
}
|
||||
else {
|
||||
const httpClient = createHttpClient();
|
||||
core.debug('Upload cache');
|
||||
yield uploadFile(httpClient, cacheId, archivePath, options);
|
||||
// Commit Cache
|
||||
core.debug('Commiting cache');
|
||||
const cacheSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||||
core.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`);
|
||||
const commitCacheResponse = yield commitCache(httpClient, cacheId, cacheSize);
|
||||
if (!(0, requestUtils_1.isSuccessStatusCode)(commitCacheResponse.statusCode)) {
|
||||
throw new Error(`Cache service responded with ${commitCacheResponse.statusCode} during commit cache.`);
|
||||
}
|
||||
core.info('Cache saved successfully');
|
||||
}
|
||||
core.info('Cache saved successfully');
|
||||
});
|
||||
}
|
||||
exports.saveCache = saveCache;
|
||||
@@ -9752,6 +9696,71 @@ exports.createTar = createTar;
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 1157:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.uploadCacheArchiveSDK = void 0;
|
||||
const core = __importStar(__nccwpck_require__(4850));
|
||||
const storage_blob_1 = __nccwpck_require__(3864);
|
||||
const errors_1 = __nccwpck_require__(6333);
|
||||
function uploadCacheArchiveSDK(signedUploadURL, archivePath, options) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// Specify data transfer options
|
||||
const uploadOptions = {
|
||||
blockSize: options === null || options === void 0 ? void 0 : options.uploadChunkSize,
|
||||
concurrency: options === null || options === void 0 ? void 0 : options.uploadConcurrency,
|
||||
maxSingleShotSize: 128 * 1024 * 1024 // 128 MiB initial transfer size
|
||||
};
|
||||
const blobClient = new storage_blob_1.BlobClient(signedUploadURL);
|
||||
const blockBlobClient = blobClient.getBlockBlobClient();
|
||||
core.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`);
|
||||
const resp = yield blockBlobClient.uploadFile(archivePath, uploadOptions);
|
||||
if (resp._response.status >= 400) {
|
||||
throw new errors_1.InvalidResponseError(`Upload failed with status code ${resp._response.status}`);
|
||||
}
|
||||
return resp;
|
||||
});
|
||||
}
|
||||
exports.uploadCacheArchiveSDK = uploadCacheArchiveSDK;
|
||||
//# sourceMappingURL=uploadUtils.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 7190:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
@@ -9790,10 +9799,14 @@ const core = __importStar(__nccwpck_require__(4850));
|
||||
*/
|
||||
function getUploadOptions(copy) {
|
||||
const result = {
|
||||
useAzureSdk: false,
|
||||
uploadConcurrency: 4,
|
||||
uploadChunkSize: 32 * 1024 * 1024
|
||||
};
|
||||
if (copy) {
|
||||
if (typeof copy.useAzureSdk === 'boolean') {
|
||||
result.useAzureSdk = copy.useAzureSdk;
|
||||
}
|
||||
if (typeof copy.uploadConcurrency === 'number') {
|
||||
result.uploadConcurrency = copy.uploadConcurrency;
|
||||
}
|
||||
@@ -9801,6 +9814,7 @@ function getUploadOptions(copy) {
|
||||
result.uploadChunkSize = copy.uploadChunkSize;
|
||||
}
|
||||
}
|
||||
core.debug(`Use Azure SDK: ${result.useAzureSdk}`);
|
||||
core.debug(`Upload concurrency: ${result.uploadConcurrency}`);
|
||||
core.debug(`Upload chunk size: ${result.uploadChunkSize}`);
|
||||
return result;
|
||||
|
||||
186
dist/save/index.js
vendored
186
dist/save/index.js
vendored
@@ -5898,11 +5898,9 @@ const path = __importStar(__nccwpck_require__(1017));
|
||||
const utils = __importStar(__nccwpck_require__(3310));
|
||||
const cacheHttpClient = __importStar(__nccwpck_require__(2370));
|
||||
const cacheTwirpClient = __importStar(__nccwpck_require__(5726));
|
||||
const downloadUtils_1 = __nccwpck_require__(318);
|
||||
const config_1 = __nccwpck_require__(6490);
|
||||
const tar_1 = __nccwpck_require__(9099);
|
||||
const constants_1 = __nccwpck_require__(4010);
|
||||
const upload_cache_1 = __nccwpck_require__(302);
|
||||
class ValidationError extends Error {
|
||||
constructor(message) {
|
||||
super(message);
|
||||
@@ -6052,6 +6050,8 @@ function restoreCacheV1(paths, primaryKey, restoreKeys, options, enableCrossOsAr
|
||||
*/
|
||||
function restoreCacheV2(paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// Override UploadOptions to force the use of Azure
|
||||
options = Object.assign(Object.assign({}, options), { useAzureSdk: true });
|
||||
restoreKeys = restoreKeys || [];
|
||||
const keys = [primaryKey, ...restoreKeys];
|
||||
core.debug('Resolved Keys:');
|
||||
@@ -6084,10 +6084,7 @@ function restoreCacheV2(paths, primaryKey, restoreKeys, options, enableCrossOsAr
|
||||
archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod));
|
||||
core.debug(`Archive path: ${archivePath}`);
|
||||
core.debug(`Starting download of archive to: ${archivePath}`);
|
||||
yield (0, downloadUtils_1.downloadCacheStorageSDK)(response.signedDownloadUrl, archivePath, options ||
|
||||
{
|
||||
timeoutInMs: 30000
|
||||
});
|
||||
yield cacheHttpClient.downloadCache(response.signedDownloadUrl, archivePath, options);
|
||||
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||||
core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`);
|
||||
if (core.isDebug()) {
|
||||
@@ -6196,7 +6193,7 @@ function saveCacheV1(paths, key, options, enableCrossOsArchive = false) {
|
||||
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})`);
|
||||
yield cacheHttpClient.saveCache(cacheId, archivePath, options);
|
||||
yield cacheHttpClient.saveCache(cacheId, archivePath, '', options);
|
||||
}
|
||||
catch (error) {
|
||||
const typedError = error;
|
||||
@@ -6233,6 +6230,8 @@ function saveCacheV1(paths, key, options, enableCrossOsArchive = false) {
|
||||
*/
|
||||
function saveCacheV2(paths, key, options, enableCrossOsArchive = false) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// Override UploadOptions to force the use of Azure
|
||||
options = Object.assign(Object.assign({}, options), { useAzureSdk: true });
|
||||
const compressionMethod = yield utils.getCompressionMethod();
|
||||
const twirpClient = cacheTwirpClient.internalCacheTwirpClient();
|
||||
let cacheId = -1;
|
||||
@@ -6267,8 +6266,7 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) {
|
||||
throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache.`);
|
||||
}
|
||||
core.debug(`Attempting to upload cache located at: ${archivePath}`);
|
||||
const uploadResponse = yield (0, upload_cache_1.uploadCacheFile)(response.signedUploadUrl, archivePath);
|
||||
core.debug(`Download response status: ${uploadResponse._response.status}`);
|
||||
yield cacheHttpClient.saveCache(cacheId, archivePath, response.signedUploadUrl, options);
|
||||
const finalizeRequest = {
|
||||
key,
|
||||
version,
|
||||
@@ -8052,71 +8050,6 @@ exports.CacheScope = new CacheScope$Type();
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 302:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.uploadCacheFile = void 0;
|
||||
const core = __importStar(__nccwpck_require__(4850));
|
||||
const storage_blob_1 = __nccwpck_require__(3864);
|
||||
const errors_1 = __nccwpck_require__(6333);
|
||||
function uploadCacheFile(signedUploadURL, archivePath) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// Specify data transfer options
|
||||
const uploadOptions = {
|
||||
blockSize: 4 * 1024 * 1024,
|
||||
concurrency: 4,
|
||||
maxSingleShotSize: 8 * 1024 * 1024 // 8 MiB initial transfer size
|
||||
};
|
||||
const blobClient = new storage_blob_1.BlobClient(signedUploadURL);
|
||||
const blockBlobClient = blobClient.getBlockBlobClient();
|
||||
core.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`);
|
||||
const resp = yield blockBlobClient.uploadFile(archivePath, uploadOptions);
|
||||
if (resp._response.status >= 400) {
|
||||
throw new errors_1.InvalidResponseError(`Upload failed with status code ${resp._response.status}`);
|
||||
}
|
||||
return resp;
|
||||
});
|
||||
}
|
||||
exports.uploadCacheFile = uploadCacheFile;
|
||||
//# sourceMappingURL=upload-cache.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 2370:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
@@ -8162,6 +8095,7 @@ const auth_1 = __nccwpck_require__(7231);
|
||||
const fs = __importStar(__nccwpck_require__(7147));
|
||||
const url_1 = __nccwpck_require__(7310);
|
||||
const utils = __importStar(__nccwpck_require__(3310));
|
||||
const uploadUtils_1 = __nccwpck_require__(1157);
|
||||
const downloadUtils_1 = __nccwpck_require__(318);
|
||||
const options_1 = __nccwpck_require__(7190);
|
||||
const requestUtils_1 = __nccwpck_require__(7865);
|
||||
@@ -8348,20 +8282,30 @@ function commitCache(httpClient, cacheId, filesize) {
|
||||
}));
|
||||
});
|
||||
}
|
||||
function saveCache(cacheId, archivePath, options) {
|
||||
function saveCache(cacheId, archivePath, signedUploadURL, options) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const httpClient = createHttpClient();
|
||||
core.debug('Upload cache');
|
||||
yield uploadFile(httpClient, cacheId, archivePath, options);
|
||||
// Commit Cache
|
||||
core.debug('Commiting cache');
|
||||
const cacheSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||||
core.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`);
|
||||
const commitCacheResponse = yield commitCache(httpClient, cacheId, cacheSize);
|
||||
if (!(0, requestUtils_1.isSuccessStatusCode)(commitCacheResponse.statusCode)) {
|
||||
throw new Error(`Cache service responded with ${commitCacheResponse.statusCode} during commit cache.`);
|
||||
const uploadOptions = (0, options_1.getUploadOptions)(options);
|
||||
if (uploadOptions.useAzureSdk) {
|
||||
// Use Azure storage SDK to upload caches directly to Azure
|
||||
if (!signedUploadURL) {
|
||||
throw new Error('Azure Storage SDK can only be used when a signed URL is provided.');
|
||||
}
|
||||
yield (0, uploadUtils_1.uploadCacheArchiveSDK)(signedUploadURL, archivePath, options);
|
||||
}
|
||||
else {
|
||||
const httpClient = createHttpClient();
|
||||
core.debug('Upload cache');
|
||||
yield uploadFile(httpClient, cacheId, archivePath, options);
|
||||
// Commit Cache
|
||||
core.debug('Commiting cache');
|
||||
const cacheSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||||
core.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`);
|
||||
const commitCacheResponse = yield commitCache(httpClient, cacheId, cacheSize);
|
||||
if (!(0, requestUtils_1.isSuccessStatusCode)(commitCacheResponse.statusCode)) {
|
||||
throw new Error(`Cache service responded with ${commitCacheResponse.statusCode} during commit cache.`);
|
||||
}
|
||||
core.info('Cache saved successfully');
|
||||
}
|
||||
core.info('Cache saved successfully');
|
||||
});
|
||||
}
|
||||
exports.saveCache = saveCache;
|
||||
@@ -9752,6 +9696,71 @@ exports.createTar = createTar;
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 1157:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.uploadCacheArchiveSDK = void 0;
|
||||
const core = __importStar(__nccwpck_require__(4850));
|
||||
const storage_blob_1 = __nccwpck_require__(3864);
|
||||
const errors_1 = __nccwpck_require__(6333);
|
||||
function uploadCacheArchiveSDK(signedUploadURL, archivePath, options) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// Specify data transfer options
|
||||
const uploadOptions = {
|
||||
blockSize: options === null || options === void 0 ? void 0 : options.uploadChunkSize,
|
||||
concurrency: options === null || options === void 0 ? void 0 : options.uploadConcurrency,
|
||||
maxSingleShotSize: 128 * 1024 * 1024 // 128 MiB initial transfer size
|
||||
};
|
||||
const blobClient = new storage_blob_1.BlobClient(signedUploadURL);
|
||||
const blockBlobClient = blobClient.getBlockBlobClient();
|
||||
core.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`);
|
||||
const resp = yield blockBlobClient.uploadFile(archivePath, uploadOptions);
|
||||
if (resp._response.status >= 400) {
|
||||
throw new errors_1.InvalidResponseError(`Upload failed with status code ${resp._response.status}`);
|
||||
}
|
||||
return resp;
|
||||
});
|
||||
}
|
||||
exports.uploadCacheArchiveSDK = uploadCacheArchiveSDK;
|
||||
//# sourceMappingURL=uploadUtils.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 7190:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
@@ -9790,10 +9799,14 @@ const core = __importStar(__nccwpck_require__(4850));
|
||||
*/
|
||||
function getUploadOptions(copy) {
|
||||
const result = {
|
||||
useAzureSdk: false,
|
||||
uploadConcurrency: 4,
|
||||
uploadChunkSize: 32 * 1024 * 1024
|
||||
};
|
||||
if (copy) {
|
||||
if (typeof copy.useAzureSdk === 'boolean') {
|
||||
result.useAzureSdk = copy.useAzureSdk;
|
||||
}
|
||||
if (typeof copy.uploadConcurrency === 'number') {
|
||||
result.uploadConcurrency = copy.uploadConcurrency;
|
||||
}
|
||||
@@ -9801,6 +9814,7 @@ function getUploadOptions(copy) {
|
||||
result.uploadChunkSize = copy.uploadChunkSize;
|
||||
}
|
||||
}
|
||||
core.debug(`Use Azure SDK: ${result.useAzureSdk}`);
|
||||
core.debug(`Upload concurrency: ${result.uploadConcurrency}`);
|
||||
core.debug(`Upload chunk size: ${result.uploadChunkSize}`);
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user