Skip to content

inline

inline #58

name: Test | MetaTrader5 Integration Test
on: [push]
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Download MetaTrader5 Installer
run: |
Invoke-WebRequest
-Uri "https://download.mql5.com/cdn/web/metaquotes.software.corp/mt5/mt5setup.exe"
-OutFile "mt5setup.exe"
shell: pwsh
- name: Install MetaTrader5
run: |
# Start installer with /auto and /portable, with timeout protection
$process = Start-Process -FilePath ".\mt5setup.exe" -ArgumentList "/auto", "/portable" -PassThru
$process.WaitForExit(300) # 300 seconds = 5 minutes
if (-not $process.HasExited) {
Write-Host "MT5 installer stuck, killing..."
Stop-Process -Id $process.Id -Force
exit 1
}
shell: pwsh
- name: Kill any existing MT5 processes
run: |
Get-Process terminal64 -ErrorAction SilentlyContinue | Stop-Process -Force
shell: pwsh
- name: Launch MetaTrader5 Terminal in portable mode
run: |
$mt5Paths = @(
"C:\Program Files\MetaTrader 5\terminal64.exe",
".\MetaTrader 5\terminal64.exe"
)
foreach ($path in $mt5Paths) {
if (Test-Path $path) {
Start-Process -FilePath $path -ArgumentList "/portable"
Write-Host "Launched MT5 from $path"
break
}
}
Start-Sleep -Seconds 15
shell: pwsh
- name: Install MetaTrader5 Python package
run: pip install MetaTrader5
- name: Run Python inline script
shell: pwsh
run: |
python -c "import MetaTrader5 as mt5; import time; print('Testing MT5 initialization...'); time.sleep(5); assert mt5.initialize(), f'Failed to initialize: {mt5.last_error()}'; print('MT5 initialized successfully'); mt5.shutdown()"