Skip to content

Commit

Permalink
Improvements to cache reporting
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
bigdaz committed Dec 23, 2023
1 parent df38ec0 commit 93050d1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/cache-extract-entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -403,9 +403,12 @@ export class ConfigurationCacheEntryExtractor extends AbstractEntryExtractor {

async extract(listener: CacheListener): Promise<void> {
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
}
Expand Down
3 changes: 3 additions & 0 deletions src/cache-reporting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 93050d1

Please sign in to comment.