(profileDir: string, packages: Packages, checkTimestamp = false)
| 33 | } |
| 34 | |
| 35 | async function cleanProfileTarget(profileDir: string, packages: Packages, checkTimestamp = false) { |
| 36 | core.debug(`cleaning profile directory "${profileDir}"`); |
| 37 | |
| 38 | // Quite a few testing utility crates store compilation artifacts as nested |
| 39 | // workspaces under `target/tests`. Notably, `target/tests/target` and |
| 40 | // `target/tests/trybuild`. |
| 41 | if (path.basename(profileDir) === "tests") { |
| 42 | try { |
| 43 | // https://github.com/vertexclique/kaos/blob/9876f6c890339741cc5be4b7cb9df72baa5a6d79/src/cargo.rs#L25 |
| 44 | // https://github.com/eupn/macrotest/blob/c4151a5f9f545942f4971980b5d264ebcd0b1d11/src/cargo.rs#L27 |
| 45 | cleanTargetDir(path.join(profileDir, "target"), packages, checkTimestamp); |
| 46 | } catch {} |
| 47 | try { |
| 48 | // https://github.com/dtolnay/trybuild/blob/eec8ca6cb9b8f53d0caf1aa499d99df52cae8b40/src/cargo.rs#L50 |
| 49 | cleanTargetDir(path.join(profileDir, "trybuild"), packages, checkTimestamp); |
| 50 | } catch {} |
| 51 | |
| 52 | // Delete everything else. |
| 53 | await rmExcept(profileDir, new Set(["target", "trybuild"]), checkTimestamp); |
| 54 | |
| 55 | return; |
| 56 | } |
| 57 | |
| 58 | let keepProfile = new Set(["build", ".fingerprint", "deps"]); |
| 59 | await rmExcept(profileDir, keepProfile); |
| 60 | |
| 61 | const keepPkg = new Set(packages.map((p) => p.name)); |
| 62 | await rmExcept(path.join(profileDir, "build"), keepPkg, checkTimestamp); |
| 63 | await rmExcept(path.join(profileDir, ".fingerprint"), keepPkg, checkTimestamp); |
| 64 | |
| 65 | const keepDeps = new Set( |
| 66 | packages.flatMap((p) => { |
| 67 | const names = []; |
| 68 | for (const n of [p.name, ...p.targets]) { |
| 69 | const name = n.replace(/-/g, "_"); |
| 70 | names.push(name, `lib${name}`); |
| 71 | } |
| 72 | return names; |
| 73 | }), |
| 74 | ); |
| 75 | await rmExcept(path.join(profileDir, "deps"), keepDeps, checkTimestamp); |
| 76 | } |
| 77 | |
| 78 | export async function getCargoBins(): Promise<Set<string>> { |
| 79 | const bins = new Set<string>(); |
no test coverage detected