mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-11-22 17:12:51 +00:00
Write Job Summary HTML directly
This allows more control over the table layout, including centering of column content.
This commit is contained in:
parent
56036f8577
commit
67f42d16a1
2 changed files with 26 additions and 20 deletions
2
.github/workflows/demo-job-summary.yml
vendored
2
.github/workflows/demo-job-summary.yml
vendored
|
@ -25,7 +25,7 @@ jobs:
|
||||||
run: ./gradlew assemble
|
run: ./gradlew assemble
|
||||||
- name: Build kotlin-dsl project without build scan
|
- name: Build kotlin-dsl project without build scan
|
||||||
working-directory: .github/workflow-samples/kotlin-dsl
|
working-directory: .github/workflow-samples/kotlin-dsl
|
||||||
run: ./gradlew check --no-scan
|
run: ./gradlew assemble check --no-scan
|
||||||
- name: Build kotlin-dsl project with build scan publish failure
|
- name: Build kotlin-dsl project with build scan publish failure
|
||||||
working-directory: .github/workflow-samples/kotlin-dsl
|
working-directory: .github/workflow-samples/kotlin-dsl
|
||||||
run: ./gradlew check -Dgradle.enterprise.url=https://not.valid.server
|
run: ./gradlew check -Dgradle.enterprise.url=https://not.valid.server
|
||||||
|
|
|
@ -44,23 +44,29 @@ export function loadBuildResults(): BuildResult[] {
|
||||||
|
|
||||||
function writeSummaryTable(results: BuildResult[]): void {
|
function writeSummaryTable(results: BuildResult[]): void {
|
||||||
core.summary.addHeading('Gradle Builds', 3)
|
core.summary.addHeading('Gradle Builds', 3)
|
||||||
core.summary.addTable([
|
|
||||||
[
|
core.summary.addRaw(`
|
||||||
{data: 'Root Project', header: true},
|
<table>
|
||||||
{data: 'Tasks', header: true},
|
<tr>
|
||||||
{data: 'Gradle Version', header: true},
|
<th>Root Project</th>
|
||||||
{data: 'Outcome', header: true},
|
<th>Requested Tasks</th>
|
||||||
{data: 'Build Scan™', header: true}
|
<th>Gradle Version</th>
|
||||||
],
|
<th>Build Outcome</th>
|
||||||
...results.map(result => [
|
<th>Build Scan™</th>
|
||||||
result.rootProjectName,
|
</tr>${results.map(result => renderBuildResultRow(result)).join('')}
|
||||||
result.requestedTasks,
|
</table>
|
||||||
result.gradleVersion,
|
`)
|
||||||
renderOutcome(result),
|
}
|
||||||
renderBuildScan(result)
|
|
||||||
])
|
function renderBuildResultRow(result: BuildResult): string {
|
||||||
])
|
return `
|
||||||
core.summary.addRaw('\n')
|
<tr>
|
||||||
|
<td>${result.rootProjectName}</td>
|
||||||
|
<td>${result.requestedTasks}</td>
|
||||||
|
<td align='center'>${result.gradleVersion}</td>
|
||||||
|
<td align='center'>${renderOutcome(result)}</td>
|
||||||
|
<td>${renderBuildScan(result)}</td>
|
||||||
|
</tr>`
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderOutcome(result: BuildResult): string {
|
function renderOutcome(result: BuildResult): string {
|
||||||
|
@ -70,7 +76,7 @@ function renderOutcome(result: BuildResult): string {
|
||||||
function renderBuildScan(result: BuildResult): string {
|
function renderBuildScan(result: BuildResult): string {
|
||||||
if (result.buildScanFailed) {
|
if (result.buildScanFailed) {
|
||||||
return renderBuildScanBadge(
|
return renderBuildScanBadge(
|
||||||
'PUBLISHED_FAILED',
|
'PUBLISH_FAILED',
|
||||||
'orange',
|
'orange',
|
||||||
'https://docs.gradle.com/enterprise/gradle-plugin/#troubleshooting'
|
'https://docs.gradle.com/enterprise/gradle-plugin/#troubleshooting'
|
||||||
)
|
)
|
||||||
|
@ -78,7 +84,7 @@ function renderBuildScan(result: BuildResult): string {
|
||||||
if (result.buildScanUri) {
|
if (result.buildScanUri) {
|
||||||
return renderBuildScanBadge('PUBLISHED', '06A0CE', result.buildScanUri)
|
return renderBuildScanBadge('PUBLISHED', '06A0CE', result.buildScanUri)
|
||||||
}
|
}
|
||||||
return renderBuildScanBadge('NOT_PUBLISHED', 'lightgrey', 'https://docs.gradle.com/enterprise/gradle-plugin/')
|
return renderBuildScanBadge('NOT_PUBLISHED', 'lightgrey', 'https://scans.gradle.com')
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderBuildScanBadge(outcomeText: string, outcomeColor: string, targetUrl: string): string {
|
function renderBuildScanBadge(outcomeText: string, outcomeColor: string, targetUrl: string): string {
|
||||||
|
|
Loading…
Reference in a new issue