Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 66 additions & 10 deletions dist/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23083,7 +23083,7 @@ var require_package = __commonJS({
"node_modules/@actions/cache/package.json"(exports2, module) {
module.exports = {
name: "@actions/cache",
version: "6.1.0",
version: "6.2.0",
description: "Actions cache lib",
keywords: [
"github",
Expand Down Expand Up @@ -31443,6 +31443,7 @@ var SystemTarPathOnWindows = `${process.env["SYSTEMDRIVE"]}\\Windows\\System32\\
var TarFilename = "cache.tar";
var ManifestFilename = "manifest.txt";
var CacheFileSizeLimit = 10 * Math.pow(1024, 3);
var CacheReadDeniedMessagePrefix = "cache read denied:";

// node_modules/@actions/cache/lib/internal/cacheUtils.js
var __awaiter12 = function(thisArg, _arguments, P, generator) {
Expand Down Expand Up @@ -64154,6 +64155,20 @@ function getCacheServiceVersion() {
return "v1";
return process.env["ACTIONS_CACHE_SERVICE_V2"] ? "v2" : "v1";
}
var KNOWN_CACHE_MODES = ["none", "read", "write", "write-only"];
function getCacheMode() {
return (process.env["ACTIONS_CACHE_MODE"] || "").trim().toLowerCase();
}
function isCacheReadable(mode) {
if (!KNOWN_CACHE_MODES.includes(mode))
return true;
return mode === "read" || mode === "write";
}
function isCacheWritable(mode) {
if (!KNOWN_CACHE_MODES.includes(mode))
return true;
return mode === "write" || mode === "write-only";
}
function getCacheServiceURL() {
const version3 = getCacheServiceVersion();
switch (version3) {
Expand Down Expand Up @@ -64227,6 +64242,7 @@ function createHttpClient() {
}
function getCacheEntry(keys, paths, options) {
return __awaiter16(this, void 0, void 0, function* () {
var _a;
const httpClient2 = createHttpClient();
const version3 = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod, options === null || options === void 0 ? void 0 : options.enableCrossOsArchive);
const resource = `cache?keys=${encodeURIComponent(keys.join(","))}&version=${version3}`;
Expand All @@ -64240,6 +64256,10 @@ function getCacheEntry(keys, paths, options) {
return null;
}
if (!isSuccessStatusCode(response.statusCode)) {
const errorMessage = (_a = response.error) === null || _a === void 0 ? void 0 : _a.message;
if (errorMessage === null || errorMessage === void 0 ? void 0 : errorMessage.includes(CacheReadDeniedMessagePrefix)) {
throw new Error(errorMessage);
}
throw new Error(`Cache service responded with ${response.statusCode}`);
}
const cacheResult = response.result;
Expand Down Expand Up @@ -65488,6 +65508,14 @@ var CacheWriteDeniedError = class _CacheWriteDeniedError extends ReserveCacheErr
Object.setPrototypeOf(this, _CacheWriteDeniedError.prototype);
}
};
var CACHE_READ_DENIED_PREFIX = CacheReadDeniedMessagePrefix;
var CacheReadDeniedError = class _CacheReadDeniedError extends Error {
constructor(message) {
super(message);
this.name = "CacheReadDeniedError";
Object.setPrototypeOf(this, _CacheReadDeniedError.prototype);
}
};
var FinalizeCacheError = class _FinalizeCacheError extends Error {
constructor(message) {
super(message);
Expand All @@ -65514,6 +65542,12 @@ function restoreCache(paths_1, primaryKey_1, restoreKeys_1, options_1) {
const cacheServiceVersion = getCacheServiceVersion();
debug(`Cache service version: ${cacheServiceVersion}`);
checkPaths(paths);
const cacheMode = getCacheMode();
if (!isCacheReadable(cacheMode)) {
info(`Cache restore skipped: the effective cache-mode '${cacheMode}' does not permit reads.`);
debug(`Skipped restore for paths [${paths.join(", ")}] with primary key '${primaryKey}'.`);
return void 0;
}
switch (cacheServiceVersion) {
case "v2":
return yield restoreCacheV2(paths, primaryKey, restoreKeys, options, enableCrossOsArchive);
Expand All @@ -65525,6 +65559,7 @@ function restoreCache(paths_1, primaryKey_1, restoreKeys_1, options_1) {
}
function restoreCacheV1(paths_1, primaryKey_1, restoreKeys_1, options_1) {
return __awaiter19(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) {
var _a;
restoreKeys = restoreKeys || [];
const keys = [primaryKey, ...restoreKeys];
debug("Resolved Keys:");
Expand All @@ -65538,10 +65573,19 @@ function restoreCacheV1(paths_1, primaryKey_1, restoreKeys_1, options_1) {
const compressionMethod = yield getCompressionMethod();
let archivePath = "";
try {
const cacheEntry = yield getCacheEntry(keys, paths, {
compressionMethod,
enableCrossOsArchive
});
let cacheEntry;
try {
cacheEntry = yield getCacheEntry(keys, paths, {
compressionMethod,
enableCrossOsArchive
});
} catch (error2) {
const errorMessage = (_a = error2 === null || error2 === void 0 ? void 0 : error2.message) !== null && _a !== void 0 ? _a : "";
if (errorMessage.includes(CACHE_READ_DENIED_PREFIX)) {
throw new CacheReadDeniedError(errorMessage);
}
throw error2;
}
if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) {
return void 0;
}
Expand Down Expand Up @@ -65583,6 +65627,7 @@ function restoreCacheV1(paths_1, primaryKey_1, restoreKeys_1, options_1) {
}
function restoreCacheV2(paths_1, primaryKey_1, restoreKeys_1, options_1) {
return __awaiter19(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) {
var _a;
options = Object.assign(Object.assign({}, options), { useAzureSdk: true });
restoreKeys = restoreKeys || [];
const keys = [primaryKey, ...restoreKeys];
Expand All @@ -65603,7 +65648,16 @@ function restoreCacheV2(paths_1, primaryKey_1, restoreKeys_1, options_1) {
restoreKeys,
version: getCacheVersion(paths, compressionMethod, enableCrossOsArchive)
};
const response = yield twirpClient.GetCacheEntryDownloadURL(request2);
let response;
try {
response = yield twirpClient.GetCacheEntryDownloadURL(request2);
} catch (error2) {
const errorMessage = (_a = error2 === null || error2 === void 0 ? void 0 : error2.message) !== null && _a !== void 0 ? _a : "";
if (errorMessage.includes(CACHE_READ_DENIED_PREFIX)) {
throw new CacheReadDeniedError(errorMessage);
}
throw error2;
}
if (!response.ok) {
debug(`Cache not found for version ${request2.version} of keys: ${keys.join(", ")}`);
return void 0;
Expand Down Expand Up @@ -65659,6 +65713,12 @@ function saveCache2(paths_1, key_1, options_1) {
debug(`Cache service version: ${cacheServiceVersion}`);
checkPaths(paths);
checkKey(key);
const cacheMode = getCacheMode();
if (!isCacheWritable(cacheMode)) {
info(`Cache save skipped: the effective cache-mode '${cacheMode}' does not permit writes.`);
debug(`Skipped save for paths [${paths.join(", ")}] with key '${key}'.`);
return -1;
}
switch (cacheServiceVersion) {
case "v2":
return yield saveCacheV2(paths, key, options, enableCrossOsArchive);
Expand Down Expand Up @@ -65716,8 +65776,6 @@ function saveCacheV1(paths_1, key_1, options_1) {
const typedError = error2;
if (typedError.name === ValidationError.name) {
throw error2;
} else if (typedError.name === CacheWriteDeniedError.name) {
warning(`Failed to save: ${typedError.message}`);
} else if (typedError.name === ReserveCacheError.name) {
info(`Failed to save: ${typedError.message}`);
} else {
Expand Down Expand Up @@ -65805,8 +65863,6 @@ function saveCacheV2(paths_1, key_1, options_1) {
const typedError = error2;
if (typedError.name === ValidationError.name) {
throw error2;
} else if (typedError.name === CacheWriteDeniedError.name) {
warning(`Failed to save: ${typedError.message}`);
} else if (typedError.name === ReserveCacheError.name) {
info(`Failed to save: ${typedError.message}`);
} else if (typedError.name === FinalizeCacheError.name) {
Expand Down
21 changes: 16 additions & 5 deletions dist/post/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23986,7 +23986,7 @@ var require_package = __commonJS({
"node_modules/@actions/cache/package.json"(exports2, module) {
module.exports = {
name: "@actions/cache",
version: "6.1.0",
version: "6.2.0",
description: "Actions cache lib",
keywords: [
"github",
Expand Down Expand Up @@ -66978,6 +66978,15 @@ function getCacheServiceVersion() {
return "v1";
return process.env["ACTIONS_CACHE_SERVICE_V2"] ? "v2" : "v1";
}
var KNOWN_CACHE_MODES = ["none", "read", "write", "write-only"];
function getCacheMode() {
return (process.env["ACTIONS_CACHE_MODE"] || "").trim().toLowerCase();
}
function isCacheWritable(mode) {
if (!KNOWN_CACHE_MODES.includes(mode))
return true;
return mode === "write" || mode === "write-only";
}
function getCacheServiceURL() {
const version3 = getCacheServiceVersion();
switch (version3) {
Expand Down Expand Up @@ -68267,6 +68276,12 @@ function saveCache2(paths_1, key_1, options_1) {
debug(`Cache service version: ${cacheServiceVersion}`);
checkPaths(paths);
checkKey(key);
const cacheMode = getCacheMode();
if (!isCacheWritable(cacheMode)) {
info(`Cache save skipped: the effective cache-mode '${cacheMode}' does not permit writes.`);
debug(`Skipped save for paths [${paths.join(", ")}] with key '${key}'.`);
return -1;
}
switch (cacheServiceVersion) {
case "v2":
return yield saveCacheV2(paths, key, options, enableCrossOsArchive);
Expand Down Expand Up @@ -68324,8 +68339,6 @@ function saveCacheV1(paths_1, key_1, options_1) {
const typedError = error2;
if (typedError.name === ValidationError.name) {
throw error2;
} else if (typedError.name === CacheWriteDeniedError.name) {
warning(`Failed to save: ${typedError.message}`);
} else if (typedError.name === ReserveCacheError.name) {
info(`Failed to save: ${typedError.message}`);
} else {
Expand Down Expand Up @@ -68413,8 +68426,6 @@ function saveCacheV2(paths_1, key_1, options_1) {
const typedError = error2;
if (typedError.name === ValidationError.name) {
throw error2;
} else if (typedError.name === CacheWriteDeniedError.name) {
warning(`Failed to save: ${typedError.message}`);
} else if (typedError.name === ReserveCacheError.name) {
info(`Failed to save: ${typedError.message}`);
} else if (typedError.name === FinalizeCacheError.name) {
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"minisign"
],
"dependencies": {
"@actions/cache": "^6.1.0",
"@actions/cache": "^6.2.0",
"@actions/core": "^3.0.1",
"@actions/exec": "^3.0.0",
"@actions/github": "^9.1.1",
Expand Down
Loading