Skip to content

Commit ed9d190

Browse files
committed
2022
1 parent 17fa867 commit ed9d190

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

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

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ on: [push]
44

55
jobs:
66
build:
7-
runs-on: windows-latest
7+
strategy:
8+
matrix:
9+
os: [windows-latest, windows-2022] # run on both Win runners
10+
runs-on: ${{ matrix.os }}
811
steps:
912
- name: Checkout repository
1013
uses: actions/checkout@v4
@@ -23,9 +26,8 @@ jobs:
2326

2427
- name: Install MetaTrader5
2528
run: |
26-
# Start installer with /auto and /portable, with timeout protection
2729
$process = Start-Process -FilePath ".\mt5setup.exe" -ArgumentList "/auto", "/portable" -PassThru
28-
$process.WaitForExit(300000) # 300 seconds = 5 minutes
30+
$process.WaitForExit(300000) # 5 minutes timeout
2931
if (-not $process.HasExited) {
3032
Write-Host "MT5 installer stuck, killing..."
3133
Stop-Process -Id $process.Id -Force
@@ -42,22 +44,39 @@ jobs:
4244
run: |
4345
$mt5Paths = @(
4446
"C:\Program Files\MetaTrader 5\terminal64.exe",
45-
".\MetaTrader 5\terminal64.exe"
47+
".\MetaTrader 5\terminal64.exe",
48+
".\MetaTrader5\terminal64.exe"
4649
)
4750
foreach ($path in $mt5Paths) {
4851
if (Test-Path $path) {
49-
Start-Process -FilePath $path -ArgumentList "/portable"
52+
Start-Process -FilePath $path -ArgumentList "/portable" -WindowStyle Hidden
5053
Write-Host "Launched MT5 from $path"
5154
break
5255
}
5356
}
5457
Start-Sleep -Seconds 15
5558
shell: pwsh
5659

60+
- name: Check MT5 process running
61+
run: |
62+
Get-Process terminal64 -ErrorAction Stop
63+
shell: pwsh
64+
5765
- name: Install MetaTrader5 Python package
5866
run: pip install MetaTrader5
5967

6068
- name: Run Python inline script
6169
shell: pwsh
6270
run: |
63-
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()"
71+
python -c "import MetaTrader5 as mt5; import time; print('Testing MT5 initialization...'); \
72+
for attempt in range(12): \
73+
if mt5.initialize(): \
74+
print('MT5 initialized successfully'); \
75+
mt5.shutdown(); \
76+
break; \
77+
else: \
78+
print(f'Attempt {attempt+1}: Not ready yet, sleeping...'); \
79+
time.sleep(5); \
80+
else: \
81+
print('Failed to initialize MT5 after waiting.'); \
82+
exit(1)"

0 commit comments

Comments
 (0)