mirror of
https://github.com/ruby/setup-ruby.git
synced 2026-09-14 06:54:20 +02:00
using actions/cache version 1.0.8
This commit is contained in:
committed by
Benoit Daloze
parent
bb8200704b
commit
e7eea4e63a
+27
-16
@@ -536,7 +536,7 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
|
|||||||
if (core.isDebug()) {
|
if (core.isDebug()) {
|
||||||
yield tar_1.listTar(archivePath, compressionMethod);
|
yield tar_1.listTar(archivePath, compressionMethod);
|
||||||
}
|
}
|
||||||
const archiveFileSize = utils.getArchiveFileSizeIsBytes(archivePath);
|
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||||||
core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`);
|
core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`);
|
||||||
yield tar_1.extractTar(archivePath, compressionMethod);
|
yield tar_1.extractTar(archivePath, compressionMethod);
|
||||||
core.info('Cache restored successfully');
|
core.info('Cache restored successfully');
|
||||||
@@ -581,18 +581,29 @@ function saveCache(paths, key, options) {
|
|||||||
const archiveFolder = yield utils.createTempDirectory();
|
const archiveFolder = yield utils.createTempDirectory();
|
||||||
const archivePath = path.join(archiveFolder, utils.getCacheFileName(compressionMethod));
|
const archivePath = path.join(archiveFolder, utils.getCacheFileName(compressionMethod));
|
||||||
core.debug(`Archive Path: ${archivePath}`);
|
core.debug(`Archive Path: ${archivePath}`);
|
||||||
yield tar_1.createTar(archiveFolder, cachePaths, compressionMethod);
|
try {
|
||||||
if (core.isDebug()) {
|
yield tar_1.createTar(archiveFolder, cachePaths, compressionMethod);
|
||||||
yield tar_1.listTar(archivePath, compressionMethod);
|
if (core.isDebug()) {
|
||||||
|
yield tar_1.listTar(archivePath, compressionMethod);
|
||||||
|
}
|
||||||
|
const fileSizeLimit = 10 * 1024 * 1024 * 1024; // 10GB per repo limit
|
||||||
|
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||||||
|
core.debug(`File Size: ${archiveFileSize}`);
|
||||||
|
if (archiveFileSize > fileSizeLimit) {
|
||||||
|
throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`);
|
||||||
|
}
|
||||||
|
core.debug(`Saving Cache (ID: ${cacheId})`);
|
||||||
|
yield cacheHttpClient.saveCache(cacheId, archivePath, options);
|
||||||
}
|
}
|
||||||
const fileSizeLimit = 5 * 1024 * 1024 * 1024; // 5GB per repo limit
|
finally {
|
||||||
const archiveFileSize = utils.getArchiveFileSizeIsBytes(archivePath);
|
// Try to delete the archive to save space
|
||||||
core.debug(`File Size: ${archiveFileSize}`);
|
try {
|
||||||
if (archiveFileSize > fileSizeLimit) {
|
yield utils.unlinkFile(archivePath);
|
||||||
throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 5GB limit, not saving cache.`);
|
}
|
||||||
|
catch (error) {
|
||||||
|
core.debug(`Failed to delete archive: ${error}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
core.debug(`Saving Cache (ID: ${cacheId})`);
|
|
||||||
yield cacheHttpClient.saveCache(cacheId, archivePath, options);
|
|
||||||
return cacheId;
|
return cacheId;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -760,7 +771,7 @@ function uploadChunk(httpClient, resourceUrl, openStream, start, end) {
|
|||||||
function uploadFile(httpClient, cacheId, archivePath, options) {
|
function uploadFile(httpClient, cacheId, archivePath, options) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
// Upload Chunks
|
// Upload Chunks
|
||||||
const fileSize = fs.statSync(archivePath).size;
|
const fileSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||||||
const resourceUrl = getCacheApiUrl(`caches/${cacheId.toString()}`);
|
const resourceUrl = getCacheApiUrl(`caches/${cacheId.toString()}`);
|
||||||
const fd = fs.openSync(archivePath, 'r');
|
const fd = fs.openSync(archivePath, 'r');
|
||||||
const uploadOptions = options_1.getUploadOptions(options);
|
const uploadOptions = options_1.getUploadOptions(options);
|
||||||
@@ -810,7 +821,7 @@ function saveCache(cacheId, archivePath, options) {
|
|||||||
yield uploadFile(httpClient, cacheId, archivePath, options);
|
yield uploadFile(httpClient, cacheId, archivePath, options);
|
||||||
// Commit Cache
|
// Commit Cache
|
||||||
core.debug('Commiting cache');
|
core.debug('Commiting cache');
|
||||||
const cacheSize = utils.getArchiveFileSizeIsBytes(archivePath);
|
const cacheSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||||||
core.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`);
|
core.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`);
|
||||||
const commitCacheResponse = yield commitCache(httpClient, cacheId, cacheSize);
|
const commitCacheResponse = yield commitCache(httpClient, cacheId, cacheSize);
|
||||||
if (!requestUtils_1.isSuccessStatusCode(commitCacheResponse.statusCode)) {
|
if (!requestUtils_1.isSuccessStatusCode(commitCacheResponse.statusCode)) {
|
||||||
@@ -890,10 +901,10 @@ function createTempDirectory() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.createTempDirectory = createTempDirectory;
|
exports.createTempDirectory = createTempDirectory;
|
||||||
function getArchiveFileSizeIsBytes(filePath) {
|
function getArchiveFileSizeInBytes(filePath) {
|
||||||
return fs.statSync(filePath).size;
|
return fs.statSync(filePath).size;
|
||||||
}
|
}
|
||||||
exports.getArchiveFileSizeIsBytes = getArchiveFileSizeIsBytes;
|
exports.getArchiveFileSizeInBytes = getArchiveFileSizeInBytes;
|
||||||
function resolvePaths(patterns) {
|
function resolvePaths(patterns) {
|
||||||
var e_1, _a;
|
var e_1, _a;
|
||||||
var _b;
|
var _b;
|
||||||
@@ -1198,7 +1209,7 @@ function downloadCacheHttpClient(archiveLocation, archivePath) {
|
|||||||
const contentLengthHeader = downloadResponse.message.headers['content-length'];
|
const contentLengthHeader = downloadResponse.message.headers['content-length'];
|
||||||
if (contentLengthHeader) {
|
if (contentLengthHeader) {
|
||||||
const expectedLength = parseInt(contentLengthHeader);
|
const expectedLength = parseInt(contentLengthHeader);
|
||||||
const actualLength = utils.getArchiveFileSizeIsBytes(archivePath);
|
const actualLength = utils.getArchiveFileSizeInBytes(archivePath);
|
||||||
if (actualLength !== expectedLength) {
|
if (actualLength !== expectedLength) {
|
||||||
throw new Error(`Incomplete download. Expected file size: ${expectedLength}, actual file size: ${actualLength}`);
|
throw new Error(`Incomplete download. Expected file size: ${expectedLength}, actual file size: ${actualLength}`);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/ruby/setup-ruby",
|
"homepage": "https://github.com/ruby/setup-ruby",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "^1.0.7",
|
"@actions/cache": "^1.0.8",
|
||||||
"@actions/core": "^1.4.0",
|
"@actions/core": "^1.4.0",
|
||||||
"@actions/exec": "^1.1.0",
|
"@actions/exec": "^1.1.0",
|
||||||
"@actions/io": "^1.1.1",
|
"@actions/io": "^1.1.1",
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
# yarn lockfile v1
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
||||||
"@actions/cache@^1.0.7":
|
"@actions/cache@^1.0.8":
|
||||||
version "1.0.7"
|
version "1.0.8"
|
||||||
resolved "https://registry.yarnpkg.com/@actions/cache/-/cache-1.0.7.tgz#d80b0f5ac1e1ad48a5e77c39685100bd49b56b1c"
|
resolved "https://registry.yarnpkg.com/@actions/cache/-/cache-1.0.8.tgz#426ad3a2127b35a4e21ad906e02202dc8b96663f"
|
||||||
integrity sha512-MY69kxuubqUFq84pFlu8m6Poxl5sR/xyhpC4JEvno7Yg9ASYdGizEmKgt0m8ovewpYKf15UAOcSC0hzS+DuosA==
|
integrity sha512-GWNNB67w93HGJRQXlsV56YqrdAuDoP3esK/mo5mzU8WoDCVjtQgJGsTdkYUX7brswtT7xnI30bWNo1WLKQ8FZQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@actions/core" "^1.2.6"
|
"@actions/core" "^1.2.6"
|
||||||
"@actions/exec" "^1.0.1"
|
"@actions/exec" "^1.0.1"
|
||||||
|
|||||||
Reference in New Issue
Block a user