Skip to content
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

Fix errors from concurrent builds with cache: enable #24

Merged
merged 2 commits into from May 20, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 15 additions & 1 deletion lib/main.js
Expand Up @@ -161,7 +161,21 @@ function run() {
const binPath = yield tc.downloadTool(url);
yield extractFn(binPath, dest);
if (cacheEnabled && cacheKey !== undefined) {
yield cache.saveCache([dest], cacheKey);
try {
yield cache.saveCache([dest], cacheKey);
}
catch (error) {
const typedError = error;
if (typedError.name === cache.ValidationError.name) {
throw error;
}
else if (typedError.name === cache.ReserveCacheError.name) {
core.info(typedError.message);
}
else {
core.warning(typedError.message);
}
}
}
core.addPath(dest);
core.info(`Successfully extracted ${project} to ${dest}`);
Expand Down
13 changes: 12 additions & 1 deletion src/main.ts
Expand Up @@ -167,7 +167,18 @@ async function run() {
await extractFn(binPath, dest);

if (cacheEnabled && cacheKey !== undefined) {
await cache.saveCache([dest], cacheKey);
try {
await cache.saveCache([dest], cacheKey);
} catch (error) {
const typedError = error as Error;
if (typedError.name === cache.ValidationError.name) {
throw error;
} else if (typedError.name === cache.ReserveCacheError.name) {
core.info(typedError.message);
} else {
core.warning(typedError.message);
}
}
}

core.addPath(dest);
Expand Down