From 7dfbe33bba86496c18247c8fa8a0b2d01ecd843f Mon Sep 17 00:00:00 2001 From: Daz DeBoer Date: Sun, 12 Sep 2021 13:09:36 -0600 Subject: [PATCH] Improve formatting for cache entry size reporting --- src/cache-gradle-user-home.ts | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/src/cache-gradle-user-home.ts b/src/cache-gradle-user-home.ts index f531eb9..d34308b 100644 --- a/src/cache-gradle-user-home.ts +++ b/src/cache-gradle-user-home.ts @@ -34,9 +34,9 @@ export class GradleUserHomeCache extends AbstractCache { async restore(): Promise { await super.restore() - await this.reportCacheEntrySize('excluding common artifacts') + await this.reportCacheEntrySize('as restored from cache') await this.restoreCommonArtifacts() - await this.reportCacheEntrySize('including common artifacts') + await this.reportCacheEntrySize('after restoring common artifacts') } private async restoreCommonArtifacts(): Promise { @@ -91,11 +91,30 @@ export class GradleUserHomeCache extends AbstractCache { if (!fs.existsSync(gradleUserHome)) { return } - core.info(`Gradle User Home cache entry: ${label}`) - await exec.exec('du', ['-h', '-c', '-t', '5M'], { - cwd: gradleUserHome, - ignoreReturnCode: true - }) + const result = await exec.getExecOutput( + 'du', + ['-h', '-c', '-t', '5M'], + { + cwd: gradleUserHome, + silent: true, + ignoreReturnCode: true + } + ) + + core.info(`Gradle User Home cache entry (directories >5M): ${label}`) + + core.info( + result.stdout + .trimEnd() + .replace(/\t/g, ' ') + .split('\n') + .map(it => { + return ` ${it}` + }) + .join('\n') + ) + + core.info('-----------------------') } async save(): Promise {