From eaa85be6b1bfdc6616fd14d8916fc5aa0435e435 Mon Sep 17 00:00:00 2001 From: Jeroen Bransen Date: Sun, 22 Jun 2025 10:43:50 +0200 Subject: [PATCH] Add cache-workspace-crates feature (#246) --- README.md | 6 ++++++ action.yml | 4 ++++ dist/save/index.js | 5 +++++ src/save.ts | 5 +++++ 4 files changed, 20 insertions(+) diff --git a/README.md b/README.md index 3a651c6..e7b4906 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,12 @@ sensible defaults. # default: "false" cache-all-crates: "" + # Similar to cache-all-crates. + # If `true` the workspace crates will be cached. + # Useful if the workspace contains libraries that are only updated sporadically. + # default: "false" + cache-workspace-crates: "" + # Determines whether the cache should be saved. # If `false`, the cache is only restored. # Useful for jobs where the matrix is additive e.g. additional Cargo features, diff --git a/action.yml b/action.yml index cb4c157..968be37 100644 --- a/action.yml +++ b/action.yml @@ -32,6 +32,10 @@ inputs: description: "Determines which crates are cached. If `true` all crates will be cached, otherwise only dependent crates will be cached." required: false default: "false" + cache-workspace-crates: + description: "Similar to cache-all-crates. If `true` the workspace crates will be cached." + required: false + default: "false" save-if: description: "Determiners whether the cache should be saved. If `false`, the cache is only restored." required: false diff --git a/dist/save/index.js b/dist/save/index.js index b23f081..bd6258d 100644 --- a/dist/save/index.js +++ b/dist/save/index.js @@ -87340,9 +87340,14 @@ async function run() { if (process.env["RUNNER_OS"] == "macOS") { await macOsWorkaround(); } + const workspaceCrates = core.getInput("cache-workspace-crates").toLowerCase() || "false"; const allPackages = []; for (const workspace of config.workspaces) { const packages = await workspace.getPackagesOutsideWorkspaceRoot(); + if (workspaceCrates === "true") { + const wsMembers = await workspace.getWorkspaceMembers(); + packages.push(...wsMembers); + } allPackages.push(...packages); try { core.info(`... Cleaning ${workspace.target} ...`); diff --git a/src/save.ts b/src/save.ts index a62019e..10fe79d 100644 --- a/src/save.ts +++ b/src/save.ts @@ -36,9 +36,14 @@ async function run() { await macOsWorkaround(); } + const workspaceCrates = core.getInput("cache-workspace-crates").toLowerCase() || "false"; const allPackages = []; for (const workspace of config.workspaces) { const packages = await workspace.getPackagesOutsideWorkspaceRoot(); + if (workspaceCrates === "true") { + const wsMembers = await workspace.getWorkspaceMembers(); + packages.push(...wsMembers); + } allPackages.push(...packages); try { core.info(`... Cleaning ${workspace.target} ...`);