Treasury & Bank Transfer Management System — سامانه مدیریت خزانهداری و حوالههای بانکی
Remove private-source one-shot Windows V6 NSIS and clipboard workflow after all GUI install/uninstall gates pass
davoodmehraban89 committed
Oct 18, 2026 at 14:05 UTC
16e4273e313bd7a9721285c917f3b502460d34fd
1 file changed
-260
.github/workflows/windows-v6-rebuilt-installed-gui-lab-once.yml
deleted
-260
@@ -1,260 +0,0 @@
1
-name: Windows V6 rebuilt installer and OS clipboard acceptance (NOT V7)
2
-on:
3
- push:
4
- branches: ['ci/public-windows-bridge-probe-20261017']
5
- paths: ['.github/workflows/windows-v6-rebuilt-installed-gui-lab-once.yml']
6
-permissions:
7
- contents: read
8
-concurrency:
9
- group: tf-v6-rebuilt-gui-one-shot
10
- cancel-in-progress: false
11
-jobs:
12
- windows-acceptance:
13
- runs-on: windows-2022
14
- timeout-minutes: 85
15
- defaults:
16
- run:
17
- shell: pwsh
18
- env:
19
- BANK_ADAPTER_MODE: disabled
20
- TREASURYFLOW_ENABLE_MAYAN_EXTERNAL_READ: '0'
21
- TREASURYFLOW_MAYAN_ENABLE_EXTERNAL_READ: '0'
22
- TREASURYFLOW_ENABLE_SQL_LAB: '0'
23
- TREASURYFLOW_DESKTOP_LOCAL: '1'
24
- NEXT_TELEMETRY_DISABLED: '1'
25
- ELECTRON_BUILDER_ALLOW_UNRESOLVED_DEPENDENCIES: 'false'
26
- steps:
27
- - name: Download exact V6 archive and private guarded repair with read-only step token
28
- env:
29
- GH_TOKEN: ${{ secrets.TF_VALIDATION_READ_TOKEN }}
30
- run: |
31
- $ErrorActionPreference='Stop'
32
- if([string]::IsNullOrWhiteSpace($env:GH_TOKEN)){throw 'PRIVATE_TOKEN_MISSING'}
33
- $input=Join-Path $env:RUNNER_TEMP 'private-input'
34
- $stage=Join-Path $env:RUNNER_TEMP 'private-stage'
35
- New-Item -ItemType Directory -Force -Path $input,$stage | Out-Null
36
- gh release download validation-inputs-20261017 --repo davoodmehraban89/TreasuryFlow-Validation-Private --pattern TreasuryFlow_Validation_Staging_20261017.zip --dir $input 1>$null 2>$null
37
- if($LASTEXITCODE -ne 0){throw 'PRIVATE_ZIP_DOWNLOAD_FAILED'}
38
- $zip=Join-Path $input 'TreasuryFlow_Validation_Staging_20261017.zip'
39
- if((Get-FileHash $zip -Algorithm SHA256).Hash -ine '9ce46ce2d2a437e08cbf28146b2cf2ac0ed078c71f1aeb537764390cdd3c552f'){throw 'STAGING_SHA256_FAILED'}
40
- Expand-Archive -LiteralPath $zip -DestinationPath $stage -Force
41
- if(!(Test-Path -LiteralPath (Join-Path $stage 'package.json'))){throw 'STAGING_ROOT_MISSING'}
42
- $raw=gh api 'repos/davoodmehraban89/TreasuryFlow-Validation-Private/contents/qa/patches/v6-sql-assertion-fix.mjs?ref=2265e7e370d254eaa09988164559b2cd0c10c0d7' 2>$null | ConvertFrom-Json
43
- if($LASTEXITCODE -ne 0 -or !$raw.content){throw 'PRIVATE_PATCH_FETCH_FAILED'}
44
- $patch=Join-Path $env:RUNNER_TEMP 'v6-private-test-assertion-fix.mjs'
45
- [IO.File]::WriteAllBytes($patch,[Convert]::FromBase64String(($raw.content -replace '\s','')))
46
- "TF_PRIVATE_STAGE=$stage" >> $env:GITHUB_ENV
47
- "TF_PRIVATE_PATCH=$patch" >> $env:GITHUB_ENV
48
- Write-Host 'GATE_PASS_STAGING_PRIVATE_PROVENANCE'
49
- - name: Setup Node 22 with private token absent
50
- uses: actions/setup-node@v4
51
- with:
52
- node-version: '22'
53
- - name: Patch exact test assertion and run all source gates without raw private logs
54
- run: |
55
- $ErrorActionPreference='Continue'
56
- $PSNativeCommandUseErrorActionPreference=$false
57
- Set-Location -LiteralPath $env:TF_PRIVATE_STAGE
58
- node $env:TF_PRIVATE_PATCH $env:TF_PRIVATE_STAGE *> (Join-Path $env:RUNNER_TEMP 'private-patch.log')
59
- if($LASTEXITCODE -ne 0){throw 'GUARDED_SQL_ASSERTION_PATCH_FAILED'}
60
- Write-Host 'GATE_PASS_GUARDED_ASSERTION_PATCH'
61
- $gates=@(
62
- @{label='NPM_CI';argv=@('ci','--no-audit','--no-fund')},
63
- @{label='UNIT_TESTS';argv=@('test','--','--reporter=dot')},
64
- @{label='TYPECHECK';argv=@('run','typecheck')},
65
- @{label='LINT';argv=@('run','lint')},
66
- @{label='NEXT_BUILD';argv=@('run','build')}
67
- )
68
- foreach($g in $gates){
69
- & npm @($g.argv) *> (Join-Path $env:RUNNER_TEMP ("private-gate-"+$g.label+".log"))
70
- if($LASTEXITCODE -ne 0){throw ("GATE_FAIL_"+$g.label+"_PRIVATE_OUTPUT_WITHHELD")}
71
- Write-Host ("GATE_PASS_"+$g.label)
72
- }
73
- node scripts/prepare-standalone.mjs *> (Join-Path $env:RUNNER_TEMP 'private-standalone.log')
74
- if($LASTEXITCODE -ne 0){throw 'GATE_FAIL_STANDALONE'}
75
- Write-Host 'GATE_PASS_STANDALONE'
76
- npm run smoke *> (Join-Path $env:RUNNER_TEMP 'private-standalone-smoke.log')
77
- if($LASTEXITCODE -ne 0){throw 'GATE_FAIL_STANDALONE_SMOKE'}
78
- Write-Host 'GATE_PASS_STANDALONE_SMOKE'
79
- - name: Build an actual ephemeral NSIS Setup from patched private V6 staging
80
- run: |
81
- $ErrorActionPreference='Continue'
82
- $PSNativeCommandUseErrorActionPreference=$false
83
- Set-Location -LiteralPath $env:TF_PRIVATE_STAGE
84
- $log=Join-Path $env:RUNNER_TEMP 'private-installer-build.log'
85
- & npx --no-install electron-builder --win nsis --x64 --publish never *> $log
86
- $builderExit=$LASTEXITCODE
87
- $txt=if(Test-Path -LiteralPath $log){Get-Content -LiteralPath $log -Raw}else{''}
88
- $classes=[ordered]@{
89
- SIGNING='code.sign|signature|signing|certificate|CSC_'
90
- NSIS_TOOL='makensis|nsis|appBuilder'
91
- DOWNLOAD='download|fetch|network|ECONNRESET|ETIMEDOUT|ENOTFOUND'
92
- FILE_MISSING='ENOENT|no.such.file|not.found|file.does.not.exist|missing'
93
- MODULE_MISSING='cannot.find.module|module.not.found|require.stack'
94
- FILE_LOCK='EPERM|EACCES|access.is.denied'
95
- CONFIG='configuration|invalid.config|schema|unsupported.target'
96
- ASAR='asar|cannot.pack|archive'
97
- PATH='path.too.long|filename.too.long'
98
- DEPENDENCIES='dependencies|node_modules|npmRebuild|rebuild'
99
- ELECTRON='electron|win-unpacked'
100
- GENERIC_ERROR='Error:|⨯|error'
101
- }
102
- foreach($k in $classes.Keys){Write-Host ("BUILDER_LOG_HAS_"+$k+"="+[bool]($txt -match $classes[$k]))}
103
- $outDir=Join-Path $env:TF_PRIVATE_STAGE 'release'
104
- $topLevelExe=@(Get-ChildItem -LiteralPath $outDir -File -Filter '*.exe' -ErrorAction SilentlyContinue)
105
- $nestedExe=@(Get-ChildItem -LiteralPath $outDir -Recurse -File -Filter '*.exe' -ErrorAction SilentlyContinue)
106
- $targetConfirmed=[bool]($txt -match 'target=nsis')
107
- Write-Host ("BUILDER_TOP_LEVEL_EXE_COUNT="+$topLevelExe.Count)
108
- Write-Host ("BUILDER_NESTED_EXE_COUNT="+$nestedExe.Count)
109
- Write-Host ("BUILDER_LOG_NSIS_TARGET_CONFIRMED="+$targetConfirmed)
110
- Write-Host ("BUILDER_PROCESS_EXIT_NONZERO="+[bool]($builderExit -ne 0))
111
- if($builderExit -ne 0){throw 'PRIVATE_V6_NSIS_BUILD_FAILED_SANITIZED_DIAGNOSTIC_ABOVE'}
112
- if(!$targetConfirmed){throw 'NSIS_TARGET_NOT_CONFIRMED_IN_BUILDER_LOG'}
113
- $setup=@($topLevelExe | Where-Object { $_.Name -match '^TreasuryFlow[-_ ].*[.]exe$' -and $_.Length -gt 1000000 })
114
- if($setup.Count -ne 1){throw 'PRIVATE_NSIS_TOP_LEVEL_INSTALLER_NOT_UNIQUE'}
115
- "TF_EPHEMERAL_NSIS_SETUP=$($setup[0].FullName)" >> $env:GITHUB_ENV
116
- Write-Host 'GATE_PASS_PRIVATE_V6_NSIS_INSTALLER_BUILD'
117
- Write-Host ('INSTALLER_SHA256='+((Get-FileHash $setup[0].FullName -Algorithm SHA256).Hash))
118
- - name: Install actual private V6 NSIS Setup into isolated Windows VM
119
- id: install
120
- run: |
121
- $ErrorActionPreference='Stop'
122
- $dest=Join-Path $env:RUNNER_TEMP 'TreasuryFlow-V6-Isolated-Installed'
123
- $process=Start-Process -FilePath $env:TF_EPHEMERAL_NSIS_SETUP -ArgumentList @('/S',('/D='+$dest)) -PassThru
124
- if(!$process.WaitForExit(240000)){try{$process.Kill()}catch{};throw 'V6_NSIS_INSTALL_TIMEOUT'}
125
- if($process.ExitCode -ne 0){throw 'V6_NSIS_NONZERO_EXIT'}
126
- $installed=@(Get-ChildItem -LiteralPath $dest -Recurse -Filter 'TreasuryFlow.exe' -File -ErrorAction SilentlyContinue)
127
- if($installed.Count -ne 1){throw 'INSTALLED_V6_EXE_NOT_UNIQUE'}
128
- "TF_INSTALLED_V6_EXE=$($installed[0].FullName)" >> $env:GITHUB_ENV
129
- "TF_V6_INSTALL_DIR=$dest" >> $env:GITHUB_ENV
130
- Write-Host 'GATE_PASS_ACTUAL_V6_NSIS_INSTALL'
131
- - name: Real Electron GUI and OS clipboard acceptance using synthetic SQL only
132
- timeout-minutes: 18
133
- run: |
134
- $ErrorActionPreference='Continue'
135
- $PSNativeCommandUseErrorActionPreference=$false
136
- $probe=Join-Path $env:RUNNER_TEMP 'tf-native-gui-os-copy.mjs'
137
- @'
138
- import assert from 'node:assert/strict';
139
- import {spawn,execFileSync} from 'node:child_process';
140
- import {writeFileSync} from 'node:fs';
141
- import {join} from 'node:path';
142
- const exe=process.argv[2];const out=process.argv[3];
143
- const report={integrations:false,writable:false,select:false,copyButton:false,osClipboard:false,bankDisabled:false,stage:'START',status:'NOT_RUN'};
144
- const sleep=ms=>new Promise(ok=>setTimeout(ok,ms));
145
- async function wait(fn,ms=75000){const end=Date.now()+ms;while(Date.now()<end){try{let v=await fn();if(v)return v}catch{}await sleep(600)}throw Error('TIMEOUT_'+report.stage)}
146
- const port=9568,base='http://127.0.0.1:3210';
147
- async function wsConnect(url){
148
- const ws=new WebSocket(url);await new Promise((ok,no)=>{const t=setTimeout(()=>no(Error('WS_TIMEOUT')),10000);ws.addEventListener('open',()=>{clearTimeout(t);ok()},{once:true});ws.addEventListener('error',()=>{clearTimeout(t);no(Error('WS_ERROR'))},{once:true})});
149
- let id=0;const pending=new Map();
150
- ws.addEventListener('message',ev=>{let msg;try{msg=JSON.parse(ev.data)}catch{return}const p=pending.get(msg.id);if(!p)return;pending.delete(msg.id);clearTimeout(p.t);msg.error?p.no(Error('CDP_ERROR')):p.ok(msg.result)});
151
- const call=(method,params={})=>new Promise((ok,no)=>{const i=++id,t=setTimeout(()=>{pending.delete(i);no(Error('CDP_TIMEOUT'))},16000);pending.set(i,{ok,no,t});ws.send(JSON.stringify({id:i,method,params}))});
152
- const evalJs=async code=>{const r=await call('Runtime.evaluate',{expression:code,returnByValue:true,awaitPromise:true});if(r.exceptionDetails)throw Error('GUI_EVALUATION_ERROR');return r.result?.value};
153
- await call('Runtime.enable');await call('Page.enable');return {ws,call,evalJs};
154
- }
155
- let electronProcess,conn;
156
- try{
157
- report.stage='LAUNCH';
158
- const prev=await fetch(base+'/api/ready',{signal:AbortSignal.timeout(1600)}).then(()=>true,()=>false);
159
- assert(!prev,'STALE_SERVER');
160
- electronProcess=spawn(exe,['--remote-debugging-port='+port,'--remote-allow-origins=*'],{stdio:'ignore',windowsHide:false,env:{...globalThis.process.env,BANK_ADAPTER_MODE:'disabled',TREASURYFLOW_DESKTOP_LOCAL:'1',TREASURYFLOW_ENABLE_MAYAN_EXTERNAL_READ:'0',TREASURYFLOW_ENABLE_SQL_LAB:'0',TREASURYFLOW_DATA_FILE:join(out,'isolated-synthetic.sqlite')}});
161
- report.stage='BACKEND';
162
- const ready=await wait(async()=>{const x=await fetch(base+'/api/ready',{signal:AbortSignal.timeout(1500)});return x.ok?x.json():null});
163
- assert(ready.status==='ready'&&ready.bankAdapter==='disabled','READINESS_CONTRACT_INVALID');
164
- report.bankDisabled=true;
165
- report.stage='CDP';
166
- const pages=async()=>{const r=await fetch('http://127.0.0.1:'+port+'/json/list',{signal:AbortSignal.timeout(1500)});return r.ok?r.json():[]};
167
- const first=await wait(async()=>{const x=await pages();return x.find(y=>y.type==='page'&&y.url?.startsWith(base)&&y.webSocketDebuggerUrl)});
168
- conn=await wsConnect(first.webSocketDebuggerUrl);
169
- report.stage='GUI_STARTUP_SETTLING';
170
- await sleep(12000);
171
- const idleReady=await fetch(base+'/api/ready',{signal:AbortSignal.timeout(1800)}).then(x=>x.json()).catch(()=>null);
172
- assert(electronProcess.exitCode===null&&idleReady?.status==='ready'&&idleReady?.bankAdapter==='disabled','ELECTRON_NOT_STABLE_AFTER_12_SECONDS');
173
- report.idleStable=true;
174
- report.stage='LOCAL_ENTRY';
175
- const initial=await conn.evalJs("({path:location.pathname,entry:[...document.querySelectorAll('a[href]')].some(a=>a.getAttribute('href')==='/dashboard')})").catch(()=>null);
176
- report.entryInitialLogin=initial?.path==='/login';
177
- report.entryLinkPresent=!!initial?.entry;
178
- if(initial?.path==='/login'&&initial.entry){
179
- await conn.evalJs("(()=>{const a=[...document.querySelectorAll('a[href]')].find(a=>a.getAttribute('href')==='/dashboard');if(a){a.click();return true}return false})()").catch(()=>null);
180
- await sleep(1500);
181
- }
182
- report.stage='SQL_PAGE';
183
- const http=await fetch(base+'/integrations',{signal:AbortSignal.timeout(10000)}).catch(()=>null);
184
- report.sqlHttpStatus=http?.status||0;
185
- const navResult=await conn.call('Page.navigate',{url:base+'/integrations'}).catch(()=>null);
186
- report.cdpNavigateAccepted=!!navResult&&!navResult.errorText;
187
- await sleep(1200);
188
- let last='';
189
- await wait(async()=>{
190
- const x=await pages();
191
- const local=x.filter(z=>z.type==='page'&&z.url?.startsWith(base));
192
- if(local.some(z=>z.url===base+'/'||z.url===base))report.rootTargetSeen=true;
193
- if(local.some(z=>z.url?.startsWith(base+'/login')))report.loginTargetSeen=true;
194
- if(local.some(z=>z.url?.startsWith(base+'/dashboard')))report.dashboardTargetSeen=true;
195
- const p=local.find(z=>z.url?.startsWith(base+'/integrations')&&z.webSocketDebuggerUrl);
196
- if(p)report.integrationsTargetSeen=true;
197
- if(!p)return false;
198
- if(p.webSocketDebuggerUrl!==last){try{conn.ws.close()}catch{}conn=await wsConnect(p.webSocketDebuggerUrl);last=p.webSocketDebuggerUrl}
199
- const state=await conn.evalJs("({path:location.pathname,hasTextarea:!!document.querySelector('textarea')})");
200
- if(state?.path==='/integrations')report.integrationsDomSeen=true;
201
- return state?.path==='/integrations'&&state?.hasTextarea;
202
- });
203
- report.integrations=true;
204
- report.stage='EDITOR';
205
- const state=await conn.evalJs("(()=>{const f=document.querySelector('textarea');f.focus();f.select();return {ro:f.readOnly,disabled:f.disabled,buttons:[...document.querySelectorAll('button')].map(b=>b.textContent?.trim())}})()");
206
- assert(!state.ro&&!state.disabled,'SQL_EDITOR_NOT_EDITABLE');
207
- assert(state.buttons.some(x=>x?.includes('انتخاب متن')),'SELECT_BUTTON_MISSING');
208
- assert(state.buttons.some(x=>x?.includes('کپی کوئری')),'COPY_BUTTON_MISSING');
209
- report.copyButton=true;
210
- const sql='SELECT TOP (7) 7 AS ClipboardAcceptanceProbe';
211
- await conn.call('Input.insertText',{text:sql});
212
- await wait(()=>conn.evalJs('document.querySelector("textarea")?.value==='+JSON.stringify(sql)),10000);
213
- report.writable=true;
214
- report.stage='SELECTION';
215
- await conn.evalJs("(()=>{[...document.querySelectorAll('button')].find(b=>b.textContent?.includes('انتخاب متن')).click();return true})()");
216
- assert(await conn.evalJs("(()=>{const f=document.querySelector('textarea');return f.selectionStart===0&&f.selectionEnd===f.value.length})()"),'REAL_SELECT_TEXT_ACTION_FAILED');
217
- report.select=true;
218
- report.stage='WINDOWS_OS_CLIPBOARD';
219
- await conn.evalJs("(()=>{[...document.querySelectorAll('button')].find(b=>b.textContent?.includes('کپی کوئری')).click();return true})()");
220
- await wait(()=>execFileSync('powershell.exe',['-NoProfile','-NonInteractive','-Command','Get-Clipboard -Raw'],{encoding:'utf8',timeout:4500}).trim()===sql,15000);
221
- report.osClipboard=true;
222
- report.status='PASS';
223
- console.log('GATE_PASS_REAL_WINDOWS_INSTALLED_ELECTRON_SQL_COPY_AND_SELECT');
224
- }catch(e){report.status='FAIL';report.failure=String(e.message||e).slice(0,90).replace(/[^A-Za-z0-9_ ]/g,'_');console.error('GUI_GATE_FAIL_'+report.failure);globalThis.process.exitCode=1}
225
- finally{try{conn?.ws.close()}catch{}if(electronProcess?.pid){try{execFileSync('taskkill.exe',['/PID',String(electronProcess.pid),'/T','/F'],{stdio:'ignore',timeout:10000})}catch{}}writeFileSync(join(out,'private-gui-report.json'),JSON.stringify(report))}
226
- '@ | Set-Content -LiteralPath $probe -Encoding utf8
227
- $reportDir=Join-Path $env:RUNNER_TEMP 'private-tf-gui'
228
- New-Item -ItemType Directory -Force -Path $reportDir | Out-Null
229
- node $probe $env:TF_INSTALLED_V6_EXE $reportDir *> (Join-Path $env:RUNNER_TEMP 'private-gui-output.log')
230
- $result=Get-Content (Join-Path $reportDir 'private-gui-report.json') -Raw | ConvertFrom-Json
231
- foreach($key in @('integrations','writable','select','copyButton','osClipboard','bankDisabled','entryInitialLogin','entryLinkPresent','rootTargetSeen','loginTargetSeen','dashboardTargetSeen','integrationsTargetSeen','integrationsDomSeen','cdpNavigateAccepted','idleStable')){
232
- Write-Host ("GUI_"+$key+"="+[bool]$result.$key)
233
- }
234
- Write-Host ("GUI_SQL_HTTP_STATUS="+[int]$result.sqlHttpStatus)
235
- if($LASTEXITCODE -ne 0 -or $result.status -ne 'PASS'){throw ('INSTALLED_GUI_'+[string]$result.stage+'_FAILED')}
236
- Write-Host 'GATE_PASS_ACTUAL_WINDOWS_OS_CLIPBOARD'
237
- - name: Silent uninstall of actual private V6 Setup
238
- if: ${{ always() && steps.install.outcome == 'success' }}
239
- run: |
240
- $ErrorActionPreference='Stop'
241
- $uninstaller=@(Get-ChildItem $env:TF_V6_INSTALL_DIR -Recurse -File -ErrorAction SilentlyContinue | Where-Object {$_.Name -match '^uninstall.*\.exe$'})
242
- if($uninstaller.Count -ne 1){throw 'V6_NSIS_UNINSTALLER_NOT_FOUND'}
243
- @(Get-Process -Name 'TreasuryFlow' -ErrorAction SilentlyContinue) | ForEach-Object { try{Stop-Process -Id $_.Id -Force -ErrorAction Stop}catch{} }
244
- $proc=Start-Process -FilePath $uninstaller[0].FullName -ArgumentList '/S' -PassThru
245
- if(!$proc.WaitForExit(90000)){try{$proc.Kill()}catch{};throw 'V6_UNINSTALL_TIMEOUT'}
246
- if($proc.ExitCode -ne 0){throw 'V6_UNINSTALL_NONZERO'}
247
- $removed=$false
248
- for($i=0;$i -lt 90;$i++){
249
- $remaining=@(Get-ChildItem $env:TF_V6_INSTALL_DIR -Recurse -File -Filter 'TreasuryFlow.exe' -ErrorAction SilentlyContinue)
250
- if($remaining.Count -eq 0){$removed=$true;break}
251
- Start-Sleep -Seconds 1
252
- }
253
- if(!$removed){throw 'V6_UNINSTALL_LEFT_EXECUTABLE_AFTER_90_SECONDS'}
254
- Write-Host 'GATE_PASS_REAL_V6_NSIS_UNINSTALL'
255
- - name: Strictly bound scope of this validation
256
- if: always()
257
- run: |
258
- Write-Host 'PRIVATE_SOURCE_BINARY_AND_RAW_TEST_LOGS=NOT_UPLOADED'
259
- Write-Host 'PRODUCTION_BANK_DISABLED=true; MAYAN_EXTERNAL_READ_DISABLED=true'
260
- Write-Host 'V7_FINAL_ACCEPTANCE=NOT_TESTED; SQL_SERVER_APP_ADAPTER=NOT_TESTED; UPGRADE_ROLLBACK=NOT_TESTED'