new: Support custom target dirs. (#19)

This commit is contained in:
Miles Johnson 2024-05-03 12:01:30 -07:00 committed by GitHub
parent c91b4202a2
commit dcab3dcf9f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 183 additions and 124 deletions

View file

@ -18,12 +18,22 @@ export function getCacheTarget(): string {
return core.getInput('cache-target') || 'debug';
}
export function getTargetPaths(): string[] {
const profile = getCacheTarget();
const dirs = core.getInput('target-dirs', { required: true }).split(',');
return dirs
.map((dir) => dir.trim())
.filter(Boolean)
.map((dir) => path.join(WORKSPACE_ROOT, dir, profile));
}
export function getCachePaths(): string[] {
return [
// ~/.cargo/registry
path.join(CARGO_HOME, 'registry'),
// /workspace/target/debug
path.join(WORKSPACE_ROOT, 'target', getCacheTarget()),
...getTargetPaths(),
];
}