Skip to content

Commit

Permalink
Add support for Rust caching
Browse files Browse the repository at this point in the history
  • Loading branch information
gmichelo committed Dec 12, 2023
1 parent 46051e1 commit 5a29e28
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 [];
Expand Down
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ async function resolveCacheMode(cacheMode: string): Promise<Path[]> {
}

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}.`);
Expand Down

0 comments on commit 5a29e28

Please sign in to comment.