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

ci: run TreasuryFlow build and packaged desktop smoke in isolated Windows GitHub Actions

davoodmehraban89 committed Oct 16, 2026 at 21:26 UTC d780edbac4a1da5e6e12197fb1153eeed2eb4ce6
1 file changed +135
.github/workflows/windows-vm-treasury-lab.yml new
+135
@@ -0,0 +1,135 @@
1 +name: TreasuryFlow Windows VM Build & Real Runtime Lab
2 +
3 +on:
4 + push:
5 + branches: [ci/windows-dual-app-lab-20261016]
6 + workflow_dispatch:
7 + inputs:
8 + v5_source_tag:
9 + description: "Private GitHub release tag with TreasuryFlow-V5-CI-Source.zip"
10 + type: string
11 + required: false
12 + v5_sha256:
13 + description: "SHA-256 of TreasuryFlow-V5-CI-Source.zip"
14 + type: string
15 + required: false
16 +
17 +permissions:
18 + contents: read
19 +
20 +jobs:
21 + treasury-windows:
22 + runs-on: windows-latest
23 + timeout-minutes: 90
24 + steps:
25 + - uses: actions/checkout@v4
26 + with:
27 + persist-credentials: false
28 + - uses: actions/setup-node@v4
29 + with:
30 + node-version: '22'
31 + cache: npm
32 + - name: Stage optional reviewed V5 sources with SHA-256 verification
33 + shell: pwsh
34 + env:
35 + GH_TOKEN: ${ secrets.GITHUB_TOKEN }
36 + SOURCE_TAG: ${ inputs.v5_source_tag }
37 + SOURCE_SHA: ${ inputs.v5_sha256 }
38 + REPO_NAME: ${ github.repository }
39 + run: |
40 + $ErrorActionPreference='Stop'
41 + $folder=$env:GITHUB_WORKSPACE
42 + if ($env:SOURCE_TAG) {
43 + if($env:SOURCE_SHA -notmatch '^[a-fA-F0-9]{64}$'){throw 'REQUIRED_V5_SHA256_MISSING'}
44 + gh release download $env:SOURCE_TAG --repo $env:REPO_NAME --pattern TreasuryFlow-V5-CI-Source.zip --dir $env:RUNNER_TEMP --clobber
45 + $zip=Join-Path $env:RUNNER_TEMP 'TreasuryFlow-V5-CI-Source.zip'
46 + if((Get-FileHash $zip -Algorithm SHA256).Hash -ne $env:SOURCE_SHA.ToUpperInvariant()){throw 'V5_SHA256_MISMATCH'}
47 + $folder=Join-Path $env:RUNNER_TEMP 'TreasuryFlow-V5'
48 + Expand-Archive -LiteralPath $zip -DestinationPath $folder -Force
49 + 'LAB_VERSION=V5_FROM_PRIVATE_RELEASE' >> $env:GITHUB_ENV
50 + } else {
51 + 'LAB_VERSION=REPO_BRANCH_NOT_V5' >> $env:GITHUB_ENV
52 + }
53 + "LAB_SOURCE=$folder" >> $env:GITHUB_ENV
54 + if(!(Test-Path (Join-Path $folder 'package-lock.json'))){throw 'PACKAGE_LOCK_MISSING'}
55 + $bad=@(Get-ChildItem $folder -Recurse -File -Force | Where-Object {$_.Name -match '^\.env($|\.)|^license\.key$|^connectionString\.txt$|\.pfx$|\.p12$|\.pem$|\.sqlite$|\.db$'})
56 + if($bad.Count){throw 'SENSITIVE_OR_RUNTIME_FILES_PRESENT'}
57 + - name: Run real code quality and unit/integration tests
58 + shell: pwsh
59 + run: |
60 + Set-Location $env:LAB_SOURCE
61 + npm ci --no-audit --no-fund
62 + if($LASTEXITCODE -ne 0){throw 'NPM_CI_FAILED'}
63 + npm run typecheck
64 + if($LASTEXITCODE -ne 0){throw 'TYPECHECK_FAILED'}
65 + npm test
66 + if($LASTEXITCODE -ne 0){throw 'TESTS_FAILED'}
67 + npm run lint
68 + if($LASTEXITCODE -ne 0){throw 'LINT_FAILED'}
69 + - name: Build and run local web application (no banking network)
70 + shell: pwsh
71 + env:
72 + BANK_ADAPTER_MODE: disabled
73 + run: |
74 + Set-Location $env:LAB_SOURCE
75 + npm run build
76 + if($LASTEXITCODE -ne 0){throw 'PRODUCTION_BUILD_FAILED'}
77 + npm run smoke
78 + if($LASTEXITCODE -ne 0){throw 'REAL_HTTP_SMOKE_FAILED'}
79 + - name: Verify availability of real native bridge source
80 + id: native
81 + shell: pwsh
82 + run: |
83 + $file=Join-Path $env:LAB_SOURCE 'native/MayanInterop/Program.cs'
84 + if(Test-Path $file){
85 + Set-Location $env:LAB_SOURCE
86 + & ./scripts/build-mayan-native.ps1
87 + if($LASTEXITCODE -ne 0){throw 'NATIVE_BUILD_FAILED'}
88 + 'buildable=true' >> $env:GITHUB_OUTPUT
89 + }elseif($env:LAB_VERSION -eq 'V5_FROM_PRIVATE_RELEASE'){
90 + 'buildable=false' >> $env:GITHUB_OUTPUT
91 + "::warning::V5 package omits native/MayanInterop/Program.cs. Full desktop build is blocked, not passed."
92 + 'Full V5 desktop build: BLOCKED_MISSING_NATIVE_BRIDGE' >> $env:GITHUB_STEP_SUMMARY
93 + }else{
94 + 'buildable=true' >> $env:GITHUB_OUTPUT
95 + }
96 + - name: Package real Windows x64 portable EXE
97 + if: steps.native.outputs.buildable == 'true'
98 + shell: pwsh
99 + run: |
100 + Set-Location $env:LAB_SOURCE
101 + node scripts/prepare-standalone.mjs
102 + if($LASTEXITCODE -ne 0){throw 'PREPARE_STANDALONE_FAILED'}
103 + npm exec -- electron-builder --win portable --x64 --publish never
104 + if($LASTEXITCODE -ne 0){throw 'DESKTOP_PORTABLE_BUILD_FAILED'}
105 + - name: Launch actual packaged EXE and check local readiness/UI
106 + if: steps.native.outputs.buildable == 'true'
107 + shell: pwsh
108 + run: |
109 + & "$env:GITHUB_WORKSPACE/scripts/windows-vm-treasury-smoke.ps1" -SourceRoot "$env:LAB_SOURCE"
110 + - name: Package genuine Windows NSIS Setup EXE
111 + if: steps.native.outputs.buildable == 'true'
112 + shell: pwsh
113 + run: |
114 + Set-Location $env:LAB_SOURCE
115 + npm exec -- electron-builder --win nsis --x64 --publish never '--config.artifactName=TreasuryFlow-Setup-${version}-Windows-${arch}.${ext}'
116 + if($LASTEXITCODE -ne 0){throw 'NSIS_BUILD_FAILED'}
117 + $setups=@(Get-ChildItem "$env:LAB_SOURCE/release/TreasuryFlow-Setup-*-Windows-x64.exe" -ErrorAction SilentlyContinue)
118 + if($setups.Count -ne 1 -or $setups[0].Length -lt 1000000){throw 'NSIS_SETUP_EXE_MISSING'}
119 + 'Setup EXE built; full unattended install acceptance remains a separate test.' >> $env:GITHUB_STEP_SUMMARY
120 + - name: Upload private Windows artifacts and non-sensitive evidence
121 + if: always()
122 + uses: actions/upload-artifact@v4
123 + with:
124 + name: treasuryflow-windows-build-and-evidence
125 + path: |
126 + ${ env.LAB_SOURCE }}/release/TreasuryFlow-*-Windows-x64.exe
127 + ${ runner.temp }}/treasuryflow-vm-evidence/*.json
128 + retention-days: 7
129 + if-no-files-found: warn
130 + - name: State safety boundary
131 + if: always()
132 + shell: pwsh
133 + run: |
134 + 'Bank LIVE disabled. No production SQL connection, live payment, public release or actual customer data.' >> $env:GITHUB_STEP_SUMMARY
135 + 'Repository branch is NOT the user V5 unless a SHA-256-pinned private source archive was staged.' >> $env:GITHUB_STEP_SUMMARY