@@ -7,7 +7,6 @@ import * as git from './git';
77import { Benchmark , BenchmarkResult } from './extract' ;
88import { Config , ToolType } from './config' ;
99import { DEFAULT_INDEX_HTML } from './default_index_html' ;
10- import { SummaryTableRow } from '@actions/core/lib/summary' ;
1110
1211export type BenchmarkSuites = { [ name : string ] : Benchmark [ ] } ;
1312export interface DataJson {
@@ -161,11 +160,11 @@ function commentFooter(): string {
161160 return `This comment was automatically generated by [workflow](${ actionUrl } ) using [github-action-benchmark](https://github.com/marketplace/actions/continuous-benchmark).` ;
162161}
163162
164- function buildComment ( benchName : string , curSuite : Benchmark , prevSuite : Benchmark ) : string {
163+ function buildComment ( benchName : string , curSuite : Benchmark , prevSuite : Benchmark , expandableDetails = true ) : string {
165164 const lines = [
166165 `# ${ benchName } ` ,
167166 '' ,
168- '<details>' ,
167+ expandableDetails ? '<details>' : ' ',
169168 '' ,
170169 `| Benchmark suite | Current: ${ curSuite . commit . id } | Previous: ${ prevSuite . commit . id } | Ratio |` ,
171170 '|-|-|-|-|' ,
@@ -189,7 +188,7 @@ function buildComment(benchName: string, curSuite: Benchmark, prevSuite: Benchma
189188 }
190189
191190 // Footer
192- lines . push ( '' , '</details>' , '' , commentFooter ( ) ) ;
191+ lines . push ( '' , expandableDetails ? '</details>' : ' ', '' , commentFooter ( ) ) ;
193192
194193 return lines . join ( '\n' ) ;
195194}
@@ -558,66 +557,12 @@ async function handleSummary(benchName: string, currBench: Benchmark, prevBench:
558557 return ;
559558 }
560559
561- const headers = [
562- {
563- data : 'Benchmark Suite' ,
564- header : true ,
565- } ,
566- {
567- data : `Current: "${ currBench . commit . id } "` ,
568- header : true ,
569- } ,
570- {
571- data : `Previous: "${ prevBench . commit . id } "` ,
572- header : true ,
573- } ,
574- {
575- data : 'Ratio' ,
576- header : true ,
577- } ,
578- ] ;
579- const rows : SummaryTableRow [ ] = currBench . benches . map ( ( bench ) => {
580- const previousBench = prevBench . benches . find ( ( pb ) => pb . name === bench . name ) ;
581-
582- if ( previousBench ) {
583- const ratio = biggerIsBetter ( config . tool )
584- ? previousBench . value / bench . value
585- : bench . value / previousBench . value ;
586-
587- return [
588- {
589- data : bench . name ,
590- } ,
591- {
592- data : strVal ( bench ) ,
593- } ,
594- {
595- data : strVal ( previousBench ) ,
596- } ,
597- {
598- data : floatStr ( ratio ) ,
599- } ,
600- ] ;
601- }
560+ const body = buildComment ( benchName , currBench , prevBench , false ) ;
602561
603- return [
604- {
605- data : bench . name ,
606- } ,
607- {
608- data : strVal ( bench ) ,
609- } ,
610- {
611- data : '-' ,
612- } ,
613- {
614- data : '-' ,
615- } ,
616- ] ;
617- } ) ;
562+ const summary = core . summary . addRaw ( body ) ;
563+
564+ core . debug ( 'Writing a summary about benchmark comparison' ) ;
565+ core . debug ( summary . stringify ( ) ) ;
618566
619- await core . summary
620- . addHeading ( `Benchmarks: ${ benchName } ` )
621- . addTable ( [ headers , ...rows ] )
622- . write ( ) ;
567+ await summary . write ( ) ;
623568}
0 commit comments