diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9fd784997c..f1482f7f4c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,8 +57,12 @@ jobs: if: github.event_name != 'pull_request' run: xvfb-run -a bun run test:desktop-perf + - name: Desktop perf trace test (fork PR) + if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository + run: xvfb-run -a bun run test:desktop-perf + - name: Desktop perf trace test and PR summary - if: github.event_name == 'pull_request' + if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository env: GH_TOKEN: ${{ github.token }} run: xvfb-run -a bun run test:desktop-perf:post diff --git a/apps/desktop/src/desktopPerfAutomation.ts b/apps/desktop/src/desktopPerfAutomation.ts index e059455c5b..09c56946be 100644 --- a/apps/desktop/src/desktopPerfAutomation.ts +++ b/apps/desktop/src/desktopPerfAutomation.ts @@ -11,6 +11,26 @@ function delay(ms: number): Promise { return new Promise((resolve) => setTimeout(resolve, ms)); } +function withTimeout(promise: Promise, timeoutMs: number, label: string): Promise { + return new Promise((resolve, reject) => { + const timeout = setTimeout(() => { + reject(new Error(`Timed out waiting for ${label} (${timeoutMs}ms).`)); + }, timeoutMs); + timeout.unref(); + + promise.then( + (value) => { + clearTimeout(timeout); + resolve(value); + }, + (error: unknown) => { + clearTimeout(timeout); + reject(error); + }, + ); + }); +} + function waitForDidFinishLoad( webContents: WebContents, options?: { timeoutMs?: number; label?: string }, @@ -348,6 +368,7 @@ export async function runDesktopPerfAutomation(window: BrowserWindow): Promise