mirror of
https://github.com/Swatinem/rust-cache
synced 2025-04-29 06:35:53 +00:00
Adds an option to do lookup-only of the cache (#217)
This commit is contained in:
parent
68b3cb7503
commit
c00f3025ca
4 changed files with 29 additions and 7 deletions
|
@ -24,6 +24,8 @@ async function run() {
|
|||
if (cacheOnFailure !== "true") {
|
||||
cacheOnFailure = "false";
|
||||
}
|
||||
var lookupOnly = core.getInput("lookup-only").toLowerCase() === "true";
|
||||
|
||||
core.exportVariable("CACHE_ON_FAILURE", cacheOnFailure);
|
||||
core.exportVariable("CARGO_INCREMENTAL", 0);
|
||||
|
||||
|
@ -31,15 +33,24 @@ async function run() {
|
|||
config.printInfo(cacheProvider);
|
||||
core.info("");
|
||||
|
||||
core.info(`... Restoring cache ...`);
|
||||
core.info(`... ${lookupOnly ? "Checking" : "Restoring"} cache ...`);
|
||||
const key = config.cacheKey;
|
||||
// Pass a copy of cachePaths to avoid mutating the original array as reported by:
|
||||
// https://github.com/actions/toolkit/pull/1378
|
||||
// TODO: remove this once the underlying bug is fixed.
|
||||
const restoreKey = await cacheProvider.cache.restoreCache(config.cachePaths.slice(), key, [config.restoreKey]);
|
||||
const restoreKey = await cacheProvider.cache.restoreCache(
|
||||
config.cachePaths.slice(),
|
||||
key,
|
||||
[config.restoreKey],
|
||||
{ lookupOnly }
|
||||
);
|
||||
if (restoreKey) {
|
||||
const match = restoreKey === key;
|
||||
core.info(`Restored from cache key "${restoreKey}" full match: ${match}.`);
|
||||
core.info(
|
||||
`${
|
||||
lookupOnly ? "Found" : "Restored from"
|
||||
} cache key "${restoreKey}" full match: ${match}.`
|
||||
);
|
||||
if (!match) {
|
||||
// pre-clean the target directory on cache mismatch
|
||||
for (const workspace of config.workspaces) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue