@@ -4,7 +4,10 @@ on: [push]
4
4
5
5
jobs :
6
6
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 }}
8
11
steps :
9
12
- name : Checkout repository
10
13
uses : actions/checkout@v4
23
26
24
27
- name : Install MetaTrader5
25
28
run : |
26
- # Start installer with /auto and /portable, with timeout protection
27
29
$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
29
31
if (-not $process.HasExited) {
30
32
Write-Host "MT5 installer stuck, killing..."
31
33
Stop-Process -Id $process.Id -Force
@@ -42,22 +44,39 @@ jobs:
42
44
run : |
43
45
$mt5Paths = @(
44
46
"C:\Program Files\MetaTrader 5\terminal64.exe",
45
- ".\MetaTrader 5\terminal64.exe"
47
+ ".\MetaTrader 5\terminal64.exe",
48
+ ".\MetaTrader5\terminal64.exe"
46
49
)
47
50
foreach ($path in $mt5Paths) {
48
51
if (Test-Path $path) {
49
- Start-Process -FilePath $path -ArgumentList "/portable"
52
+ Start-Process -FilePath $path -ArgumentList "/portable" -WindowStyle Hidden
50
53
Write-Host "Launched MT5 from $path"
51
54
break
52
55
}
53
56
}
54
57
Start-Sleep -Seconds 15
55
58
shell : pwsh
56
59
60
+ - name : Check MT5 process running
61
+ run : |
62
+ Get-Process terminal64 -ErrorAction Stop
63
+ shell : pwsh
64
+
57
65
- name : Install MetaTrader5 Python package
58
66
run : pip install MetaTrader5
59
67
60
68
- name : Run Python inline script
61
69
shell : pwsh
62
70
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