diff --git a/CHANGELOG.md b/CHANGELOG.md index 815a17f..7835fed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index a7e4674..f6624d8 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/action.yml b/action.yml index ef1aeff..fb11227 100644 --- a/action.yml +++ b/action.yml @@ -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: diff --git a/src/main.ts b/src/main.ts index f6cfcc0..62da4bc 100644 --- a/src/main.ts +++ b/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':