mirror of
https://github.com/Swatinem/rust-cache
synced 2025-04-27 05:35:53 +00:00
Allow opting out of caching $CARGO_HOME/bin. (#216)
Prevents wiping the bin directory, which is harmful for self-hosted runners.
This commit is contained in:
parent
9a2e0d3212
commit
e8e63cdbf2
6 changed files with 59 additions and 15 deletions
25
dist/save/index.js
vendored
25
dist/save/index.js
vendored
|
@ -77276,6 +77276,8 @@ class CacheConfig {
|
|||
this.cacheKey = "";
|
||||
/** The secondary (restore) key that only contains the prefix and environment */
|
||||
this.restoreKey = "";
|
||||
/** Whether to cache CARGO_HOME/.bin */
|
||||
this.cacheBin = true;
|
||||
/** The workspace configurations */
|
||||
this.workspaces = [];
|
||||
/** The cargo binaries present during main step */
|
||||
|
@ -77351,6 +77353,7 @@ class CacheConfig {
|
|||
// Construct the lockfiles portion of the key:
|
||||
// This considers all the files found via globbing for various manifests
|
||||
// and lockfiles.
|
||||
self.cacheBin = core.getInput("cache-bin").toLowerCase() == "true";
|
||||
// Constructs the workspace config and paths to restore:
|
||||
// The workspaces are given using a `$workspace -> $target` syntax.
|
||||
const workspaces = [];
|
||||
|
@ -77445,7 +77448,13 @@ class CacheConfig {
|
|||
self.keyFiles = sort_and_uniq(keyFiles);
|
||||
key += `-${lockHash}`;
|
||||
self.cacheKey = key;
|
||||
self.cachePaths = [CARGO_HOME];
|
||||
self.cachePaths = [
|
||||
external_path_default().join(CARGO_HOME, "registry"),
|
||||
external_path_default().join(CARGO_HOME, "git"),
|
||||
];
|
||||
if (self.cacheBin) {
|
||||
self.cachePaths = [external_path_default().join(CARGO_HOME, "bin"), ...self.cachePaths];
|
||||
}
|
||||
const cacheTargets = core.getInput("cache-targets").toLowerCase() || "true";
|
||||
if (cacheTargets === "true") {
|
||||
self.cachePaths.push(...workspaces.map((ws) => ws.target));
|
||||
|
@ -77907,12 +77916,14 @@ async function run() {
|
|||
catch (e) {
|
||||
core.debug(`${e.stack}`);
|
||||
}
|
||||
try {
|
||||
core.info(`... Cleaning cargo/bin ...`);
|
||||
await cleanBin(config.cargoBins);
|
||||
}
|
||||
catch (e) {
|
||||
core.debug(`${e.stack}`);
|
||||
if (config.cacheBin) {
|
||||
try {
|
||||
core.info(`... Cleaning cargo/bin ...`);
|
||||
await cleanBin(config.cargoBins);
|
||||
}
|
||||
catch (e) {
|
||||
core.debug(`${e.stack}`);
|
||||
}
|
||||
}
|
||||
try {
|
||||
core.info(`... Cleaning cargo git cache ...`);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue