Skip to content

Commit

Permalink
Feature: Add summary title
Browse files Browse the repository at this point in the history
Add new option `report-title` to add H1 title to the Markdown report

Resolves #540
  • Loading branch information
Michael Marcus authored and Jozef Izso committed May 17, 2025
1 parent d1bf678 commit 0841c81
Show file tree
Hide file tree
Showing 20 changed files with 65 additions and 8 deletions.
1 change: 1 addition & 0 deletions __tests__/__outputs__/dart-json.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Test Results
![Tests failed](https://img.shields.io/badge/tests-1%20passed%2C%204%20failed%2C%201%20skipped-critical)
|Report|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
Expand Down
1 change: 1 addition & 0 deletions __tests__/__outputs__/dotnet-nunit.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Test Results
![Tests failed](https://img.shields.io/badge/tests-3%20passed%2C%205%20failed%2C%201%20skipped-critical)
|Report|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
Expand Down
1 change: 1 addition & 0 deletions __tests__/__outputs__/dotnet-trx.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Test Results
![Tests failed](https://img.shields.io/badge/tests-5%20passed%2C%205%20failed%2C%201%20skipped-critical)
|Report|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
Expand Down
1 change: 1 addition & 0 deletions __tests__/__outputs__/fluent-validation-test-results.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Test Results
![Tests passed successfully](https://img.shields.io/badge/tests-803%20passed%2C%201%20skipped-success)
<details><summary>Expand for details</summary>

Expand Down
1 change: 1 addition & 0 deletions __tests__/__outputs__/jest-junit-eslint.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Test Results
![Tests passed successfully](https://img.shields.io/badge/tests-1%20passed-success)
<details><summary>Expand for details</summary>

Expand Down
1 change: 1 addition & 0 deletions __tests__/__outputs__/jest-junit.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Test Results
![Tests failed](https://img.shields.io/badge/tests-1%20passed%2C%204%20failed%2C%201%20skipped-critical)
|Report|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
Expand Down
1 change: 1 addition & 0 deletions __tests__/__outputs__/jest-react-component-test-results.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Test Results
![Tests passed successfully](https://img.shields.io/badge/tests-1%20passed-success)
<details><summary>Expand for details</summary>

Expand Down
1 change: 1 addition & 0 deletions __tests__/__outputs__/jest-test-results.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Test Results
![Tests failed](https://img.shields.io/badge/tests-4207%20passed%2C%202%20failed%2C%2030%20skipped-critical)
|Report|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
Expand Down
1 change: 1 addition & 0 deletions __tests__/__outputs__/junit-with-message.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Test Results
![Tests failed](https://img.shields.io/badge/tests-1%20failed-critical)
|Report|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
Expand Down
1 change: 1 addition & 0 deletions __tests__/__outputs__/mocha-json.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Test Results
![Tests failed](https://img.shields.io/badge/tests-1%20passed%2C%204%20failed%2C%201%20skipped-critical)
|Report|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
Expand Down
1 change: 1 addition & 0 deletions __tests__/__outputs__/mocha-test-results.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Test Results
![Tests passed successfully](https://img.shields.io/badge/tests-833%20passed%2C%206%20skipped-success)
<details><summary>Expand for details</summary>

Expand Down
1 change: 1 addition & 0 deletions __tests__/__outputs__/provider-test-results.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Test Results
![Tests failed](https://img.shields.io/badge/tests-268%20passed%2C%201%20failed-critical)
|Report|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
Expand Down
1 change: 1 addition & 0 deletions __tests__/__outputs__/pulsar-test-results-no-merge.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Test Results
![Tests failed](https://img.shields.io/badge/tests-1%20failed%2C%201%20skipped-critical)
|Report|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
Expand Down
1 change: 1 addition & 0 deletions __tests__/__outputs__/pulsar-test-results.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Test Results
![Tests failed](https://img.shields.io/badge/tests-793%20passed%2C%201%20failed%2C%2014%20skipped-critical)
|Report|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
Expand Down
1 change: 1 addition & 0 deletions __tests__/__outputs__/rspec-json.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Test Results
![Tests failed](https://img.shields.io/badge/tests-1%20passed%2C%201%20failed%2C%201%20skipped-critical)
|Report|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
Expand Down
1 change: 1 addition & 0 deletions __tests__/__outputs__/silent-notes-test-results.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Test Results
![Tests passed successfully](https://img.shields.io/badge/tests-67%20passed%2C%2012%20skipped-success)
<details><summary>Expand for details</summary>

Expand Down
1 change: 1 addition & 0 deletions __tests__/__outputs__/swift-xunit.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Test Results
![Tests failed](https://img.shields.io/badge/tests-2%20passed%2C%201%20failed-critical)
|Report|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
Expand Down
27 changes: 23 additions & 4 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 20 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class TestReporter {
readonly onlySummary = core.getInput('only-summary', {required: false}) === 'true'
readonly useActionsSummary = core.getInput('use-actions-summary', {required: false}) === 'true'
readonly badgeTitle = core.getInput('badge-title', {required: false})
readonly reportTitle = core.getInput('report-title', {required: false})
readonly token = core.getInput('token', {required: true})
readonly octokit: InstanceType<typeof GitHub>
readonly context = getCheckRunContext()
Expand Down Expand Up @@ -164,11 +165,19 @@ class TestReporter {
}
}

const {listSuites, listTests, onlySummary, useActionsSummary, badgeTitle} = this
const {listSuites, listTests, onlySummary, useActionsSummary, badgeTitle, reportTitle} = this

let baseUrl = ''
if (this.useActionsSummary) {
const summary = getReport(results, {listSuites, listTests, baseUrl, onlySummary, useActionsSummary, badgeTitle})
const summary = getReport(results, {
listSuites,
listTests,
baseUrl,
onlySummary,
useActionsSummary,
badgeTitle,
reportTitle
})

core.info('Summary content:')
core.info(summary)
Expand All @@ -188,7 +197,15 @@ class TestReporter {

core.info('Creating report summary')
baseUrl = createResp.data.html_url as string
const summary = getReport(results, {listSuites, listTests, baseUrl, onlySummary, useActionsSummary, badgeTitle})
const summary = getReport(results, {
listSuites,
listTests,
baseUrl,
onlySummary,
useActionsSummary,
badgeTitle,
reportTitle
})

core.info('Creating annotations')
const annotations = getAnnotations(results, this.maxAnnotations)
Expand Down
6 changes: 5 additions & 1 deletion src/report/get-report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface ReportOptions {
onlySummary: boolean
useActionsSummary: boolean
badgeTitle: string
reportTitle: string
}

const defaultOptions: ReportOptions = {
Expand All @@ -23,7 +24,8 @@ const defaultOptions: ReportOptions = {
baseUrl: '',
onlySummary: false,
useActionsSummary: true,
badgeTitle: 'tests'
badgeTitle: 'tests',
reportTitle: 'Test Results'
}

export function getReport(results: TestRunResult[], options: ReportOptions = defaultOptions): string {
Expand Down Expand Up @@ -101,6 +103,8 @@ function getByteLength(text: string): number {

function renderReport(results: TestRunResult[], options: ReportOptions): string[] {
const sections: string[] = []
sections.push(`# ${options.reportTitle}`)

const badge = getReportBadge(results, options)
sections.push(badge)

Expand Down

0 comments on commit 0841c81

Please sign in to comment.