Treasury & Bank Transfer Management System — سامانه مدیریت خزانه‌داری و حواله‌های بانکی

ci: diagnose direct Electron startup without expensive Windows packaging

davoodmehraban89 committed Oct 16, 2026 at 23:46 UTC f6eb4da6bb787a8f9afd73cfe014162d8b5cc7f1
1 file changed +94
.github/workflows/windows-electron-diagnostic.yml new
+94
@@ -0,0 +1,94 @@
1 +name: TreasuryFlow Windows Direct Electron Diagnostic
2 +
3 +on:
4 + push:
5 + branches:
6 + - ci/windows-dual-app-lab-20261016
7 + paths:
8 + - .github/workflows/windows-electron-diagnostic.yml
9 + workflow_dispatch:
10 +
11 +permissions:
12 + contents: read
13 +
14 +jobs:
15 + electron-startup:
16 + runs-on: windows-latest
17 + timeout-minutes: 25
18 + env:
19 + BANK_ADAPTER_MODE: disabled
20 + TREASURYFLOW_DESKTOP_LOCAL: '1'
21 + NEXT_TELEMETRY_DISABLED: '1'
22 + steps:
23 + - uses: actions/checkout@v4
24 + with:
25 + persist-credentials: false
26 + - uses: actions/setup-node@v4
27 + with:
28 + node-version: '22'
29 + cache: npm
30 + - name: Build local-only Next application without packaging
31 + shell: pwsh
32 + run: |
33 + $ErrorActionPreference='Stop'
34 + npm ci --no-audit --no-fund
35 + if($LASTEXITCODE -ne 0){throw 'NPM_CI_FAILED'}
36 + npm run build
37 + if($LASTEXITCODE -ne 0){throw 'NEXT_BUILD_FAILED'}
38 + node scripts/prepare-standalone.mjs
39 + if($LASTEXITCODE -ne 0){throw 'STANDALONE_PREPARATION_FAILED'}
40 + - name: Start direct Electron executable and capture sanitized failure evidence
41 + shell: pwsh
42 + run: |
43 + $ErrorActionPreference='Stop'
44 + $exe=Join-Path $env:GITHUB_WORKSPACE 'node_modules/electron/dist/electron.exe'
45 + $stdout=Join-Path $env:RUNNER_TEMP 'tf-electron-direct.stdout'
46 + $stderr=Join-Path $env:RUNNER_TEMP 'tf-electron-direct.stderr'
47 + $env:TREASURYFLOW_DATA_FILE=Join-Path $env:RUNNER_TEMP 'tf-direct-test.sqlite'
48 + $report=[ordered]@{schema='treasuryflow-electron-direct-v1';os=$env:RUNNER_OS;run=$env:GITHUB_RUN_ID;head=$env:GITHUB_SHA;exeFound=$false;processLaunched=$false;exitCode=$null;readiness=$false;bankDisabled=$false;stdoutSize=0;stderrSize=0;stderrIndicators=@();outcome='NOT_RUN'}
49 + $p=$null
50 + try {
51 + if(!(Test-Path $exe)){throw 'ELECTRON_BINARY_MISSING'}
52 + $report.exeFound=$true
53 + $p=Start-Process -FilePath $exe -ArgumentList @('.') -WorkingDirectory $env:GITHUB_WORKSPACE -PassThru -RedirectStandardOutput $stdout -RedirectStandardError $stderr
54 + $report.processLaunched=$true
55 + $deadline=[DateTime]::UtcNow.AddSeconds(45)
56 + while([DateTime]::UtcNow -lt $deadline) {
57 + Start-Sleep -Milliseconds 700
58 + $p.Refresh()
59 + if($p.HasExited){$report.exitCode=$p.ExitCode;throw ('DIRECT_ELECTRON_EXIT_'+$p.ExitCode)}
60 + try {
61 + $resp=Invoke-RestMethod 'http://127.0.0.1:3210/api/ready' -TimeoutSec 2
62 + if($resp.status -eq 'ready' -and $resp.bankAdapter -eq 'disabled'){$report.readiness=$true;$report.bankDisabled=$true;break}
63 + }catch{}
64 + }
65 + if(!$report.readiness){throw 'DIRECT_ELECTRON_READINESS_TIMEOUT'}
66 + $report.outcome='DIRECT_ELECTRON_PROCESS_AND_HTTP_PASS'
67 + }catch{
68 + $report.outcome='FAILED'
69 + $report.failureCode=$_.Exception.Message
70 + }finally{
71 + if($p -and !$p.HasExited){try{& taskkill.exe /T /F /PID $p.Id | Out-Null}catch{}}
72 + if(Test-Path $stdout){$report.stdoutSize=(Get-Item $stdout).Length}
73 + if(Test-Path $stderr){
74 + $report.stderrSize=(Get-Item $stderr).Length
75 + $raw=Get-Content $stderr -Raw -ErrorAction SilentlyContinue
76 + $report.stderrIndicators=@('MODULE_NOT_FOUND','ERR_MODULE_NOT_FOUND','ENOENT','EPERM','EACCES','EADDRINUSE','cannot','failed','error') | Where-Object {$raw -match [regex]::Escape($_)}
77 + $safe=@(Get-Content $stderr -Tail 12 -ErrorAction SilentlyContinue | Where-Object {$_ -match '(?i)(error|module|failed|cannot|ENOENT|electron)'})
78 + foreach($line in $safe){
79 + $scrubbed=$line -replace '(?i)(secret|token|password)\s*[:=]\s*\S+','$1=[REDACTED]'
80 + if($scrubbed.Length -gt 250){$scrubbed=$scrubbed.Substring(0,250)}
81 + Write-Host ('Electron diagnostic: '+$scrubbed)
82 + }
83 + }
84 + $report | ConvertTo-Json -Depth 5 | Set-Content (Join-Path $env:GITHUB_WORKSPACE 'treasuryflow-electron-diagnostic.json') -Encoding UTF8
85 + }
86 + if($report.outcome -ne 'DIRECT_ELECTRON_PROCESS_AND_HTTP_PASS'){throw $report.failureCode}
87 + - name: Upload sanitized startup evidence only
88 + if: always()
89 + uses: actions/upload-artifact@v4
90 + with:
91 + name: treasuryflow-electron-direct-diagnostic
92 + path: treasuryflow-electron-diagnostic.json
93 + retention-days: 3
94 + if-no-files-found: warn