3
0
Fork 0
mirror of https://github.com/Swatinem/rust-cache synced 2025-04-11 23:23:34 +00:00

better logging, better staging

This commit is contained in:
Jonathan Kelley 2025-01-28 21:14:58 -08:00
parent a0f80e7b74
commit 70758ffdc7
No known key found for this signature in database
GPG key ID: 1FBB50F7EB0A08BE
2 changed files with 16 additions and 5 deletions

View file

@ -79,11 +79,15 @@ async function cleanProfileTarget(profileDir: string, packages: Packages, checkT
await fillModifiedTimes(incrementalDir);
// Write the modified times to the incremental folder
core.debug(`writing incremental-restore.json for ${incrementalDir} with ${modifiedTimes} files`);
core.debug(`writing incremental-restore.json for ${incrementalDir} files`);
for (const file of modifiedTimes.keys()) {
core.debug(` ${file} -> ${modifiedTimes.get(file)}`);
}
const contents = JSON.stringify({ modifiedTimes });
await fs.promises.writeFile(path.join(incrementalDir, "incremental-restore.json"), contents);
}
await rmExcept(profileDir, keepProfile);
const keepPkg = new Set(packages.map((p) => p.name));

View file

@ -4,6 +4,7 @@ import * as exec from "@actions/exec";
import { cleanBin, cleanGit, cleanRegistry, cleanTargetDir } from "./cleanup";
import { CacheConfig, isCacheUpToDate } from "./config";
import { getCacheProvider, reportError } from "./utils";
import { rm } from "fs/promises";
process.on("uncaughtException", (e) => {
core.error(e.message);
@ -72,16 +73,22 @@ async function run() {
core.debug(`${(e as any).stack}`);
}
// Save the incremental cache before we delete it
if (config.incremental) {
core.info(`... Saving incremental cache ...`);
await cacheProvider.cache.saveCache(config.incrementalPaths.slice(), config.incrementalKey);
for (const path of config.incrementalPaths) {
core.debug(` deleting ${path}`);
await rm(path);
}
}
core.info(`... Saving cache ...`);
// Pass a copy of cachePaths to avoid mutating the original array as reported by:
// https://github.com/actions/toolkit/pull/1378
// TODO: remove this once the underlying bug is fixed.
await cacheProvider.cache.saveCache(config.cachePaths.slice(), config.cacheKey);
if (config.incremental) {
core.info(`... Saving incremental cache ...`);
await cacheProvider.cache.saveCache(config.incrementalPaths.slice(), config.incrementalKey);
}
} catch (e) {
reportError(e);
}