From 93050d148346fbbff400b10e2d2e8cedaeee38d1 Mon Sep 17 00:00:00 2001 From: daz Date: Sat, 23 Dec 2023 11:26:48 -0700 Subject: [PATCH] Improvements to cache reporting - Avoid "Entry not saved: reason unknown" when entry was not restored - Avoid "Entry not saved: Encryption key not provided" when no config-cache data found - Avoid spurious log message when no config-cache data found --- src/cache-extract-entries.ts | 11 +++++++---- src/cache-reporting.ts | 3 +++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/cache-extract-entries.ts b/src/cache-extract-entries.ts index 68e455b..deac72e 100644 --- a/src/cache-extract-entries.ts +++ b/src/cache-extract-entries.ts @@ -393,7 +393,7 @@ export class ConfigurationCacheEntryExtractor extends AbstractEntryExtractor { if (cacheEntries.length > 0) { core.info(`Not restoring configuration-cache state, as ${reason}`) for (const cacheEntry of cacheEntries) { - listener.entry(cacheEntry.pattern).markNotRestored(reason).markNotSaved(reason) + listener.entry(cacheEntry.pattern).markNotRestored(reason) } // Update the results file based on no entries restored @@ -403,9 +403,12 @@ export class ConfigurationCacheEntryExtractor extends AbstractEntryExtractor { async extract(listener: CacheListener): Promise { if (!params.getCacheEncryptionKey()) { - core.info('Not saving configuration-cache state, as no encryption key was provided') - for (const cacheEntry of this.getExtractedCacheEntryDefinitions()) { - listener.entry(cacheEntry.pattern).markNotSaved('No encryption key provided') + const cacheEntryDefinitions = this.getExtractedCacheEntryDefinitions() + if (cacheEntryDefinitions.length > 0) { + core.info('Not saving configuration-cache state, as no encryption key was provided') + for (const cacheEntry of cacheEntryDefinitions) { + listener.entry(cacheEntry.pattern).markNotSaved('No encryption key provided') + } } return } diff --git a/src/cache-reporting.ts b/src/cache-reporting.ts index 11d5fd2..0a90800 100644 --- a/src/cache-reporting.ts +++ b/src/cache-reporting.ts @@ -198,6 +198,9 @@ function getSavedMessage(entry: CacheEntryListener, cacheReadOnly: boolean): str if (cacheReadOnly) { return '(Entry not saved: cache is read-only)' } + if (entry.notRestored) { + return '(Entry not saved: not restored)' + } return '(Entry not saved: reason unknown)' } if (entry.savedSize === 0) {