diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f1482f7f4c..b840be9421 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,16 +53,50 @@ jobs: test -f apps/desktop/dist-electron/preload.js grep -nE "desktopBridge|getWsUrl|PICK_FOLDER_CHANNEL|wsUrl" apps/desktop/dist-electron/preload.js + - name: Install desktop runtime deps (Linux) + if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt-get install -y \ + xvfb \ + xauth \ + libgtk-3-0 \ + libnotify4 \ + libnss3 \ + libxss1 \ + libxtst6 \ + libatspi2.0-0 \ + libdrm2 \ + libgbm1 \ + libxrandr2 \ + libxshmfence1 \ + libxi6 \ + xdg-utils + sudo apt-get install -y libasound2t64 || sudo apt-get install -y libasound2 + - name: Desktop perf trace test if: github.event_name != 'pull_request' + env: + T3CODE_PERF_TIMEOUT_MS: "420000" 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 + env: + T3CODE_PERF_TIMEOUT_MS: "420000" run: xvfb-run -a bun run test:desktop-perf - name: Desktop perf trace test and PR summary if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository env: GH_TOKEN: ${{ github.token }} + T3CODE_PERF_TIMEOUT_MS: "420000" run: xvfb-run -a bun run test:desktop-perf:post + + - name: Upload desktop perf artifacts + if: always() + uses: actions/upload-artifact@v4 + with: + name: desktop-perf-artifacts + path: /tmp/t3code-perf-artifacts + if-no-files-found: ignore diff --git a/scripts/desktop-perf-trace.mjs b/scripts/desktop-perf-trace.mjs index d83391cf56..eda1f167c6 100644 --- a/scripts/desktop-perf-trace.mjs +++ b/scripts/desktop-perf-trace.mjs @@ -339,6 +339,34 @@ async function waitForDoneFile(donePath, child, timeoutMs) { throw new Error(`Timed out waiting for done marker at ${donePath}`); } +function tailLogText(logChunks, lineCount = 120) { + const lines = logChunks.join("").split(/\r?\n/); + return lines.slice(-lineCount).join("\n").trim(); +} + +function inferDesktopPerfTimeoutHint(logChunks) { + const joined = logChunks.join(""); + const lowered = joined.toLowerCase(); + + if (lowered.includes("error while loading shared libraries")) { + return "Electron failed to start due missing Linux shared libraries."; + } + if (lowered.includes("no usable sandbox")) { + return "Electron sandbox failed to initialize in CI."; + } + if (lowered.includes("port is already in use")) { + return "Dev server port collision prevented Electron from loading the renderer."; + } + if (!joined.includes("[desktop-perf]")) { + return "Desktop perf automation never started; Electron likely did not boot successfully."; + } + if (joined.includes("[desktop-perf]") && !joined.includes("[desktop-perf] trace recorded")) { + return "Desktop perf automation started but did not complete trace recording."; + } + + return "Desktop perf automation timed out before writing the done marker."; +} + async function terminateProcessTree(child) { if (child.exitCode !== null) return; @@ -522,6 +550,19 @@ async function main() { let donePayload; try { donePayload = await waitForDoneFile(donePath, child, timeoutMs); + } catch (error) { + const baseMessage = error instanceof Error ? error.message : String(error); + const hint = inferDesktopPerfTimeoutHint(logs); + const logTail = tailLogText(logs); + throw new Error( + [ + baseMessage, + `Hint: ${hint}`, + `Artifacts dir: ${artifactsDir}`, + `Run log: ${logPath}`, + logTail.length > 0 ? `Recent log tail:\n${logTail}` : "Recent log tail: ", + ].join("\n"), + ); } finally { await terminateProcessTree(child); }