Treasury & Bank Transfer Management System — سامانه مدیریت خزانهداری و حوالههای بانکی
After strict NSIS command failure, probe existing Windows EXE install/clipboard safely without converting failure into pass
davoodmehraban89 committed
Oct 19, 2026 at 02:11 UTC
8dc90abe0b39132363e0a65993fbdfd974a3ac3d
1 file changed
+113
.github/workflows/private-v6-builder-ephemeral-20261018.yml
+113
@@ -139,6 +139,119 @@ jobs:
139
Write-Host ('DIAGNOSTIC_LAST_VERIFIED_PHASE='+$lastPhase)
140
$match=[regex]::Match($record,$known)
141
$code=if($match.Success){$match.Value}else{'PRIVATE_BUILD_FAILED_DETAILS_RETAINED_ONLY_ON_EPHEMERAL_WINDOWS_RUNNER'}
142
+ # Diagnostic-only probe of an EXE made before a packaging-command
143
+ # failure. The job MUST still fail, even if this EXE is usable.
144
+ try {
145
+ $probeRelease=Join-Path $env:RUNNER_TEMP 'private-stage/release'
146
+ $probeSetup=@(Get-ChildItem -LiteralPath $probeRelease -Filter 'TreasuryFlow*.exe' -File -ErrorAction SilentlyContinue |
147
+ Where-Object {$_.Length -gt 1000000})
148
+ Write-Host ('PRIVATE_QA_NSIS_PROBE_CANDIDATE_COUNT='+$probeSetup.Count)
149
+ if($probeSetup.Count -eq 1){
150
+ $probeDir=Join-Path $env:RUNNER_TEMP 'v6-packager-failure-setup-probe'
151
+ $probeData=Join-Path $env:RUNNER_TEMP 'v6-packager-failure-data'
152
+ New-Item -ItemType Directory -Path $probeData -Force | Out-Null
153
+ $p=Start-Process -FilePath $probeSetup[0].FullName -ArgumentList @('/S',('/D='+$probeDir)) -PassThru
154
+ if(!$p.WaitForExit(150000)){try{$p.Kill()}catch{};throw 'PROBE_INSTALL_TIMEOUT'}
155
+ if($p.ExitCode -ne 0){throw 'PROBE_INSTALL_EXIT'}
156
+ $app=@(Get-ChildItem -LiteralPath $probeDir -Recurse -File -Filter 'TreasuryFlow.exe' -ErrorAction SilentlyContinue)
157
+ if($app.Count -ne 1){throw 'PROBE_NOT_A_VALID_INSTALLER'}
158
+ Write-Host 'GATE_PASS_DIAGNOSTIC_EXISTING_EXE_NSIS_INSTALL'
159
+ $guiPath=Join-Path $work $paths[3]
160
+ & node $guiPath $app[0].FullName $probeData *> (Join-Path $work 'private-failed-builder-gui-probe.txt')
161
+ $guiJson=Join-Path $probeData 'private-gui-report.json'
162
+ if($LASTEXITCODE -eq 0 -and (Test-Path -LiteralPath $guiJson)){
163
+ $probeResult=Get-Content -LiteralPath $guiJson -Raw | ConvertFrom-Json
164
+ if($probeResult.status -eq 'PASS' -and $probeResult.osClipboard -and $probeResult.bankDisabled){
165
+ Write-Host 'GATE_PASS_DIAGNOSTIC_EXISTING_EXE_REAL_WINDOWS_CLIPBOARD'
166
+ }else{Write-Host 'PRIVATE_QA_DIAGNOSTIC_EXISTING_EXE_GUI_REPORT_FAIL'}
167
+ } else {Write-Host 'PRIVATE_QA_DIAGNOSTIC_EXISTING_EXE_GUI_EXECUTION_FAIL'}
168
+ $remove=@(Get-ChildItem -LiteralPath $probeDir -Recurse -File -ErrorAction SilentlyContinue |
169
+ Where-Object {$_.Name -match '^uninstall.*[.]exe
170
+ }
171
+ $deliverables=Join-Path $destination 'PRIVATE_QA_DELIVERABLES'
172
+ $proof=Get-Content (Join-Path $deliverables 'NONFINAL_QA_SHA256_MANIFEST.json') -Raw | ConvertFrom-Json
173
+ $source=Join-Path $deliverables 'TreasuryFlow_V6_1.0.1_Patched_NONFINAL_QA_Source.zip'
174
+ $exe=Join-Path $deliverables 'TreasuryFlow_V6_1.0.1_Patched_NONFINAL_QA_Setup.exe'
175
+ if(!(Test-Path $source) -or !(Test-Path $exe) -or $proof.finalRelease -ne $false -or $proof.v7FinalAccepted -ne $false -or $proof.productionNpmVulnerabilities -ne 0){throw 'NONFINAL_MANIFEST_POLICY_FAILED'}
176
+ if((Get-FileHash $source -Algorithm SHA256).Hash -ne $proof.patchedSourceSha256 -or
177
+ (Get-FileHash $exe -Algorithm SHA256).Hash -ne $proof.patchedInstallerSha256){throw 'NONFINAL_MANIFEST_DIGEST_MISMATCH'}
178
+ Write-Host 'PRIVATE_V6_PATCHED_SOURCE_AND_WINDOWS_SETUP_BUILD_PASS'
179
+ Write-Host 'PRIVATE_V6_NPM_SECURITY_TEST_TYPECHECK_LINT_BUILD_SMOKE_PASS'
180
+ Write-Host 'NO_SOURCE_OR_BINARY_UPLOADED_TO_PUBLIC_ARTIFACTS'
181
+ # Replay installed native GUI/clipboard acceptance on this exact built EXE.
182
+ & node --check (Join-Path $work $paths[3])
183
+ if($LASTEXITCODE -ne 0){throw 'INSTALLED_GUI_HARNESS_SYNTAX_FAILED'}
184
+ $env:BANK_ADAPTER_MODE='disabled'
185
+ $env:TREASURYFLOW_DESKTOP_LOCAL='1'
186
+ $env:TREASURYFLOW_ENABLE_MAYAN_EXTERNAL_READ='0'
187
+ $env:TREASURYFLOW_MAYAN_ENABLE_EXTERNAL_READ='0'
188
+ $env:TREASURYFLOW_ENABLE_SQL_LAB='0'
189
+ $isolation=Join-Path $env:RUNNER_TEMP 'v6-gui-test-data'
190
+ $installDir=Join-Path $env:RUNNER_TEMP 'TreasuryFlow-V6-Isolated-Installed'
191
+ New-Item -ItemType Directory -Path $isolation -Force | Out-Null
192
+ $install=Start-Process -FilePath $exe -ArgumentList @('/S',('/D='+$installDir)) -PassThru
193
+ if(!$install.WaitForExit(240000)){try{$install.Kill()}catch{};throw 'V6_NSIS_INSTALL_TIMEOUT'}
194
+ if($install.ExitCode -ne 0){throw 'V6_NSIS_NONZERO_EXIT'}
195
+ $installed=@(Get-ChildItem -LiteralPath $installDir -Recurse -Filter 'TreasuryFlow.exe' -File -ErrorAction SilentlyContinue)
196
+ if($installed.Count -ne 1){throw 'INSTALLED_V6_EXE_NOT_UNIQUE'}
197
+ Write-Host 'GATE_PASS_SAME_ARTIFACT_NSIS_INSTALL'
198
+ $guiLog=Join-Path $work 'private-installed-gui-log.txt'
199
+ & node (Join-Path $work $paths[3]) $installed[0].FullName $isolation *> $guiLog
200
+ if($LASTEXITCODE -ne 0){
201
+ $guiRecord=Get-Content (Join-Path $isolation 'private-gui-report.json') -Raw | ConvertFrom-Json
202
+ $safe=$guiRecord.failure -replace '[^A-Z0-9_ ]',''
203
+ if(!$safe){$safe='UNKNOWN'}
204
+ throw ('V6_SAME_ARTIFACT_INSTALLED_GUI_FAILED_'+$safe)
205
+ }
206
+ $guiRecord=Get-Content (Join-Path $isolation 'private-gui-report.json') -Raw | ConvertFrom-Json
207
+ if($guiRecord.status -ne 'PASS' -or !$guiRecord.osClipboard -or !$guiRecord.bankDisabled -or
208
+ !$guiRecord.copyButton -or !$guiRecord.writable -or !$guiRecord.select){throw 'V6_SAME_ARTIFACT_GUI_REPORT_FAIL'}
209
+ Write-Host 'GATE_PASS_SAME_ARTIFACT_INSTALLED_WINDOWS_OS_CLIPBOARD'
210
+ # Independently exercise real installed Electron 10-route navigation,
211
+ # three synthetic actions, restart persistence and audit on same EXE.
212
+ & node --check (Join-Path $work $paths[4])
213
+ if($LASTEXITCODE -ne 0){throw 'INSTALLED_10_ROUTE_HARNESS_SYNTAX_FAILED'}
214
+ $uat=Join-Path $env:RUNNER_TEMP 'v6-full-native-uat'
215
+ New-Item -ItemType Directory -Path $uat -Force | Out-Null
216
+ & node (Join-Path $work $paths[4]) $installed[0].FullName $uat *> (Join-Path $work 'private-native-10route-uat.log')
217
+ $uatReportFile=Join-Path $uat 'treasuryflow-native-gui.json'
218
+ if(!(Test-Path -LiteralPath $uatReportFile)){throw 'INSTALLED_10_ROUTE_UAT_REPORT_MISSING'}
219
+ $uatReport=Get-Content -LiteralPath $uatReportFile -Raw | ConvertFrom-Json
220
+ if($LASTEXITCODE -ne 0 -or $uatReport.outcome -ne 'REAL_INSTALLED_ELECTRON_GUI_PASS' -or
221
+ $uatReport.visitedRoutes.Count -ne 10 -or !$uatReport.syntheticAccount -or
222
+ !$uatReport.syntheticBeneficiary -or !$uatReport.syntheticDraft -or
223
+ !$uatReport.durableData -or !$uatReport.auditPersisted -or !$uatReport.appReopened){
224
+ $safeStage=[string]$uatReport.stage -replace '[^a-zA-Z0-9_-]',''
225
+ throw ('V6_SAME_ARTIFACT_NATIVE_UAT_FAILED_AT_'+$safeStage)
226
+ }
227
+ Write-Host 'GATE_PASS_SAME_ARTIFACT_INSTALLED_10_ROUTES_3_SYNTHETIC_ACTIONS_RESTART_AUDIT'
228
+
229
+ $uninstall=@(Get-ChildItem -LiteralPath $installDir -Recurse -File -ErrorAction SilentlyContinue |
230
+ Where-Object {$_.Name -match '^uninstall.*[.]exe$'})
231
+ if($uninstall.Count -ne 1){throw 'V6_NSIS_UNINSTALLER_NOT_FOUND'}
232
+ $uninstallProcess=Start-Process -FilePath $uninstall[0].FullName -ArgumentList '/S' -PassThru
233
+ if(!$uninstallProcess.WaitForExit(90000)){try{$uninstallProcess.Kill()}catch{};throw 'V6_UNINSTALL_TIMEOUT'}
234
+ if($uninstallProcess.ExitCode -ne 0){throw 'V6_UNINSTALL_NONZERO'}
235
+ for($i=0;$i -lt 90;$i++){
236
+ $remaining=@(Get-ChildItem -LiteralPath $installDir -Recurse -File -Filter 'TreasuryFlow.exe' -ErrorAction SilentlyContinue)
237
+ if($remaining.Count -eq 0){break}
238
+ Start-Sleep -Seconds 1
239
+ }
240
+ if($remaining.Count -gt 0){throw 'V6_UNINSTALL_LEFT_BINARY'}
241
+ Write-Host 'GATE_PASS_SAME_ARTIFACT_NSIS_UNINSTALL'
242
+ Write-Host 'V6_NONFINAL_PRIVATE_QA_10_PLUS_GATES_FULL_PASS'
243
+
244
+})
245
+ if($remove.Count -eq 1){
246
+ $un=Start-Process -FilePath $remove[0].FullName -ArgumentList '/S' -PassThru
247
+ if($un.WaitForExit(90000) -and $un.ExitCode -eq 0){
248
+ Write-Host 'GATE_PASS_DIAGNOSTIC_EXISTING_EXE_NSIS_UNINSTALL'
249
+ }
250
+ }
251
+ }
252
+ }catch {
253
+ Write-Host 'PRIVATE_QA_DIAGNOSTIC_EXISTING_EXE_INSTALL_OR_GUI_PROBE_FAILED'
254
+ }
255
throw $code
256
}
257
$deliverables=Join-Path $destination 'PRIVATE_QA_DELIVERABLES'