1
0
Fork 0
mirror of https://github.com/dorny/test-reporter.git synced 2026-05-06 18:47:35 +02:00

Refactor summary output to use a temporary file

This commit is contained in:
Jozef Izso 2026-04-25 14:20:21 +02:00
parent 49ad12d837
commit bd45c7a559
Failed to extract signature
4 changed files with 17 additions and 6 deletions

View file

@ -2,7 +2,7 @@
## 3.1.0 ## 3.1.0
* Feature: Add `list-files` input to control test report file listing https://github.com/dorny/test-reporter/pull/773 * Feature: Add `list-files` input to control test report file listing https://github.com/dorny/test-reporter/pull/773
* Feature: Add `summary` output with the generated summary in Markdown format https://github.com/dorny/test-reporter/pull/772 * Feature: Add `summary_file` output with the path to the generated summary in Markdown format https://github.com/dorny/test-reporter/pull/772
## 3.0.0 ## 3.0.0
* Feature: Use NodeJS 24 LTS as default runtime https://github.com/dorny/test-reporter/pull/738 * Feature: Use NodeJS 24 LTS as default runtime https://github.com/dorny/test-reporter/pull/738

View file

@ -225,7 +225,7 @@ jobs:
| time | Test execution time [ms] | | time | Test execution time [ms] |
| url | Check run URL | | url | Check run URL |
| url_html | Check run URL HTML | | url_html | Check run URL HTML |
| summary | Generated test report summary in Markdown format | | summary_file | Path to a file containing the generated test report summary in Markdown format |
| slug_prefix| Random anchor links slug prefix generated for the summary headers | | slug_prefix| Random anchor links slug prefix generated for the summary headers |
## Supported formats ## Supported formats

View file

@ -130,8 +130,8 @@ outputs:
description: Check run URL description: Check run URL
url_html: url_html:
description: Check run URL HTML description: Check run URL HTML
summary: summary_file:
description: Generated test report summary in Markdown format description: Path to a file containing the generated test report summary in Markdown format
slug_prefix: slug_prefix:
description: Random prefix added to generated report anchor slugs for this action run description: Random prefix added to generated report anchor slugs for this action run
runs: runs:

View file

@ -2,6 +2,9 @@ import * as core from '@actions/core'
import * as github from '@actions/github' import * as github from '@actions/github'
import {GitHub} from '@actions/github/lib/utils' import {GitHub} from '@actions/github/lib/utils'
import {randomBytes} from 'node:crypto' import {randomBytes} from 'node:crypto'
import {writeFileSync} from 'node:fs'
import {tmpdir} from 'node:os'
import {join} from 'node:path'
import {ArtifactProvider} from './input-providers/artifact-provider.js' import {ArtifactProvider} from './input-providers/artifact-provider.js'
import {LocalFileProvider} from './input-providers/local-file-provider.js' import {LocalFileProvider} from './input-providers/local-file-provider.js'
@ -221,7 +224,7 @@ class TestReporter {
core.info('Summary content:') core.info('Summary content:')
core.info(summary) core.info(summary)
core.setOutput('summary', summary) this.writeSummaryFile(summary)
await core.summary.addRaw(summary).write() await core.summary.addRaw(summary).write()
} else { } else {
core.info(`Creating check run ${name}`) core.info(`Creating check run ${name}`)
@ -253,7 +256,7 @@ class TestReporter {
core.info('Creating annotations') core.info('Creating annotations')
const annotations = getAnnotations(results, this.maxAnnotations) const annotations = getAnnotations(results, this.maxAnnotations)
core.setOutput('summary', summary) this.writeSummaryFile(summary)
const isFailed = this.failOnError && results.some(tr => tr.result === 'failed') const isFailed = this.failOnError && results.some(tr => tr.result === 'failed')
const conclusion = isFailed ? 'failure' : 'success' const conclusion = isFailed ? 'failure' : 'success'
@ -280,6 +283,14 @@ class TestReporter {
return results return results
} }
writeSummaryFile(summary: string): void {
const dir = process.env.RUNNER_TEMP || tmpdir()
const file = join(dir, `test-reporter-summary-${randomBytes(8).toString('hex')}.md`)
writeFileSync(file, summary)
core.info(`Summary written to ${file}`)
core.setOutput('summary_file', file)
}
getParser(reporter: string, options: ParseOptions): TestParser { getParser(reporter: string, options: ParseOptions): TestParser {
switch (reporter) { switch (reporter) {
case 'dart-json': case 'dart-json':