refactor: simplify split-cache handling

Restore cache entries sequentially, keep saves parallel with per-entry error handling, and simplify the cache test setup.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
qmuntal
2026-11-09 12:29:31 +01:00
co-authored by Copilot
parent aa2cac01fd
commit 57097ea729
9 changed files with 74 additions and 421 deletions
+1 -10
View File
@@ -8,7 +8,6 @@ import {State, Outputs} from './constants.js';
import {PackageManagerInfo} from './package-managers.js';
import {
CacheEntry,
canRestoreCachesInParallel,
getCacheDirectoryPath,
getPackageManagerInfo
} from './cache-utils.js';
@@ -49,7 +48,7 @@ export const restoreCache = async (
primaryKey: primaryKeys[directory.kind]
}));
const restoreEntry = async (entry: CacheEntry) => {
for (const entry of entries) {
core.debug(`${entry.kind} primary key is ${entry.primaryKey}`);
try {
entry.matchedKey = await cache.restoreCache(
@@ -65,14 +64,6 @@ export const restoreCache = async (
const message = error instanceof Error ? error.message : String(error);
core.warning(`Restore ${entry.kind} cache failed: ${message}`);
}
};
if (canRestoreCachesInParallel(entries)) {
await Promise.all(entries.map(restoreEntry));
} else {
for (const entry of entries) {
await restoreEntry(entry);
}
}
// Preserve the resolved paths so the post step uses the same cache versions,