mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-12-26 08:42:08 -05:00
Improve rendering of Job Summary
This commit is contained in:
parent
1903bd4674
commit
56036f8577
1 changed files with 25 additions and 7 deletions
|
@ -11,6 +11,7 @@ export interface BuildResult {
|
||||||
get gradleHomeDir(): string
|
get gradleHomeDir(): string
|
||||||
get buildFailed(): boolean
|
get buildFailed(): boolean
|
||||||
get buildScanUri(): string
|
get buildScanUri(): string
|
||||||
|
get buildScanFailed(): boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function writeJobSummary(buildResults: BuildResult[], cacheListener: CacheListener): Promise<void> {
|
export async function writeJobSummary(buildResults: BuildResult[], cacheListener: CacheListener): Promise<void> {
|
||||||
|
@ -48,23 +49,40 @@ function writeSummaryTable(results: BuildResult[]): void {
|
||||||
{data: 'Root Project', header: true},
|
{data: 'Root Project', header: true},
|
||||||
{data: 'Tasks', header: true},
|
{data: 'Tasks', header: true},
|
||||||
{data: 'Gradle Version', header: true},
|
{data: 'Gradle Version', header: true},
|
||||||
{data: 'Outcome', header: true}
|
{data: 'Outcome', header: true},
|
||||||
|
{data: 'Build Scan™', header: true}
|
||||||
],
|
],
|
||||||
...results.map(result => [
|
...results.map(result => [
|
||||||
result.rootProjectName,
|
result.rootProjectName,
|
||||||
result.requestedTasks,
|
result.requestedTasks,
|
||||||
result.gradleVersion,
|
result.gradleVersion,
|
||||||
renderOutcome(result)
|
renderOutcome(result),
|
||||||
|
renderBuildScan(result)
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
core.summary.addRaw('\n')
|
core.summary.addRaw('\n')
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderOutcome(result: BuildResult): string {
|
function renderOutcome(result: BuildResult): string {
|
||||||
const labelPart = result.buildScanUri ? 'Build%20Scan%E2%84%A2' : 'Build'
|
return result.buildFailed ? ':x:' : ':white_check_mark:'
|
||||||
const outcomePart = result.buildFailed ? 'FAILED-red' : 'SUCCESS-brightgreen'
|
}
|
||||||
const badgeUrl = `https://img.shields.io/badge/${labelPart}-${outcomePart}?logo=Gradle`
|
|
||||||
const badgeHtml = `<img src="${badgeUrl}" alt="Gradle Build">`
|
function renderBuildScan(result: BuildResult): string {
|
||||||
const targetUrl = result.buildScanUri ? result.buildScanUri : '#'
|
if (result.buildScanFailed) {
|
||||||
|
return renderBuildScanBadge(
|
||||||
|
'PUBLISHED_FAILED',
|
||||||
|
'orange',
|
||||||
|
'https://docs.gradle.com/enterprise/gradle-plugin/#troubleshooting'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (result.buildScanUri) {
|
||||||
|
return renderBuildScanBadge('PUBLISHED', '06A0CE', result.buildScanUri)
|
||||||
|
}
|
||||||
|
return renderBuildScanBadge('NOT_PUBLISHED', 'lightgrey', 'https://docs.gradle.com/enterprise/gradle-plugin/')
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderBuildScanBadge(outcomeText: string, outcomeColor: string, targetUrl: string): string {
|
||||||
|
const badgeUrl = `https://img.shields.io/badge/Build%20Scan%E2%84%A2-${outcomeText}-${outcomeColor}?logo=Gradle`
|
||||||
|
const badgeHtml = `<img src="${badgeUrl}" alt="Build Scan ${outcomeText}" />`
|
||||||
return `<a href="${targetUrl}" rel="nofollow">${badgeHtml}</a>`
|
return `<a href="${targetUrl}" rel="nofollow">${badgeHtml}</a>`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue