Skip to content

Commit

Permalink
Wrapped saving pre-commit cache to cache, in a try catch block
Browse files Browse the repository at this point in the history
  • Loading branch information
s-weigand committed Oct 12, 2020
1 parent 763fbaf commit 470aac6
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion index.js
Expand Up @@ -54,7 +54,20 @@ async function main() {
const restored = await cache.restoreCache(cachePaths, cacheKey);
const ret = await exec.exec('pre-commit', args, {ignoreReturnCode: push});
if (!restored) {
await cache.saveCache(cachePaths, cacheKey);
try {
await cache.saveCache(cachePaths, cacheKey);
} catch (e) {
core.warning(
[
"There was an error saving the pre-commit environments to cache:\n\n",
`${e.message}\n\n`,
"This only has performance implications and won't change the result of your pre-commit tests.\n",
"If this problem persists on your default branch, you can try to fix it by editing your '.pre-commit-config.yaml'. ",
"I.e. run 'pre-commit autoupdate' or simply add a blank line. ",
"This will result in a different hash value and thus a different cache target.",
].join("")
);
}
}

if (ret && push) {
Expand Down

0 comments on commit 470aac6

Please sign in to comment.