Skip to content

Commit 99ebc4c

Browse files
committed
Update package
1 parent c3b5798 commit 99ebc4c

File tree

1 file changed

+66
-37
lines changed

1 file changed

+66
-37
lines changed

dist/index.js

+66-37
Original file line numberDiff line numberDiff line change
@@ -224478,7 +224478,7 @@ async function generatePRComment(testRunUrlsMap) {
224478224478
const checks = await (0, k6helper_1.fetchChecks)(testRunId);
224479224479
console.log(`Checks`);
224480224480
console.log(JSON.stringify(checks, null, 2));
224481-
const markdownSummary = (0, markdownRenderer_1.generateMarkdownSummary)(testRunSummary.metrics_summary, checks);
224481+
const markdownSummary = (0, markdownRenderer_1.generateMarkdownSummary)(testRunSummary.metrics_summary, testRunSummary.baseline_test_run_details?.metrics_summary, checks);
224482224482
resultSummaryStrings.push(markdownSummary);
224483224483
resultSummaryStrings.push('\n');
224484224484
}
@@ -225084,7 +225084,7 @@ function extractTestRunId(testRunUrl) {
225084225084
*/
225085225085
async function fetchTestRunSummary(testRunId) {
225086225086
const baseUrl = getK6CloudBaseUrl();
225087-
const url = `${baseUrl}/cloud/v5/test_runs(${testRunId})/result_summary?$select=metrics_summary`;
225087+
const url = `${baseUrl}/cloud/v5/test_runs(${testRunId})/result_summary?$select=metrics_summary,baseline_test_run_details`;
225088225088
return (0, apiUtils_1.apiRequest)(url);
225089225089
}
225090225090
/**
@@ -225126,6 +225126,7 @@ exports.getBrowserMetricsMarkdown = getBrowserMetricsMarkdown;
225126225126
exports.getChecksMarkdown = getChecksMarkdown;
225127225127
exports.getThresholdsMarkdown = getThresholdsMarkdown;
225128225128
exports.getTestRunStatusMarkdown = getTestRunStatusMarkdown;
225129+
exports.getPercentageChange = getPercentageChange;
225129225130
exports.generateMarkdownSummary = generateMarkdownSummary;
225130225131
const orval_core_1 = __nccwpck_require__(70009);
225131225132
/**
@@ -225158,36 +225159,37 @@ function formatFloat(value, unit = '', defaultValue = '0') {
225158225159
* Generates markdown for trend summary data
225159225160
* @param trendSummary The trend summary data
225160225161
* @param title The title for the trend summary section
225162+
* @param baselineTrendSummary The baseline trend summary data
225161225163
* @returns Markdown string for the trend summary
225162225164
*/
225163-
function getTrendSummaryMarkdown(trendSummary, title) {
225165+
function getTrendSummaryMarkdown(trendSummary, title, baselineTrendSummary) {
225164225166
if (!trendSummary)
225165225167
return '';
225166225168
const trendSummaryStrings = [];
225167225169
trendSummaryStrings.push(title);
225168-
trendSummaryStrings.push(` - ⬇️ Minimum: <b>${formatFloat(trendSummary.min, 'ms')}</b> ⬆️ Maximum: <b>${formatFloat(trendSummary.max, 'ms')}</b>`);
225169-
trendSummaryStrings.push(` - ⏺️ Average: <b>${formatFloat(trendSummary.mean, 'ms')}</b> 🔀 Standard Deviation: <b>${formatFloat(trendSummary.stdev, 'ms')}</b> `);
225170-
trendSummaryStrings.push(` - 🔝 P95: <b>${formatFloat(trendSummary.p95, 'ms')}</b> 🚀 P99: <b>${formatFloat(trendSummary.p99, 'ms')}</b> `);
225170+
trendSummaryStrings.push(` - ⬇️ Minimum: <b>${formatFloat(trendSummary.min, 'ms')}</b>${baselineTrendSummary ? getPercentageChange(trendSummary.min, baselineTrendSummary.min) : ''} ⬆️ Maximum: <b>${formatFloat(trendSummary.max, 'ms')}</b>${baselineTrendSummary ? getPercentageChange(trendSummary.max, baselineTrendSummary.max) : ''}`);
225171+
trendSummaryStrings.push(` - ⏺️ Average: <b>${formatFloat(trendSummary.mean, 'ms')}</b>${baselineTrendSummary ? getPercentageChange(trendSummary.mean, baselineTrendSummary.mean) : ''} 🔀 Standard Deviation: <b>${formatFloat(trendSummary.stdev, 'ms')}</b>${baselineTrendSummary ? getPercentageChange(trendSummary.stdev, baselineTrendSummary.stdev) : ''} `);
225172+
trendSummaryStrings.push(` - 🔝 P95: <b>${formatFloat(trendSummary.p95, 'ms')}</b>${baselineTrendSummary ? getPercentageChange(trendSummary.p95, baselineTrendSummary.p95) : ''} 🚀 P99: <b>${formatFloat(trendSummary.p99, 'ms')}</b>${baselineTrendSummary ? getPercentageChange(trendSummary.p99, baselineTrendSummary.p99) : ''} `);
225171225173
return trendSummaryStrings.join('\n');
225172225174
}
225173225175
/**
225174225176
* Generates markdown for HTTP metrics
225175225177
* @param httpMetrics HTTP metrics data
225176225178
* @returns Markdown string for HTTP metrics
225177225179
*/
225178-
function getHttpMetricsMarkdown(httpMetrics) {
225180+
function getHttpMetricsMarkdown(httpMetrics, baselineHttpMetrics) {
225179225181
if (!httpMetrics || Object.keys(httpMetrics).length === 0) {
225180225182
return [];
225181225183
}
225182225184
const markdownSections = [];
225183225185
markdownSections.push(`### 🌐 HTTP Metrics`);
225184225186
markdownSections.push('');
225185-
markdownSections.push(`- ⏳ 95th Percentile Response Time: **${formatFloat(httpMetrics.duration?.p95, 'ms')}** ⚡`);
225186-
markdownSections.push(`- 🔢 Total Requests: **${formatNumber(httpMetrics.requests_count)}**`);
225187-
markdownSections.push(`- ⚠️ Failed Requests: **${formatNumber(httpMetrics.failures_count)}**`);
225188-
markdownSections.push(`- 🚀 Average Request Rate: **${formatFloat(httpMetrics.rps_mean)}**`);
225189-
markdownSections.push(`- 🔝 Peak RPS: **${formatFloat(httpMetrics.rps_max)}**`);
225190-
markdownSections.push(`- ${getTrendSummaryMarkdown(httpMetrics.duration, '🕒 Request Duration')}`);
225187+
markdownSections.push(`- ⏳ 95th Percentile Response Time: **${formatFloat(httpMetrics.duration?.p95, 'ms')}**${baselineHttpMetrics?.duration ? getPercentageChange(httpMetrics.duration?.p95, baselineHttpMetrics.duration?.p95) : ''} ⚡`);
225188+
markdownSections.push(`- 🔢 Total Requests: **${formatNumber(httpMetrics.requests_count)}**${baselineHttpMetrics ? getPercentageChange(httpMetrics.requests_count, baselineHttpMetrics.requests_count, true) : ''}`);
225189+
markdownSections.push(`- ⚠️ Failed Requests: **${formatNumber(httpMetrics.failures_count)}**${baselineHttpMetrics ? getPercentageChange(httpMetrics.failures_count, baselineHttpMetrics.failures_count) : ''}`);
225190+
markdownSections.push(`- 🚀 Average Request Rate: **${formatFloat(httpMetrics.rps_mean)}**${baselineHttpMetrics ? getPercentageChange(httpMetrics.rps_mean, baselineHttpMetrics.rps_mean, true) : ''}`);
225191+
markdownSections.push(`- 🔝 Peak RPS: **${formatFloat(httpMetrics.rps_max)}**${baselineHttpMetrics ? getPercentageChange(httpMetrics.rps_max, baselineHttpMetrics.rps_max, true) : ''}`);
225192+
markdownSections.push(`- ${getTrendSummaryMarkdown(httpMetrics.duration, '🕒 Request Duration', baselineHttpMetrics?.duration)}`);
225191225193
markdownSections.push('');
225192225194
return markdownSections;
225193225195
}
@@ -225196,18 +225198,18 @@ function getHttpMetricsMarkdown(httpMetrics) {
225196225198
* @param wsMetrics WebSocket metrics data
225197225199
* @returns Markdown string for WebSocket metrics
225198225200
*/
225199-
function getWebSocketMetricsMarkdown(wsMetrics) {
225201+
function getWebSocketMetricsMarkdown(wsMetrics, baselineWsMetrics) {
225200225202
if (!wsMetrics || Object.keys(wsMetrics).length === 0) {
225201225203
return [];
225202225204
}
225203225205
const markdownSections = [];
225204225206
markdownSections.push(`### 🔌 WebSocket Metrics`);
225205225207
markdownSections.push('');
225206-
markdownSections.push(`- 📤 Messages Sent: **${formatNumber(wsMetrics.msgs_sent)}**`);
225207-
markdownSections.push(`- 📥 Messages Received: **${formatNumber(wsMetrics.msgs_received)}**`);
225208-
markdownSections.push(`- 👥 Total Sessions: **${formatNumber(wsMetrics.sessions)}**`);
225209-
markdownSections.push(`- ${getTrendSummaryMarkdown(wsMetrics.session_duration, '⏱️ Session Duration')}`);
225210-
markdownSections.push(`- ${getTrendSummaryMarkdown(wsMetrics.connecting, '🔌 Connection Time')}`);
225208+
markdownSections.push(`- 📤 Messages Sent: **${formatNumber(wsMetrics.msgs_sent)}**${baselineWsMetrics ? getPercentageChange(wsMetrics.msgs_sent, baselineWsMetrics.msgs_sent, true) : ''}`);
225209+
markdownSections.push(`- 📥 Messages Received: **${formatNumber(wsMetrics.msgs_received)}**${baselineWsMetrics ? getPercentageChange(wsMetrics.msgs_received, baselineWsMetrics.msgs_received, true) : ''}`);
225210+
markdownSections.push(`- 👥 Total Sessions: **${formatNumber(wsMetrics.sessions)}**${baselineWsMetrics ? getPercentageChange(wsMetrics.sessions, baselineWsMetrics.sessions, true) : ''}`);
225211+
markdownSections.push(`- ${getTrendSummaryMarkdown(wsMetrics.session_duration, '⏱️ Session Duration', baselineWsMetrics?.session_duration)}`);
225212+
markdownSections.push(`- ${getTrendSummaryMarkdown(wsMetrics.connecting, '🔌 Connection Time', baselineWsMetrics?.connecting)}`);
225211225213
markdownSections.push('');
225212225214
return markdownSections;
225213225215
}
@@ -225216,23 +225218,24 @@ function getWebSocketMetricsMarkdown(wsMetrics) {
225216225218
* @param grpcMetrics gRPC metrics data
225217225219
* @returns Markdown string for gRPC metrics
225218225220
*/
225219-
function getGrpcMetricsMarkdown(grpcMetrics) {
225221+
function getGrpcMetricsMarkdown(grpcMetrics, baselineGrpcMetrics) {
225220225222
if (!grpcMetrics || Object.keys(grpcMetrics).length === 0) {
225221225223
return [];
225222225224
}
225223225225
const markdownSections = [];
225224225226
markdownSections.push(`### 📡 gRPC Metrics`);
225225225227
markdownSections.push('');
225226-
markdownSections.push(`The 95th percentile response time of the system being tested was **${formatFloat(grpcMetrics.duration?.p95)}** and **${formatNumber(grpcMetrics.requests_count)}** requests were made at an average request rate of **${formatFloat(grpcMetrics.rps_mean)}** requests/second.`);
225228+
markdownSections.push(`The 95th percentile response time of the system being tested was **${formatFloat(grpcMetrics.duration?.p95)}**${baselineGrpcMetrics?.duration ? getPercentageChange(grpcMetrics.duration?.p95, baselineGrpcMetrics.duration?.p95) : ''} and **${formatNumber(grpcMetrics.requests_count)}**${baselineGrpcMetrics ? getPercentageChange(grpcMetrics.requests_count, baselineGrpcMetrics.requests_count, true) : ''} requests were made at an average request rate of **${formatFloat(grpcMetrics.rps_mean)}**${baselineGrpcMetrics ? getPercentageChange(grpcMetrics.rps_mean, baselineGrpcMetrics.rps_mean, true) : ''} requests/second.`);
225227225229
markdownSections.push('<details>');
225228225230
markdownSections.push('<summary><strong>gRPC Metrics</strong></summary>\n');
225229225231
markdownSections.push('| Metric | Value |');
225230225232
markdownSections.push('|--------|-------|');
225231-
markdownSections.push(`| Total Requests | ${formatNumber(grpcMetrics.requests_count)} |`);
225232-
markdownSections.push(`| Average RPS | ${formatFloat(grpcMetrics.rps_mean)} |`);
225233-
markdownSections.push(`| Peak RPS | ${formatFloat(grpcMetrics.rps_max)} |`);
225233+
markdownSections.push(`| Total Requests | ${formatNumber(grpcMetrics.requests_count)}${baselineGrpcMetrics ? getPercentageChange(grpcMetrics.requests_count, baselineGrpcMetrics.requests_count, true) : ''} |`);
225234+
markdownSections.push(`| Average RPS | ${formatFloat(grpcMetrics.rps_mean)}${baselineGrpcMetrics ? getPercentageChange(grpcMetrics.rps_mean, baselineGrpcMetrics.rps_mean, true) : ''} |`);
225235+
markdownSections.push(`| Peak RPS | ${formatFloat(grpcMetrics.rps_max)}${baselineGrpcMetrics ? getPercentageChange(grpcMetrics.rps_max, baselineGrpcMetrics.rps_max, true) : ''} |`);
225234225236
const durationMean = grpcMetrics.duration?.mean;
225235-
markdownSections.push(`| Average Duration | ${formatFloat(durationMean, 'ms')} |`);
225237+
const baselineDurationMean = baselineGrpcMetrics?.duration?.mean;
225238+
markdownSections.push(`| Average Duration | ${formatFloat(durationMean, 'ms')}${baselineDurationMean ? getPercentageChange(durationMean, baselineDurationMean) : ''} |`);
225236225239
markdownSections.push('</details>\n');
225237225240
return markdownSections;
225238225241
}
@@ -225241,7 +225244,7 @@ function getGrpcMetricsMarkdown(grpcMetrics) {
225241225244
* @param browserMetrics Browser metrics data
225242225245
* @returns Markdown string for browser metrics
225243225246
*/
225244-
function getBrowserMetricsMarkdown(browserMetrics) {
225247+
function getBrowserMetricsMarkdown(browserMetrics, baselineBrowserMetrics) {
225245225248
if (!browserMetrics || Object.keys(browserMetrics).length === 0) {
225246225249
return [];
225247225250
}
@@ -225252,15 +225255,21 @@ function getBrowserMetricsMarkdown(browserMetrics) {
225252225255
markdownSections.push('<summary><strong>Browser Metrics</strong></summary>\n');
225253225256
markdownSections.push('| Metric | Value |');
225254225257
markdownSections.push('|--------|-------|');
225255-
markdownSections.push(`| Data Received | ${formatNumber(browserMetrics.browser_data_received)} |`);
225256-
markdownSections.push(`| Data Sent | ${formatNumber(browserMetrics.browser_data_sent)} |`);
225257-
markdownSections.push(`| HTTP Requests | ${formatNumber(browserMetrics.http_request_count)} |`);
225258-
markdownSections.push(`| HTTP Failures | ${formatNumber(browserMetrics.http_failure_count)} |`);
225258+
markdownSections.push(`| Data Received | ${formatNumber(browserMetrics.browser_data_received)}${baselineBrowserMetrics ? getPercentageChange(browserMetrics.browser_data_received, baselineBrowserMetrics.browser_data_received, false) : ''} |`);
225259+
markdownSections.push(`| Data Sent | ${formatNumber(browserMetrics.browser_data_sent)}${baselineBrowserMetrics ? getPercentageChange(browserMetrics.browser_data_sent, baselineBrowserMetrics.browser_data_sent, true) : ''} |`);
225260+
markdownSections.push(`| HTTP Requests | ${formatNumber(browserMetrics.http_request_count)}${baselineBrowserMetrics ? getPercentageChange(browserMetrics.http_request_count, baselineBrowserMetrics.http_request_count, true) : ''} |`);
225261+
markdownSections.push(`| HTTP Failures | ${formatNumber(browserMetrics.http_failure_count)}${baselineBrowserMetrics ? getPercentageChange(browserMetrics.http_failure_count, baselineBrowserMetrics.http_failure_count, false) : ''} |`);
225259225262
// Web Vitals
225260225263
const vitals = ['cls', 'fcp', 'fid', 'inp', 'lcp', 'ttfb'];
225261225264
for (const vital of vitals) {
225262-
const vitalP75 = browserMetrics[`web_vital_${vital}_p75`];
225263-
markdownSections.push(`| ${vital.toUpperCase()} p75 | ${formatFloat(vitalP75, 'ms')} |`);
225265+
const vitalKey = `web_vital_${vital}_p75`;
225266+
const vitalP75 = browserMetrics[vitalKey];
225267+
const baselineVitalP75 = baselineBrowserMetrics
225268+
? baselineBrowserMetrics[vitalKey]
225269+
: undefined;
225270+
// For CLS, lower is better, for others it depends on the specific metric
225271+
const higherIsBetter = vital === 'cls' ? false : false;
225272+
markdownSections.push(`| ${vital.toUpperCase()} p75 | ${formatFloat(vitalP75, 'ms')}${baselineVitalP75 ? getPercentageChange(vitalP75, baselineVitalP75, higherIsBetter) : ''} |`);
225264225273
}
225265225274
markdownSections.push('</details>\n');
225266225275
return markdownSections;
@@ -225358,12 +225367,32 @@ function getTestRunStatusMarkdown(testRunStatus) {
225358225367
}
225359225368
return `- **Overall Status:** ${statusString}`;
225360225369
}
225370+
/**
225371+
* Calculates percentage change between current and baseline values
225372+
* @param current The current metric value
225373+
* @param baseline The baseline metric value
225374+
* @param higherIsBetter Whether a higher value is considered better (defaults to false)
225375+
* @returns Formatted string with percentage change and direction icon
225376+
*/
225377+
function getPercentageChange(current, baseline, higherIsBetter = false) {
225378+
if (current === undefined || baseline === undefined || baseline === 0) {
225379+
return '';
225380+
}
225381+
const percentChange = ((current - baseline) / baseline) * 100;
225382+
const absolutePercentChange = Math.abs(percentChange).toFixed(2);
225383+
// For metrics where lower is better (like response time), a decrease is positive
225384+
// For metrics where higher is better (like throughput), an increase is positive
225385+
const isPositive = higherIsBetter ? percentChange > 0 : percentChange < 0;
225386+
const icon = isPositive ? '✅' : '❌';
225387+
const direction = percentChange > 0 ? '↑' : '↓';
225388+
return ` (${icon} ${direction} ${absolutePercentChange}%)`;
225389+
}
225361225390
/**
225362225391
* Generates a complete markdown summary from metrics data
225363225392
* @param metricsSummary The complete metrics summary object
225364225393
* @returns Markdown string for all metrics
225365225394
*/
225366-
function generateMarkdownSummary(metricsSummary, checks) {
225395+
function generateMarkdownSummary(metricsSummary, baselineTestRunMetricsSummary, checks) {
225367225396
if (!metricsSummary)
225368225397
return 'No metrics data available.';
225369225398
const markdownSections = [];
@@ -225372,13 +225401,13 @@ function generateMarkdownSummary(metricsSummary, checks) {
225372225401
// Add thresholds summary
225373225402
markdownSections.push(...getThresholdsMarkdown(metricsSummary.thresholds_summary));
225374225403
// Add HTTP metrics
225375-
markdownSections.push(...getHttpMetricsMarkdown(metricsSummary.http_metric_summary));
225404+
markdownSections.push(...getHttpMetricsMarkdown(metricsSummary.http_metric_summary, baselineTestRunMetricsSummary?.http_metric_summary));
225376225405
// Add WebSocket metrics
225377-
markdownSections.push(...getWebSocketMetricsMarkdown(metricsSummary.ws_metric_summary));
225406+
markdownSections.push(...getWebSocketMetricsMarkdown(metricsSummary.ws_metric_summary, baselineTestRunMetricsSummary?.ws_metric_summary));
225378225407
// Add gRPC metrics
225379-
markdownSections.push(...getGrpcMetricsMarkdown(metricsSummary.grpc_metric_summary));
225408+
markdownSections.push(...getGrpcMetricsMarkdown(metricsSummary.grpc_metric_summary, baselineTestRunMetricsSummary?.grpc_metric_summary));
225380225409
// Add browser metrics
225381-
markdownSections.push(...getBrowserMetricsMarkdown(metricsSummary.browser_metric_summary));
225410+
markdownSections.push(...getBrowserMetricsMarkdown(metricsSummary.browser_metric_summary, baselineTestRunMetricsSummary?.browser_metric_summary));
225382225411
return markdownSections.length ? markdownSections.join('\n') : '';
225383225412
}
225384225413

0 commit comments

Comments
 (0)