Skip to content

Commit eaa85be

Browse files
authored
Add cache-workspace-crates feature (#246)
1 parent 901019c commit eaa85be

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ sensible defaults.
6060
# default: "false"
6161
cache-all-crates: ""
6262

63+
# Similar to cache-all-crates.
64+
# If `true` the workspace crates will be cached.
65+
# Useful if the workspace contains libraries that are only updated sporadically.
66+
# default: "false"
67+
cache-workspace-crates: ""
68+
6369
# Determines whether the cache should be saved.
6470
# If `false`, the cache is only restored.
6571
# Useful for jobs where the matrix is additive e.g. additional Cargo features,

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ inputs:
3232
description: "Determines which crates are cached. If `true` all crates will be cached, otherwise only dependent crates will be cached."
3333
required: false
3434
default: "false"
35+
cache-workspace-crates:
36+
description: "Similar to cache-all-crates. If `true` the workspace crates will be cached."
37+
required: false
38+
default: "false"
3539
save-if:
3640
description: "Determiners whether the cache should be saved. If `false`, the cache is only restored."
3741
required: false

dist/save/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87340,9 +87340,14 @@ async function run() {
8734087340
if (process.env["RUNNER_OS"] == "macOS") {
8734187341
await macOsWorkaround();
8734287342
}
87343+
const workspaceCrates = core.getInput("cache-workspace-crates").toLowerCase() || "false";
8734387344
const allPackages = [];
8734487345
for (const workspace of config.workspaces) {
8734587346
const packages = await workspace.getPackagesOutsideWorkspaceRoot();
87347+
if (workspaceCrates === "true") {
87348+
const wsMembers = await workspace.getWorkspaceMembers();
87349+
packages.push(...wsMembers);
87350+
}
8734687351
allPackages.push(...packages);
8734787352
try {
8734887353
core.info(`... Cleaning ${workspace.target} ...`);

src/save.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,14 @@ async function run() {
3636
await macOsWorkaround();
3737
}
3838

39+
const workspaceCrates = core.getInput("cache-workspace-crates").toLowerCase() || "false";
3940
const allPackages = [];
4041
for (const workspace of config.workspaces) {
4142
const packages = await workspace.getPackagesOutsideWorkspaceRoot();
43+
if (workspaceCrates === "true") {
44+
const wsMembers = await workspace.getWorkspaceMembers();
45+
packages.push(...wsMembers);
46+
}
4247
allPackages.push(...packages);
4348
try {
4449
core.info(`... Cleaning ${workspace.target} ...`);

0 commit comments

Comments
 (0)