update registry cleaning

This commit is contained in:
Arpad Borsos
2022-07-09 18:51:34 +02:00
parent 911d8e9e55
commit 7b8626742a
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