mirror of
https://github.com/moonrepo/setup-rust.git
synced 2025-04-29 13:30:03 +00:00
Revert "new: Delete cache older than 14 days."
This reverts commit 0716d005db
.
This commit is contained in:
parent
0716d005db
commit
0027d396fa
4 changed files with 4 additions and 21 deletions
|
@ -93,7 +93,6 @@ The following optimizations and considerations are taken into account when cachi
|
||||||
crate, a checkout will be performed on-demand.
|
crate, a checkout will be performed on-demand.
|
||||||
- The `/registry` directory is _cleaned_ before saving the cache. This includes removing `src`,
|
- The `/registry` directory is _cleaned_ before saving the cache. This includes removing `src`,
|
||||||
`.cache`, and any other unnecessary files.
|
`.cache`, and any other unnecessary files.
|
||||||
- Registry artifacts older than 14 days will be removed.
|
|
||||||
- `/target/debug`
|
- `/target/debug`
|
||||||
- Only the `debug` profile is cached, as this profile is typically used for formatting, linting,
|
- Only the `debug` profile is cached, as this profile is typically used for formatting, linting,
|
||||||
and testing.
|
and testing.
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
{
|
{
|
||||||
"name": "@moonrepo/setup-rust",
|
"name": "@moonrepo/setup-rust",
|
||||||
"version": "0.4.2",
|
"version": "0.4.1",
|
||||||
"description": "A GitHub action for setting up Rust and Cargo.",
|
"description": "A GitHub action for setting up Rust and Cargo.",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "ncc build ./index.ts && ncc build ./post.ts --out ./dist/post",
|
"build": "ncc build ./index.ts && ncc build ./post.ts --out ./dist/post",
|
||||||
"check": "pnpm run lint && pnpm run typecheck",
|
"check": "npm run lint && npm run typecheck",
|
||||||
"lint": "eslint --ext .ts,.js --fix .",
|
"lint": "eslint --ext .ts,.js --fix .",
|
||||||
"typecheck": "tsc --noEmit"
|
"typecheck": "tsc --noEmit"
|
||||||
},
|
},
|
||||||
|
|
16
src/cargo.ts
16
src/cargo.ts
|
@ -7,7 +7,7 @@ import * as core from '@actions/core';
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
import * as glob from '@actions/glob';
|
import * as glob from '@actions/glob';
|
||||||
import * as tc from '@actions/tool-cache';
|
import * as tc from '@actions/tool-cache';
|
||||||
import { padDate, rmrf } from './helpers';
|
import { rmrf } from './fs';
|
||||||
import { RUST_HASH, RUST_VERSION } from './rust';
|
import { RUST_HASH, RUST_VERSION } from './rust';
|
||||||
|
|
||||||
export const CARGO_HOME = process.env.CARGO_HOME ?? path.join(os.homedir(), '.cargo');
|
export const CARGO_HOME = process.env.CARGO_HOME ?? path.join(os.homedir(), '.cargo');
|
||||||
|
@ -129,19 +129,7 @@ export async function cleanCargoRegistry() {
|
||||||
const registryDir = path.join(CARGO_HOME, 'registry');
|
const registryDir = path.join(CARGO_HOME, 'registry');
|
||||||
|
|
||||||
// .cargo/registry/src - Delete entirely
|
// .cargo/registry/src - Delete entirely
|
||||||
const staleDate = new Date();
|
await exec.exec('cargo', ['cache', '--autoclean']);
|
||||||
|
|
||||||
// eslint-disable-next-line no-magic-numbers
|
|
||||||
staleDate.setDate(staleDate.getDate() - 14);
|
|
||||||
|
|
||||||
await exec.exec('cargo', [
|
|
||||||
'cache',
|
|
||||||
'--autoclean',
|
|
||||||
'--remove-if-older-than',
|
|
||||||
`${staleDate.getFullYear()}.${padDate(staleDate.getMonth() + 1)}.${padDate(
|
|
||||||
staleDate.getDate(),
|
|
||||||
)}`,
|
|
||||||
]);
|
|
||||||
|
|
||||||
// .cargo/registry/index - Delete .cache directories
|
// .cargo/registry/index - Delete .cache directories
|
||||||
const indexDir = path.join(registryDir, 'index');
|
const indexDir = path.join(registryDir, 'index');
|
||||||
|
|
|
@ -10,7 +10,3 @@ export async function rmrf(dir: string) {
|
||||||
core.warning(`Failed to delete ${dir}: ${error}`);
|
core.warning(`Failed to delete ${dir}: ${error}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function padDate(value: number) {
|
|
||||||
return String(value).padStart(2, '0');
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue