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

Fix malformed CI YAML, accurately split logs, and investigate installed EXE while preserving strict failure

davoodmehraban89 committed Oct 19, 2026 at 02:13 UTC 711bf3db217f16e7b631eff3ba107be450b009a8
1 file changed +27 -110
.github/workflows/private-v6-builder-ephemeral-20261018.yml
+27 -110
@@ -93,7 +93,7 @@ jobs:
93 $releasePath=Join-Path $env:RUNNER_TEMP 'private-stage/release'
94 $binCount=@(Get-ChildItem -LiteralPath $releasePath -File -Filter '*.exe' -ErrorAction SilentlyContinue).Count
95 Write-Host ('PRIVATE_NSIS_RESULT_EXE_PRESENT='+[bool]($binCount -gt 0))
96 - $lastLineCount=@($nsisText -split '\\r?\\n' | Where-Object {$_ -match '(?i)error|fail|exit|throw'}).Count
96 + $lastLineCount=@($nsisText -split '\r?\n' | Where-Object {$_ -match '(?i)error|fail|exit|throw'}).Count
97 Write-Host ('PRIVATE_NSIS_ERROR_LIKE_LINE_COUNT='+[Math]::Min($lastLineCount,100))
98 $shortCodes=[regex]::Matches($nsisText,'\\b(?:ERR_[A-Z0-9_]{4,64}|E(?:ACCES|PERM|NOENT|EXIST|CONNRESET|TIMEDOUT|NOTFOUND|NOSPC|NAMETOOLONG|PROTO|AI_AGAIN))\\b')
99 $codes=@($shortCodes | ForEach-Object {$_.Value} | Select-Object -Unique | Select-Object -First 8)
@@ -127,7 +127,7 @@ jobs:
127 'exists','cannot','isnt','doesnt','trying','use','using','please',
128 'cannot','build','building','built','pack','packaging','unpack',
129 'not','proper','invalid','has','have','had','failed','called')
130 - $failureLines=@($nsisText -split '\\r?\\n' | Where-Object {$_ -match '(?i)error|failed|exception|⨯'})
130 + $failureLines=@($nsisText -split '\r?\n' | Where-Object {$_ -match '(?i)error|failed|exception|⨯'})
131 $terminalLine=if($failureLines.Count -gt 0){[string]$failureLines[$failureLines.Count-1]}else{''}
132 $words=@([regex]::Matches($terminalLine,'[A-Za-z]{2,24}') |
133 ForEach-Object {$_.Value.ToLowerInvariant()} |
@@ -139,118 +139,35 @@ 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.
142 try {
143 $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 - }
144 + $cand=@(Get-ChildItem -LiteralPath $probeRelease -Filter 'TreasuryFlow*.exe' -File -ErrorAction SilentlyContinue | Where-Object {$_.Length -gt 1000000})
145 + Write-Host ('DIAGNOSTIC_INSTALLER_COUNT='+$cand.Count)
146 + if($cand.Count -eq 1){
147 + $testHome=Join-Path $env:RUNNER_TEMP 'v6-diagnostic-installed'
148 + $testData=Join-Path $env:RUNNER_TEMP 'v6-diagnostic-data'
149 + New-Item -ItemType Directory -Path $testData -Force | Out-Null
150 + $p=Start-Process -FilePath $cand[0].FullName -ArgumentList @('/S',('/D='+$testHome)) -PassThru
151 + if(!$p.WaitForExit(120000)){try{$p.Kill()}catch{};throw 'TEST_INSTALL_TIMED_OUT'}
152 + if($p.ExitCode -ne 0){throw 'TEST_INSTALL_EXIT'}
153 + $installedExe=@(Get-ChildItem -LiteralPath $testHome -Recurse -File -Filter 'TreasuryFlow.exe' -ErrorAction SilentlyContinue)
154 + if($installedExe.Count -ne 1){throw 'TEST_EXE_NOT_INSTALLED'}
155 + Write-Host 'PROBE_PASS_NSIS_INSTALL_WHILE_PACKAGER_EXIT_NONZERO'
156 + & node (Join-Path $work $paths[3]) $installedExe[0].FullName $testData *> (Join-Path $work 'private-gui-probe.log')
157 + if($LASTEXITCODE -eq 0){
158 + $data=Get-Content (Join-Path $testData 'private-gui-report.json') -Raw | ConvertFrom-Json
159 + if($data.status -eq 'PASS' -and $data.osClipboard){
160 + Write-Host 'PROBE_PASS_REAL_WINDOWS_CLIPBOARD_WHILE_PACKAGER_EXIT_NONZERO'
161 + }else{Write-Host 'PROBE_FAIL_GUI_ASSERTION'}
162 + }else{Write-Host 'PROBE_FAIL_GUI_EXECUTION'}
163 + $un=@(Get-ChildItem -LiteralPath $testHome -Recurse -File -Filter 'Uninstall*.exe' -ErrorAction SilentlyContinue)
164 + if($un.Count -eq 1){
165 + $up=Start-Process -FilePath $un[0].FullName -ArgumentList '/S' -PassThru
166 + if($up.WaitForExit(90000) -and $up.ExitCode -eq 0){Write-Host 'PROBE_PASS_NSIS_UNINSTALL_WHILE_PACKAGER_EXIT_NONZERO'}
167 }
168 }
252 - }catch {
253 - Write-Host 'PRIVATE_QA_DIAGNOSTIC_EXISTING_EXE_INSTALL_OR_GUI_PROBE_FAILED'
169 + }catch{
170 + Write-Host 'PROBE_FAIL_DIAGNOSTIC_INSTALL_OR_GUI'
171 }
172 throw $code
173 }