Skip to content

Commit

Permalink
bump js
Browse files Browse the repository at this point in the history
  • Loading branch information
jkelleyrtp committed Jan 29, 2025
1 parent 70758ff commit 8c8c352
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 20 deletions.
35 changes: 22 additions & 13 deletions dist/restore/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86765,8 +86765,12 @@ class CacheConfig {
constructor() {
/** All the paths we want to cache */
this.cachePaths = [];
/** All the paths we want to cache for incremental builds */
this.incrementalPaths = [];
/** The primary cache key */
this.cacheKey = "";
/** The primary cache key for incremental builds */
this.incrementalKey = "";
/**
* The secondary (restore) key that only contains the prefix and environment
* This should be used if the primary cacheKey is not available - IE pulling from main on a branch
Expand Down Expand Up @@ -86950,13 +86954,14 @@ class CacheConfig {
let lockHash = digest(hasher);
keyFiles.push(...parsedKeyFiles);
self.keyFiles = sort_and_uniq(keyFiles);
// todo(jon): make sure we differentiate incrementals on different branches
// we can use just a single cache per incremental branch
if (self.incremental) {
key += `-incremental`;
}
key += `-${lockHash}`;
self.cacheKey = key;
if (self.incremental) {
// wire the incremental key to be just for this branch
const branchName = lib_core.getInput("incremental-key") || "-shared";
const incrementalKey = key + `-incremental` + branchName;
self.incrementalKey = incrementalKey;
}
self.cachePaths = [external_path_default().join(config_CARGO_HOME, "registry"), external_path_default().join(config_CARGO_HOME, "git")];
if (self.cacheBin) {
self.cachePaths = [
Expand All @@ -86977,7 +86982,7 @@ class CacheConfig {
if (self.incremental) {
if (cacheTargets === "true") {
for (const target of self.workspaces.map((ws) => ws.target)) {
self.cachePaths.push(external_path_default().join(target, "incremental"));
self.incrementalPaths.push(external_path_default().join(target, "incremental"));
}
}
}
Expand Down Expand Up @@ -87176,7 +87181,10 @@ async function cleanProfileTarget(profileDir, packages, checkTimestamp, incremen
};
await fillModifiedTimes(incrementalDir);
// Write the modified times to the incremental folder
lib_core.debug(`writing incremental-restore.json for ${incrementalDir} with ${modifiedTimes} files`);
lib_core.debug(`writing incremental-restore.json for ${incrementalDir} files`);
for (const file of modifiedTimes.keys()) {
lib_core.debug(` ${file} -> ${modifiedTimes.get(file)}`);
}
const contents = JSON.stringify({ modifiedTimes });
await external_fs_default().promises.writeFile(external_path_default().join(incrementalDir, "incremental-restore.json"), contents);
}
Expand Down Expand Up @@ -87452,16 +87460,17 @@ async function run() {
// 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.
const restoreKey = await cacheProvider.cache.restoreCache(config.cachePaths.slice(), key, [config.restoreKey], {
lookupOnly,
});
const restoreKey = await cacheProvider.cache.restoreCache(config.cachePaths.slice(), key, [config.restoreKey], { lookupOnly });
if (restoreKey) {
const match = restoreKey === key;
lib_core.info(`${lookupOnly ? "Found" : "Restored from"} cache key "${restoreKey}" full match: ${match}.`);
if (config.incremental) {
lib_core.debug("restoring incremental builds");
for (const workspace of config.workspaces) {
await restoreIncremental(workspace.target);
const incrementalKey = await cacheProvider.cache.restoreCache(config.incrementalPaths.slice(), config.incrementalKey, [config.restoreKey], { lookupOnly });
lib_core.debug(`restoring incremental builds from ${incrementalKey}`);
if (incrementalKey) {
for (const workspace of config.workspaces) {
await restoreIncremental(workspace.target);
}
}
}
if (!match || config.isIncrementalMissing()) {
Expand Down
32 changes: 25 additions & 7 deletions dist/save/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86765,8 +86765,12 @@ class CacheConfig {
constructor() {
/** All the paths we want to cache */
this.cachePaths = [];
/** All the paths we want to cache for incremental builds */
this.incrementalPaths = [];
/** The primary cache key */
this.cacheKey = "";
/** The primary cache key for incremental builds */
this.incrementalKey = "";
/**
* The secondary (restore) key that only contains the prefix and environment
* This should be used if the primary cacheKey is not available - IE pulling from main on a branch
Expand Down Expand Up @@ -86950,13 +86954,14 @@ class CacheConfig {
let lockHash = digest(hasher);
keyFiles.push(...parsedKeyFiles);
self.keyFiles = sort_and_uniq(keyFiles);
// todo(jon): make sure we differentiate incrementals on different branches
// we can use just a single cache per incremental branch
if (self.incremental) {
key += `-incremental`;
}
key += `-${lockHash}`;
self.cacheKey = key;
if (self.incremental) {
// wire the incremental key to be just for this branch
const branchName = lib_core.getInput("incremental-key") || "-shared";
const incrementalKey = key + `-incremental` + branchName;
self.incrementalKey = incrementalKey;
}
self.cachePaths = [external_path_default().join(CARGO_HOME, "registry"), external_path_default().join(CARGO_HOME, "git")];
if (self.cacheBin) {
self.cachePaths = [
Expand All @@ -86977,7 +86982,7 @@ class CacheConfig {
if (self.incremental) {
if (cacheTargets === "true") {
for (const target of self.workspaces.map((ws) => ws.target)) {
self.cachePaths.push(external_path_default().join(target, "incremental"));
self.incrementalPaths.push(external_path_default().join(target, "incremental"));
}
}
}
Expand Down Expand Up @@ -87176,7 +87181,10 @@ async function cleanProfileTarget(profileDir, packages, checkTimestamp, incremen
};
await fillModifiedTimes(incrementalDir);
// Write the modified times to the incremental folder
lib_core.debug(`writing incremental-restore.json for ${incrementalDir} with ${modifiedTimes} files`);
lib_core.debug(`writing incremental-restore.json for ${incrementalDir} files`);
for (const file of modifiedTimes.keys()) {
lib_core.debug(` ${file} -> ${modifiedTimes.get(file)}`);
}
const contents = JSON.stringify({ modifiedTimes });
await external_fs_default().promises.writeFile(external_path_default().join(incrementalDir, "incremental-restore.json"), contents);
}
Expand Down Expand Up @@ -87422,6 +87430,7 @@ async function rmRF(dirName) {




process.on("uncaughtException", (e) => {
lib_core.error(e.message);
if (e.stack) {
Expand Down Expand Up @@ -87482,6 +87491,15 @@ async function run() {
catch (e) {
lib_core.debug(`${e.stack}`);
}
// Save the incremental cache before we delete it
if (config.incremental) {
lib_core.info(`... Saving incremental cache ...`);
await cacheProvider.cache.saveCache(config.incrementalPaths.slice(), config.incrementalKey);
for (const path of config.incrementalPaths) {
lib_core.debug(` deleting ${path}`);
await (0,promises_.rm)(path);
}
}
lib_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
Expand Down

0 comments on commit 8c8c352

Please sign in to comment.