Skip to content

Use exponential-backoff for cache restore/save #961

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2025
Merged
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
57 changes: 57 additions & 0 deletions analysis/packages/setup-ocaml/src/cache.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
async function restoreCache(
key: string,
restoreKeys: string[],
paths: string[],
options?: DownloadOptions,
) {
if (!cache.isFeatureAvailable()) {
core.info("Actions cache service feature is unavailable");
return;
}
try {
const cacheKey = await cache.restoreCache(paths, key, restoreKeys, options);
if (cacheKey) {
core.info(`Cache restored from key: ${cacheKey}`);
} else {
core.info(
`Cache is not found for input keys: ${[key, ...restoreKeys].join(", ")}`,
);
}
return cacheKey;
} catch (error) {
if (error instanceof Error) {
core.info(`Cache restore error: ${error.message}`);
} else if (error instanceof AggregateError) {
core.info(
`Cache restore network error: ${error.code || "unknown error"}`,
);
} else {
core.info(`Cache restore unknown error: ${String(error)}`);
}
core.notice(
"An internal error has occurred in cache backend. Please check https://www.githubstatus.com for any ongoing issue in actions.",
);
return;
}
}

async function saveCache(key: string, paths: string[]) {
if (!cache.isFeatureAvailable()) {
core.info("Actions cache service feature is unavailable");
return;
}
try {
await cache.saveCache(paths, key);
} catch (error) {
if (error instanceof Error) {
core.info(`Cache save error: ${error.message}`);
} else if (error instanceof AggregateError) {
core.info(`Cache save network error: ${error.code || "unknown error"}`);
} else {
core.info(`Cache save unknown error: ${String(error)}`);
}
core.notice(
"An internal error has occurred in cache backend. Please check https://www.githubstatus.com for any ongoing issue in actions.",
);
}
}
206 changes: 206 additions & 0 deletions dist/LICENSE.txt

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

Loading