1
0
Fork 0
mirror of https://github.com/dorny/test-reporter.git synced 2026-05-06 10:37:36 +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,6 +2,9 @@ import * as core from '@actions/core'
import * as github from '@actions/github'
import {GitHub} from '@actions/github/lib/utils'
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 {LocalFileProvider} from './input-providers/local-file-provider.js'
@ -221,7 +224,7 @@ class TestReporter {
core.info('Summary content:')
core.info(summary)
core.setOutput('summary', summary)
this.writeSummaryFile(summary)
await core.summary.addRaw(summary).write()
} else {
core.info(`Creating check run ${name}`)
@ -253,7 +256,7 @@ class TestReporter {
core.info('Creating annotations')
const annotations = getAnnotations(results, this.maxAnnotations)
core.setOutput('summary', summary)
this.writeSummaryFile(summary)
const isFailed = this.failOnError && results.some(tr => tr.result === 'failed')
const conclusion = isFailed ? 'failure' : 'success'
@ -280,6 +283,14 @@ class TestReporter {
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 {
switch (reporter) {
case 'dart-json':