From 5a29e28a38820cd51e524a5578abdfee7223624f Mon Sep 17 00:00:00 2001 From: Giulio Micheloni Date: Tue, 12 Dec 2023 22:57:04 +0100 Subject: [PATCH] Add support for Rust caching --- action.yml | 2 +- dist/index.js | 3 +++ src/index.ts | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 666f3b2..fcd107f 100644 --- a/action.yml +++ b/action.yml @@ -13,7 +13,7 @@ inputs: default: "false" required: false cache: - description: "A list of native cache modes. Supported options are 'go,yarn,pnpm'" + description: "A list of native cache modes. Supported options are 'go,yarn,pnpm,rust'" required: false outputs: cache-hit: diff --git a/dist/index.js b/dist/index.js index e38dd95..10be5ce 100644 --- a/dist/index.js +++ b/dist/index.js @@ -27096,6 +27096,9 @@ async function resolveCacheMode(cacheMode) { paths.push({ path: mod + "/node_modules", wipe: true }); } return paths; + case "rust": + // Do not cache the whole ~/.cargo dir as it contains ~/.cargo/bin, where the cargo binary lives + return [{ path: "~/.cargo/registry" }, { path: "~/.cargo/git" }, { path: "./target" }]; default: core.warning(`Unknown cache option: ${cacheMode}.`); return []; diff --git a/src/index.ts b/src/index.ts index 264f02d..137ce7b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -124,6 +124,10 @@ async function resolveCacheMode(cacheMode: string): Promise { } return paths; + + case "rust": + // Do not cache the whole ~/.cargo dir as it contains ~/.cargo/bin, where the cargo binary lives + return [{ path: "~/.cargo/registry" }, { path: "~/.cargo/git" }, { path: "./target" }]; default: core.warning(`Unknown cache option: ${cacheMode}.`);