mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-11-22 17:12:51 +00:00
Adding caching details to Job Summary
This commit is contained in:
parent
86e82987ba
commit
f9c8fcf79f
2 changed files with 48 additions and 17 deletions
|
@ -92,22 +92,47 @@ export function logCachingReport(listener: CacheListener): void {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
core.info(`---------- Caching Summary -------------
|
core.summary.addHeading('Caching Summary')
|
||||||
Restored Entries Count: ${getCount(listener.cacheEntries, e => e.restoredSize)}
|
|
||||||
Size: ${getSum(listener.cacheEntries, e => e.restoredSize)}
|
|
||||||
Saved Entries Count: ${getCount(listener.cacheEntries, e => e.savedSize)}
|
|
||||||
Size: ${getSum(listener.cacheEntries, e => e.savedSize)}`)
|
|
||||||
|
|
||||||
core.startGroup('Cache Entry details')
|
const entries = listener.cacheEntries
|
||||||
for (const entry of listener.cacheEntries) {
|
.map(
|
||||||
core.info(`Entry: ${entry.entryName}
|
entry =>
|
||||||
|
`Entry: ${entry.entryName}
|
||||||
Requested Key : ${entry.requestedKey ?? ''}
|
Requested Key : ${entry.requestedKey ?? ''}
|
||||||
Restored Key : ${entry.restoredKey ?? ''}
|
Restored Key : ${entry.restoredKey ?? ''}
|
||||||
Size: ${formatSize(entry.restoredSize)}
|
Size: ${formatSize(entry.restoredSize)}
|
||||||
Saved Key : ${entry.savedKey ?? ''}
|
Saved Key : ${entry.savedKey ?? ''}
|
||||||
Size: ${formatSize(entry.savedSize)}`)
|
Size: ${formatSize(entry.savedSize)}`
|
||||||
}
|
)
|
||||||
core.endGroup()
|
.join('\n')
|
||||||
|
|
||||||
|
core.summary.addRaw(
|
||||||
|
`
|
||||||
|
|
||||||
|
| | Count | Size (Mb) | Size (B) |
|
||||||
|
| - | -: | -: | -: |
|
||||||
|
| Restored | ${getCount(listener.cacheEntries, e => e.restoredSize)} | ${getMegaBytes(
|
||||||
|
listener.cacheEntries,
|
||||||
|
e => e.restoredSize
|
||||||
|
)} | ${getBytes(listener.cacheEntries, e => e.restoredSize)} |
|
||||||
|
| Saved | ${getCount(listener.cacheEntries, e => e.savedSize)} | ${getMegaBytes(
|
||||||
|
listener.cacheEntries,
|
||||||
|
e => e.savedSize
|
||||||
|
)} | ${getBytes(listener.cacheEntries, e => e.savedSize)} |
|
||||||
|
|
||||||
|
`
|
||||||
|
)
|
||||||
|
|
||||||
|
core.summary.addDetails(
|
||||||
|
'Cache Entry Details',
|
||||||
|
`
|
||||||
|
<pre>
|
||||||
|
${entries}
|
||||||
|
</pre>
|
||||||
|
`
|
||||||
|
)
|
||||||
|
|
||||||
|
core.summary.write()
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCount(
|
function getCount(
|
||||||
|
@ -117,14 +142,19 @@ function getCount(
|
||||||
return cacheEntries.filter(e => predicate(e) !== undefined).length
|
return cacheEntries.filter(e => predicate(e) !== undefined).length
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSum(
|
function getBytes(
|
||||||
cacheEntries: CacheEntryListener[],
|
cacheEntries: CacheEntryListener[],
|
||||||
predicate: (value: CacheEntryListener) => number | undefined
|
predicate: (value: CacheEntryListener) => number | undefined
|
||||||
): string {
|
): number {
|
||||||
if (cacheEntries.length === 0) {
|
return cacheEntries.map(e => predicate(e) ?? 0).reduce((p, v) => p + v, 0)
|
||||||
return '0'
|
}
|
||||||
}
|
|
||||||
return formatSize(cacheEntries.map(e => predicate(e) ?? 0).reduce((p, v) => p + v, 0))
|
function getMegaBytes(
|
||||||
|
cacheEntries: CacheEntryListener[],
|
||||||
|
predicate: (value: CacheEntryListener) => number | undefined
|
||||||
|
): number {
|
||||||
|
const bytes = getBytes(cacheEntries, predicate)
|
||||||
|
return Math.round(bytes / (1024 * 1024))
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatSize(bytes: number | undefined): string {
|
function formatSize(bytes: number | undefined): string {
|
||||||
|
|
|
@ -34,6 +34,7 @@ function loadBuildResults(): BuildResult[] {
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeSummaryTable(results: BuildResult[]): void {
|
function writeSummaryTable(results: BuildResult[]): void {
|
||||||
|
core.summary.addHeading('Gradle Builds', 3)
|
||||||
core.summary.addRaw(`| Root Project | Tasks | Gradle Version | Outcome |\n| - | - | - | - |\n`)
|
core.summary.addRaw(`| Root Project | Tasks | Gradle Version | Outcome |\n| - | - | - | - |\n`)
|
||||||
for (const result of results) {
|
for (const result of results) {
|
||||||
const tableRow = `| ${result.rootProject} \
|
const tableRow = `| ${result.rootProject} \
|
||||||
|
|
Loading…
Reference in a new issue