Treasury & Bank Transfer Management System — سامانه مدیریت خزانهداری و حوالههای بانکی
test: add real NSIS silent install and installed TreasuryFlow runtime probe
davoodmehraban89 committed
Oct 16, 2026 at 21:39 UTC
a7d81d01ca9742ff778413ad41da718a21c0c2f9
1 file changed
+54
scripts/windows-vm-treasury-install-smoke.ps1
new
+54
@@ -0,0 +1,54 @@
1
+param([Parameter(Mandatory=$true)][string]$SourceRoot)
2
+$ErrorActionPreference='Stop'
3
+$evidenceDir=Join-Path $env:RUNNER_TEMP 'treasuryflow-vm-evidence'
4
+New-Item -ItemType Directory $evidenceDir -Force | Out-Null
5
+$report=[ordered]@{installerPresent=$false;installerSha256=$null;silentInstall='NOT_RUN';
6
+ installedExecutableFound=$false;installedProcessLaunched=$false;httpReady=$false;
7
+ bankAdapterDisabled=$false;homeHtmlLoaded=$false;outcome='NOT_RUN'}
8
+$target=Join-Path $env:RUNNER_TEMP 'TreasuryFlow-VM-Installed'
9
+$p=$null
10
+try {
11
+ $installers=@(Get-ChildItem -Path (Join-Path $SourceRoot 'release') -File -Filter 'TreasuryFlow-Setup-*-Windows-x64.exe')
12
+ if($installers.Count -ne 1){throw 'EXPECTED_EXACTLY_ONE_NSIS_SETUP_EXE'}
13
+ $setup=$installers[0].FullName
14
+ $report.installerPresent=$true
15
+ $report.installerSha256=(Get-FileHash $setup -Algorithm SHA256).Hash
16
+ if(Test-Path $target){throw 'INSTALL_TEST_DIRECTORY_ALREADY_EXISTS'}
17
+ # NSIS silent switch; /D=<path> must be the last argument.
18
+ $setupProcess=Start-Process -FilePath $setup -ArgumentList @('/S',('/D='+$target)) -PassThru -Wait
19
+ if($setupProcess.ExitCode -ne 0){throw ('NSIS_INSTALLER_NONZERO_EXIT_'+$setupProcess.ExitCode)}
20
+ if(!(Test-Path $target)){throw 'NSIS_INSTALL_LOCATION_NOT_CREATED'}
21
+ $report.silentInstall='PASS'
22
+ $apps=@(Get-ChildItem $target -Recurse -File -Filter 'TreasuryFlow.exe' -ErrorAction SilentlyContinue)
23
+ if($apps.Count -ne 1){throw 'INSTALLED_EXE_NOT_FOUND'}
24
+ $report.installedExecutableFound=$true
25
+ $env:BANK_ADAPTER_MODE='disabled'
26
+ $env:TREASURYFLOW_DATA_FILE=Join-Path $evidenceDir 'isolated-installed.sqlite'
27
+ $p=Start-Process -FilePath $apps[0].FullName -WorkingDirectory $apps[0].DirectoryName -PassThru
28
+ $report.installedProcessLaunched=$true
29
+ for($i=0;$i -lt 90;$i++){
30
+ Start-Sleep -Milliseconds 700
31
+ try {
32
+ $ready=Invoke-RestMethod 'http://127.0.0.1:3210/api/ready' -TimeoutSec 2
33
+ if($ready.status -eq 'ready'){
34
+ $report.httpReady=$true
35
+ $report.bankAdapterDisabled=($ready.bankAdapter -eq 'disabled')
36
+ break
37
+ }
38
+ }catch{}
39
+ }
40
+ if(!$report.httpReady){throw 'INSTALLED_APP_READINESS_TIMEOUT'}
41
+ if(!$report.bankAdapterDisabled){throw 'INSTALLED_APP_BANK_NOT_DISABLED'}
42
+ $home=Invoke-WebRequest 'http://127.0.0.1:3210' -TimeoutSec 12
43
+ $report.homeHtmlLoaded=($home.StatusCode -eq 200 -and $home.Content -match 'TreasuryFlow')
44
+ if(!$report.homeHtmlLoaded){throw 'INSTALLED_APP_HTML_FAILED'}
45
+ $report.outcome='NSIS_INSTALL_AND_INSTALLED_RUNTIME_PASS'
46
+ 'A REAL NSIS Setup was silently installed under runner.temp, and the installed TreasuryFlow executable passed local readiness and HTML checks.' >> $env:GITHUB_STEP_SUMMARY
47
+}catch {
48
+ $report.outcome='FAIL'
49
+ $report.failureCode=$_.Exception.Message
50
+ throw
51
+}finally {
52
+ if($p -and !$p.HasExited){try{& taskkill.exe /T /F /PID $p.Id | Out-Null}catch{}}
53
+ $report|ConvertTo-Json -Depth 4|Set-Content (Join-Path $evidenceDir 'installed-runtime.json') -Encoding UTF8
54
+}