MCPcopy Create free account
hub / github.com/coinbase/cb-mpc / buildAlertComment

Function buildAlertComment

vendors/github-action-benchmark/src/write.ts:201–237  ·  view source on GitHub ↗
(
    alerts: Alert[],
    benchName: string,
    curSuite: Benchmark,
    prevSuite: Benchmark,
    threshold: number,
    cc: string[],
)

Source from the content-addressed store, hash-verified

199}
200
201function buildAlertComment(
202 alerts: Alert[],
203 benchName: string,
204 curSuite: Benchmark,
205 prevSuite: Benchmark,
206 threshold: number,
207 cc: string[],
208): string {
209 // Do not show benchmark name if it is the default value 'Benchmark'.
210 const benchmarkText = benchName === 'Benchmark' ? '' : ` **'${benchName}'**`;
211 const title = threshold === 0 ? '# Performance Report' : '# :warning: **Performance Alert** :warning:';
212 const thresholdString = floatStr(threshold);
213 const lines = [
214 title,
215 '',
216 `Possible performance regression was detected for benchmark${benchmarkText}.`,
217 `Benchmark result of this commit is worse than the previous benchmark result exceeding threshold \`${thresholdString}\`.`,
218 '',
219 `| Benchmark suite | Current: ${curSuite.commit.id} | Previous: ${prevSuite.commit.id} | Ratio |`,
220 '|-|-|-|-|',
221 ];
222
223 for (const alert of alerts) {
224 const { current, prev, ratio } = alert;
225 const line = `| \`${current.name}\` | ${strVal(current)} | ${strVal(prev)} | \`${floatStr(ratio)}\` |`;
226 lines.push(line);
227 }
228
229 // Footer
230 lines.push('', commentFooter());
231
232 if (cc.length > 0) {
233 lines.push('', `CC: ${cc.join(' ')}`);
234 }
235
236 return lines.join('\n');
237}
238
239async function leaveComment(commitId: string, body: string, token: string) {
240 core.debug('Sending comment:\n' + body);

Callers 1

handleAlertFunction · 0.85

Calls 4

floatStrFunction · 0.85
strValFunction · 0.85
commentFooterFunction · 0.85
joinMethod · 0.80

Tested by

no test coverage detected