Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 159 markdown rendering for summary is broken #218

Merged
merged 7 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
tool: 'cargo'
output-file-path: examples/rust/output.txt
fail-on-alert: true
github-token: ${{ secrets.GITHUB_TOKEN }}
summary-always: true
- run: node ./dist/scripts/ci_validate_modification.js before_data.js 'Rust Benchmark'

go:
Expand Down Expand Up @@ -68,6 +68,7 @@ jobs:
output-file-path: examples/go/output.txt
skip-fetch-gh-pages: true
fail-on-alert: true
summary-always: true
- run: node ./dist/scripts/ci_validate_modification.js before_data.js 'Go Benchmark'

benchmarkjs:
Expand Down Expand Up @@ -97,6 +98,7 @@ jobs:
output-file-path: examples/benchmarkjs/output.txt
skip-fetch-gh-pages: true
fail-on-alert: true
summary-always: true
- run: node ./dist/scripts/ci_validate_modification.js before_data.js 'Benchmark.js Benchmark'

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

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

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

julia-benchmark:
Expand Down Expand Up @@ -240,6 +245,7 @@ jobs:
output-file-path: examples/julia/output.json
skip-fetch-gh-pages: true
fail-on-alert: true
summary-always: true
- run: node ./dist/scripts/ci_validate_modification.js before_data.js 'Julia benchmark'

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

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

only-alert-with-cache:
Expand Down
73 changes: 9 additions & 64 deletions src/write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import { Benchmark, BenchmarkResult } from './extract';
import { Config, ToolType } from './config';
import { DEFAULT_INDEX_HTML } from './default_index_html';
import { SummaryTableRow } from '@actions/core/lib/summary';

export type BenchmarkSuites = { [name: string]: Benchmark[] };
export interface DataJson {
Expand Down Expand Up @@ -161,11 +160,11 @@
return `This comment was automatically generated by [workflow](${actionUrl}) using [github-action-benchmark](https://github.com/marketplace/actions/continuous-benchmark).`;
}

function buildComment(benchName: string, curSuite: Benchmark, prevSuite: Benchmark): string {
function buildComment(benchName: string, curSuite: Benchmark, prevSuite: Benchmark, expandableDetails = true): string {
const lines = [
`# ${benchName}`,
'',
'<details>',
expandableDetails ? '<details>' : '',
'',
`| Benchmark suite | Current: ${curSuite.commit.id} | Previous: ${prevSuite.commit.id} | Ratio |`,
'|-|-|-|-|',
Expand All @@ -189,7 +188,7 @@
}

// Footer
lines.push('', '</details>', '', commentFooter());
lines.push('', expandableDetails ? '</details>' : '', '', commentFooter());

return lines.join('\n');
}
Expand Down Expand Up @@ -439,7 +438,7 @@
console.log(
`Automatically pushed the generated commit to ${ghPagesBranch} branch since 'auto-push' is set to true`,
);
} catch (err: any) {

Check warning on line 441 in src/write.ts

View workflow job for this annotation

GitHub Actions / Run linting and formatting check

Unexpected any. Specify a different type
if (!isRemoteRejectedError(err)) {
throw err;
}
Expand Down Expand Up @@ -558,66 +557,12 @@
return;
}

const headers = [
{
data: 'Benchmark Suite',
header: true,
},
{
data: `Current: "${currBench.commit.id}"`,
header: true,
},
{
data: `Previous: "${prevBench.commit.id}"`,
header: true,
},
{
data: 'Ratio',
header: true,
},
];
const rows: SummaryTableRow[] = currBench.benches.map((bench) => {
const previousBench = prevBench.benches.find((pb) => pb.name === bench.name);

if (previousBench) {
const ratio = biggerIsBetter(config.tool)
? previousBench.value / bench.value
: bench.value / previousBench.value;

return [
{
data: bench.name,
},
{
data: strVal(bench),
},
{
data: strVal(previousBench),
},
{
data: floatStr(ratio),
},
];
}
const body = buildComment(benchName, currBench, prevBench, false);

return [
{
data: bench.name,
},
{
data: strVal(bench),
},
{
data: '-',
},
{
data: '-',
},
];
});
const summary = core.summary.addRaw(body);

core.debug('Writing a summary about benchmark comparison');
core.debug(summary.stringify());

await core.summary
.addHeading(`Benchmarks: ${benchName}`)
.addTable([headers, ...rows])
.write();
await summary.write();
}
Loading