66 build :
77 strategy :
88 matrix :
9- os : [windows-latest, windows-2025 ]
9+ os : [windows-latest]
1010 runs-on : ${{ matrix.os }}
1111 steps :
1212 - name : Checkout repository
@@ -19,51 +19,65 @@ jobs:
1919
2020 - name : Download MetaTrader5 Installer
2121 run : |
22- Invoke-WebRequest `
23- -Uri "https://download.mql5.com/cdn/web/metaquotes.software.corp/mt5/ mt5setup.exe" `
24- -OutFile "mt5setup.exe"
22+ $url = "https://download.mql5.com/cdn/web/metaquotes.software.corp/mt5/mt5setup.exe"
23+ $output = "$env:GITHUB_WORKSPACE\ mt5setup.exe"
24+ Invoke-WebRequest -Uri $url -OutFile $output
2525 shell : pwsh
2626
2727 - name : Install MetaTrader5
2828 run : |
29- $process = Start-Process -FilePath ".\mt5setup.exe" -ArgumentList "/auto", "/portable" -PassThru
30- $process.WaitForExit(300000) # Wait for up to 5 minutes
31- if (-not $process.HasExited) {
32- Write-Host "MT5 installer stuck, killing..."
33- Stop-Process -Id $process.Id -Force
29+ $installArgs = @(
30+ "/S",
31+ "/portable=$env:GITHUB_WORKSPACE\MT5Portable",
32+ "/skipupdate"
33+ )
34+ Start-Process "$env:GITHUB_WORKSPACE\mt5setup.exe" -ArgumentList $installArgs -Wait -NoNewWindow
35+ if (-not (Test-Path "$env:GITHUB_WORKSPACE\MT5Portable\terminal64.exe")) {
36+ Write-Error "Installation failed - terminal.exe not found"
3437 exit 1
3538 }
3639 shell : pwsh
3740
38- - name : Kill any existing MT5 processes
41+ - name : Launch MetaTrader5
3942 run : |
40- Get-Process terminal64 -ErrorAction SilentlyContinue | Stop-Process -Force
41- shell : pwsh
43+ $mt5Path = "$env:GITHUB_WORKSPACE\MT5Portable\terminal64.exe"
44+ $configPath = "$env:GITHUB_WORKSPACE\MT5Portable\config"
45+
46+ # Create basic configuration
47+ New-Item -Path $configPath -ItemType Directory -Force
48+ Set-Content -Path "$configPath\servers.dat" -Value "YourServerHere,Demo,ServerAddressHere,443"
4249
43- - name : Launch MetaTrader5 Terminal in portable mode
44- run : |
45- $mt5Paths = @(
46- "C:\Program Files\MetaTrader 5\terminal64.exe",
47- ".\MetaTrader 5\terminal64.exe",
48- ".\MetaTrader5\terminal64.exe"
49- )
50- foreach ($path in $mt5Paths) {
51- if (Test-Path $path) {
52- Start-Process -FilePath $path -ArgumentList "/portable" -WindowStyle Hidden
53- Write-Host "Launched MT5 from $path"
54- break
55- }
50+ # Launch with headless options
51+ $process = Start-Process $mt5Path -ArgumentList @(
52+ "/portable",
53+ "/headless",
54+ "/config:$configPath",
55+ "/login:12345 /password:demo /server:ServerAddressHere"
56+ ) -PassThru
57+
58+ # Wait and verify process
59+ Start-Sleep -Seconds 60
60+ if ($process.HasExited -or -not (Get-Process terminal64 -ErrorAction SilentlyContinue)) {
61+ Write-Error "Failed to launch MT5"
62+ Get-Content "$env:GITHUB_WORKSPACE\MT5Portable\logs\*.log" | Write-Host
63+ exit 1
5664 }
57- Start-Sleep -Seconds 30 # Increase wait time for MT5 to fully launch
5865 shell : pwsh
5966
60- - name : Check MT5 process running
67+ - name : Run MT5 Test
6168 run : |
62- Get-Process terminal64 -ErrorAction Stop
63- shell : pwsh
64-
65- - name : Install MetaTrader5 Python package
66- run : pip install MetaTrader5
67-
68- - name : Run MT5 test script
69- run : python tests/integration/test_mt5_connection.py
69+ python -c "import os, MetaTrader5 as mt5
70+ print('Python version:', os.sys.version)
71+ for i in range(10):
72+ try:
73+ if mt5.initialize():
74+ print('MT5 initialized successfully')
75+ print(mt5.terminal_info())
76+ mt5.shutdown()
77+ exit(0)
78+ print(f'Attempt {i+1} failed')
79+ except Exception as e:
80+ print(f'Error: {str(e)}')
81+ import time; time.sleep(10)
82+ print('All attempts failed')
83+ exit(1)"
0 commit comments