Skip to content

Commit

Permalink
Minor improvement to logging in post-action
Browse files Browse the repository at this point in the history
- Ensure that "Caching Gradle state" group always has 1 message
- Only print cache report when entries were restored or saved
  • Loading branch information
bigdaz committed Nov 5, 2021
1 parent 4e89983 commit 4137be6
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dist/main/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/main/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/post/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/post/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/cache-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,15 @@ export abstract class AbstractCache {

async save(listener: CacheListener): Promise<void> {
if (!this.cacheOutputExists()) {
this.debug(`No ${this.cacheDescription} to cache.`)
core.info(`No ${this.cacheDescription} to cache.`)
return
}

const cacheKey = core.getState(this.cacheKeyStateKey)
const cacheResult = core.getState(this.cacheResultStateKey)

if (!cacheKey) {
this.debug(`${this.cacheDescription} existed prior to cache restore. Not saving.`)
core.info(`${this.cacheDescription} existed prior to cache restore. Not saving.`)
return
}

Expand Down
4 changes: 4 additions & 0 deletions src/caches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ export async function save(): Promise<void> {
}

function logCachingReport(listener: CacheListener): void {
if (listener.cacheEntries.length === 0) {
return
}

core.info(`---------- Caching Summary -------------
Restored Entries Count: ${getCount(listener.cacheEntries, e => e.restoredSize)}
Size: ${getSum(listener.cacheEntries, e => e.restoredSize)}
Expand Down

0 comments on commit 4137be6

Please sign in to comment.