Skip to content

Commit d1027a9

Browse files
s-weigandasottile
authored andcommitted
Wrapped saving pre-commit cache to cache, in a try catch block
1 parent 0404b96 commit d1027a9

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

index.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,20 @@ async function main() {
5454
const restored = await cache.restoreCache(cachePaths, cacheKey);
5555
const ret = await exec.exec('pre-commit', args, {ignoreReturnCode: push});
5656
if (!restored) {
57-
await cache.saveCache(cachePaths, cacheKey);
57+
try {
58+
await cache.saveCache(cachePaths, cacheKey);
59+
} catch (e) {
60+
core.warning(
61+
`There was an error saving the pre-commit environments to cache:
62+
63+
${e.message || e}
64+
65+
This only has performance implications and won't change the result of your pre-commit tests.
66+
If this problem persists on your default branch, you can try to fix it by editing your '.pre-commit-config.yaml'.
67+
For example try to run 'pre-commit autoupdate' or simply add a blank line.
68+
This will result in a different hash value and thus a different cache target.`.replace(/^ +/gm, '')
69+
);
70+
}
5871
}
5972

6073
if (ret && push) {

0 commit comments

Comments
 (0)