Cache multiple target directories from 'target-dir'

This commit is contained in:
Nick Mosher
2021-07-16 16:58:46 -04:00
committed by Arpad Borsos
parent fa61956921
commit 260a713186
15 changed files with 195 additions and 41 deletions

View File

@@ -23,7 +23,8 @@ async function run() {
}
try {
const { paths: savePaths, key } = await getCacheConfig();
const { paths, workspaces, key } = await getCacheConfig();
const savePaths = paths.concat(workspaces);
if (core.getState(stateKey) === key) {
core.info(`Cache up-to-date.`);
@@ -34,7 +35,8 @@ async function run() {
await macOsWorkaround();
const registryName = await getRegistryName();
const packages = await getPackages();
const packages = await getPackages(workspaces);
core.info("Detected repository packages to cache: " + JSON.stringify(packages));
if (registryName) {
try {
@@ -56,10 +58,14 @@ async function run() {
core.info(`[warning] ${(e as any).stack}`);
}
try {
await cleanTarget(packages);
} catch (e) {
core.info(`[warning] ${(e as any).stack}`);
for (const workspace of workspaces) {
const target = path.join(workspace, "target");
try {
await cleanTarget(target, packages);
}
catch (e) {
core.info(`[warning] ${(e as any).stack}`);
}
}
core.info(`Saving paths:\n ${savePaths.join("\n ")}`);
@@ -170,5 +176,5 @@ async function macOsWorkaround() {
// Workaround for https://github.com/actions/cache/issues/403
// Also see https://github.com/rust-lang/cargo/issues/8603
await exec.exec("sudo", ["/usr/sbin/purge"], { silent: true });
} catch {}
} catch { }
}