Skip to content

Commit

Permalink
better logging, better staging
Browse files Browse the repository at this point in the history
  • Loading branch information
jkelleyrtp committed Jan 29, 2025
1 parent a0f80e7 commit 70758ff
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/cleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
15 changes: 11 additions & 4 deletions src/save.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 70758ff

Please sign in to comment.