Skip to content

more test

more test #44

name: Test | Test MetaTrader5 Initialization
on:
push:
branches: ['*']
pull_request:
jobs:
test:
runs-on: windows-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Direct Download and Install MetaTrader 5
run: |
# Download latest MT5 setup directly from official source
Invoke-WebRequest -Uri "https://download.mql5.com/cdn/web/metaquotes.software.corp/mt5/mt5setup.exe" -OutFile mt5setup.exe
# Install with modern silent parameters
Start-Process -FilePath .\mt5setup.exe -ArgumentList "/auto", "/portable" -Wait
# Check standard and portable locations
$possiblePaths = @(
"C:\Program Files\MetaTrader 5\terminal64.exe",
".\MetaTrader 5\terminal64.exe",
"$env:APPDATA\MetaQuotes\Terminal\MetaTrader5\terminal64.exe"
)
$found = $false
foreach ($path in $possiblePaths) {
if (Test-Path $path) {
Write-Host "MetaTrader 5 found at: $path"
$found = $true
break
}
}
if (-not $found) {
Write-Error "MetaTrader 5 installation not found in expected locations"
# Search for installation
Write-Host "Searching for MT5 installation..."
$foundPaths = Get-ChildItem -Path "C:\" -Filter "terminal64.exe" -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty FullName
foreach ($path in $foundPaths) {
Write-Host "Found MT5 at: $path"
}
exit 1
}
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install MetaTrader5 pytest
- name: Configure MT5 for headless operation
run: |
# Create data directory for portable mode
$mt5DataDir = ".\MT5_Data"
New-Item -Path $mt5DataDir -ItemType Directory -Force
# Set environment variables for headless operation
echo "MT5_HEADLESS=1" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
# Find MT5 path to pass to the test
$mt5Path = ""
$possiblePaths = @(
"C:\Program Files\MetaTrader 5\terminal64.exe",
".\MetaTrader 5\terminal64.exe",
"$env:APPDATA\MetaQuotes\Terminal\MetaTrader5\terminal64.exe"
)
foreach ($path in $possiblePaths) {
if (Test-Path $path) {
$mt5Path = $path
echo "MT5_PATH=$mt5Path" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Write-Host "Setting MT5_PATH to $mt5Path"
break
}
}
- name: Test MT5 initialization
run: |
# Use the existing test script
python test/integration/test_mt5_initialization.py
env:
MT5_HEADLESS: 1