From 0f47a5bec1212ec4da3285a85656427f189fbf2c Mon Sep 17 00:00:00 2001 From: Michael Marcus Date: Fri, 28 Mar 2025 17:11:15 -0400 Subject: [PATCH] Update README; use empty string as default --- README.md | 7 ++++++- __tests__/java-junit.test.ts | 3 ++- dist/index.js | 8 ++++---- src/report/get-report.ts | 10 +++++----- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 3f8afbe..e5abd85 100644 --- a/README.md +++ b/README.md @@ -154,6 +154,11 @@ jobs: # Allows you to generate reports for Actions Summary # https://github.blog/2022-05-09-supercharging-github-actions-with-job-summaries/ use-actions-summary: 'true' + + # Optionally specify a title (Heading level 1) for the report. Leading and trailing whitespace are ignored. + # This is useful for separating your test report from other sections in the build summary. + # If omitted or set to whitespace/empty, no title will be printed. + report-title: '' # Customize the title of badges shown for each Actions Summary. # Useful when distinguish summaries for tests ran in multiple Actions steps. @@ -345,7 +350,7 @@ Support for Swift test results in xUnit format is experimental - should work but Unfortunately, there are some known issues and limitations caused by GitHub API: -- Test report (i.e. Check Run summary) is markdown text. No custom styling or HTML is possible. +- Test report (i.e. build summary) is Markdown text. No custom styling or HTML is possible. - Maximum report size is 65535 bytes. Input parameters `list-suites` and `list-tests` will be automatically adjusted if max size is exceeded. - Test report can't reference any additional files (e.g. screenshots). You can use `actions/upload-artifact@v4` to upload them and inspect them manually. - Check Runs are created for specific commit SHA. It's not possible to specify under which workflow test report should belong if more diff --git a/__tests__/java-junit.test.ts b/__tests__/java-junit.test.ts index 949341f..b70fd21 100644 --- a/__tests__/java-junit.test.ts +++ b/__tests__/java-junit.test.ts @@ -13,7 +13,8 @@ describe('java-junit tests', () => { baseUrl: '', onlySummary: false, useActionsSummary: true, - badgeTitle: 'tests' + badgeTitle: 'tests', + reportTitle: '' } it('produces empty test run result when there are no test cases', async () => { diff --git a/dist/index.js b/dist/index.js index 0e63008..5a53d66 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1817,7 +1817,8 @@ const defaultOptions = { baseUrl: '', onlySummary: false, useActionsSummary: true, - badgeTitle: 'tests' + badgeTitle: 'tests', + reportTitle: '' }; function getReport(results, options = defaultOptions) { core.info('Generating check run summary'); @@ -1880,9 +1881,8 @@ function getByteLength(text) { } function renderReport(results, options) { const sections = []; - const { reportTitle } = options; - // Suppress the report title for empty string or whitespace - if (reportTitle && reportTitle.trim()) { + const reportTitle = options.reportTitle.trim(); + if (reportTitle) { sections.push(`# ${reportTitle}`); } const badge = getReportBadge(results, options); diff --git a/src/report/get-report.ts b/src/report/get-report.ts index 01320b7..1ed6656 100644 --- a/src/report/get-report.ts +++ b/src/report/get-report.ts @@ -15,7 +15,7 @@ export interface ReportOptions { onlySummary: boolean useActionsSummary: boolean badgeTitle: string - reportTitle?: string + reportTitle: string } const defaultOptions: ReportOptions = { @@ -24,7 +24,8 @@ const defaultOptions: ReportOptions = { baseUrl: '', onlySummary: false, useActionsSummary: true, - badgeTitle: 'tests' + badgeTitle: 'tests', + reportTitle: '' } export function getReport(results: TestRunResult[], options: ReportOptions = defaultOptions): string { @@ -103,9 +104,8 @@ function getByteLength(text: string): number { function renderReport(results: TestRunResult[], options: ReportOptions): string[] { const sections: string[] = [] - const {reportTitle} = options - // Suppress the report title for empty string or whitespace - if (reportTitle && reportTitle.trim()) { + const reportTitle: string = options.reportTitle.trim() + if (reportTitle) { sections.push(`# ${reportTitle}`) }