@mui/internal-benchmark 0.0.1 → 0.0.3-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.mjs +1 -1
- package/package.json +3 -2
- package/reporter.mjs +12 -0
- package/syncPrComment.d.mts +9 -0
- package/syncPrComment.mjs +27 -0
- package/upload.mjs +1 -1
package/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/internal-benchmark",
|
|
3
|
-
"version": "0.0.1",
|
|
3
|
+
"version": "0.0.3-canary.1",
|
|
4
4
|
"author": "MUI Team",
|
|
5
5
|
"description": "Benchmark utilities for MUI projects. Internal package.",
|
|
6
6
|
"repository": {
|
|
@@ -67,5 +67,6 @@
|
|
|
67
67
|
"default": "./vitest.mjs"
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
}
|
|
70
|
+
},
|
|
71
|
+
"gitSha": "a24bc8adf051b6b19ebdae8a80aaa2650d9b2ae7"
|
|
71
72
|
}
|
package/reporter.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import { getCiMetadata } from "./ciReport.mjs";
|
|
|
4
4
|
import { calculateMean, calculateStdDev, quantile, isOutlier } from "./stats.mjs";
|
|
5
5
|
import { dim, red, green, yellow, cyan, printTable, fileUrl } from "./format.mjs";
|
|
6
6
|
import { uploadCiReport } from "./upload.mjs";
|
|
7
|
+
import { syncPrComment } from "./syncPrComment.mjs";
|
|
7
8
|
// Import for TaskMeta augmentation side effect
|
|
8
9
|
import "./taskMetaAugmentation.mjs";
|
|
9
10
|
const byNumeric = (a, b) => a - b;
|
|
@@ -243,6 +244,17 @@ class BenchmarkReporter {
|
|
|
243
244
|
console.log(yellow('\nSkipping upload: some test cases failed'));
|
|
244
245
|
} else {
|
|
245
246
|
await uploadCiReport(results);
|
|
247
|
+
if (results.repo) {
|
|
248
|
+
try {
|
|
249
|
+
// eslint-disable-next-line no-console
|
|
250
|
+
console.log('Syncing PR comment via dashboard API...');
|
|
251
|
+
const commentResult = await syncPrComment(results.repo);
|
|
252
|
+
// eslint-disable-next-line no-console
|
|
253
|
+
console.log(commentResult.skipped ? 'No open PR found for this branch, skipping.' : 'PR comment synced.');
|
|
254
|
+
} catch (error) {
|
|
255
|
+
console.error('Failed to sync PR comment:', error instanceof Error ? error.message : error);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
246
258
|
}
|
|
247
259
|
}
|
|
248
260
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const DEFAULT_API_URL = 'https://frontend-public.mui.com';
|
|
2
|
+
/**
|
|
3
|
+
* Syncs a PR comment via the dashboard API.
|
|
4
|
+
*/
|
|
5
|
+
export async function syncPrComment(repo) {
|
|
6
|
+
const oidcToken = process.env.CIRCLE_OIDC_TOKEN_V2;
|
|
7
|
+
if (!oidcToken) {
|
|
8
|
+
throw new Error('CIRCLE_OIDC_TOKEN_V2 environment variable is required for PR comment sync');
|
|
9
|
+
}
|
|
10
|
+
const apiUrl = process.env.CI_REPORT_API_URL || DEFAULT_API_URL;
|
|
11
|
+
const url = new URL('/api/ci-reports/sync-pr-comment', apiUrl);
|
|
12
|
+
const response = await fetch(url, {
|
|
13
|
+
method: 'POST',
|
|
14
|
+
headers: {
|
|
15
|
+
'Content-Type': 'application/json',
|
|
16
|
+
Authorization: `Bearer ${oidcToken}`
|
|
17
|
+
},
|
|
18
|
+
body: JSON.stringify({
|
|
19
|
+
repo
|
|
20
|
+
})
|
|
21
|
+
});
|
|
22
|
+
if (!response.ok) {
|
|
23
|
+
const responseText = await response.text();
|
|
24
|
+
throw new Error(`Sync PR comment API returned ${response.status} ${response.statusText}: ${responseText}`);
|
|
25
|
+
}
|
|
26
|
+
return response.json();
|
|
27
|
+
}
|
package/upload.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { benchmarkUploadSchema } from "./ciReport.mjs";
|
|
2
2
|
async function uploadCiReport(report, options) {
|
|
3
3
|
benchmarkUploadSchema.parse(report);
|
|
4
|
-
const apiUrl = options?.apiUrl ?? process.env.CI_REPORT_API_URL ?? 'https://
|
|
4
|
+
const apiUrl = options?.apiUrl ?? process.env.CI_REPORT_API_URL ?? 'https://frontend-public.mui.com';
|
|
5
5
|
const url = new URL('/api/ci-reports/upload', apiUrl);
|
|
6
6
|
const oidcToken = process.env.CIRCLE_OIDC_TOKEN_V2;
|
|
7
7
|
if (!oidcToken) {
|