mirror of
https://github.com/Swatinem/rust-cache.git
synced 2025-08-15 05:05:09 +00:00
added prefix-key, cache-directories, and cache-targets as features
This commit is contained in:
parent
22c9328bcb
commit
e713427804
11
action.yml
11
action.yml
@ -2,6 +2,10 @@ name: "Rust Cache"
|
|||||||
description: "A GitHub Action that implements smart caching for rust/cargo projects with sensible defaults."
|
description: "A GitHub Action that implements smart caching for rust/cargo projects with sensible defaults."
|
||||||
author: "Arpad Borsos <swatinem@swatinem.de>"
|
author: "Arpad Borsos <swatinem@swatinem.de>"
|
||||||
inputs:
|
inputs:
|
||||||
|
prefix-key:
|
||||||
|
description: "The prefix cache key, this can be changed to start a new cache manually"
|
||||||
|
required: false
|
||||||
|
default: "v0-rust"
|
||||||
shared-key:
|
shared-key:
|
||||||
description: "An additional cache key that is stable over multiple jobs"
|
description: "An additional cache key that is stable over multiple jobs"
|
||||||
required: false
|
required: false
|
||||||
@ -14,6 +18,13 @@ inputs:
|
|||||||
workspaces:
|
workspaces:
|
||||||
description: "Paths to multiple Cargo workspaces and their target directories, separated by newlines"
|
description: "Paths to multiple Cargo workspaces and their target directories, separated by newlines"
|
||||||
required: false
|
required: false
|
||||||
|
cache-directories:
|
||||||
|
description: "Additional non workspace directories, separated by newlines"
|
||||||
|
required: false
|
||||||
|
cache-targets:
|
||||||
|
description: "Determines whether workspace targets are cached"
|
||||||
|
required: false
|
||||||
|
default: "true"
|
||||||
cache-on-failure:
|
cache-on-failure:
|
||||||
description: "Cache even if the build fails. Defaults to false"
|
description: "Cache even if the build fails. Defaults to false"
|
||||||
required: false
|
required: false
|
||||||
|
@ -50,7 +50,7 @@ export class CacheConfig {
|
|||||||
// This uses either the `shared-key` input,
|
// This uses either the `shared-key` input,
|
||||||
// or the `key` input combined with the `job` key.
|
// or the `key` input combined with the `job` key.
|
||||||
|
|
||||||
let key = `v0-rust`;
|
let key = core.getInput("prefix-key");
|
||||||
|
|
||||||
const sharedKey = core.getInput("shared-key");
|
const sharedKey = core.getInput("shared-key");
|
||||||
if (sharedKey) {
|
if (sharedKey) {
|
||||||
@ -154,7 +154,16 @@ export class CacheConfig {
|
|||||||
}
|
}
|
||||||
self.workspaces = workspaces;
|
self.workspaces = workspaces;
|
||||||
|
|
||||||
self.cachePaths = [CARGO_HOME, ...workspaces.map((ws) => ws.target)];
|
self.cachePaths = [CARGO_HOME];
|
||||||
|
const cacheTargets = core.getInput("cache-targets").toLowerCase();
|
||||||
|
if (cacheTargets === "true") {
|
||||||
|
self.cachePaths.push(...workspaces.map((ws) => ws.target));
|
||||||
|
}
|
||||||
|
|
||||||
|
const cacheDirectories = core.getInput("cache-directories");
|
||||||
|
for (const dir of cacheDirectories.trim().split("\n")) {
|
||||||
|
self.cachePaths.push(dir);
|
||||||
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user