diff --git a/src/common.ts b/src/common.ts index 18aa588..1fb93f8 100644 --- a/src/common.ts +++ b/src/common.ts @@ -15,6 +15,7 @@ export const paths = { }; export interface CacheConfig { + name: string; path: string; key: string; restoreKeys?: Array; @@ -45,10 +46,25 @@ export async function getCaches(): Promise { targetKey = `${targetKey}-`; } return { - index: { path: paths.index, key: "registry-index-XXX", restoreKeys: ["registry-index"] }, - cache: { path: paths.cache, key: `registry-cache-${lockHash}`, restoreKeys: ["registry-cache"] }, - git: { path: paths.git, key: "git-db" }, + index: { + name: "Registry Index", + path: paths.index, + key: "registry-index-XXX", + restoreKeys: ["registry-index"], + }, + cache: { + name: "Registry Cache", + path: paths.cache, + key: `registry-cache-${lockHash}`, + restoreKeys: ["registry-cache"], + }, + git: { + name: "Git Dependencies", + path: paths.git, + key: "git-db", + }, target: { + name: "Target", path: paths.target, key: `target-${targetKey}${rustKey}-${lockHash}`, restoreKeys: [`target-${targetKey}${rustKey}`], diff --git a/src/restore.ts b/src/restore.ts index 653e4c7..efc50e9 100644 --- a/src/restore.ts +++ b/src/restore.ts @@ -11,13 +11,15 @@ async function run() { core.exportVariable("CARGO_INCREMENTAL", 0); const caches = await getCaches(); - for (const [name, { path, key, restoreKeys }] of Object.entries(caches)) { + for (const [type, { name, path, key, restoreKeys }] of Object.entries(caches)) { try { - core.startGroup(`Restoring "${path}" from "${key}"…`); + core.startGroup(`Restoring ${name}"…`); + core.info(`Restoring to path "${path}".`); + core.info(`Using keys:\n ${[key, ...restoreKeys].join("\n ")}`); const restoreKey = await cache.restoreCache([path], key, restoreKeys); if (restoreKey) { - core.info(`Restored "${path}" from cache key "${restoreKey}".`); - core.saveState(name, restoreKey); + core.info(`Restored from cache key "${restoreKey}".`); + core.saveState(type, restoreKey); } else { core.info("No cache found."); } diff --git a/src/save.ts b/src/save.ts index 7dca4ca..93aada8 100644 --- a/src/save.ts +++ b/src/save.ts @@ -28,16 +28,16 @@ async function run() { delete (caches as any).cache; } - for (const [name, { path, key }] of Object.entries(caches)) { - if (core.getState(name) === key) { - core.info(`Cache for "${path}" up-to-date.`); + for (const [type, { name, path, key }] of Object.entries(caches)) { + if (core.getState(type) === key) { + core.info(`${name} up-to-date.`); continue; } try { - core.startGroup(`Saving "${path}" to cache key "${key}"…`); - if (await cache.saveCache([path], key)) { - core.info(`Saved "${path}" to cache key "${key}".`); - } + core.startGroup(`Saving ${name}…`); + core.info(`Saving path "${path}".`); + core.info(`Using key "${key}".`); + await cache.saveCache([path], key); } catch (e) { core.info(`[warning] ${e.message}`); } finally {