Compare commits

...

4 Commits

Author SHA1 Message Date
Bassem Dghaidi
b4b70a7f57 Implement cache v2 2024-06-10 12:13:36 -07:00
Bassem Dghaidi
b88a5b44f3 Implement cache v2 2024-06-10 12:02:34 -07:00
Bassem Dghaidi
643d6d6123 Implement cache v2 2024-06-10 11:37:36 -07:00
Bassem Dghaidi
f7e6edf3a0 Implement cache v2 2024-06-10 11:07:49 -07:00
5 changed files with 303 additions and 20 deletions

View File

@ -9852,6 +9852,7 @@ const constants_1 = __nccwpck_require__(4010);
const cacheHttpClient = __importStar(__nccwpck_require__(2370));
const cacheTwirpClient = __importStar(__nccwpck_require__(5451));
const tar_1 = __nccwpck_require__(9099);
const upload_cache_1 = __nccwpck_require__(8105);
class ValidationError extends Error {
constructor(message) {
super(message);
@ -9983,12 +9984,12 @@ function saveCache(paths, key, options, enableCrossOsArchive = false) {
// TODO: REMOVE ME
// Making a call to the service
const twirpClient = cacheTwirpClient.internalBlobCacheTwirpClient();
const getBlobRequest = {
owner: "link-/test",
keys: ['test-123412631236126'],
const getSignedUploadURL = {
organization: "github",
keys: [key],
};
const getBlobResponse = yield twirpClient.GetCachedBlob(getBlobRequest);
core.info(`GetCachedBlobResponse: ${JSON.stringify(getBlobResponse)}`);
const signedUploadURL = yield twirpClient.GetCacheBlobUploadURL(getSignedUploadURL);
core.info(`GetCacheBlobUploadURLResponse: ${JSON.stringify(signedUploadURL)}`);
const compressionMethod = yield utils.getCompressionMethod();
let cacheId = -1;
const cachePaths = yield utils.resolvePaths(paths);
@ -10012,6 +10013,12 @@ function saveCache(paths, key, options, enableCrossOsArchive = false) {
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.`);
}
// Cache v2 upload
// inputs:
// - getSignedUploadURL
// - archivePath
core.info(`Saving Cache v2: ${archivePath}`);
yield (0, upload_cache_1.UploadCache)(signedUploadURL, archivePath);
core.debug('Reserving Cache');
const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, {
compressionMethod,
@ -12312,6 +12319,69 @@ exports.createTar = createTar;
/***/ }),
/***/ 8105:
/***/ (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.UploadCache = void 0;
const core = __importStar(__nccwpck_require__(4850));
const storage_blob_1 = __nccwpck_require__(3864);
function UploadCache(uploadURL, archivePath) {
return __awaiter(this, void 0, void 0, function* () {
core.info(`Uploading ${archivePath} to: ${JSON.stringify(uploadURL)}`);
// Specify data transfer options
const uploadOptions = {
blockSize: 4 * 1024 * 1024,
concurrency: 2,
maxSingleShotSize: 8 * 1024 * 1024, // 8 MiB initial transfer size
};
// const blobClient: BlobClient = new BlobClient(uploadURL.urls[0])
const blobClient = new storage_blob_1.BlobClient(uploadURL.urls[0].url);
const blockBlobClient = blobClient.getBlockBlobClient();
core.info(`BlobClient: ${JSON.stringify(blobClient)}`);
core.info(`blockBlobClient: ${JSON.stringify(blockBlobClient)}`);
return blockBlobClient.uploadFile(archivePath, uploadOptions);
});
}
exports.UploadCache = UploadCache;
//# sourceMappingURL=upload-cache.js.map
/***/ }),
/***/ 7190:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {

80
dist/restore/index.js vendored
View File

@ -9852,6 +9852,7 @@ const constants_1 = __nccwpck_require__(4010);
const cacheHttpClient = __importStar(__nccwpck_require__(2370));
const cacheTwirpClient = __importStar(__nccwpck_require__(5451));
const tar_1 = __nccwpck_require__(9099);
const upload_cache_1 = __nccwpck_require__(8105);
class ValidationError extends Error {
constructor(message) {
super(message);
@ -9983,12 +9984,12 @@ function saveCache(paths, key, options, enableCrossOsArchive = false) {
// TODO: REMOVE ME
// Making a call to the service
const twirpClient = cacheTwirpClient.internalBlobCacheTwirpClient();
const getBlobRequest = {
owner: "link-/test",
keys: ['test-123412631236126'],
const getSignedUploadURL = {
organization: "github",
keys: [key],
};
const getBlobResponse = yield twirpClient.GetCachedBlob(getBlobRequest);
core.info(`GetCachedBlobResponse: ${JSON.stringify(getBlobResponse)}`);
const signedUploadURL = yield twirpClient.GetCacheBlobUploadURL(getSignedUploadURL);
core.info(`GetCacheBlobUploadURLResponse: ${JSON.stringify(signedUploadURL)}`);
const compressionMethod = yield utils.getCompressionMethod();
let cacheId = -1;
const cachePaths = yield utils.resolvePaths(paths);
@ -10012,6 +10013,12 @@ function saveCache(paths, key, options, enableCrossOsArchive = false) {
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.`);
}
// Cache v2 upload
// inputs:
// - getSignedUploadURL
// - archivePath
core.info(`Saving Cache v2: ${archivePath}`);
yield (0, upload_cache_1.UploadCache)(signedUploadURL, archivePath);
core.debug('Reserving Cache');
const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, {
compressionMethod,
@ -12312,6 +12319,69 @@ exports.createTar = createTar;
/***/ }),
/***/ 8105:
/***/ (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.UploadCache = void 0;
const core = __importStar(__nccwpck_require__(4850));
const storage_blob_1 = __nccwpck_require__(3864);
function UploadCache(uploadURL, archivePath) {
return __awaiter(this, void 0, void 0, function* () {
core.info(`Uploading ${archivePath} to: ${JSON.stringify(uploadURL)}`);
// Specify data transfer options
const uploadOptions = {
blockSize: 4 * 1024 * 1024,
concurrency: 2,
maxSingleShotSize: 8 * 1024 * 1024, // 8 MiB initial transfer size
};
// const blobClient: BlobClient = new BlobClient(uploadURL.urls[0])
const blobClient = new storage_blob_1.BlobClient(uploadURL.urls[0].url);
const blockBlobClient = blobClient.getBlockBlobClient();
core.info(`BlobClient: ${JSON.stringify(blobClient)}`);
core.info(`blockBlobClient: ${JSON.stringify(blockBlobClient)}`);
return blockBlobClient.uploadFile(archivePath, uploadOptions);
});
}
exports.UploadCache = UploadCache;
//# sourceMappingURL=upload-cache.js.map
/***/ }),
/***/ 7190:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {

View File

@ -9852,6 +9852,7 @@ const constants_1 = __nccwpck_require__(4010);
const cacheHttpClient = __importStar(__nccwpck_require__(2370));
const cacheTwirpClient = __importStar(__nccwpck_require__(5451));
const tar_1 = __nccwpck_require__(9099);
const upload_cache_1 = __nccwpck_require__(8105);
class ValidationError extends Error {
constructor(message) {
super(message);
@ -9983,12 +9984,12 @@ function saveCache(paths, key, options, enableCrossOsArchive = false) {
// TODO: REMOVE ME
// Making a call to the service
const twirpClient = cacheTwirpClient.internalBlobCacheTwirpClient();
const getBlobRequest = {
owner: "link-/test",
keys: ['test-123412631236126'],
const getSignedUploadURL = {
organization: "github",
keys: [key],
};
const getBlobResponse = yield twirpClient.GetCachedBlob(getBlobRequest);
core.info(`GetCachedBlobResponse: ${JSON.stringify(getBlobResponse)}`);
const signedUploadURL = yield twirpClient.GetCacheBlobUploadURL(getSignedUploadURL);
core.info(`GetCacheBlobUploadURLResponse: ${JSON.stringify(signedUploadURL)}`);
const compressionMethod = yield utils.getCompressionMethod();
let cacheId = -1;
const cachePaths = yield utils.resolvePaths(paths);
@ -10012,6 +10013,12 @@ function saveCache(paths, key, options, enableCrossOsArchive = false) {
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.`);
}
// Cache v2 upload
// inputs:
// - getSignedUploadURL
// - archivePath
core.info(`Saving Cache v2: ${archivePath}`);
yield (0, upload_cache_1.UploadCache)(signedUploadURL, archivePath);
core.debug('Reserving Cache');
const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, {
compressionMethod,
@ -12312,6 +12319,69 @@ exports.createTar = createTar;
/***/ }),
/***/ 8105:
/***/ (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.UploadCache = void 0;
const core = __importStar(__nccwpck_require__(4850));
const storage_blob_1 = __nccwpck_require__(3864);
function UploadCache(uploadURL, archivePath) {
return __awaiter(this, void 0, void 0, function* () {
core.info(`Uploading ${archivePath} to: ${JSON.stringify(uploadURL)}`);
// Specify data transfer options
const uploadOptions = {
blockSize: 4 * 1024 * 1024,
concurrency: 2,
maxSingleShotSize: 8 * 1024 * 1024, // 8 MiB initial transfer size
};
// const blobClient: BlobClient = new BlobClient(uploadURL.urls[0])
const blobClient = new storage_blob_1.BlobClient(uploadURL.urls[0].url);
const blockBlobClient = blobClient.getBlockBlobClient();
core.info(`BlobClient: ${JSON.stringify(blobClient)}`);
core.info(`blockBlobClient: ${JSON.stringify(blockBlobClient)}`);
return blockBlobClient.uploadFile(archivePath, uploadOptions);
});
}
exports.UploadCache = UploadCache;
//# sourceMappingURL=upload-cache.js.map
/***/ }),
/***/ 7190:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {

80
dist/save/index.js vendored
View File

@ -9852,6 +9852,7 @@ const constants_1 = __nccwpck_require__(4010);
const cacheHttpClient = __importStar(__nccwpck_require__(2370));
const cacheTwirpClient = __importStar(__nccwpck_require__(5451));
const tar_1 = __nccwpck_require__(9099);
const upload_cache_1 = __nccwpck_require__(8105);
class ValidationError extends Error {
constructor(message) {
super(message);
@ -9983,12 +9984,12 @@ function saveCache(paths, key, options, enableCrossOsArchive = false) {
// TODO: REMOVE ME
// Making a call to the service
const twirpClient = cacheTwirpClient.internalBlobCacheTwirpClient();
const getBlobRequest = {
owner: "link-/test",
keys: ['test-123412631236126'],
const getSignedUploadURL = {
organization: "github",
keys: [key],
};
const getBlobResponse = yield twirpClient.GetCachedBlob(getBlobRequest);
core.info(`GetCachedBlobResponse: ${JSON.stringify(getBlobResponse)}`);
const signedUploadURL = yield twirpClient.GetCacheBlobUploadURL(getSignedUploadURL);
core.info(`GetCacheBlobUploadURLResponse: ${JSON.stringify(signedUploadURL)}`);
const compressionMethod = yield utils.getCompressionMethod();
let cacheId = -1;
const cachePaths = yield utils.resolvePaths(paths);
@ -10012,6 +10013,12 @@ function saveCache(paths, key, options, enableCrossOsArchive = false) {
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.`);
}
// Cache v2 upload
// inputs:
// - getSignedUploadURL
// - archivePath
core.info(`Saving Cache v2: ${archivePath}`);
yield (0, upload_cache_1.UploadCache)(signedUploadURL, archivePath);
core.debug('Reserving Cache');
const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, {
compressionMethod,
@ -12312,6 +12319,69 @@ exports.createTar = createTar;
/***/ }),
/***/ 8105:
/***/ (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.UploadCache = void 0;
const core = __importStar(__nccwpck_require__(4850));
const storage_blob_1 = __nccwpck_require__(3864);
function UploadCache(uploadURL, archivePath) {
return __awaiter(this, void 0, void 0, function* () {
core.info(`Uploading ${archivePath} to: ${JSON.stringify(uploadURL)}`);
// Specify data transfer options
const uploadOptions = {
blockSize: 4 * 1024 * 1024,
concurrency: 2,
maxSingleShotSize: 8 * 1024 * 1024, // 8 MiB initial transfer size
};
// const blobClient: BlobClient = new BlobClient(uploadURL.urls[0])
const blobClient = new storage_blob_1.BlobClient(uploadURL.urls[0].url);
const blockBlobClient = blobClient.getBlockBlobClient();
core.info(`BlobClient: ${JSON.stringify(blobClient)}`);
core.info(`blockBlobClient: ${JSON.stringify(blockBlobClient)}`);
return blockBlobClient.uploadFile(archivePath, uploadOptions);
});
}
exports.UploadCache = UploadCache;
//# sourceMappingURL=upload-cache.js.map
/***/ }),
/***/ 7190:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {

3
package-lock.json generated
View File

@ -71,6 +71,7 @@
}
},
"../toolkit/packages/cache": {
"name": "@actions/cache",
"version": "3.2.4",
"license": "MIT",
"dependencies": {
@ -112,6 +113,7 @@
"extraneous": true
},
"../toolkit/packages/exec": {
"name": "@actions/exec",
"version": "1.1.1",
"license": "MIT",
"dependencies": {
@ -119,6 +121,7 @@
}
},
"../toolkit/packages/io": {
"name": "@actions/io",
"version": "1.1.3",
"license": "MIT"
},