3
0
Fork 0
mirror of https://github.com/Swatinem/rust-cache synced 2025-11-08 00:15:06 +00:00

update registry cleaning

This commit is contained in:
Arpad Borsos 2022-07-09 18:51:34 +02:00
parent 911d8e9e55
commit 7b8626742a
No known key found for this signature in database
GPG key ID: FC7BCA77824B3298
7 changed files with 188 additions and 212 deletions

View file

@ -1,8 +1,6 @@
import * as cache from "@actions/cache";
import * as core from "@actions/core";
import * as exec from "@actions/exec";
import * as glob from "@actions/glob";
import path from "path";
import { cleanBin, cleanGit, cleanRegistry, cleanTargetDir } from "./cleanup";
import { CacheConfig, STATE_KEY } from "./config";
@ -44,26 +42,23 @@ async function run() {
}
}
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}`);
}
try {
core.info(`... Cleaning cargo registry ...`);
await cleanRegistry(allPackages);
} catch (e) {
core.info(`[warning] ${(e as any).stack}`);
}
try {
core.info(`... Cleaning cargo/bin ...`);
await cleanBin(config);
await cleanBin();
} catch (e) {
core.info(`[warning] ${(e as any).stack}`);
}
try {
core.info(`... Cleaning cargo git cache ...`);
await cleanGit(config, allPackages);
await cleanGit(allPackages);
} catch (e) {
core.info(`[warning] ${(e as any).stack}`);
}
@ -77,20 +72,6 @@ async function run() {
run();
async function getRegistryName(config: CacheConfig): Promise<string | null> {
const globber = await glob.create(`${config.cargoIndex}/**/.last-updated`, { followSymbolicLinks: false });
const files = await globber.glob();
if (files.length > 1) {
core.warning(`got multiple registries: "${files.join('", "')}"`);
}
const first = files.shift()!;
if (!first) {
return null;
}
return path.basename(path.dirname(first));
}
async function macOsWorkaround() {
try {
// Workaround for https://github.com/actions/cache/issues/403