Unverified Commit eed01f09 authored by Daz DeBoer's avatar Daz DeBoer Committed by GitHub
Browse files

Add action heading to Gradle job summary (#1058)

Job summaries from setup-gradle/dependency-submission had no top-level
heading, so they read poorly when another action's summary content lands
in the same job. Name the action explicitly so the block is attributable
when summaries are stacked.

---------

Co-authored-by: default avatarClaude Sonnet 5 <[email protected]>
parent 889dc537
Loading
Loading
Loading
Loading
+11 −2
Changes for sources/src/job-summary.ts: 11 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -15,8 +15,11 @@ export async function generateJobSummary(
): Promise<void> {
    core.startGroup('Generating Job Summary')

    const heading = renderActionHeading()

    const errors = renderErrors()
    if (errors) {
        core.summary.addRaw(heading)
        core.summary.addRaw(errors)
        await core.summary.write()
        return
@@ -31,6 +34,7 @@ export async function generateJobSummary(
    core.info(cachingReport)

    if (config.shouldGenerateJobSummary(hasFailure)) {
        core.summary.addRaw(heading)
        core.summary.addRaw(summaryTable)
        core.summary.addRaw(cachingReport)
        await core.summary.write()
@@ -57,8 +61,7 @@ async function addPRComment(jobSummary: string): Promise<void> {
    core.info(`Adding Job Summary as comment to PR #${pull_request_number}.`)

    const prComment = `${jobMarker(context)}
<h3>Job Summary for Gradle</h3>
<a href="${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}" target="_blank">
${renderActionHeading()}<a href="${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}" target="_blank">
<h5>${context.workflow} :: <em>${context.job}</em></h5>
</a>

@@ -97,6 +100,12 @@ export function renderSummaryTable(results: BuildResult[]): string {
    return `${renderDeprecations()}\n${renderBuildResults(results)}`
}

function renderActionHeading(): string {
    const actionId = getActionId()
    const caption = actionId ? ` <sub><em>captured by ${actionId}</em></sub>` : ''
    return `<h3>Gradle Builds${caption}</h3>\n\n`
}

function renderErrors(): string | undefined {
    const errors = getErrors()
    if (errors.length === 0) {