Skip to content

Commit d58623d

Browse files
authored
fix: 159 markdown rendering for summary is broken (#218)
* add additional debug lines to `handleSummary` function * create a summary without expandable details * add summary always to all CI benchmarks
1 parent 6fc0096 commit d58623d

2 files changed

Lines changed: 18 additions & 65 deletions

File tree

.github/workflows/ci.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
tool: 'cargo'
3636
output-file-path: examples/rust/output.txt
3737
fail-on-alert: true
38-
github-token: ${{ secrets.GITHUB_TOKEN }}
38+
summary-always: true
3939
- run: node ./dist/scripts/ci_validate_modification.js before_data.js 'Rust Benchmark'
4040

4141
go:
@@ -68,6 +68,7 @@ jobs:
6868
output-file-path: examples/go/output.txt
6969
skip-fetch-gh-pages: true
7070
fail-on-alert: true
71+
summary-always: true
7172
- run: node ./dist/scripts/ci_validate_modification.js before_data.js 'Go Benchmark'
7273

7374
benchmarkjs:
@@ -97,6 +98,7 @@ jobs:
9798
output-file-path: examples/benchmarkjs/output.txt
9899
skip-fetch-gh-pages: true
99100
fail-on-alert: true
101+
summary-always: true
100102
- run: node ./dist/scripts/ci_validate_modification.js before_data.js 'Benchmark.js Benchmark'
101103

102104
pytest-benchmark:
@@ -132,6 +134,7 @@ jobs:
132134
output-file-path: examples/pytest/output.json
133135
skip-fetch-gh-pages: true
134136
fail-on-alert: true
137+
summary-always: true
135138
- run: node ./dist/scripts/ci_validate_modification.js before_data.js 'Python Benchmark with pytest-benchmark'
136139

137140
google-benchmark-framework:
@@ -168,6 +171,7 @@ jobs:
168171
output-file-path: examples/cpp/benchmark_result.json
169172
skip-fetch-gh-pages: true
170173
fail-on-alert: true
174+
summary-always: true
171175
- run: node ./dist/scripts/ci_validate_modification.js before_data.js 'C++ Benchmark'
172176

173177
catch2-framework:
@@ -202,6 +206,7 @@ jobs:
202206
output-file-path: examples/catch2/benchmark_result.txt
203207
skip-fetch-gh-pages: true
204208
fail-on-alert: true
209+
summary-always: true
205210
- run: node ./dist/scripts/ci_validate_modification.js before_data.js 'Catch2 Benchmark'
206211

207212
julia-benchmark:
@@ -240,6 +245,7 @@ jobs:
240245
output-file-path: examples/julia/output.json
241246
skip-fetch-gh-pages: true
242247
fail-on-alert: true
248+
summary-always: true
243249
- run: node ./dist/scripts/ci_validate_modification.js before_data.js 'Julia benchmark'
244250

245251
benchmarkdotnet-framework:
@@ -272,6 +278,7 @@ jobs:
272278
output-file-path: examples/benchmarkdotnet/BenchmarkDotNet.Artifacts/results/Sample.Benchmarks-report-full-compressed.json
273279
skip-fetch-gh-pages: true
274280
fail-on-alert: true
281+
summary-always: true
275282
- run: node ./dist/scripts/ci_validate_modification.js before_data.js 'Benchmark.Net Benchmark'
276283

277284
jmh:
@@ -308,6 +315,7 @@ jobs:
308315
output-file-path: examples/java/jmh-result.json
309316
skip-fetch-gh-pages: true
310317
fail-on-alert: true
318+
summary-always: true
311319
- run: node ./dist/scripts/ci_validate_modification.js before_data.js 'JMH Benchmark'
312320

313321
only-alert-with-cache:

src/write.ts

Lines changed: 9 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import * as git from './git';
77
import { Benchmark, BenchmarkResult } from './extract';
88
import { Config, ToolType } from './config';
99
import { DEFAULT_INDEX_HTML } from './default_index_html';
10-
import { SummaryTableRow } from '@actions/core/lib/summary';
1110

1211
export type BenchmarkSuites = { [name: string]: Benchmark[] };
1312
export 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

Comments
 (0)