From 88c6cd1766b176821cebf996b76085840591ee12 Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Thu, 16 Jul 2026 23:19:25 +0900 Subject: [PATCH] refactor(gh): unify heap snapshot output paths --- .../frontend-browser-diagnostics.inspect.mts | 18 +++++++++++------- .../frontend-browser-diagnostics.inspect.yml | 6 +++--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.github/scripts/frontend-browser-diagnostics.inspect.mts b/.github/scripts/frontend-browser-diagnostics.inspect.mts index eb3a228840..1f0d74875f 100644 --- a/.github/scripts/frontend-browser-diagnostics.inspect.mts +++ b/.github/scripts/frontend-browser-diagnostics.inspect.mts @@ -11,7 +11,7 @@ import { HeadlessChromeController, summarizeBrowserDiagnostics, summarizeNetwork import type { BrowserMeasurement, NetworkRequest, NetworkSummary } from './chrome.mts'; import { closeUserSetupDialog, postNote, signupThroughUi, visitHome } from '../../packages/frontend/test/e2e/shared.ts'; -const [baseDirArg, headDirArg, baseOutputArg, headOutputArg, baseHeapSnapshotOutputArg, headHeapSnapshotOutputArg] = process.argv.slice(2); +const [baseDirArg, headDirArg, baseOutputArg, headOutputArg] = process.argv.slice(2); const baseUrl = process.env.FRONTEND_BROWSER_METRICS_URL ?? 'http://127.0.0.1:61812'; const sampleCount = util.readIntegerEnv('FRONTEND_BROWSER_METRICS_SAMPLE_COUNT', 5, 1); @@ -20,6 +20,10 @@ const heapSnapshotWorkDirs = { base: resolve('frontend-browser-base-heap-snapshots'), head: resolve('frontend-browser-head-heap-snapshots'), } as const; +const heapSnapshotOutputPaths = { + base: resolve('base-heap-snapshot.heapsnapshot'), + head: resolve('head-heap-snapshot.heapsnapshot'), +} as const; type BrowserMeasurementSample = BrowserMeasurement & { round: number; @@ -230,14 +234,14 @@ function heapSnapshotPath(label: 'base' | 'head', round: number) { return join(heapSnapshotWorkDirs[label], `round-${round}.heapsnapshot`); } -async function saveRepresentativeHeapSnapshot(label: 'base' | 'head', report: BrowserMetricsReport, outputPath: string) { +async function saveRepresentativeHeapSnapshot(label: 'base' | 'head', report: BrowserMetricsReport) { const representative = selectRepresentativeSample(report.samples, sample => sample.heapSnapshot.categories.total); - await copyFile(heapSnapshotPath(label, representative.round), outputPath); + await copyFile(heapSnapshotPath(label, representative.round), heapSnapshotOutputPaths[label]); process.stderr.write(`[${label}] Selected round ${representative.round} heap snapshot for artifact\n`); await rm(heapSnapshotWorkDirs[label], { recursive: true, force: true }); } -async function genReport(label: 'base' | 'head', repoDir: string, outputPath: string, heapSnapshotSavePath: string) { +async function genReport(label: 'base' | 'head', repoDir: string, outputPath: string) { let server: ReturnType | null = null; try { @@ -261,15 +265,15 @@ async function genReport(label: 'base' | 'head', repoDir: string, outputPath: st await writeFile(outputPath, JSON.stringify(report, null, '\t')); process.stderr.write(`[${label}] Wrote browser metrics report to ${outputPath}\n`); - await saveRepresentativeHeapSnapshot(label, report, heapSnapshotSavePath); + await saveRepresentativeHeapSnapshot(label, report); } finally { if (server != null) await util.stopServer(server); } } async function main() { - await genReport('base', resolve(baseDirArg), resolve(baseOutputArg), resolve(baseHeapSnapshotOutputArg)); - await genReport('head', resolve(headDirArg), resolve(headOutputArg), resolve(headHeapSnapshotOutputArg)); + await genReport('base', resolve(baseDirArg), resolve(baseOutputArg)); + await genReport('head', resolve(headDirArg), resolve(headOutputArg)); } await main(); diff --git a/.github/workflows/frontend-browser-diagnostics.inspect.yml b/.github/workflows/frontend-browser-diagnostics.inspect.yml index 4841cb3822..92f645ab26 100644 --- a/.github/workflows/frontend-browser-diagnostics.inspect.yml +++ b/.github/workflows/frontend-browser-diagnostics.inspect.yml @@ -127,13 +127,13 @@ jobs: run: | REPORT_DIR="$RUNNER_TEMP/frontend-browser-diagnostics" mkdir -p "$REPORT_DIR" - node after/.github/scripts/frontend-browser-diagnostics.inspect.mts before after "$REPORT_DIR/before-browser.json" "$REPORT_DIR/after-browser.json" "$REPORT_DIR/base-heap-snapshot.heapsnapshot" "$REPORT_DIR/head-heap-snapshot.heapsnapshot" + node after/.github/scripts/frontend-browser-diagnostics.inspect.mts before after "$REPORT_DIR/before-browser.json" "$REPORT_DIR/after-browser.json" - name: Upload browser base heap snapshot id: upload-browser-base-heap-snapshot uses: actions/upload-artifact@v7 with: - path: ${{ runner.temp }}/frontend-browser-diagnostics/base-heap-snapshot.heapsnapshot + path: base-heap-snapshot.heapsnapshot archive: false if-no-files-found: error retention-days: 7 @@ -142,7 +142,7 @@ jobs: id: upload-browser-head-heap-snapshot uses: actions/upload-artifact@v7 with: - path: ${{ runner.temp }}/frontend-browser-diagnostics/head-heap-snapshot.heapsnapshot + path: head-heap-snapshot.heapsnapshot archive: false if-no-files-found: error retention-days: 7