diff --git a/src/cache-extract-entries.ts b/src/cache-extract-entries.ts index 184cf8d..c7bbe67 100644 --- a/src/cache-extract-entries.ts +++ b/src/cache-extract-entries.ts @@ -212,7 +212,7 @@ abstract class AbstractEntryExtractor { if (previouslyRestoredKey === cacheKey) { cacheDebug(`No change to previously restored ${artifactType}. Not saving.`) - entryListener.markUnchanged('entry contents unchanged') + entryListener.markUnchanged('contents unchanged') } else { core.info(`Caching ${artifactType} with path '${pattern}' and cache key: ${cacheKey}`) await saveCache([pattern], cacheKey, entryListener) diff --git a/src/cache-reporting.ts b/src/cache-reporting.ts index fda2e42..ae8bb3a 100644 --- a/src/cache-reporting.ts +++ b/src/cache-reporting.ts @@ -6,6 +6,8 @@ import * as core from '@actions/core' */ export class CacheListener { cacheEntries: CacheEntryListener[] = [] + isCacheReadOnly = false + isCacheWriteOnly = false get fullyRestored(): boolean { return this.cacheEntries.every(x => !x.wasRequestedButNotRestored()) @@ -108,10 +110,10 @@ export function logCachingReport(listener: CacheListener): void { Requested Key : ${entry.requestedKey ?? ''} Restored Key : ${entry.restoredKey ?? ''} Size: ${formatSize(entry.restoredSize)} - ${getRestoredMessage(entry)} + ${getRestoredMessage(entry, listener.isCacheWriteOnly)} Saved Key : ${entry.savedKey ?? ''} Size: ${formatSize(entry.savedSize)} - ${getSavedMessage(entry)} + ${getSavedMessage(entry, listener.isCacheReadOnly)} ---` ) .join('\n') @@ -133,6 +135,13 @@ export function logCachingReport(listener: CacheListener): void { ` ) + if (listener.isCacheReadOnly) { + core.summary.addRaw('- **Cache is read-only**\n') + } + if (listener.isCacheWriteOnly) { + core.summary.addRaw('- **Cache is write-only**\n') + } + core.summary.addDetails( 'Cache Entry Details', ` @@ -144,25 +153,31 @@ ${entries} ) } -function getRestoredMessage(entry: CacheEntryListener): string { +function getRestoredMessage(entry: CacheEntryListener, isCacheWriteOnly: boolean): string { + if (isCacheWriteOnly) { + return '(Entry not restored: cache is write-only)' + } if (entry.restoredKey === undefined) { - return '(No match found)' + return '(Entry not restored: no match found)' } if (entry.restoredKey === entry.requestedKey) { - return '(Exact match found)' + return '(Entry restored: exact match found)' } - return '(Fuzzy match found)' + return '(Entry restored: partial match found)' } -function getSavedMessage(entry: CacheEntryListener): string { +function getSavedMessage(entry: CacheEntryListener, isCacheReadOnly: boolean): string { if (entry.unchanged) { return `(Entry not saved: ${entry.unchanged})` } if (entry.savedKey === undefined) { - return '(Entry not saved: ???' + if (isCacheReadOnly) { + return '(Entry not saved: cache is read-only)' + } + return '(Entry not saved: reason unknown)' } if (entry.savedSize === 0) { - return '(Could not save: entry exists)' + return '(Entry not saved: entry with key already exists)' } return '(Entry saved)' } diff --git a/src/caches.ts b/src/caches.ts index a5f774f..54247cf 100644 --- a/src/caches.ts +++ b/src/caches.ts @@ -35,6 +35,7 @@ export async function restore(gradleUserHome: string, cacheListener: CacheListen if (isCacheWriteOnly()) { core.info('Cache is write-only: will not restore from cache.') + cacheListener.isCacheWriteOnly = true return } @@ -50,6 +51,7 @@ export async function save(gradleUserHome: string, cacheListener: CacheListener) if (isCacheReadOnly()) { core.info('Cache is read-only: will not save state for use in subsequent builds.') + cacheListener.isCacheReadOnly = true return }