mirror of
https://github.com/moonrepo/setup-rust.git
synced 2025-04-30 05:40:03 +00:00
Add new input.
This commit is contained in:
parent
e6a829b5bd
commit
6a8624d80a
5 changed files with 23 additions and 8 deletions
|
@ -1,6 +1,9 @@
|
||||||
# 1.2.0
|
# 1.2.0
|
||||||
|
|
||||||
- Updated to not save the cache if one of the required paths does not exist.
|
- Added a `target-dirs` input, allowing the target folders to be specified. Can now cache multiple
|
||||||
|
target folders.
|
||||||
|
- Updated to skip caching a directory if it does not exist, instead of failing.
|
||||||
|
- Updated dependencies.
|
||||||
|
|
||||||
# 1.1.0
|
# 1.1.0
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,8 @@ optional.
|
||||||
- `inherit-toolchain` - Inherit all toolchain settings from the `rust-toolchain.toml` file. Defaults
|
- `inherit-toolchain` - Inherit all toolchain settings from the `rust-toolchain.toml` file. Defaults
|
||||||
to `false`.
|
to `false`.
|
||||||
- `targets` - Comma-separated list of additional targets to install.
|
- `targets` - Comma-separated list of additional targets to install.
|
||||||
|
- `target-dirs` - Comma-separated list of target folder paths, relative from the repository root.
|
||||||
|
Defaults to `target`.
|
||||||
- `profile` - Profile to install. Defaults to `minimal`.
|
- `profile` - Profile to install. Defaults to `minimal`.
|
||||||
|
|
||||||
## Configuring the Rust toolchain
|
## Configuring the Rust toolchain
|
||||||
|
|
|
@ -24,6 +24,9 @@ inputs:
|
||||||
default: 'false'
|
default: 'false'
|
||||||
targets:
|
targets:
|
||||||
description: 'Comma-separated list of additional targets to install.'
|
description: 'Comma-separated list of additional targets to install.'
|
||||||
|
target-dirs:
|
||||||
|
description: 'Comma-separated list of target folder paths, relative from the repository root.'
|
||||||
|
default: 'target'
|
||||||
profile:
|
profile:
|
||||||
description: 'Profile to install. Defaults to "minimal".'
|
description: 'Profile to install. Defaults to "minimal".'
|
||||||
outputs:
|
outputs:
|
||||||
|
|
|
@ -18,12 +18,19 @@ export function getCacheTarget(): string {
|
||||||
return core.getInput('cache-target') || 'debug';
|
return core.getInput('cache-target') || 'debug';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getTargetPaths(): string[] {
|
||||||
|
const profile = getCacheTarget();
|
||||||
|
const dirs = core.getInput('target-dirs', { required: true }).split(',');
|
||||||
|
|
||||||
|
return dirs.filter((dir) => dir.trim()).map((dir) => path.join(WORKSPACE_ROOT, dir, profile));
|
||||||
|
}
|
||||||
|
|
||||||
export function getCachePaths(): string[] {
|
export function getCachePaths(): string[] {
|
||||||
return [
|
return [
|
||||||
// ~/.cargo/registry
|
// ~/.cargo/registry
|
||||||
path.join(CARGO_HOME, 'registry'),
|
path.join(CARGO_HOME, 'registry'),
|
||||||
// /workspace/target/debug
|
// /workspace/target/debug
|
||||||
path.join(WORKSPACE_ROOT, 'target', getCacheTarget()),
|
...getTargetPaths(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
12
src/cargo.ts
12
src/cargo.ts
|
@ -165,15 +165,15 @@ export async function saveCache() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const cachePaths = getCachePaths();
|
const cachePaths = getCachePaths().filter((cachePath) => {
|
||||||
|
|
||||||
for (const cachePath of cachePaths) {
|
|
||||||
if (!fs.existsSync(cachePath)) {
|
if (!fs.existsSync(cachePath)) {
|
||||||
core.info(`Cache path ${cachePath} does not exist, skipping save`);
|
core.info(`Cache path ${cachePath} does not exist, skipping`);
|
||||||
return;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
await cleanCargoRegistry();
|
await cleanCargoRegistry();
|
||||||
await cleanTargetProfile();
|
await cleanTargetProfile();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue