Skip to content

Commit 798b11e

Browse files
authored
fix: enable persist-credentials in benchmark PR check workflow (#7806)
2 parents 881d5b2 + 25eab79 commit 798b11e

File tree

2 files changed

+43
-10
lines changed

2 files changed

+43
-10
lines changed

.github/workflows/benchmark.pr-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
uses: actions/checkout@v4
1616
with:
1717
fetch-depth: 0
18-
persist-credentials: false
18+
persist-credentials: true
1919

2020
- name: Install and execute benchmark
2121
uses: ./.github/actions/benchmark

packages/tools/benchmark-tests/scripts/compare-benchmark.mjs

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
1-
import { existsSync, readFileSync, writeFileSync } from 'fs';
1+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
22

3-
const current = JSON.parse(readFileSync('benchmark-result.json', 'utf-8'));
4-
const baseline = existsSync('benchmark-baseline.json') ? JSON.parse(readFileSync('benchmark-baseline.json', 'utf-8')) : [];
3+
const loadJson = (path) => {
4+
return existsSync(path) ? JSON.parse(readFileSync(path, 'utf-8')) : [];
5+
};
56

6-
let hasRegression = false;
7+
const current = loadJson('benchmark-result.json');
8+
const baseline = loadJson('benchmark-baseline.json');
79

8-
let markdown = `## Hydration Benchmark Report (vs Baseline)\n\n`;
9-
markdown += `| Component | Current | Baseline | Δ% | Result |\n`;
10-
markdown += `|-----------|---------|----------|-----|--------|\n`;
10+
const rows = [];
11+
let hasRegression = false;
1112

1213
for (const entry of current) {
1314
const prev = baseline.find((b) => b.name === entry.name);
1415
const now = entry.value;
1516

1617
if (!prev) {
17-
markdown += `| \`${entry.name}\` | ${now}ms | – | – | 🆕 |\n`;
18+
rows.push({
19+
name: entry.name,
20+
current: now,
21+
baseline: null,
22+
percent: null,
23+
markdown: `| \`${entry.name}\` | ${now}ms | – | – | 🆕 |`,
24+
});
1825
continue;
1926
}
2027

@@ -25,9 +32,35 @@ for (const entry of current) {
2532

2633
if (percent > 5) hasRegression = true;
2734

28-
markdown += `| \`${entry.name}\` | ${now}ms | ${old}ms | ${diffStr} | ${emoji} |\n`;
35+
rows.push({
36+
name: entry.name,
37+
current: now,
38+
baseline: old,
39+
percent,
40+
markdown: `| \`${entry.name}\` | ${now}ms | ${old}ms | ${diffStr} | ${emoji} |`,
41+
});
2942
}
3043

44+
const top5 = rows
45+
.filter((r) => r.percent !== null)
46+
.sort((a, b) => Math.abs(b.percent) - Math.abs(a.percent))
47+
.slice(0, 5);
48+
49+
const rest = rows.filter((r) => !top5.includes(r)).sort((a, b) => a.name.localeCompare(b.name));
50+
51+
let markdown = `## Hydration Benchmark Report (vs Baseline)\n\n`;
52+
53+
markdown += `### 📊 Top 5 Änderungen\n\n`;
54+
markdown += `| Component | Current | Baseline | Δ% | Result |\n`;
55+
markdown += `|-----------|---------|----------|-----|--------|\n`;
56+
markdown += top5.map((r) => r.markdown).join('\n') + '\n\n';
57+
58+
markdown += `<details>\n<summary>📋 Alle Ergebnisse anzeigen</summary>\n\n`;
59+
markdown += `| Component | Current | Baseline | Δ% | Result |\n`;
60+
markdown += `|-----------|---------|----------|-----|--------|\n`;
61+
markdown += rest.map((r) => r.markdown).join('\n') + '\n';
62+
markdown += `</details>\n`;
63+
3164
writeFileSync('benchmark-report.md', markdown);
3265

3366
if (hasRegression) {

0 commit comments

Comments
 (0)