|
| 1 | +name: Test | Integration Test |
| 2 | + |
| 3 | +on: [push] |
| 4 | + |
| 5 | +jobs: |
| 6 | + build: |
| 7 | + runs-on: windows-latest |
| 8 | + timeout-minutes: 15 |
| 9 | + steps: |
| 10 | + - name: Checkout repository |
| 11 | + uses: actions/checkout@v4 |
| 12 | + |
| 13 | + - name: Set up Python |
| 14 | + uses: actions/setup-python@v4 |
| 15 | + with: |
| 16 | + python-version: '3.11' |
| 17 | + |
| 18 | + - name: Download MetaTrader5 Installer |
| 19 | + shell: pwsh |
| 20 | + run: | |
| 21 | + $url = "https://download.mql5.com/cdn/web/metaquotes.software.corp/mt5/mt5setup.exe" |
| 22 | + $output = "$env:GITHUB_WORKSPACE\mt5setup.exe" |
| 23 | + Invoke-WebRequest -Uri $url -OutFile $output |
| 24 | + Write-Host "Download completed. File size: $((Get-Item $output).Length) bytes" |
| 25 | +
|
| 26 | + - name: Install MetaTrader5 |
| 27 | + run: | |
| 28 | + $process = Start-Process -FilePath ".\mt5setup.exe" -ArgumentList "/auto", "/portable" -PassThru |
| 29 | + $process.WaitForExit(300000) |
| 30 | + if (-not $process.HasExited) { |
| 31 | + Write-Host "MT5 installer stuck, killing..." |
| 32 | + Stop-Process -Id $process.Id -Force |
| 33 | + exit 1 |
| 34 | + } |
| 35 | + shell: pwsh |
| 36 | + |
| 37 | + - name: Launch MT5 |
| 38 | + shell: pwsh |
| 39 | + run: | |
| 40 | + $mt5Path = Resolve-Path "C:\Program Files\MetaTrader 5\terminal64.exe" |
| 41 | +
|
| 42 | + # Launch with diagnostics |
| 43 | + Start-Process $mt5Path -ArgumentList @( |
| 44 | + "/portable", |
| 45 | + "/headless", |
| 46 | + "/config:config", |
| 47 | + "/noreport" |
| 48 | + ) -NoNewWindow |
| 49 | +
|
| 50 | + # Verify process start |
| 51 | + $attempts = 0 |
| 52 | + while ($attempts -lt 10) { |
| 53 | + if (Get-Process terminal64 -ErrorAction SilentlyContinue) { |
| 54 | + Write-Host "MT5 process detected" |
| 55 | + break |
| 56 | + } |
| 57 | + $attempts++ |
| 58 | + Start-Sleep 5 |
| 59 | + } |
| 60 | +
|
| 61 | + if (-not (Get-Process terminal64 -ErrorAction SilentlyContinue)) { |
| 62 | + Get-Content ".\MetaTrader 5\logs\*.log" | Write-Host |
| 63 | + throw "MT5 failed to start" |
| 64 | + } |
| 65 | +
|
| 66 | + - name: Install MetaTrader5 Python package |
| 67 | + run: pip install MetaTrader5 |
| 68 | + |
| 69 | + - name: Run MT5 Test |
| 70 | + env: |
| 71 | + MT5_LOGIN: ${{ secrets.MT5_LOGIN }} |
| 72 | + MT5_PASSWORD: ${{ secrets.MT5_PASSWORD }} |
| 73 | + MT5_SERVER: "MetaQuotes-Demo" |
| 74 | + MT5_PATH: "C:\\Program Files\\MetaTrader 5\\terminal64.exe" |
| 75 | + run: | |
| 76 | + python tests/integration/test_mt5_connection.py |
0 commit comments