From 1c70765f6619961c00d0825a53e3b7d740660699 Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Fri, 3 May 2024 11:51:38 -0700 Subject: [PATCH] Add logs. --- package.json | 2 +- src/cache.ts | 5 ++++- src/cargo.ts | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e0add0f..c1ecad7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@moonrepo/setup-rust", - "version": "1.0.3", + "version": "1.2.0", "description": "A GitHub action for setting up Rust and Cargo.", "main": "dist/index.js", "scripts": { diff --git a/src/cache.ts b/src/cache.ts index 5dc0190..3a63c80 100644 --- a/src/cache.ts +++ b/src/cache.ts @@ -22,7 +22,10 @@ export function getTargetPaths(): string[] { const profile = getCacheTarget(); const dirs = core.getInput('target-dirs', { required: true }).split(','); - return dirs.filter((dir) => dir.trim()).map((dir) => path.join(WORKSPACE_ROOT, dir, profile)); + return dirs + .map((dir) => dir.trim()) + .filter(Boolean) + .map((dir) => path.join(WORKSPACE_ROOT, dir, profile)); } export function getCachePaths(): string[] { diff --git a/src/cargo.ts b/src/cargo.ts index 01a4883..d8f3732 100644 --- a/src/cargo.ts +++ b/src/cargo.ts @@ -179,6 +179,13 @@ export async function saveCache() { core.info(`Saving cache with key ${primaryKey}`); + core.debug(`Cache key: ${primaryKey}`); + core.debug('Cache paths:'); + + for (const cachePath of cachePaths) { + core.debug(`- ${cachePath}`); + } + await cache.saveCache(cachePaths, primaryKey); } @@ -190,6 +197,15 @@ export async function restoreCache() { core.info('Attempting to restore cache'); const primaryKey = await getPrimaryCacheKey(); + const cachePaths = getCachePaths(); + + core.debug(`Cache key: ${primaryKey}`); + core.debug('Cache paths:'); + + for (const cachePath of cachePaths) { + core.debug(`- ${cachePath}`); + } + const cacheKey = await cache.restoreCache(getCachePaths(), primaryKey, getCachePrefixes()); if (cacheKey) {