mirror of
https://github.com/Swatinem/rust-cache
synced 2025-06-07 09:03:26 +00:00
better logging, better staging
This commit is contained in:
parent
a0f80e7b74
commit
70758ffdc7
2 changed files with 16 additions and 5 deletions
|
@ -79,11 +79,15 @@ async function cleanProfileTarget(profileDir: string, packages: Packages, checkT
|
||||||
await fillModifiedTimes(incrementalDir);
|
await fillModifiedTimes(incrementalDir);
|
||||||
|
|
||||||
// Write the modified times to the incremental folder
|
// 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 });
|
const contents = JSON.stringify({ modifiedTimes });
|
||||||
await fs.promises.writeFile(path.join(incrementalDir, "incremental-restore.json"), contents);
|
await fs.promises.writeFile(path.join(incrementalDir, "incremental-restore.json"), contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
await rmExcept(profileDir, keepProfile);
|
await rmExcept(profileDir, keepProfile);
|
||||||
|
|
||||||
const keepPkg = new Set(packages.map((p) => p.name));
|
const keepPkg = new Set(packages.map((p) => p.name));
|
||||||
|
|
15
src/save.ts
15
src/save.ts
|
@ -4,6 +4,7 @@ import * as exec from "@actions/exec";
|
||||||
import { cleanBin, cleanGit, cleanRegistry, cleanTargetDir } from "./cleanup";
|
import { cleanBin, cleanGit, cleanRegistry, cleanTargetDir } from "./cleanup";
|
||||||
import { CacheConfig, isCacheUpToDate } from "./config";
|
import { CacheConfig, isCacheUpToDate } from "./config";
|
||||||
import { getCacheProvider, reportError } from "./utils";
|
import { getCacheProvider, reportError } from "./utils";
|
||||||
|
import { rm } from "fs/promises";
|
||||||
|
|
||||||
process.on("uncaughtException", (e) => {
|
process.on("uncaughtException", (e) => {
|
||||||
core.error(e.message);
|
core.error(e.message);
|
||||||
|
@ -72,16 +73,22 @@ async function run() {
|
||||||
core.debug(`${(e as any).stack}`);
|
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 ...`);
|
core.info(`... Saving cache ...`);
|
||||||
// Pass a copy of cachePaths to avoid mutating the original array as reported by:
|
// Pass a copy of cachePaths to avoid mutating the original array as reported by:
|
||||||
// https://github.com/actions/toolkit/pull/1378
|
// https://github.com/actions/toolkit/pull/1378
|
||||||
// TODO: remove this once the underlying bug is fixed.
|
// TODO: remove this once the underlying bug is fixed.
|
||||||
await cacheProvider.cache.saveCache(config.cachePaths.slice(), config.cacheKey);
|
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) {
|
} catch (e) {
|
||||||
reportError(e);
|
reportError(e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue