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

1 name: TreasuryFlow Windows VM Build & Real Runtime Lab
2
3 on:
4 workflow_dispatch:
5 inputs:
6 v5_source_tag:
7 description: "Private GitHub release tag with TreasuryFlow-V5-CI-Source.zip"
8 type: string
9 required: false
10 v5_sha256:
11 description: "SHA-256 of TreasuryFlow-V5-CI-Source.zip"
12 type: string
13 required: false
14
15 permissions:
16 contents: read
17
18 jobs:
19 treasury-windows:
20 runs-on: windows-latest
21 timeout-minutes: 90
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: Stage optional reviewed V5 sources with SHA-256 verification
31 shell: pwsh
32 env:
33 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34 SOURCE_TAG: ${{ inputs.v5_source_tag }}
35 SOURCE_SHA: ${{ inputs.v5_sha256 }}
36 REPO_NAME: ${{ github.repository }}
37 run: |
38 $ErrorActionPreference='Stop'
39 $folder=$env:GITHUB_WORKSPACE
40 if ($env:SOURCE_TAG) {
41 if($env:SOURCE_SHA -notmatch '^[a-fA-F0-9]{64}$'){throw 'REQUIRED_V5_SHA256_MISSING'}
42 gh release download $env:SOURCE_TAG --repo $env:REPO_NAME --pattern TreasuryFlow-V5-CI-Source.zip --dir $env:RUNNER_TEMP --clobber
43 $zip=Join-Path $env:RUNNER_TEMP 'TreasuryFlow-V5-CI-Source.zip'
44 if((Get-FileHash $zip -Algorithm SHA256).Hash -ne $env:SOURCE_SHA.ToUpperInvariant()){throw 'V5_SHA256_MISMATCH'}
45 $folder=Join-Path $env:RUNNER_TEMP 'TreasuryFlow-V5'
46 Expand-Archive -LiteralPath $zip -DestinationPath $folder -Force
47 'LAB_VERSION=V5_FROM_PRIVATE_RELEASE' >> $env:GITHUB_ENV
48 } else {
49 'LAB_VERSION=REPO_BRANCH_NOT_V5' >> $env:GITHUB_ENV
50 }
51 "LAB_SOURCE=$folder" >> $env:GITHUB_ENV
52 if(!(Test-Path (Join-Path $folder 'package-lock.json'))){throw 'PACKAGE_LOCK_MISSING'}
53 $bad=@(Get-ChildItem $folder -Recurse -File -Force | Where-Object {$_.Name -match '^\.env($|\.)|^license\.key$|^connectionString\.txt$|\.pfx$|\.p12$|\.pem$|\.sqlite$|\.db$'})
54 if($bad.Count){throw 'SENSITIVE_OR_RUNTIME_FILES_PRESENT'}
55 - name: Fail closed if actual V5 native bridge source is missing
56 shell: pwsh
57 run: |
58 if ($env:LAB_VERSION -eq 'V5_FROM_PRIVATE_RELEASE') {
59 $source=Join-Path $env:LAB_SOURCE 'native/MayanInterop/Program.cs'
60 if (!(Test-Path $source)) {
61 'V5 Windows build: BLOCKED_MISSING_NATIVE_BRIDGE_SOURCE' >> $env:GITHUB_STEP_SUMMARY
62 throw 'V5_NATIVE_BRIDGE_SOURCE_MISSING'
63 }
64 }
65 - name: Run independently testable Mayan/Treasury semantic comparison regressions
66 shell: pwsh
67 run: |
68 node --test qa/mayan/compare-runtime.node.mjs
69 if($LASTEXITCODE -ne 0){throw 'PARITY_CONTRACT_TESTS_FAILED'}
70 node --test qa/windows/electron-readiness.node.mjs
71 if($LASTEXITCODE -ne 0){throw 'ELECTRON_READINESS_REGRESSION_TESTS_FAILED'}
72 node --test qa/windows/gui-readiness.node.mjs
73 if($LASTEXITCODE -ne 0){throw 'GUI_HYDRATION_REGRESSION_TESTS_FAILED'}
74 node --test qa/windows/synthetic-iban.node.mjs
75 if($LASTEXITCODE -ne 0){throw 'SYNTHETIC_IBAN_FIXTURE_INVALID'}
76 - name: Run real code quality and unit/integration tests
77 shell: pwsh
78 run: |
79 Set-Location $env:LAB_SOURCE
80 npm ci --no-audit --no-fund
81 if($LASTEXITCODE -ne 0){throw 'NPM_CI_FAILED'}
82 npm run typecheck
83 if($LASTEXITCODE -ne 0){throw 'TYPECHECK_FAILED'}
84 npm test
85 if($LASTEXITCODE -ne 0){throw 'TESTS_FAILED'}
86 npm run lint
87 if($LASTEXITCODE -ne 0){throw 'LINT_FAILED'}
88 - name: Build and run local web application (no banking network)
89 shell: pwsh
90 env:
91 BANK_ADAPTER_MODE: disabled
92 run: |
93 Set-Location $env:LAB_SOURCE
94 npm run build
95 if($LASTEXITCODE -ne 0){throw 'PRODUCTION_BUILD_FAILED'}
96 npm run smoke
97 if($LASTEXITCODE -ne 0){throw 'REAL_HTTP_SMOKE_FAILED'}
98 - name: Verify availability of real native bridge source
99 id: native
100 shell: pwsh
101 run: |
102 $file=Join-Path $env:LAB_SOURCE 'native/MayanInterop/Program.cs'
103 if(Test-Path $file){
104 Set-Location $env:LAB_SOURCE
105 & ./scripts/build-mayan-native.ps1
106 if($LASTEXITCODE -ne 0){throw 'NATIVE_BUILD_FAILED'}
107 'buildable=true' >> $env:GITHUB_OUTPUT
108 }elseif($env:LAB_VERSION -eq 'V5_FROM_PRIVATE_RELEASE'){
109 'Full V5 desktop build: BLOCKED_MISSING_NATIVE_BRIDGE_SOURCE' >> $env:GITHUB_STEP_SUMMARY
110 throw 'V5_NATIVE_BRIDGE_SOURCE_MISSING'
111 }else{
112 'buildable=true' >> $env:GITHUB_OUTPUT
113 }
114 - name: Prepare real unpacked Electron without slow portable packaging
115 if: steps.native.outputs.buildable == 'true'
116 shell: pwsh
117 run: |
118 Set-Location $env:LAB_SOURCE
119 node scripts/prepare-standalone.mjs
120 if($LASTEXITCODE -ne 0){throw 'PREPARE_STANDALONE_FAILED'}
121 npm exec -- electron-builder --dir --win --x64 --publish never
122 if($LASTEXITCODE -ne 0){throw 'UNPACKED_ELECTRON_BUILD_FAILED'}
123 $modules=Join-Path $env:LAB_SOURCE 'release/win-unpacked/resources/standalone/node_modules'
124 foreach($module in @('next','react','react-dom')){
125 if(!(Test-Path (Join-Path $modules "$module/package.json"))){throw ("PACKAGED_RUNTIME_MODULE_MISSING_"+$module)}
126 }
127 'Verified runtime Next, React, ReactDOM modules physically exist in packaged resources.' >> $env:GITHUB_STEP_SUMMARY
128 - name: Probe real unpacked Electron EXE before the portable bootstrapper
129 if: steps.native.outputs.buildable == 'true'
130 shell: pwsh
131 run: |
132 & "$env:GITHUB_WORKSPACE/scripts/windows-vm-unpacked-smoke.ps1" -SourceRoot "$env:LAB_SOURCE"
133 - name: Package real Windows x64 portable EXE
134 if: steps.native.outputs.buildable == 'true'
135 shell: pwsh
136 run: |
137 Set-Location $env:LAB_SOURCE
138 npm exec -- electron-builder --win portable --x64 --publish never
139 if($LASTEXITCODE -ne 0){throw 'DESKTOP_PORTABLE_BUILD_FAILED'}
140 - name: Launch actual packaged EXE and check local readiness/UI
141 if: steps.native.outputs.buildable == 'true'
142 shell: pwsh
143 run: |
144 & "$env:GITHUB_WORKSPACE/scripts/windows-vm-treasury-smoke.ps1" -SourceRoot "$env:LAB_SOURCE"
145 - name: Package genuine Windows NSIS Setup EXE
146 if: steps.native.outputs.buildable == 'true'
147 shell: pwsh
148 run: |
149 Set-Location $env:LAB_SOURCE
150 npm exec -- electron-builder --win nsis --x64 --publish never
151 if($LASTEXITCODE -ne 0){throw 'NSIS_BUILD_FAILED'}
152 $setups=@(Get-ChildItem "$env:LAB_SOURCE/release/TreasuryFlow-Setup-*-Windows-x64.exe" -ErrorAction SilentlyContinue)
153 if($setups.Count -ne 1 -or $setups[0].Length -lt 1000000){throw 'NSIS_SETUP_EXE_MISSING'}
154 $portables=@(Get-ChildItem "$env:LAB_SOURCE/release/TreasuryFlow-*-Windows-x64.exe" -File | Where-Object {$_.Name -notlike '*Setup*'})
155 if($portables.Count -ne 1){throw 'PORTABLE_ARTIFACT_WAS_OVERWRITTEN'}
156 if((Get-FileHash $portables[0].FullName -Algorithm SHA256).Hash -eq (Get-FileHash $setups[0].FullName -Algorithm SHA256).Hash){throw 'SETUP_PORTABLE_COLLISION'}
157 'Setup EXE built; full unattended install acceptance remains a separate test.' >> $env:GITHUB_STEP_SUMMARY
158 - name: Silent-install genuine NSIS Setup and run its installed EXE
159 if: steps.native.outputs.buildable == 'true'
160 shell: pwsh
161 run: |
162 & "$env:GITHUB_WORKSPACE/scripts/windows-vm-treasury-install-smoke.ps1" -SourceRoot "$env:LAB_SOURCE"
163 - name: Inspect real installed Electron browser window and query-copy UI through CDP
164 if: steps.native.outputs.buildable == 'true'
165 shell: pwsh
166 run: |
167 $folder=Join-Path $env:RUNNER_TEMP 'TreasuryFlow-VM-Installed'
168 $app=@(Get-ChildItem $folder -File -Recurse -Filter 'TreasuryFlow.exe' -ErrorAction SilentlyContinue)
169 if($app.Count -ne 1){throw 'REAL_INSTALLED_ELECTRON_EXE_MISSING'}
170 $output=Join-Path $env:RUNNER_TEMP 'treasuryflow-vm-evidence'
171 node "$env:GITHUB_WORKSPACE/qa/windows/electron-native-gui-smoke.mjs" $app[0].FullName $output
172 if($LASTEXITCODE -ne 0){throw 'INSTALLED_ELECTRON_GUI_CDP_FAILED'}
173 - name: Uninstall real NSIS installation after native tests
174 if: steps.native.outputs.buildable == 'true'
175 shell: pwsh
176 run: |
177 & "$env:GITHUB_WORKSPACE/scripts/windows-vm-treasury-uninstall-smoke.ps1" -InstalledFolder (Join-Path $env:RUNNER_TEMP 'TreasuryFlow-VM-Installed')
178 - name: Record run-bound VM evidence without inferring success
179 if: always()
180 shell: pwsh
181 run: |
182 $folder=Join-Path $env:RUNNER_TEMP 'treasuryflow-vm-evidence'
183 New-Item -ItemType Directory -Path $folder -Force | Out-Null
184 $checks=@(
185 @{file='unpacked-runtime.json';pass='UNPACKED_ELECTRON_HTTP_AND_PROCESS_PASS';check='unpacked_process'},
186 @{file='runtime.json';pass='PACKAGED_PROCESS_AND_HTTP_PASS';check='packaged_runtime'},
187 @{file='installed-runtime.json';pass='NSIS_INSTALL_AND_INSTALLED_RUNTIME_PASS';check='nsis_installed_runtime'},
188 @{file='treasuryflow-native-gui.json';pass='REAL_INSTALLED_ELECTRON_GUI_PASS';check='installed_gui'},
189 @{file='uninstall-runtime.json';pass='NSIS_REAL_UNINSTALL_PASS';check='real_uninstall'}
190 )
191 $results=@()
192 foreach($item in $checks){
193 $file=Join-Path $folder $item.file
194 $state='MISSING'
195 if(Test-Path $file){
196 try {
197 $record=Get-Content $file -Raw | ConvertFrom-Json
198 $state=if($record.outcome -eq $item.pass){'PASS'}else{'FAILED_OR_INCOMPLETE'}
199 if($state -eq 'PASS' -and $item.check -eq 'installed_gui'){
200 $required=@('preLaunchPortClear','localEntry','realCDP','localOrigin','integrations','queryEditor','copyQuery','copyExactlyEditedSql','syntheticAccount','syntheticBeneficiary','syntheticDraft','appReopened','durableData','auditPersisted')
201 foreach($field in $required){
202 if(-not $record.$field){$state='FINANCIAL_UI_MATRIX_INCOMPLETE';break}
203 }
204 if(@($record.visitedRoutes).Count -ne 10){$state='ROUTE_MATRIX_INCOMPLETE'}
205 if(@($record.postRestartRoutes).Count -ne 4){$state='POST_RESTART_DATA_ROUTES_NOT_VERIFIED'}
206 if($record.persistenceEvidenceMethod -ne 'INSTALLED_ELECTRON_HTTP_AFTER_CDP_REOPEN'){$state='PERSISTENCE_METHOD_UNVERIFIED'}
207 }
208 }catch{$state='UNREADABLE'}
209 }
210 $results+=@{name=$item.check;file=$item.file;result=$state}
211 }
212 $verified=(@($results | Where-Object {$_.result -ne 'PASS'}).Count -eq 0)
213 $proof=[ordered]@{
214 schema='treasuryflow-windows-vm-evidence-v1'
215 repository=$env:GITHUB_REPOSITORY
216 run_id=$env:GITHUB_RUN_ID
217 run_attempt=$env:GITHUB_RUN_ATTEMPT
218 head_sha=$env:GITHUB_SHA
219 ref=$env:GITHUB_REF
220 runner_os=$env:RUNNER_OS
221 runner_name=$env:RUNNER_NAME
222 run_url="$env:GITHUB_SERVER_URL/$env:GITHUB_REPOSITORY/actions/runs/$env:GITHUB_RUN_ID"
223 source_kind=$env:LAB_VERSION
224 windows_acceptance=if($verified){'PASS'}else{'NOT_VERIFIED'}
225 checks=$results
226 }
227 $proof | ConvertTo-Json -Depth 6 | Set-Content (Join-Path $folder 'verification.json') -Encoding UTF8
228 "Evidence run: $($proof.run_url)" >> $env:GITHUB_STEP_SUMMARY
229 "Head SHA: $env:GITHUB_SHA; runner OS: $env:RUNNER_OS; acceptance: $($proof.windows_acceptance)" >> $env:GITHUB_STEP_SUMMARY
230 - name: Upload synthetic branch-only Windows artifacts and non-sensitive evidence
231 # This repository is PUBLIC. Never upload a V5 archive-derived binary.
232 if: always() && (github.event_name == 'push' || inputs.v5_source_tag == '')
233 uses: actions/upload-artifact@v4
234 with:
235 name: treasuryflow-windows-build-and-evidence
236 path: |
237 ${{ env.LAB_SOURCE }}/release/TreasuryFlow-*-Windows-x64.exe
238 ${{ runner.temp }}/treasuryflow-vm-evidence/*.json
239 ${{ runner.temp }}/treasuryflow-vm-evidence/*.png
240 retention-days: 7
241 if-no-files-found: warn
242 - name: State safety boundary
243 if: always()
244 shell: pwsh
245 run: |
246 'Bank LIVE disabled. No production SQL connection, live payment, public release or actual customer data.' >> $env:GITHUB_STEP_SUMMARY
247 'Repository branch is NOT the user V5 unless a SHA-256-pinned private source archive was staged.' >> $env:GITHUB_STEP_SUMMARY
248 'Local entry link is NOT a credential-authenticated login; cross-version upgrade is NOT VERIFIED without a vetted baseline installer.' >> $env:GITHUB_STEP_SUMMARY