Skip to content

Commit 78f2a03

Browse files
Feat/collapse large reports (#172)
1 parent 0c64268 commit 78f2a03

File tree

15 files changed

+186
-8
lines changed

15 files changed

+186
-8
lines changed

.github/workflows/build-and-test.yaml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ jobs:
3333
flaky-rate-report: true
3434
slowest-report: true
3535
previous-results-report: true
36-
use-suite-name: true
3736
upload-artifact: true
3837
env:
3938
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -247,6 +246,27 @@ jobs:
247246
env:
248247
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
249248
if: always()
249+
collapse-large-reports-test:
250+
needs: build-and-test
251+
runs-on: ubuntu-latest
252+
steps:
253+
- name: Checkout code
254+
uses: actions/checkout@v4
255+
- name: Install dependencies
256+
run: npm install
257+
- name: Modify reports
258+
run: npm run modify-reports
259+
- name: Collapse Large Reports Test
260+
uses: ./
261+
with:
262+
report-path: './ctrf-reports/*.json'
263+
test-report: true
264+
test-list-report: true
265+
collapse-large-reports: true
266+
annotate: false
267+
env:
268+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
269+
if: always()
250270
junit-to-ctrf-test:
251271
needs: build-and-test
252272
runs-on: ubuntu-latest

__tests__/ctrf/report-preparation.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ function createSingleReportInputs(): Inputs {
554554
summary: false,
555555
pullRequest: false,
556556
issue: '',
557+
collapseLargeReports: false,
557558
summaryReport: true, // Only 1 report enabled
558559
githubReport: false,
559560
testReport: false,

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ inputs:
175175
description: 'Upload the processed CTRF report for future processing'
176176
required: false
177177
default: false
178+
collapse-large-reports:
179+
description: 'Collapse large reports (test-table and test-list) by default.'
180+
required: false
181+
default: false
178182

179183
# Advanced Options
180184
artifact-name:

dist/index.js

Lines changed: 59 additions & 0 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.

dist/reports/failed-table.hbs

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

dist/reports/test-list.hbs

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

dist/reports/test-table.hbs

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

src/core/inputs.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export function getCliInputs(args: Arguments): Inputs {
1717
summary: true,
1818
pullRequest: args.pullRequest || false,
1919
issue: '',
20+
collapseLargeReports: false,
2021
summaryReport: args._.includes('summary'),
2122
githubReport: args._.includes('github'),
2223
testReport: args._.includes('tests'),
@@ -81,6 +82,7 @@ export function getInputs(): Inputs {
8182
githubReport: core.getInput('github-report').toLowerCase() === 'true',
8283
pullRequest: core.getInput('pull-request').toLowerCase() === 'true',
8384
issue: core.getInput('issue').toLowerCase() || '',
85+
collapseLargeReports: core.getInput('collapse-large-reports').toLowerCase() === 'true',
8486
summaryReport: core.getInput('summary-report').toLowerCase() === 'true',
8587
testReport: core.getInput('test-report').toLowerCase() === 'true',
8688
testListReport: core.getInput('test-list-report').toLowerCase() === 'true',

src/handlebars/helpers/ctrf.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Handlebars from 'handlebars'
22
import { getEmoji, getGitHubIcon } from '../../ctrf/helpers'
33
import { CtrfTest, CtrfTestState } from '../../types'
4+
import * as core from '@actions/core'
45

56
/**
67
* Filters an array of tests to only those that have failed, then limits the result to a specified number.
@@ -366,3 +367,25 @@ export function formatTestPathHelper(): void {
366367
)
367368
})
368369
}
370+
371+
/**
372+
* Gets the collapse-large-reports input value from GitHub Actions.
373+
*
374+
* @example
375+
* In Handlebars:
376+
* {{#if (getCollapseLargeReports)}}
377+
* <details><summary>Tests</summary>
378+
* <!-- content -->
379+
* </details>
380+
* {{else}}
381+
* <!-- content -->
382+
* {{/if}}
383+
*
384+
* @returns {boolean} True if collapse-large-reports is enabled, false otherwise.
385+
*/
386+
export function getCollapseLargeReportsHelper(): void {
387+
Handlebars.registerHelper('getCollapseLargeReports', () => {
388+
const input = core.getInput('collapse-large-reports')
389+
return input ? input.toLowerCase() === 'true' : false
390+
})
391+
}

0 commit comments

Comments
 (0)