Implement cache v2

This commit is contained in:
Bassem Dghaidi 2024-06-10 11:07:49 -07:00 committed by GitHub
parent 270eaa9768
commit f7e6edf3a0
5 changed files with 299 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);
@ -10029,6 +10030,12 @@ function saveCache(paths, key, options, enableCrossOsArchive = false) {
}
core.debug(`Saving Cache (ID: ${cacheId})`);
yield cacheHttpClient.saveCache(cacheId, archivePath, options);
// Cache v2 upload
// inputs:
// - getSignedUploadURL
// - archivePath
core.debug(`Saving Cache v2: ${archivePath}`);
yield (0, upload_cache_1.UploadCache)(signedUploadURL, archivePath);
}
catch (error) {
const typedError = error;
@ -12312,6 +12319,68 @@ 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.debug(`Uploading cache to: ${uploadURL}`);
// Specify data transfer options
const uploadOptions = {
blockSize: 4 * 1024 * 1024,
concurrency: 2,
maxSingleShotSize: 8 * 1024 * 1024, // 8 MiB initial transfer size
};
// Create blob client from container client
// const blobClient: BlobClient = new BlobClient(uploadURL.urls[0])
const blobClient = new storage_blob_1.BlobClient(uploadURL.urls[0].url);
const blockBlobClient = blobClient.getBlockBlobClient();
return blockBlobClient.uploadFile(archivePath, uploadOptions);
});
}
exports.UploadCache = UploadCache;
//# sourceMappingURL=upload-cache.js.map
/***/ }),
/***/ 7190:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {

79
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);
@ -10029,6 +10030,12 @@ function saveCache(paths, key, options, enableCrossOsArchive = false) {
}
core.debug(`Saving Cache (ID: ${cacheId})`);
yield cacheHttpClient.saveCache(cacheId, archivePath, options);
// Cache v2 upload
// inputs:
// - getSignedUploadURL
// - archivePath
core.debug(`Saving Cache v2: ${archivePath}`);
yield (0, upload_cache_1.UploadCache)(signedUploadURL, archivePath);
}
catch (error) {
const typedError = error;
@ -12312,6 +12319,68 @@ 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.debug(`Uploading cache to: ${uploadURL}`);
// Specify data transfer options
const uploadOptions = {
blockSize: 4 * 1024 * 1024,
concurrency: 2,
maxSingleShotSize: 8 * 1024 * 1024, // 8 MiB initial transfer size
};
// Create blob client from container client
// const blobClient: BlobClient = new BlobClient(uploadURL.urls[0])
const blobClient = new storage_blob_1.BlobClient(uploadURL.urls[0].url);
const blockBlobClient = blobClient.getBlockBlobClient();
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);
@ -10029,6 +10030,12 @@ function saveCache(paths, key, options, enableCrossOsArchive = false) {
}
core.debug(`Saving Cache (ID: ${cacheId})`);
yield cacheHttpClient.saveCache(cacheId, archivePath, options);
// Cache v2 upload
// inputs:
// - getSignedUploadURL
// - archivePath
core.debug(`Saving Cache v2: ${archivePath}`);
yield (0, upload_cache_1.UploadCache)(signedUploadURL, archivePath);
}
catch (error) {
const typedError = error;
@ -12312,6 +12319,68 @@ 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.debug(`Uploading cache to: ${uploadURL}`);
// Specify data transfer options
const uploadOptions = {
blockSize: 4 * 1024 * 1024,
concurrency: 2,
maxSingleShotSize: 8 * 1024 * 1024, // 8 MiB initial transfer size
};
// Create blob client from container client
// const blobClient: BlobClient = new BlobClient(uploadURL.urls[0])
const blobClient = new storage_blob_1.BlobClient(uploadURL.urls[0].url);
const blockBlobClient = blobClient.getBlockBlobClient();
return blockBlobClient.uploadFile(archivePath, uploadOptions);
});
}
exports.UploadCache = UploadCache;
//# sourceMappingURL=upload-cache.js.map
/***/ }),
/***/ 7190:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {

79
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);
@ -10029,6 +10030,12 @@ function saveCache(paths, key, options, enableCrossOsArchive = false) {
}
core.debug(`Saving Cache (ID: ${cacheId})`);
yield cacheHttpClient.saveCache(cacheId, archivePath, options);
// Cache v2 upload
// inputs:
// - getSignedUploadURL
// - archivePath
core.debug(`Saving Cache v2: ${archivePath}`);
yield (0, upload_cache_1.UploadCache)(signedUploadURL, archivePath);
}
catch (error) {
const typedError = error;
@ -12312,6 +12319,68 @@ 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.debug(`Uploading cache to: ${uploadURL}`);
// Specify data transfer options
const uploadOptions = {
blockSize: 4 * 1024 * 1024,
concurrency: 2,
maxSingleShotSize: 8 * 1024 * 1024, // 8 MiB initial transfer size
};
// Create blob client from container client
// const blobClient: BlobClient = new BlobClient(uploadURL.urls[0])
const blobClient = new storage_blob_1.BlobClient(uploadURL.urls[0].url);
const blockBlobClient = blobClient.getBlockBlobClient();
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"
},