mirror of
https://github.com/gradle/gradle-build-action
synced 2024-11-24 10:32:20 +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
|
||||
}
|
||||
|
||||
core.info(`---------- 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.summary.addHeading('Caching Summary')
|
||||
|
||||
core.startGroup('Cache Entry details')
|
||||
for (const entry of listener.cacheEntries) {
|
||||
core.info(`Entry: ${entry.entryName}
|
||||
const entries = listener.cacheEntries
|
||||
.map(
|
||||
entry =>
|
||||
`Entry: ${entry.entryName}
|
||||
Requested Key : ${entry.requestedKey ?? ''}
|
||||
Restored Key : ${entry.restoredKey ?? ''}
|
||||
Size: ${formatSize(entry.restoredSize)}
|
||||
Saved Key : ${entry.savedKey ?? ''}
|
||||
Size: ${formatSize(entry.savedSize)}`)
|
||||
}
|
||||
core.endGroup()
|
||||
Size: ${formatSize(entry.savedSize)}`
|
||||
)
|
||||
.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(
|
||||
|
@ -117,14 +142,19 @@ function getCount(
|
|||
return cacheEntries.filter(e => predicate(e) !== undefined).length
|
||||
}
|
||||
|
||||
function getSum(
|
||||
function getBytes(
|
||||
cacheEntries: CacheEntryListener[],
|
||||
predicate: (value: CacheEntryListener) => number | undefined
|
||||
): string {
|
||||
if (cacheEntries.length === 0) {
|
||||
return '0'
|
||||
}
|
||||
return formatSize(cacheEntries.map(e => predicate(e) ?? 0).reduce((p, v) => p + v, 0))
|
||||
): number {
|
||||
return 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 {
|
||||
|
|
|
@ -34,6 +34,7 @@ function loadBuildResults(): BuildResult[] {
|
|||
}
|
||||
|
||||
function writeSummaryTable(results: BuildResult[]): void {
|
||||
core.summary.addHeading('Gradle Builds', 3)
|
||||
core.summary.addRaw(`| Root Project | Tasks | Gradle Version | Outcome |\n| - | - | - | - |\n`)
|
||||
for (const result of results) {
|
||||
const tableRow = `| ${result.rootProject} \
|
||||
|
|
Loading…
Reference in a new issue