Save-only warning added

This commit is contained in:
Sankalp Kotewar 2022-12-20 16:15:42 +00:00 committed by GitHub
parent 8955114d15
commit 1d114a8000
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 85 additions and 19 deletions

View file

@ -10,10 +10,11 @@ import * as utils from "./utils/actionUtils";
// throw an uncaught exception. Instead of failing this action, just warn.
process.on("uncaughtException", e => utils.logWarning(e.message));
async function saveImpl(stateProvider: IStateProvider): Promise<void> {
async function saveImpl(stateProvider: IStateProvider): Promise<number> {
let cacheId;
try {
if (!utils.isCacheFeatureAvailable()) {
return;
return 0;
}
if (!utils.isValidEvent()) {
@ -22,7 +23,7 @@ async function saveImpl(stateProvider: IStateProvider): Promise<void> {
process.env[Events.Key]
} is not supported because it's not tied to a branch or tag ref.`
);
return;
return 0;
}
// If restore has stored a primary key in state, reuse that
@ -33,7 +34,7 @@ async function saveImpl(stateProvider: IStateProvider): Promise<void> {
if (!primaryKey) {
utils.logWarning(`Key is not specified.`);
return;
return 0;
}
// If matched restore key is same as primary key, then do not save cache
@ -44,14 +45,14 @@ async function saveImpl(stateProvider: IStateProvider): Promise<void> {
core.info(
`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`
);
return;
return 0;
}
const cachePaths = utils.getInputAsArray(Inputs.Path, {
required: true
});
const cacheId = await cache.saveCache(cachePaths, primaryKey, {
cacheId = await cache.saveCache(cachePaths, primaryKey, {
uploadChunkSize: utils.getInputAsInt(Inputs.UploadChunkSize)
});
@ -61,6 +62,7 @@ async function saveImpl(stateProvider: IStateProvider): Promise<void> {
} catch (error: unknown) {
utils.logWarning((error as Error).message);
}
return cacheId;
}
export default saveImpl;

View file

@ -1,8 +1,13 @@
import * as core from "@actions/core";
import saveImpl from "./saveImpl";
import { NullStateProvider } from "./stateProvider";
async function run(): Promise<void> {
await saveImpl(new NullStateProvider());
const cacheId = await saveImpl(new NullStateProvider());
if (cacheId === -1) {
core.warning(`Cache save failed.`);
}
}
run();