mirror of
https://code.forgejo.org/actions/cache.git
synced 2025-04-23 03:45:31 +00:00
Release v1.0.3
This commit is contained in:
parent
44543250bd
commit
cffae9552b
12 changed files with 114 additions and 52 deletions
15
dist/restore/index.js
vendored
15
dist/restore/index.js
vendored
|
@ -1533,11 +1533,12 @@ function getCacheEntry(keys) {
|
|||
throw new Error(`Cache service responded with ${response.statusCode}`);
|
||||
}
|
||||
const cacheResult = response.result;
|
||||
core.debug(`Cache Result:`);
|
||||
core.debug(JSON.stringify(cacheResult));
|
||||
if (!cacheResult || !cacheResult.archiveLocation) {
|
||||
throw new Error("Cache not found.");
|
||||
}
|
||||
core.setSecret(cacheResult.archiveLocation);
|
||||
core.debug(`Cache Result:`);
|
||||
core.debug(JSON.stringify(cacheResult));
|
||||
return cacheResult;
|
||||
});
|
||||
}
|
||||
|
@ -2208,6 +2209,11 @@ function getCacheState() {
|
|||
return undefined;
|
||||
}
|
||||
exports.getCacheState = getCacheState;
|
||||
function logWarning(message) {
|
||||
const warningPrefix = "[warning]";
|
||||
core.info(`${warningPrefix}${message}`);
|
||||
}
|
||||
exports.logWarning = logWarning;
|
||||
function resolvePath(filePath) {
|
||||
if (filePath[0] === "~") {
|
||||
const home = os.homedir();
|
||||
|
@ -2996,9 +3002,10 @@ function run() {
|
|||
try {
|
||||
// Validate inputs, this can cause task failure
|
||||
if (!utils.isValidEvent()) {
|
||||
core.setFailed(`Event Validation Error: The event type ${process.env[constants_1.Events.Key]} is not supported. Only ${utils
|
||||
utils.logWarning(`Event Validation Error: The event type ${process.env[constants_1.Events.Key]} is not supported. Only ${utils
|
||||
.getSupportedEvents()
|
||||
.join(", ")} events are supported at this time.`);
|
||||
return;
|
||||
}
|
||||
const cachePath = utils.resolvePath(core.getInput(constants_1.Inputs.Path, { required: true }));
|
||||
core.debug(`Cache Path: ${cachePath}`);
|
||||
|
@ -3063,7 +3070,7 @@ function run() {
|
|||
core.info(`Cache restored from key: ${cacheEntry && cacheEntry.cacheKey}`);
|
||||
}
|
||||
catch (error) {
|
||||
core.warning(error.message);
|
||||
utils.logWarning(error.message);
|
||||
utils.setCacheHitOutput(false);
|
||||
}
|
||||
}
|
||||
|
|
22
dist/save/index.js
vendored
22
dist/save/index.js
vendored
|
@ -1533,11 +1533,12 @@ function getCacheEntry(keys) {
|
|||
throw new Error(`Cache service responded with ${response.statusCode}`);
|
||||
}
|
||||
const cacheResult = response.result;
|
||||
core.debug(`Cache Result:`);
|
||||
core.debug(JSON.stringify(cacheResult));
|
||||
if (!cacheResult || !cacheResult.archiveLocation) {
|
||||
throw new Error("Cache not found.");
|
||||
}
|
||||
core.setSecret(cacheResult.archiveLocation);
|
||||
core.debug(`Cache Result:`);
|
||||
core.debug(JSON.stringify(cacheResult));
|
||||
return cacheResult;
|
||||
});
|
||||
}
|
||||
|
@ -2208,6 +2209,11 @@ function getCacheState() {
|
|||
return undefined;
|
||||
}
|
||||
exports.getCacheState = getCacheState;
|
||||
function logWarning(message) {
|
||||
const warningPrefix = "[warning]";
|
||||
core.info(`${warningPrefix}${message}`);
|
||||
}
|
||||
exports.logWarning = logWarning;
|
||||
function resolvePath(filePath) {
|
||||
if (filePath[0] === "~") {
|
||||
const home = os.homedir();
|
||||
|
@ -2882,11 +2888,17 @@ const utils = __importStar(__webpack_require__(443));
|
|||
function run() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
if (!utils.isValidEvent()) {
|
||||
utils.logWarning(`Event Validation Error: The event type ${process.env[constants_1.Events.Key]} is not supported. Only ${utils
|
||||
.getSupportedEvents()
|
||||
.join(", ")} events are supported at this time.`);
|
||||
return;
|
||||
}
|
||||
const state = utils.getCacheState();
|
||||
// Inputs are re-evaluted before the post action, so we want the original key used for restore
|
||||
const primaryKey = core.getState(constants_1.State.CacheKey);
|
||||
if (!primaryKey) {
|
||||
core.warning(`Error retrieving key from state.`);
|
||||
utils.logWarning(`Error retrieving key from state.`);
|
||||
return;
|
||||
}
|
||||
if (utils.isExactKeyMatch(primaryKey, state)) {
|
||||
|
@ -2918,13 +2930,13 @@ function run() {
|
|||
const archiveFileSize = utils.getArchiveFileSize(archivePath);
|
||||
core.debug(`File Size: ${archiveFileSize}`);
|
||||
if (archiveFileSize > fileSizeLimit) {
|
||||
core.warning(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 400MB limit, not saving cache.`);
|
||||
utils.logWarning(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 400MB limit, not saving cache.`);
|
||||
return;
|
||||
}
|
||||
yield cacheHttpClient.saveCache(primaryKey, archivePath);
|
||||
}
|
||||
catch (error) {
|
||||
core.warning(error.message);
|
||||
utils.logWarning(error.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue