diff --git a/dist/restore/index.js b/dist/restore/index.js index 3477533..cb97279 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -61646,7 +61646,7 @@ class Workspace { cwd: this.root, })); for (const pkg of meta.packages) { - if (!pkg.manifest_path.startsWith(this.root)) { + if (pkg.manifest_path.startsWith(this.root)) { continue; } const targets = pkg.targets.filter((t) => t.kind[0] === "lib").map((t) => t.name); @@ -61875,7 +61875,7 @@ async function cleanTargetDir(targetDir, packages) { if (dirent.isDirectory()) { let dirName = external_path_default().join(dir.path, dirent.name); // is it a profile dir, or a nested target dir? - let isNestedTarget = await exists(external_path_default().join(dirName, "CACHEDIR.TAG")); + let isNestedTarget = (await exists(external_path_default().join(dirName, "CACHEDIR.TAG"))) || (await exists(external_path_default().join(dirName, ".rustc_info.json"))); try { if (isNestedTarget) { await cleanTargetDir(dirName, packages); @@ -61891,19 +61891,10 @@ async function cleanTargetDir(targetDir, packages) { } } await external_fs_default().promises.unlink(external_path_default().join(targetDir, "./.rustc_info.json")); - // TODO: remove all unknown files, clean all directories like profiles - try { - await cleanProfileTarget(external_path_default().join(targetDir, "debug"), packages); - } - catch { } - try { - await cleanProfileTarget(external_path_default().join(targetDir, "release"), packages); - } - catch { } } async function cleanProfileTarget(profileDir, packages) { - await lib_io.rmRF(external_path_default().join(profileDir, "./examples")); - await lib_io.rmRF(external_path_default().join(profileDir, "./incremental")); + await lib_io.rmRF(external_path_default().join(profileDir, "examples")); + await lib_io.rmRF(external_path_default().join(profileDir, "incremental")); let dir; // remove all *files* from the profile directory dir = await external_fs_default().promises.opendir(profileDir); @@ -61913,8 +61904,8 @@ async function cleanProfileTarget(profileDir, packages) { } } const keepPkg = new Set(packages.map((p) => p.name)); - await rmExcept(external_path_default().join(profileDir, "./build"), keepPkg); - await rmExcept(external_path_default().join(profileDir, "./.fingerprint"), keepPkg); + await rmExcept(external_path_default().join(profileDir, "build"), keepPkg); + await rmExcept(external_path_default().join(profileDir, ".fingerprint"), keepPkg); const keepDeps = new Set(packages.flatMap((p) => { const names = []; for (const n of [p.name, ...p.targets]) { @@ -61923,7 +61914,7 @@ async function cleanProfileTarget(profileDir, packages) { } return names; })); - await rmExcept(external_path_default().join(profileDir, "./deps"), keepDeps); + await rmExcept(external_path_default().join(profileDir, "deps"), keepDeps); } async function cleanBin(config) { const bins = await config.getCargoBins(); diff --git a/dist/save/index.js b/dist/save/index.js index 57fc170..a0ec253 100644 --- a/dist/save/index.js +++ b/dist/save/index.js @@ -61646,7 +61646,7 @@ class Workspace { cwd: this.root, })); for (const pkg of meta.packages) { - if (!pkg.manifest_path.startsWith(this.root)) { + if (pkg.manifest_path.startsWith(this.root)) { continue; } const targets = pkg.targets.filter((t) => t.kind[0] === "lib").map((t) => t.name); @@ -61875,7 +61875,7 @@ async function cleanTargetDir(targetDir, packages) { if (dirent.isDirectory()) { let dirName = external_path_default().join(dir.path, dirent.name); // is it a profile dir, or a nested target dir? - let isNestedTarget = await exists(external_path_default().join(dirName, "CACHEDIR.TAG")); + let isNestedTarget = (await exists(external_path_default().join(dirName, "CACHEDIR.TAG"))) || (await exists(external_path_default().join(dirName, ".rustc_info.json"))); try { if (isNestedTarget) { await cleanTargetDir(dirName, packages); @@ -61891,19 +61891,10 @@ async function cleanTargetDir(targetDir, packages) { } } await external_fs_default().promises.unlink(external_path_default().join(targetDir, "./.rustc_info.json")); - // TODO: remove all unknown files, clean all directories like profiles - try { - await cleanProfileTarget(external_path_default().join(targetDir, "debug"), packages); - } - catch { } - try { - await cleanProfileTarget(external_path_default().join(targetDir, "release"), packages); - } - catch { } } async function cleanProfileTarget(profileDir, packages) { - await io.rmRF(external_path_default().join(profileDir, "./examples")); - await io.rmRF(external_path_default().join(profileDir, "./incremental")); + await io.rmRF(external_path_default().join(profileDir, "examples")); + await io.rmRF(external_path_default().join(profileDir, "incremental")); let dir; // remove all *files* from the profile directory dir = await external_fs_default().promises.opendir(profileDir); @@ -61913,8 +61904,8 @@ async function cleanProfileTarget(profileDir, packages) { } } const keepPkg = new Set(packages.map((p) => p.name)); - await rmExcept(external_path_default().join(profileDir, "./build"), keepPkg); - await rmExcept(external_path_default().join(profileDir, "./.fingerprint"), keepPkg); + await rmExcept(external_path_default().join(profileDir, "build"), keepPkg); + await rmExcept(external_path_default().join(profileDir, ".fingerprint"), keepPkg); const keepDeps = new Set(packages.flatMap((p) => { const names = []; for (const n of [p.name, ...p.targets]) { @@ -61923,7 +61914,7 @@ async function cleanProfileTarget(profileDir, packages) { } return names; })); - await rmExcept(external_path_default().join(profileDir, "./deps"), keepDeps); + await rmExcept(external_path_default().join(profileDir, "deps"), keepDeps); } async function cleanBin(config) { const bins = await config.getCargoBins(); @@ -62062,21 +62053,22 @@ async function run() { } // TODO: remove this once https://github.com/actions/toolkit/pull/553 lands await macOsWorkaround(); - core.info(`... Cleaning Cache ...`); - const registryName = await getRegistryName(config); const allPackages = []; for (const workspace of config.workspaces) { const packages = await workspace.getPackages(); allPackages.push(...packages); try { + core.info(`... Cleaning ${workspace.target} ...`); await cleanTargetDir(workspace.target, packages); } catch (e) { core.info(`[warning] ${e.stack}`); } } + const registryName = await getRegistryName(config); if (registryName) { try { + core.info(`... Cleaning cargo registry ...`); await cleanRegistry(config, registryName, allPackages); } catch (e) { @@ -62084,12 +62076,14 @@ async function run() { } } try { + core.info(`... Cleaning cargo/bin ...`); await cleanBin(config); } catch (e) { core.info(`[warning] ${e.stack}`); } try { + core.info(`... Cleaning cargo git cache ...`); await cleanGit(config, allPackages); } catch (e) { diff --git a/src/cleanup.ts b/src/cleanup.ts index 09052b1..95e408b 100644 --- a/src/cleanup.ts +++ b/src/cleanup.ts @@ -14,7 +14,8 @@ export async function cleanTargetDir(targetDir: string, packages: Packages) { if (dirent.isDirectory()) { let dirName = path.join(dir.path, dirent.name); // is it a profile dir, or a nested target dir? - let isNestedTarget = await exists(path.join(dirName, "CACHEDIR.TAG")); + let isNestedTarget = + (await exists(path.join(dirName, "CACHEDIR.TAG"))) || (await exists(path.join(dirName, ".rustc_info.json"))); try { if (isNestedTarget) { @@ -29,19 +30,11 @@ export async function cleanTargetDir(targetDir: string, packages: Packages) { } await fs.promises.unlink(path.join(targetDir, "./.rustc_info.json")); - - // TODO: remove all unknown files, clean all directories like profiles - try { - await cleanProfileTarget(path.join(targetDir, "debug"), packages); - } catch {} - try { - await cleanProfileTarget(path.join(targetDir, "release"), packages); - } catch {} } async function cleanProfileTarget(profileDir: string, packages: Packages) { - await io.rmRF(path.join(profileDir, "./examples")); - await io.rmRF(path.join(profileDir, "./incremental")); + await io.rmRF(path.join(profileDir, "examples")); + await io.rmRF(path.join(profileDir, "incremental")); let dir: fs.Dir; // remove all *files* from the profile directory @@ -53,8 +46,8 @@ async function cleanProfileTarget(profileDir: string, packages: Packages) { } const keepPkg = new Set(packages.map((p) => p.name)); - await rmExcept(path.join(profileDir, "./build"), keepPkg); - await rmExcept(path.join(profileDir, "./.fingerprint"), keepPkg); + await rmExcept(path.join(profileDir, "build"), keepPkg); + await rmExcept(path.join(profileDir, ".fingerprint"), keepPkg); const keepDeps = new Set( packages.flatMap((p) => { @@ -66,7 +59,7 @@ async function cleanProfileTarget(profileDir: string, packages: Packages) { return names; }), ); - await rmExcept(path.join(profileDir, "./deps"), keepDeps); + await rmExcept(path.join(profileDir, "deps"), keepDeps); } export async function cleanBin(config: CacheConfig) { diff --git a/src/save.ts b/src/save.ts index d985999..d4ee0dc 100644 --- a/src/save.ts +++ b/src/save.ts @@ -32,23 +32,22 @@ async function run() { // TODO: remove this once https://github.com/actions/toolkit/pull/553 lands await macOsWorkaround(); - core.info(`... Cleaning Cache ...`); - - const registryName = await getRegistryName(config); - const allPackages = []; for (const workspace of config.workspaces) { const packages = await workspace.getPackages(); allPackages.push(...packages); try { + core.info(`... Cleaning ${workspace.target} ...`); await cleanTargetDir(workspace.target, packages); } catch (e) { core.info(`[warning] ${(e as any).stack}`); } } + const registryName = await getRegistryName(config); if (registryName) { try { + core.info(`... Cleaning cargo registry ...`); await cleanRegistry(config, registryName, allPackages); } catch (e) { core.info(`[warning] ${(e as any).stack}`); @@ -56,12 +55,14 @@ async function run() { } try { + core.info(`... Cleaning cargo/bin ...`); await cleanBin(config); } catch (e) { core.info(`[warning] ${(e as any).stack}`); } try { + core.info(`... Cleaning cargo git cache ...`); await cleanGit(config, allPackages); } catch (e) { core.info(`[warning] ${(e as any).stack}`); diff --git a/src/workspace.ts b/src/workspace.ts index 0f81eb9..835a4a6 100644 --- a/src/workspace.ts +++ b/src/workspace.ts @@ -14,7 +14,7 @@ export class Workspace { }), ); for (const pkg of meta.packages) { - if (!pkg.manifest_path.startsWith(this.root)) { + if (pkg.manifest_path.startsWith(this.root)) { continue; } const targets = pkg.targets.filter((t) => t.kind[0] === "lib").map((t) => t.name);