Skip to content

Commit 5c9969e

Browse files
authored
Merge pull request #1439 from mikepenz/feature/1435_2
Add `job_summary_text` input to include custom text in job summary
2 parents 6be04cc + b958369 commit 5c9969e

File tree

7 files changed

+34
-13
lines changed

7 files changed

+34
-13
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ jobs:
4444
include_passed: true
4545
detailed_summary: true
4646
summary: '<table><thead><tr><th> Application (src/applications) </th></tr></thead><tbody><tr><td> test </td></tr></tbody></table>'
47+
job_summary_text: |
48+
# Test Header for Example Junit Test Report
49+
50+
This is some custom body to show in the summary.
4751
check_title_template: '{{SUITE_NAME}} | {{TEST_NAME}}'
4852
annotate_only: ${{ github.event_name == 'workflow_dispatch' }}
4953

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ jobs:
9696
| `annotate_only` | Optional. Will only annotate the results on the files, won't create a check run. Defaults to `false`. |
9797
| `transformers` | Optional. Array of `Transformer`s offering the ability to adjust the fileName. Defaults to: `[{"searchValue":"::","replaceValue":"/"}]` |
9898
| `job_summary` | Optional. Enables the publishing of the job summary for the results. Defaults to `true`. May be required to disable [Enterprise Server](https://github.com/mikepenz/action-junit-report/issues/637) |
99+
| `job_summary_text` | Optional. Additional text to include in the job summary prior to the tables. Defaults to empty string. |
99100
| `detailed_summary` | Optional. Include table with all test results in the summary (Also applies to comment). Defaults to `false`. |
100101
| `flaky_summary` | Optional. Include table with all flaky results in the summary (Also applies to comment). Defaults to `false`. |
101102
| `verbose_summary` | Optional. Detail table will note if there were no test annotations for a test suite (Also applies to comment). Defaults to `true`. |

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ inputs:
9090
description: 'Enables the publishing of a JOB_SUMMARY with the report.'
9191
required: false
9292
default: 'true'
93+
job_summary_text:
94+
description: 'Additional text to include in the job summary prior to the tables'
95+
required: false
96+
default: ''
9397
detailed_summary:
9498
description: 'Include table with all test results in summary'
9599
required: false

dist/index.js

Lines changed: 11 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/annotator.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,16 +146,22 @@ export async function attachSummary(
146146
table: SummaryTableRow[],
147147
detailsTable: SummaryTableRow[],
148148
flakySummary: SummaryTableRow[],
149-
checkInfos: CheckInfo[] = []
149+
checkInfos: CheckInfo[] = [],
150+
summaryText?: string
150151
): Promise<void> {
152+
// Add summary text if provided
153+
if (summaryText) {
154+
core.summary.addRaw(summaryText)
155+
}
156+
151157
if (table.length > 0) {
152-
await core.summary.addTable(table).write()
158+
core.summary.addTable(table)
153159
}
154160
if (detailsTable.length > 1) {
155-
await core.summary.addTable(detailsTable).write()
161+
core.summary.addTable(detailsTable)
156162
}
157163
if (flakySummary.length > 1) {
158-
await core.summary.addTable(flakySummary).write()
164+
core.summary.addTable(flakySummary)
159165
}
160166

161167
// Add check links to the job summary if any checks were created
@@ -166,7 +172,7 @@ export async function attachSummary(
166172
core.summary.addList(links)
167173
}
168174
core.summary.addSeparator()
169-
core.summary.write()
175+
await core.summary.write()
170176
}
171177

172178
export function buildCommentIdentifier(checkName: string[]): string {

src/main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export async function run(): Promise<void> {
2929
const checkRetries = core.getInput('check_retries') === 'true'
3030
const annotateNotice = core.getInput('annotate_notice') === 'true'
3131
const jobSummary = core.getInput('job_summary') === 'true'
32+
const jobSummaryText = core.getInput('job_summary_text')
3233
const detailedSummary = core.getInput('detailed_summary') === 'true'
3334
const flakySummary = core.getInput('flaky_summary') === 'true'
3435
const verboseSummary = core.getInput('verbose_summary') === 'true'
@@ -197,7 +198,7 @@ export async function run(): Promise<void> {
197198
)
198199
if (jobSummary && supportsJobSummary) {
199200
try {
200-
await attachSummary(table, detailTable, flakyTable, checkInfos)
201+
await attachSummary(table, detailTable, flakyTable, checkInfos, jobSummaryText)
201202
} catch (error) {
202203
core.error(`❌ Failed to set the summary using the provided token. (${error})`)
203204
}

0 commit comments

Comments
 (0)