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:
parent
49ad12d837
commit
bd45c7a559
4 changed files with 17 additions and 6 deletions
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
## 3.1.0
|
||||
* 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
|
||||
* Feature: Use NodeJS 24 LTS as default runtime https://github.com/dorny/test-reporter/pull/738
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ jobs:
|
|||
| time | Test execution time [ms] |
|
||||
| url | Check run URL |
|
||||
| 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 |
|
||||
|
||||
## Supported formats
|
||||
|
|
|
|||
|
|
@ -130,8 +130,8 @@ outputs:
|
|||
description: Check run URL
|
||||
url_html:
|
||||
description: Check run URL HTML
|
||||
summary:
|
||||
description: Generated test report summary in Markdown format
|
||||
summary_file:
|
||||
description: Path to a file containing the generated test report summary in Markdown format
|
||||
slug_prefix:
|
||||
description: Random prefix added to generated report anchor slugs for this action run
|
||||
runs:
|
||||
|
|
|
|||
15
src/main.ts
15
src/main.ts
|
|
@ -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':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue