From 4539e352a5eb5d210835b51fd3796c317b355fa6 Mon Sep 17 00:00:00 2001 From: cute-omega <92797441+cute-omega@users.noreply.github.com> Date: Tue, 25 Nov 2025 13:58:07 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AD=BE=E5=87=BA=E7=94=A8=E5=8F=8D=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/npm-run-electron.yml | 10 +---- .../run-electron-with-timeout.ps1 | 2 +- .../run-electron-with-timeout.sh | 0 scripts/run-electron-with-timeout.js | 43 ------------------- 4 files changed, 3 insertions(+), 52 deletions(-) rename {scripts => _script}/run-electron-with-timeout.ps1 (96%) rename {scripts => _script}/run-electron-with-timeout.sh (100%) delete mode 100644 scripts/run-electron-with-timeout.js diff --git a/.github/workflows/npm-run-electron.yml b/.github/workflows/npm-run-electron.yml index 9ad70ed..d488e5f 100644 --- a/.github/workflows/npm-run-electron.yml +++ b/.github/workflows/npm-run-electron.yml @@ -102,17 +102,11 @@ jobs: - name: npm run electron (auto-exit after 30min) run: | - echo "======================================================================"; - echo "cd packages/gui"; - echo "--------------------"; - cd packages/gui; - dir || ls -lah; - echo "======================================================================"; echo "npm run electron with timeout"; echo "--------------------"; if [ "$RUNNER_OS" = "Windows" ]; then - powershell ../../scripts/run-electron-with-timeout.ps1 + powershell _script/run-electron-with-timeout.ps1 else - bash ../../scripts/run-electron-with-timeout.sh + bash _script/run-electron-with-timeout.sh fi diff --git a/scripts/run-electron-with-timeout.ps1 b/_script/run-electron-with-timeout.ps1 similarity index 96% rename from scripts/run-electron-with-timeout.ps1 rename to _script/run-electron-with-timeout.ps1 index 3a3411f..31522c3 100644 --- a/scripts/run-electron-with-timeout.ps1 +++ b/_script/run-electron-with-timeout.ps1 @@ -14,7 +14,7 @@ while ($timer.Elapsed.TotalSeconds -lt $TimeoutSeconds) { Write-Host "❌ 程序运行不正常" exit 1 } - Start-Sleep -Seconds 1 + Start-Sleep -Seconds 60 } if (!$process.HasExited) { diff --git a/scripts/run-electron-with-timeout.sh b/_script/run-electron-with-timeout.sh similarity index 100% rename from scripts/run-electron-with-timeout.sh rename to _script/run-electron-with-timeout.sh diff --git a/scripts/run-electron-with-timeout.js b/scripts/run-electron-with-timeout.js deleted file mode 100644 index 8baff3d..0000000 --- a/scripts/run-electron-with-timeout.js +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env node -import { spawn } from 'node:child_process' -import path from 'node:path' - -const timeoutMs = Number(process.env.ELECTRON_TIMEOUT_MS ?? 30 * 60 * 1000) // 30 minutes -const workdir = path.resolve(process.argv[2] ?? 'packages/gui') -const command = process.platform === 'win32' ? 'npm.cmd' : 'npm' - -console.log(`Starting npm run electron in ${workdir} with ${timeoutMs / 60000} minute timeout...`) - -const child = spawn(command, ['run', 'electron'], { - cwd: workdir, - stdio: 'inherit', -}) - -let timedOut = false - -const timer = setTimeout(() => { - timedOut = true - console.log(`\n⏱ Electron run completed ${timeoutMs / 60000} minutes without error, terminating...`) - child.kill('SIGTERM') - setTimeout(() => { - if (!child.killed) - child.kill('SIGKILL') - }, 5000) -}, timeoutMs) - -child.on('exit', (code, signal) => { - clearTimeout(timer) - if (timedOut) { - console.log('✅ 程序运行正常') - process.exit(0) - } else { - console.log('❌ 程序运行不正常') - process.exit(1) - } -}) - -child.on('error', (err) => { - clearTimeout(timer) - console.error('Failed to start electron:', err) - process.exit(1) -})