Skip to content

Commit 6df0698

Browse files
committed
metrics: improve comment
1 parent 354db50 commit 6df0698

File tree

2 files changed

+27
-21
lines changed

2 files changed

+27
-21
lines changed

packages/replay/metrics/configs/ci/process.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Result } from '../../src/results/result.js';
66
import { ResultsSet } from '../../src/results/results-set.js';
77
import { Git } from '../../src/util/git.js';
88
import { GitHub } from '../../src/util/github.js';
9-
import { artifactName,baselineResultsDir, latestResultFile, previousResultsDir } from './env.js';
9+
import { artifactName, baselineResultsDir, latestResultFile, previousResultsDir } from './env.js';
1010

1111
const latestResult = Result.readFromFile(latestResultFile);
1212
const branch = await Git.branch;
@@ -25,7 +25,7 @@ if (baseBranch != branch) {
2525
const baseResults = new ResultsSet(baselineResultsDir);
2626
await prComment.addCurrentResult(await ResultsAnalyzer.analyze(latestResult, baseResults), 'Baseline');
2727
await prComment.addAdditionalResultsSet(
28-
`Baseline results on branch: ${baseBranch}`,
28+
`Baseline results on branch: <code>${baseBranch}</code>`,
2929
// We skip the first one here because it's already included as `Baseline` column above in addCurrentResult().
3030
baseResults.items().slice(1, 10)
3131
);
@@ -34,7 +34,7 @@ if (baseBranch != branch) {
3434
}
3535

3636
await prComment.addAdditionalResultsSet(
37-
`Previous results on branch: ${branch}`,
37+
`Previous results on branch: <code>${branch}</code>`,
3838
previousResults.items().slice(0, 10)
3939
);
4040

packages/replay/metrics/src/results/pr-comment.ts

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,34 +47,40 @@ export class PrCommentBuilder {
4747
this._buffer += `
4848
<h2>${this.title}</h2>
4949
<table>
50-
<thead>
51-
<tr>
52-
<th rowspan="2">&nbsp;</th>
53-
<th colspan="3" align="center">This PR (${await Git.hash})</th>
54-
${maybeOther(() => `<th colspan="3" align="center">${otherName} (${analysis.otherHash})</a></th>`)}
55-
</tr>
56-
<tr>
57-
<th align="right">Plain</th>
58-
<th align="right">+Replay</th>
59-
<th align="right">Diff</th>
60-
${maybeOther(() => `
61-
<th align="right">Plain</th>
62-
<th align="right">+Replay</th>
63-
<th align="right">Diff</th>`)}
64-
</tr>
65-
</thead>`
50+
<thead>`;
51+
52+
const headerCols = '<th align="right">Plain</th><th align="right">+Replay</th><th align="right">Diff</th>';
53+
if (analysis.otherHash != undefined) {
54+
// If "other" is defined, add an aditional row of headers.
55+
this._buffer += `
56+
<tr>
57+
<th rowspan="2">&nbsp;</th>
58+
<th colspan="3" align="center">This PR (${await Git.hash})</th>
59+
<th colspan="3" align="center">${otherName} (${analysis.otherHash})</a></th>
60+
</tr>
61+
<tr>
62+
${headerCols}
63+
${headerCols}
64+
</tr>`;
65+
} else {
66+
this._buffer += `
67+
<tr>
68+
<th>&nbsp;</th>
69+
${headerCols}
70+
</tr>`;
71+
}
6672

6773
for (const item of analysis.items) {
6874
this._buffer += `
6975
<tr>
7076
<th align="right">${printableMetricName(item.metric)}</th>
7177
<td align="right">${item.value.a}</td>
7278
<td align="right">${item.value.b}</td>
73-
<td align="right">${item.value.diff}</td>
79+
<td align="right"><strong>${item.value.diff}</strong></td>
7480
${maybeOther(() => `
7581
<td align="right">${item.other!.a}</td>
7682
<td align="right">${item.other!.b}</td>
77-
<td align="right">${item.other!.diff}</td>`)}
83+
<td align="right"><strong>${item.other!.diff}</strong></td>`)}
7884
</tr>`
7985
}
8086

0 commit comments

Comments
 (0)