Skip to content

Commit 6278622

Browse files
committed
another test
1 parent 7419e48 commit 6278622

File tree

1 file changed

+75
-5
lines changed

1 file changed

+75
-5
lines changed

.github/workflows/test-metatrader5-integration.yml

Lines changed: 75 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@ jobs:
2626
# Install with modern silent parameters
2727
Start-Process -FilePath .\mt5setup.exe -ArgumentList "/auto", "/portable" -Wait
2828
29-
# Check standard and portable locations
29+
# Check standard and portable locations for both 32-bit and 64-bit versions
3030
$possiblePaths = @(
3131
"C:\Program Files\MetaTrader 5\terminal64.exe",
32+
"C:\Program Files\MetaTrader 5\terminal.exe",
3233
".\MetaTrader 5\terminal64.exe",
33-
"$env:APPDATA\MetaQuotes\Terminal\MetaTrader5\terminal64.exe"
34+
".\MetaTrader 5\terminal.exe",
35+
"$env:APPDATA\MetaQuotes\Terminal\MetaTrader5\terminal64.exe",
36+
"$env:APPDATA\MetaQuotes\Terminal\MetaTrader5\terminal.exe"
3437
)
3538
3639
$found = $false
@@ -68,27 +71,94 @@ jobs:
6871
6972
# Set environment variables for headless operation
7073
echo "MT5_HEADLESS=1" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
74+
echo "MT5_TIMEOUT=60000" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
75+
echo "MT5_DEBUG=1" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
7176
72-
# Find MT5 path to pass to the test
77+
# Find MT5 path to pass to the test - check both 32-bit and 64-bit versions
7378
$mt5Path = ""
7479
$possiblePaths = @(
7580
"C:\Program Files\MetaTrader 5\terminal64.exe",
81+
"C:\Program Files\MetaTrader 5\terminal.exe",
7682
".\MetaTrader 5\terminal64.exe",
77-
"$env:APPDATA\MetaQuotes\Terminal\MetaTrader5\terminal64.exe"
83+
".\MetaTrader 5\terminal.exe",
84+
"$env:APPDATA\MetaQuotes\Terminal\MetaTrader5\terminal64.exe",
85+
"$env:APPDATA\MetaQuotes\Terminal\MetaTrader5\terminal.exe"
7886
)
7987
8088
foreach ($path in $possiblePaths) {
8189
if (Test-Path $path) {
8290
$mt5Path = $path
91+
$mt5Dir = Split-Path -Parent $mt5Path
8392
echo "MT5_PATH=$mt5Path" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
93+
echo "MT5_DIR=$mt5Dir" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
8494
Write-Host "Setting MT5_PATH to $mt5Path"
95+
Write-Host "Setting MT5_DIR to $mt5Dir"
96+
97+
# Create minimal configuration file to help with headless mode
98+
$configContent = @"
99+
[Common]
100+
Login=0
101+
ProxyEnable=0
102+
CertCheckDisable=1
103+
AutoUpdate=0
104+
DisableStartupCompany=1
105+
EnableOpenCL=0
106+
News=0
107+
StartupCompany=0
108+
Community=0
109+
AutoUpdate.Enable=0
110+
"@
111+
$configPath = Join-Path $mt5Dir "config\default.ini"
112+
New-Item -Path (Split-Path -Parent $configPath) -ItemType Directory -Force
113+
Set-Content -Path $configPath -Value $configContent
114+
Write-Host "Created default config at $configPath"
115+
85116
break
86117
}
87118
}
88119

120+
- name: Debug environment
121+
run: |
122+
Write-Host "Environment variables:"
123+
Get-ChildItem Env:
124+
125+
Write-Host "MT5 directory contents:"
126+
if (Test-Path $env:MT5_DIR) {
127+
Get-ChildItem -Path $env:MT5_DIR -Recurse -Depth 1 | Select-Object FullName
128+
}
129+
130+
Write-Host "System processes:"
131+
Get-Process | Where-Object { $_.Name -like "*MetaTrader*" -or $_.Name -like "*terminal*" } | Format-Table -AutoSize
132+
89133
- name: Test MT5 initialization
90134
run: |
135+
# Kill any existing MT5 processes
136+
Get-Process | Where-Object { $_.Name -like "*MetaTrader*" -or $_.Name -like "*terminal*" } | ForEach-Object {
137+
Write-Host "Killing process $($_.Name) with ID $($_.Id)"
138+
Stop-Process -Id $_.Id -Force -ErrorAction SilentlyContinue
139+
}
140+
141+
# Give system time to clean up processes
142+
Start-Sleep -Seconds 5
143+
144+
# Start MT5 manually first with configurations that help in headless mode
145+
$mt5Process = Start-Process -FilePath $env:MT5_PATH -ArgumentList "/portable", "/config:default.ini", "/skipupdate", "/minimize" -PassThru
146+
Write-Host "Started MT5 process with ID $($mt5Process.Id)"
147+
148+
# Give MT5 time to fully initialize before Python tries to connect
149+
Start-Sleep -Seconds 10
150+
151+
# Check process is still running
152+
$mt5Running = Get-Process -Id $mt5Process.Id -ErrorAction SilentlyContinue
153+
if ($mt5Running) {
154+
Write-Host "MT5 process is still running with ID $($mt5Process.Id)"
155+
} else {
156+
Write-Host "Warning: MT5 process is no longer running"
157+
}
158+
91159
# Use the existing test script
92160
python test/integration/test_mt5_initialization.py
93161
env:
94-
MT5_HEADLESS: 1
162+
MT5_HEADLESS: 1
163+
MT5_TIMEOUT: 60000
164+
MT5_DEBUG: 1

0 commit comments

Comments
 (0)