implement support for CARGO_HOME

fixes #8
This commit is contained in:
Arpad Borsos 2021-01-28 18:16:36 +01:00
parent cbcc887094
commit 2639a56bb8
3 changed files with 7 additions and 4 deletions

View File

@ -20,10 +20,11 @@ export const stateKey = "RUST_CACHE_KEY";
const stateHash = "RUST_CACHE_HASH";
const home = os.homedir();
const cargoHome = process.env.CARGO_HOME || path.join(home, ".cargo");
export const paths = {
index: path.join(home, ".cargo/registry/index"),
cache: path.join(home, ".cargo/registry/cache"),
git: path.join(home, ".cargo/git"),
index: path.join(cargoHome, "registry/index"),
cache: path.join(cargoHome, "registry/cache"),
git: path.join(cargoHome, "git"),
target: "target",
};

View File

@ -9,6 +9,7 @@ async function run() {
const { paths, key, restoreKeys } = await getCacheConfig();
core.info(`Restoring paths:\n ${paths.join("\n ")}`);
core.info(`In directory:\n ${process.cwd()}`);
core.info(`Using keys:\n ${[key, ...restoreKeys].join("\n ")}`);
const restoreKey = await cache.restoreCache(paths, key, restoreKeys);
if (restoreKey) {

View File

@ -35,7 +35,8 @@ async function run() {
} catch {}
core.info(`Saving paths:\n ${savePaths.join("\n ")}`);
core.info(`Using key "${key}".`);
core.info(`In directory:\n ${process.cwd()}`);
core.info(`Using key:\n ${key}`);
await cache.saveCache(savePaths, key);
} catch (e) {
core.info(`[warning] ${e.message}`);