mirror of
https://github.com/Swatinem/rust-cache
synced 2025-11-07 07:56:04 +00:00
Cache multiple target directories from 'target-dir'
This commit is contained in:
parent
fa61956921
commit
260a713186
15 changed files with 195 additions and 41 deletions
20
src/save.ts
20
src/save.ts
|
|
@ -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 { }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue