Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test | MetaTrader5 Integration Test | |
| on: [push] | |
| jobs: | |
| build: | |
| runs-on: windows-latest | |
| timeout-minutes: 15 | |
| 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 | |
| shell: pwsh | |
| run: | | |
| $url = "https://download.mql5.com/cdn/web/metaquotes.software.corp/mt5/mt5setup.exe" | |
| $output = "$env:GITHUB_WORKSPACE\mt5setup.exe" | |
| Invoke-WebRequest -Uri $url -OutFile $output | |
| Write-Host "Download completed. File size: $((Get-Item $output).Length) bytes" | |
| - name: Install MetaTrader5 | |
| shell: pwsh | |
| run: | | |
| $installDir = "$env:GITHUB_WORKSPACE\MT5Portable" | |
| # Verify and clean installation directory | |
| if (Test-Path $installDir) { | |
| Remove-Item -Recurse -Force $installDir | |
| } | |
| # Run installer with explicit paths | |
| $process = Start-Process "$env:GITHUB_WORKSPACE\mt5setup.exe" ` | |
| -ArgumentList @( | |
| "/S", | |
| "/portable=`"$installDir`"", | |
| "/skipupdate" | |
| ) -PassThru -NoNewWindow | |
| # Wait for installation with timeout | |
| if (-not $process.WaitForExit(300000)) { | |
| Write-Error "Installation timed out after 5 minutes" | |
| exit 1 | |
| } | |
| # Verify installation | |
| if (-not (Test-Path "$installDir\terminal64.exe")) { | |
| Write-Host "Directory contents:" | |
| Get-ChildItem $installDir -Recurse | |
| Write-Error "Installation failed - terminal64.exe not found" | |
| exit 1 | |
| } | |
| - name: Launch MT5 | |
| shell: pwsh | |
| run: | | |
| $mt5Path = Resolve-Path ".\MetaTrader 5\terminal64.exe" | |
| # Kill existing instances | |
| taskkill /IM terminal64.exe /F 2>&1 | Out-Null | |
| # Launch with diagnostics | |
| Start-Process $mt5Path -ArgumentList @( | |
| "/portable", | |
| "/headless", | |
| "/config:config", | |
| "/noreport" | |
| ) -NoNewWindow | |
| # Verify process start | |
| $attempts = 0 | |
| while ($attempts -lt 10) { | |
| if (Get-Process terminal64 -ErrorAction SilentlyContinue) { | |
| Write-Host "MT5 process detected" | |
| break | |
| } | |
| $attempts++ | |
| Start-Sleep 5 | |
| } | |
| if (-not (Get-Process terminal64 -ErrorAction SilentlyContinue)) { | |
| Get-Content ".\MetaTrader 5\logs\*.log" | Write-Host | |
| throw "MT5 failed to start" | |
| } | |
| - name: Run MT5 Test | |
| shell: pwsh | |
| run: | | |
| python -c "import os, MetaTrader5 as mt5 | |
| print('Python version:', os.sys.version) | |
| for i in range(10): | |
| try: | |
| if mt5.initialize(): | |
| print('MT5 initialized successfully') | |
| print(mt5.terminal_info()) | |
| mt5.shutdown() | |
| exit(0) | |
| print(f'Attempt {i+1} failed') | |
| except Exception as e: | |
| print(f'Error: {str(e)}') | |
| import time; time.sleep(10) | |
| print('All attempts failed') | |
| exit(1)" |