Treasury & Bank Transfer Management System — سامانه مدیریت خزانهداری و حوالههای بانکی
One-shot Windows V6 private-source NSIS build, install, GUI OS clipboard and uninstall test with no private artifact
davoodmehraban89 committed
Oct 18, 2026 at 06:10 UTC
a2faafc51c1040dcb6fa2b0fb4cd5b2ecb801086
1 file changed
+196
.github/workflows/windows-v6-rebuilt-installed-gui-lab-once.yml
new
+196
@@ -0,0 +1,196 @@
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
+ & npx --no-install electron-builder --win nsis --x64 --publish never *> (Join-Path $env:RUNNER_TEMP 'private-installer-build.log')
85
+ if($LASTEXITCODE -ne 0){throw 'PRIVATE_V6_NSIS_BUILD_FAILED'}
86
+ $setup=@(Get-ChildItem (Join-Path $env:TF_PRIVATE_STAGE 'release') -Recurse -File -Filter 'TreasuryFlow-Setup-*-Windows-x64.exe' -ErrorAction SilentlyContinue)
87
+ if($setup.Count -ne 1 -or $setup[0].Length -lt 1000000){throw 'PRIVATE_SETUP_OUTPUT_NOT_UNIQUE'}
88
+ "TF_EPHEMERAL_NSIS_SETUP=$($setup[0].FullName)" >> $env:GITHUB_ENV
89
+ Write-Host 'GATE_PASS_PRIVATE_V6_NSIS_INSTALLER_BUILD'
90
+ Write-Host ('INSTALLER_SHA256='+((Get-FileHash $setup[0].FullName -Algorithm SHA256).Hash))
91
+ - name: Install actual private V6 NSIS Setup into isolated Windows VM
92
+ id: install
93
+ run: |
94
+ $ErrorActionPreference='Stop'
95
+ $dest=Join-Path $env:RUNNER_TEMP 'TreasuryFlow-V6-Isolated-Installed'
96
+ $process=Start-Process -FilePath $env:TF_EPHEMERAL_NSIS_SETUP -ArgumentList @('/S',('/D='+$dest)) -PassThru
97
+ if(!$process.WaitForExit(240000)){try{$process.Kill()}catch{};throw 'V6_NSIS_INSTALL_TIMEOUT'}
98
+ if($process.ExitCode -ne 0){throw 'V6_NSIS_NONZERO_EXIT'}
99
+ $installed=@(Get-ChildItem -LiteralPath $dest -Recurse -Filter 'TreasuryFlow.exe' -File -ErrorAction SilentlyContinue)
100
+ if($installed.Count -ne 1){throw 'INSTALLED_V6_EXE_NOT_UNIQUE'}
101
+ "TF_INSTALLED_V6_EXE=$($installed[0].FullName)" >> $env:GITHUB_ENV
102
+ "TF_V6_INSTALL_DIR=$dest" >> $env:GITHUB_ENV
103
+ Write-Host 'GATE_PASS_ACTUAL_V6_NSIS_INSTALL'
104
+ - name: Real Electron GUI and OS clipboard acceptance using synthetic SQL only
105
+ timeout-minutes: 18
106
+ run: |
107
+ $ErrorActionPreference='Continue'
108
+ $PSNativeCommandUseErrorActionPreference=$false
109
+ $probe=Join-Path $env:RUNNER_TEMP 'tf-native-gui-os-copy.mjs'
110
+ @'
111
+ import assert from 'node:assert/strict';
112
+ import {spawn,execFileSync} from 'node:child_process';
113
+ import {writeFileSync} from 'node:fs';
114
+ import {join} from 'node:path';
115
+ const exe=process.argv[2];const out=process.argv[3];
116
+ const report={integrations:false,writable:false,select:false,copyButton:false,osClipboard:false,bankDisabled:false,stage:'START',status:'NOT_RUN'};
117
+ const sleep=ms=>new Promise(ok=>setTimeout(ok,ms));
118
+ 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)}
119
+ const port=9568,base='http://127.0.0.1:3210';
120
+ async function wsConnect(url){
121
+ 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})});
122
+ let id=0;const pending=new Map();
123
+ 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)});
124
+ 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}))});
125
+ 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};
126
+ await call('Runtime.enable');await call('Page.enable');return {ws,call,evalJs};
127
+ }
128
+ let process,conn;
129
+ try{
130
+ report.stage='LAUNCH';
131
+ const prev=await fetch(base+'/api/ready',{signal:AbortSignal.timeout(1600)}).then(()=>true,()=>false);
132
+ assert(!prev,'STALE_SERVER');
133
+ process=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')}});
134
+ report.stage='BACKEND';
135
+ const ready=await wait(async()=>{const x=await fetch(base+'/api/ready',{signal:AbortSignal.timeout(1500)});return x.ok?x.json():null});
136
+ assert(ready.status==='ready'&&ready.bankAdapter==='disabled','READINESS_CONTRACT_INVALID');
137
+ report.bankDisabled=true;
138
+ report.stage='CDP';
139
+ const pages=async()=>{const r=await fetch('http://127.0.0.1:'+port+'/json/list',{signal:AbortSignal.timeout(1500)});return r.ok?r.json():[]};
140
+ const first=await wait(async()=>{const x=await pages();return x.find(y=>y.type==='page'&&y.url?.startsWith(base)&&y.webSocketDebuggerUrl)});
141
+ conn=await wsConnect(first.webSocketDebuggerUrl);
142
+ report.stage='SQL_PAGE';
143
+ await conn.call('Page.navigate',{url:base+'/integrations'}).catch(()=>null);
144
+ let last='';
145
+ await wait(async()=>{const x=await pages();const p=x.find(z=>z.type==='page'&&z.url?.startsWith(base+'/integrations')&&z.webSocketDebuggerUrl);if(!p)return false;if(p.webSocketDebuggerUrl!==last){try{conn.ws.close()}catch{}conn=await wsConnect(p.webSocketDebuggerUrl);last=p.webSocketDebuggerUrl}return conn.evalJs("location.pathname==='/integrations'&&!!document.querySelector('textarea')&&document.body?.innerText.includes('اتصال به دیتابیس')")});
146
+ report.integrations=true;
147
+ report.stage='EDITOR';
148
+ 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())}})()");
149
+ assert(!state.ro&&!state.disabled,'SQL_EDITOR_NOT_EDITABLE');
150
+ assert(state.buttons.some(x=>x?.includes('انتخاب متن')),'SELECT_BUTTON_MISSING');
151
+ assert(state.buttons.some(x=>x?.includes('کپی کوئری')),'COPY_BUTTON_MISSING');
152
+ report.copyButton=true;
153
+ const sql='SELECT TOP (7) 7 AS ClipboardAcceptanceProbe';
154
+ await conn.call('Input.insertText',{text:sql});
155
+ await wait(()=>conn.evalJs('document.querySelector("textarea")?.value==='+JSON.stringify(sql)),10000);
156
+ report.writable=true;
157
+ report.stage='SELECTION';
158
+ await conn.evalJs("(()=>{[...document.querySelectorAll('button')].find(b=>b.textContent?.includes('انتخاب متن')).click();return true})()");
159
+ assert(await conn.evalJs("(()=>{const f=document.querySelector('textarea');return f.selectionStart===0&&f.selectionEnd===f.value.length})()"),'REAL_SELECT_TEXT_ACTION_FAILED');
160
+ report.select=true;
161
+ report.stage='WINDOWS_OS_CLIPBOARD';
162
+ await conn.evalJs("(()=>{[...document.querySelectorAll('button')].find(b=>b.textContent?.includes('کپی کوئری')).click();return true})()");
163
+ await wait(()=>execFileSync('powershell.exe',['-NoProfile','-NonInteractive','-Command','Get-Clipboard -Raw'],{encoding:'utf8',timeout:4500}).trim()===sql,15000);
164
+ report.osClipboard=true;
165
+ report.status='PASS';
166
+ console.log('GATE_PASS_REAL_WINDOWS_INSTALLED_ELECTRON_SQL_COPY_AND_SELECT');
167
+ }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}
168
+ finally{try{conn?.ws.close()}catch{}if(process?.pid){try{execFileSync('taskkill.exe',['/PID',String(process.pid),'/T','/F'],{stdio:'ignore',timeout:10000})}catch{}}writeFileSync(join(out,'private-gui-report.json'),JSON.stringify(report))}
169
+ '@ | Set-Content -LiteralPath $probe -Encoding utf8
170
+ $reportDir=Join-Path $env:RUNNER_TEMP 'private-tf-gui'
171
+ New-Item -ItemType Directory -Force -Path $reportDir | Out-Null
172
+ node $probe $env:TF_INSTALLED_V6_EXE $reportDir *> (Join-Path $env:RUNNER_TEMP 'private-gui-output.log')
173
+ $result=Get-Content (Join-Path $reportDir 'private-gui-report.json') -Raw | ConvertFrom-Json
174
+ foreach($key in @('integrations','writable','select','copyButton','osClipboard','bankDisabled')){
175
+ Write-Host ("GUI_"+$key+"="+[bool]$result.$key)
176
+ }
177
+ if($LASTEXITCODE -ne 0 -or $result.status -ne 'PASS'){throw ('INSTALLED_GUI_'+[string]$result.stage+'_FAILED')}
178
+ Write-Host 'GATE_PASS_ACTUAL_WINDOWS_OS_CLIPBOARD'
179
+ - name: Silent uninstall of actual private V6 Setup
180
+ if: ${{ always() && steps.install.outcome == 'success' }}
181
+ run: |
182
+ $ErrorActionPreference='Stop'
183
+ $uninstaller=@(Get-ChildItem $env:TF_V6_INSTALL_DIR -Recurse -File -ErrorAction SilentlyContinue | Where-Object {$_.Name -match '^uninstall.*\.exe$'})
184
+ if($uninstaller.Count -ne 1){throw 'V6_NSIS_UNINSTALLER_NOT_FOUND'}
185
+ $proc=Start-Process -FilePath $uninstaller[0].FullName -ArgumentList '/S' -PassThru
186
+ if(!$proc.WaitForExit(90000)){try{$proc.Kill()}catch{};throw 'V6_UNINSTALL_TIMEOUT'}
187
+ if($proc.ExitCode -ne 0){throw 'V6_UNINSTALL_NONZERO'}
188
+ $remaining=@(Get-ChildItem $env:TF_V6_INSTALL_DIR -Recurse -File -Filter 'TreasuryFlow.exe' -ErrorAction SilentlyContinue)
189
+ if($remaining.Count -ne 0){throw 'V6_UNINSTALL_LEFT_EXECUTABLE'}
190
+ Write-Host 'GATE_PASS_REAL_V6_NSIS_UNINSTALL'
191
+ - name: Strictly bound scope of this validation
192
+ if: always()
193
+ run: |
194
+ Write-Host 'PRIVATE_SOURCE_BINARY_AND_RAW_TEST_LOGS=NOT_UPLOADED'
195
+ Write-Host 'PRODUCTION_BANK_DISABLED=true; MAYAN_EXTERNAL_READ_DISABLED=true'
196
+ Write-Host 'V7_FINAL_ACCEPTANCE=NOT_TESTED; SQL_SERVER_APP_ADAPTER=NOT_TESTED; UPGRADE_ROLLBACK=NOT_TESTED'