Skip to content

Commit 30a42c0

Browse files
committed
fix: tolerate cache errors
This is befuddling, but I suppose caching is a nice-to-have so it's not so important if it's borked for internal reasons.
1 parent 16392ef commit 30a42c0

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

src/index.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,6 @@ async function installGitHubReleaseBinary(
7676
].join("-");
7777
const restoreCache = await cache.restoreCache(cachePaths, cacheKey);
7878

79-
// DEBUG:
80-
core.warning(`Restore cache: ${restoreCache}`);
81-
8279
// If unable to restore from the cache, download the binary from GitHub
8380
if (restoreCache === undefined) {
8481
const releaseAsset = await fetchReleaseAssetMetadataFromTag(
@@ -96,7 +93,24 @@ async function installGitHubReleaseBinary(
9693
{ accept: "application/octet-stream" }
9794
);
9895

99-
await cache.saveCache(cachePaths, cacheKey);
96+
// Tolerate cache errors.
97+
// Possibly related to https://github.com/actions/toolkit/issues/658
98+
try {
99+
await cache.saveCache(cachePaths, cacheKey);
100+
} catch (error) {
101+
// NOTE: this is an unlawful cast
102+
const typedError = error as Error;
103+
switch (typedError.name) {
104+
case cache.ValidationError.name:
105+
throw error;
106+
case cache.ReserveCacheError.name:
107+
core.info(typedError.message);
108+
break;
109+
default:
110+
core.warning(typedError.message);
111+
break;
112+
}
113+
}
100114
}
101115

102116
// Permissions are an attribute of the filesystem, not the file.

0 commit comments

Comments
 (0)