Skip to content

Commit 0ce4869

Browse files
committed
test
1 parent a5733ec commit 0ce4869

File tree

1 file changed

+56
-81
lines changed

1 file changed

+56
-81
lines changed
Lines changed: 56 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,59 @@
1-
name: MetaTrader5 Integration Test
1+
name: Test | MetaTrader5 Integration Test
22

33
on: [push]
44

55
jobs:
6-
test:
6+
build:
77
runs-on: windows-latest
8-
timeout-minutes: 15 # Increased timeout
8+
timeout-minutes: 15
99
steps:
10-
- name: Checkout code
10+
- name: Checkout repository
1111
uses: actions/checkout@v4
1212

13-
- name: Install MT5 (Portable)
13+
- name: Set up Python
14+
uses: actions/setup-python@v4
15+
with:
16+
python-version: '3.11'
17+
18+
- name: Download MetaTrader5 Installer
1419
shell: pwsh
1520
run: |
16-
# Clean previous installation
17-
if (Test-Path ".\MetaTrader 5") {
18-
Remove-Item -Recurse -Force ".\MetaTrader 5"
19-
}
20-
21-
# Download with retries
22-
$retries = 3
23-
do {
24-
try {
25-
Invoke-WebRequest https://download.mql5.com/cdn/web/metaquotes.software.corp/mt5/mt5setup.exe `
26-
-OutFile mt5setup.exe -TimeoutSec 60
27-
break
28-
} catch {
29-
$retries--
30-
if ($retries -eq 0) { throw }
31-
Write-Host "Download failed, retries left: $retries"
32-
Start-Sleep 5
33-
}
34-
} while ($retries -gt 0)
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"
3525
36-
# Install with explicit paths
37-
$installProcess = Start-Process .\mt5setup.exe `
38-
-ArgumentList @("/portable", "/skipupdate", "/auto") `
39-
-PassThru -NoNewWindow
26+
- name: Install MetaTrader5
27+
shell: pwsh
28+
run: |
29+
$installDir = "$env:GITHUB_WORKSPACE\MT5Portable"
4030
41-
# Wait with timeout
42-
if (-not $installProcess.WaitForExit(180000)) {
43-
Write-Error "Installation timed out after 3 minutes"
44-
exit 1
31+
# Verify and clean installation directory
32+
if (Test-Path $installDir) {
33+
Remove-Item -Recurse -Force $installDir
4534
}
35+
36+
# Run installer with explicit paths
37+
$process = Start-Process "$env:GITHUB_WORKSPACE\mt5setup.exe" `
38+
-ArgumentList @(
39+
"/S",
40+
"/portable=`"$installDir`"",
41+
"/skipupdate"
42+
) -PassThru -NoNewWindow
4643
47-
# Verify installation
48-
if (-not (Test-Path ".\MetaTrader 5\terminal64.exe")) {
49-
Write-Host "Installed directory contents:"
50-
Get-ChildItem ".\MetaTrader 5" -Recurse
51-
throw "Installation failed - terminal64.exe missing"
44+
# Wait for installation with timeout
45+
if (-not $process.WaitForExit(300000)) {
46+
Write-Error "Installation timed out after 5 minutes"
47+
exit 1
5248
}
53-
54-
- name: Configure Server
55-
shell: pwsh
56-
run: |
57-
$configPath = ".\MetaTrader 5\config"
58-
New-Item -Path $configPath -ItemType Directory -Force
5949
60-
# Create server configuration
61-
@"
62-
DemoServer,Demo,demo.example.com,443
63-
"@ | Set-Content "$configPath\servers.dat"
64-
65-
# Create basic terminal configuration
66-
@"
67-
[Common]
68-
Language=English
69-
AutoUpdate=0
70-
EnableNews=0
71-
[Connection]
72-
EnableWebRequest=0
73-
"@ | Set-Content "$configPath\terminal.ini"
50+
# Verify installation
51+
if (-not (Test-Path "$installDir\terminal64.exe")) {
52+
Write-Host "Directory contents:"
53+
Get-ChildItem $installDir -Recurse
54+
Write-Error "Installation failed - terminal64.exe not found"
55+
exit 1
56+
}
7457
7558
- name: Launch MT5
7659
shell: pwsh
@@ -104,29 +87,21 @@ EnableWebRequest=0
10487
throw "MT5 failed to start"
10588
}
10689
107-
- name: Test Connection
90+
- name: Run MT5 Test
10891
shell: pwsh
10992
run: |
110-
# Allow more time for terminal initialization
111-
Start-Sleep -Seconds 45
112-
113-
python -c "
114-
import MetaTrader5 as mt5
115-
from time import sleep
116-
import sys
117-
118-
max_attempts = 8
119-
for attempt in range(max_attempts):
120-
try:
121-
if mt5.initialize():
122-
print(f'Successfully connected to MT5 {mt5.version()}')
123-
print('Terminal info:', mt5.terminal_info()._asdict())
124-
mt5.shutdown()
125-
sys.exit(0)
126-
print(f'Attempt {attempt+1}/{max_attempts}: Initialize failed')
127-
except Exception as e:
128-
print(f'Attempt {attempt+1}/{max_attempts}: Error - {str(e)}')
129-
sleep(10)
130-
print('All connection attempts failed')
131-
sys.exit(1)
132-
"
93+
python -c "import os, MetaTrader5 as mt5
94+
print('Python version:', os.sys.version)
95+
for i in range(10):
96+
try:
97+
if mt5.initialize():
98+
print('MT5 initialized successfully')
99+
print(mt5.terminal_info())
100+
mt5.shutdown()
101+
exit(0)
102+
print(f'Attempt {i+1} failed')
103+
except Exception as e:
104+
print(f'Error: {str(e)}')
105+
import time; time.sleep(10)
106+
print('All attempts failed')
107+
exit(1)"

0 commit comments

Comments
 (0)