Skip to content

Commit 718a36a

Browse files
if prev reports exist show delta summary (#240)
1 parent 024bc4b commit 718a36a

File tree

4 files changed

+36
-8
lines changed

4 files changed

+36
-8
lines changed

badges/coverage.svg

Lines changed: 1 addition & 1 deletion
Loading

dist/index.js

Lines changed: 14 additions & 2 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/github/core.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as core from '@actions/core'
22
import { limitPreviousReports, stripAnsi, getEmoji } from '../ctrf'
33
import { generateMarkdown } from '../handlebars/core'
4-
import { Inputs, ReportConditionals } from '../types'
4+
import { Inputs, PreviousResult, ReportConditionals } from '../types'
55
import { Report } from 'ctrf'
66
import { readTemplate, reportTypeToInputKey } from '../utils'
77
import { BuiltInReports, getBasePath } from '../reports/core'
@@ -17,6 +17,9 @@ import { isAnyReportEnabled } from '../utils/report-utils'
1717
* @param report - The CTRF report to generate views from.
1818
*/
1919
export function generateViews(inputs: Inputs, report: Report): void {
20+
const hasPreviousResults =
21+
((report.extra?.previousResults as PreviousResult[])?.length ?? 0) > 0
22+
2023
if (inputs.title) {
2124
core.summary.addHeading(inputs.title, 2).addEOL().addEOL()
2225
}
@@ -27,8 +30,11 @@ export function generateViews(inputs: Inputs, report: Report): void {
2730
core.info(
2831
'No specific report selected. Generating default reports: summary, failed, flaky, skipped, and tests.'
2932
)
30-
31-
addViewToSummary('### Summary', BuiltInReports.SummaryTable, report)
33+
if (hasPreviousResults === false) {
34+
addViewToSummary('### Summary', BuiltInReports.SummaryTable, report)
35+
} else {
36+
addViewToSummary('### Summary', BuiltInReports.SummaryDeltaTable, report)
37+
}
3238
if (reportConditionals?.showFailedReports) {
3339
addViewToSummary('### Failed Tests', BuiltInReports.FailedTable, report)
3440
} else {
@@ -196,12 +202,22 @@ function generateReportByType(
196202
inputs: Inputs,
197203
report: Report
198204
): void {
205+
const hasPreviousResults =
206+
((report.extra?.previousResults as PreviousResult[])?.length ?? 0) > 0
199207
const reportConditionals = report.extra
200208
?.reportConditionals as ReportConditionals
201209
switch (reportType) {
202210
case 'summary-report':
203211
core.info('Adding summary report to summary')
204-
addViewToSummary('### Summary', BuiltInReports.SummaryTable, report)
212+
if (hasPreviousResults === false) {
213+
addViewToSummary('### Summary', BuiltInReports.SummaryTable, report)
214+
} else {
215+
addViewToSummary(
216+
'### Summary',
217+
BuiltInReports.SummaryDeltaTable,
218+
report
219+
)
220+
}
205221
break
206222
case 'summary-delta-report':
207223
core.info('Adding summary delta report to summary')

0 commit comments

Comments
 (0)