Skip to content

Commit 7419e48

Browse files
committed
more test
1 parent 9db0674 commit 7419e48

File tree

1 file changed

+57
-31
lines changed

1 file changed

+57
-31
lines changed

.github/workflows/test-metatrader5-integration.yml

Lines changed: 57 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,51 +18,77 @@ jobs:
1818
with:
1919
python-version: '3.11'
2020

21-
- name: Download and Install MetaTrader 5
21+
- name: Direct Download and Install MetaTrader 5
2222
run: |
23-
# Download MT5 setup
23+
# Download latest MT5 setup directly from official source
2424
Invoke-WebRequest -Uri "https://download.mql5.com/cdn/web/metaquotes.software.corp/mt5/mt5setup.exe" -OutFile mt5setup.exe
2525
26-
# Install MT5 silently
27-
Start-Process -FilePath .\mt5setup.exe -ArgumentList "/auto" -Wait
26+
# Install with modern silent parameters
27+
Start-Process -FilePath .\mt5setup.exe -ArgumentList "/auto", "/portable" -Wait
2828
29-
# Verify installation
30-
$mtPath = "C:\Program Files\MetaTrader 5\terminal64.exe"
31-
if (Test-Path $mtPath) {
32-
Write-Host "MetaTrader 5 installed successfully"
33-
} else {
34-
Write-Error "MetaTrader 5 installation failed"
29+
# Check standard and portable locations
30+
$possiblePaths = @(
31+
"C:\Program Files\MetaTrader 5\terminal64.exe",
32+
".\MetaTrader 5\terminal64.exe",
33+
"$env:APPDATA\MetaQuotes\Terminal\MetaTrader5\terminal64.exe"
34+
)
35+
36+
$found = $false
37+
foreach ($path in $possiblePaths) {
38+
if (Test-Path $path) {
39+
Write-Host "MetaTrader 5 found at: $path"
40+
$found = $true
41+
break
42+
}
43+
}
44+
45+
if (-not $found) {
46+
Write-Error "MetaTrader 5 installation not found in expected locations"
47+
48+
# Search for installation
49+
Write-Host "Searching for MT5 installation..."
50+
$foundPaths = Get-ChildItem -Path "C:\" -Filter "terminal64.exe" -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty FullName
51+
foreach ($path in $foundPaths) {
52+
Write-Host "Found MT5 at: $path"
53+
}
54+
3555
exit 1
3656
}
3757
3858
- name: Install Python dependencies
3959
run: |
4060
python -m pip install --upgrade pip
41-
pip install MetaTrader5
61+
pip install MetaTrader5 pytest
4262
43-
# - name: Create MT5 portable configuration
44-
# run: |
45-
# # Create a portable MT5 directory
46-
# mkdir -p "$env:APPDATA\MetaTrader5Portable"
63+
- name: Configure MT5 for headless operation
64+
run: |
65+
# Create data directory for portable mode
66+
$mt5DataDir = ".\MT5_Data"
67+
New-Item -Path $mt5DataDir -ItemType Directory -Force
4768
48-
# # Set environment variables to make MT5 run in headless mode
49-
# echo "MT5_HEADLESS=1" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
50-
# echo "MT5_PORTABLE_PATH=$env:APPDATA\MetaTrader5Portable" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
69+
# Set environment variables for headless operation
70+
echo "MT5_HEADLESS=1" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
5171
52-
# # Copy MT5 files to portable location if needed
53-
# if (-not (Test-Path "$env:APPDATA\MetaTrader5Portable\terminal64.exe")) {
54-
# Copy-Item -Path "C:\Program Files\MetaTrader 5\*" -Destination "$env:APPDATA\MetaTrader5Portable\" -Recurse
55-
# }
72+
# Find MT5 path to pass to the test
73+
$mt5Path = ""
74+
$possiblePaths = @(
75+
"C:\Program Files\MetaTrader 5\terminal64.exe",
76+
".\MetaTrader 5\terminal64.exe",
77+
"$env:APPDATA\MetaQuotes\Terminal\MetaTrader5\terminal64.exe"
78+
)
5679
57-
# # Verify portable setup
58-
# if (Test-Path "$env:APPDATA\MetaTrader5Portable\terminal64.exe") {
59-
# Write-Host "MetaTrader 5 portable setup created successfully"
60-
# } else {
61-
# Write-Error "MetaTrader 5 portable setup failed"
62-
# exit 1
63-
# }
80+
foreach ($path in $possiblePaths) {
81+
if (Test-Path $path) {
82+
$mt5Path = $path
83+
echo "MT5_PATH=$mt5Path" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
84+
Write-Host "Setting MT5_PATH to $mt5Path"
85+
break
86+
}
87+
}
6488
6589
- name: Test MT5 initialization
6690
run: |
67-
# Run the MT5 initialization test script from the repository
68-
python test/integration/test_mt5_initialization.py
91+
# Use the existing test script
92+
python test/integration/test_mt5_initialization.py
93+
env:
94+
MT5_HEADLESS: 1

0 commit comments

Comments
 (0)