From 4c124e58eafe8ce9fd560cce8dce7ca028d73a1f Mon Sep 17 00:00:00 2001 From: Ashcon Partovi Date: Mon, 22 Apr 2024 17:55:03 -0700 Subject: [PATCH] Fix workflow --- .github/actions/cache/action.mjs | 3 +- .github/actions/cache/dist/action.mjs | 3 +- .github/actions/cache/dist/restore/action.mjs | 33 +++++++++---------- .github/actions/cache/dist/save/action.mjs | 22 ++++++------- .github/actions/cache/restore/action.mjs | 30 ++++++++--------- .github/actions/cache/save/action.mjs | 19 +++++------ 6 files changed, 54 insertions(+), 56 deletions(-) diff --git a/.github/actions/cache/action.mjs b/.github/actions/cache/action.mjs index 0955ec8745..c2692e9515 100644 --- a/.github/actions/cache/action.mjs +++ b/.github/actions/cache/action.mjs @@ -74,7 +74,8 @@ export async function saveCache() { if (isGithubHosted()) { console.log("Using GitHub cache..."); try { - return await saveGithubCache([path], key); + const cacheId = await saveGithubCache([path], key); + return !!cacheId; } catch (error) { console.error("Failed to save cache:", error); return false; diff --git a/.github/actions/cache/dist/action.mjs b/.github/actions/cache/dist/action.mjs index a004c35b20..1608df8c12 100644 --- a/.github/actions/cache/dist/action.mjs +++ b/.github/actions/cache/dist/action.mjs @@ -69689,7 +69689,8 @@ async function saveCache() { if (isGithubHosted()) { console.log("Using GitHub cache..."); try { - return await cache.saveCache([path], key); + const cacheId = await cache.saveCache([path], key); + return !!cacheId; } catch (error) { console.error("Failed to save cache:", error); return false; diff --git a/.github/actions/cache/dist/restore/action.mjs b/.github/actions/cache/dist/restore/action.mjs index 1a3c3b78b7..c8d871f13f 100644 --- a/.github/actions/cache/dist/restore/action.mjs +++ b/.github/actions/cache/dist/restore/action.mjs @@ -69689,7 +69689,8 @@ async function saveCache() { if (isGithubHosted()) { console.log("Using GitHub cache..."); try { - return await cache.saveCache([path], key); + const cacheId = await cache.saveCache([path], key); + return !!cacheId; } catch (error) { console.error("Failed to save cache:", error); return false; @@ -69733,21 +69734,19 @@ var cacheDir = core.getInput("cache-dir") || join(tmpdir(), ".github", "cache"); // restore/action.mjs var core2 = __toESM(require_core(), 1); async function main() { - try { - const result = await restoreCache(); - if (result) { - const { cacheHit, cacheKey } = result; - console.log("Cache key:", cacheKey, cacheHit ? "(hit)" : "(miss)"); - core2.setOutput("cache-hit", cacheHit); - core2.setOutput("cache-matched-key", cacheKey); - if (cacheHit) { - core2.setOutput("cache-primary-key", cacheKey); - } - return; - } - } catch (error) { - console.error("Failed to restore cache:", error); + const result = await restoreCache(); + if (!result) { + process.exit(1); + } + const { cacheHit, cacheKey } = result; + console.log("Cache key:", cacheKey, cacheHit ? "(hit)" : "(miss)"); + core2.setOutput("cache-hit", cacheHit); + core2.setOutput("cache-matched-key", cacheKey); + if (cacheHit) { + core2.setOutput("cache-primary-key", cacheKey); } - process.exit(1); } -main(); +main().catch((error) => { + console.error("Failed to restore cache:", error); + process.exit(1); +}); diff --git a/.github/actions/cache/dist/save/action.mjs b/.github/actions/cache/dist/save/action.mjs index b45ae8b1bd..aa0f76d77c 100644 --- a/.github/actions/cache/dist/save/action.mjs +++ b/.github/actions/cache/dist/save/action.mjs @@ -69689,7 +69689,8 @@ async function saveCache() { if (isGithubHosted()) { console.log("Using GitHub cache..."); try { - return await cache.saveCache([path], key); + const cacheId = await cache.saveCache([path], key); + return !!cacheId; } catch (error) { console.error("Failed to save cache:", error); return false; @@ -69732,15 +69733,14 @@ var cacheDir = core.getInput("cache-dir") || join(tmpdir(), ".github", "cache"); // save/action.mjs async function main() { - try { - const ok = await saveCache(); - if (ok) { - console.log("Cache saved"); - return; - } - } catch (error) { - console.error("Failed to restore cache:", error); + const saved = await saveCache(); + if (saved) { + console.log("Cache saved"); + } else { + process.exit(1); } - process.exit(1); } -main(); +main().catch((error) => { + console.error("Failed to save cache:", error); + process.exit(1); +}); diff --git a/.github/actions/cache/restore/action.mjs b/.github/actions/cache/restore/action.mjs index e4f3001f1c..3063fc81aa 100644 --- a/.github/actions/cache/restore/action.mjs +++ b/.github/actions/cache/restore/action.mjs @@ -2,22 +2,20 @@ import { setOutput } from "@actions/core"; import { restoreCache } from "../action.mjs"; async function main() { - try { - const result = await restoreCache(); - if (result) { - const { cacheHit, cacheKey } = result; - console.log("Cache key:", cacheKey, cacheHit ? "(hit)" : "(miss)"); - setOutput("cache-hit", cacheHit); - setOutput("cache-matched-key", cacheKey); - if (cacheHit) { - setOutput("cache-primary-key", cacheKey); - } - return; - } - } catch (error) { - console.error("Failed to restore cache:", error); + const result = await restoreCache(); + if (!result) { + process.exit(1); + } + const { cacheHit, cacheKey } = result; + console.log("Cache key:", cacheKey, cacheHit ? "(hit)" : "(miss)"); + setOutput("cache-hit", cacheHit); + setOutput("cache-matched-key", cacheKey); + if (cacheHit) { + setOutput("cache-primary-key", cacheKey); } - process.exit(1); } -main(); +main().catch(error => { + console.error("Failed to restore cache:", error); + process.exit(1); +}); diff --git a/.github/actions/cache/save/action.mjs b/.github/actions/cache/save/action.mjs index 10da503063..ed62f8b8f7 100644 --- a/.github/actions/cache/save/action.mjs +++ b/.github/actions/cache/save/action.mjs @@ -1,16 +1,15 @@ import { saveCache } from "../action.mjs"; async function main() { - try { - const ok = await saveCache(); - if (ok) { - console.log("Cache saved"); - return; - } - } catch (error) { - console.error("Failed to restore cache:", error); + const saved = await saveCache(); + if (saved) { + console.log("Cache saved"); + } else { + process.exit(1); } - process.exit(1); } -main(); +main().catch(error => { + console.error("Failed to save cache:", error); + process.exit(1); +});