diff --git a/src/index.ts b/src/index.ts index c29d2a260..2d2215357 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ import * as core from '@actions/core'; import { configFromJobInput } from './config'; import { extractResult } from './extract'; -import { writeBenchmark, writeSummary } from './write'; +import { writeBenchmark } from './write'; async function main() { const config = await configFromJobInput(); @@ -12,10 +12,6 @@ async function main() { await writeBenchmark(bench, config); - if (config.summaryAlways) { - await writeSummary(bench, config); - } - console.log('github-action-benchmark was run successfully!', '\nData:', bench); } diff --git a/src/write.ts b/src/write.ts index 945117696..19e75d5c8 100644 --- a/src/write.ts +++ b/src/write.ts @@ -536,17 +536,15 @@ export async function writeBenchmark(bench: Benchmark, config: Config) { } else { await handleComment(name, bench, prevBench, config); await handleAlert(name, bench, prevBench, config); + await handleSummary(name, bench, prevBench, config); } } -export async function writeSummary(bench: Benchmark, config: Config): Promise { - const { name, externalDataJsonPath } = config; - const prevBench = externalDataJsonPath - ? await writeBenchmarkToExternalJson(bench, externalDataJsonPath, config) - : await writeBenchmarkToGitHubPages(bench, config); +async function handleSummary(benchName: string, currBench: Benchmark, prevBench: Benchmark, config: Config) { + const { summaryAlways } = config; - if (prevBench === null) { - core.debug('Alert check was skipped because previous benchmark result was not found'); + if (!summaryAlways) { + core.debug('Summary was skipped because summary-always is disabled'); return; } @@ -556,7 +554,7 @@ export async function writeSummary(bench: Benchmark, config: Config): Promise { + const rows: SummaryTableRow[] = currBench.benches.map((bench) => { const previousBench = prevBench.benches.find((pb) => pb.name === bench.name); if (previousBench) { @@ -609,7 +607,7 @@ export async function writeSummary(bench: Benchmark, config: Config): Promise