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) -})