diff --git a/.github/workflows/selftest.yml b/.github/workflows/selftest.yml index a2e842ae..ca4a3a72 100644 --- a/.github/workflows/selftest.yml +++ b/.github/workflows/selftest.yml @@ -22,8 +22,10 @@ jobs: override: true - uses: ./ + with: + cache-on-failure: true - run: | cargo install cargo-deny --locked cargo check - cargo test + cargo test \ No newline at end of file diff --git a/README.md b/README.md index 16bb6b99..a92e9afd 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,9 @@ located in the repo root. : `target-dir` The target directory that should be cleaned and persisted, defaults to `./target`. +: `cache-on-failure` +Cache even if the build fails, defaults to false + ## Outputs : `cache-hit` diff --git a/action.yml b/action.yml index a4d19580..d20981c9 100644 --- a/action.yml +++ b/action.yml @@ -14,6 +14,9 @@ inputs: target-dir: description: "The target dir that should be cleaned and persisted, defaults to `./target`" required: false + cache-on-failure: + description: "Cache even if the build fails. Defaults to false" + required: false outputs: cache-hit: description: "A boolean value that indicates an exact match was found" @@ -21,7 +24,7 @@ runs: using: "node12" main: "dist/restore/index.js" post: "dist/save/index.js" - post-if: "success()" + post-if: "success() || env.CACHE_ON_FAILURE == 'true'" branding: icon: "archive" color: "gray-dark" diff --git a/src/common.ts b/src/common.ts index 8ee4c477..1ff12731 100644 --- a/src/common.ts +++ b/src/common.ts @@ -9,6 +9,9 @@ import path from "path"; process.on("uncaughtException", (e) => { core.info(`[warning] ${e.message}`); + if (e.stack) { + core.info(e.stack) + } }); const cwd = core.getInput("working-directory"); diff --git a/src/restore.ts b/src/restore.ts index 1c257abc..c53cbf4b 100644 --- a/src/restore.ts +++ b/src/restore.ts @@ -4,6 +4,11 @@ import { cleanTarget, getCacheConfig, getCargoBins, getPackages, stateBins, stat async function run() { try { + var cacheOnFailure = core.getInput("cache-on-failure").toLowerCase() + if (cacheOnFailure !== "true") { + cacheOnFailure = "false" + } + core.exportVariable("CACHE_ON_FAILURE", cacheOnFailure) core.exportVariable("CARGO_INCREMENTAL", 0); const { paths, key, restoreKeys } = await getCacheConfig();