-
-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathtest-pytest-and-integration.yml
More file actions
95 lines (83 loc) · 2.97 KB
/
test-pytest-and-integration.yml
File metadata and controls
95 lines (83 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Test | Pytest and Integration Test
on:
workflow_dispatch:
pull_request:
push:
branches: ['*']
schedule:
- cron: '0 12 * * 0' # Run every week monday at 12:00
jobs:
build:
runs-on: windows-latest
timeout-minutes: 15
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Download MetaTrader5 Installer
shell: pwsh
run: |
$url = "https://download.mql5.com/cdn/web/metaquotes.software.corp/mt5/mt5setup.exe"
$output = "$env:GITHUB_WORKSPACE\mt5setup.exe"
Invoke-WebRequest -Uri $url -OutFile $output
Write-Host "Download completed. File size: $((Get-Item $output).Length) bytes"
- name: Install MetaTrader5
run: |
$process = Start-Process -FilePath ".\mt5setup.exe" -ArgumentList "/auto", "/portable" -PassThru
$process.WaitForExit(300000)
if (-not $process.HasExited) {
Write-Host "MT5 installer stuck, killing..."
Stop-Process -Id $process.Id -Force
exit 1
}
shell: pwsh
- name: Launch MT5
shell: pwsh
run: |
$mt5Path = Resolve-Path "C:\Program Files\MetaTrader 5\terminal64.exe"
# Launch with diagnostics
Start-Process $mt5Path -ArgumentList @(
"/portable",
"/headless",
"/config:config",
"/noreport"
) -NoNewWindow
# Verify process start
$attempts = 0
while ($attempts -lt 10) {
if (Get-Process terminal64 -ErrorAction SilentlyContinue) {
Write-Host "MT5 process detected"
break
}
$attempts++
Start-Sleep 5
}
if (-not (Get-Process terminal64 -ErrorAction SilentlyContinue)) {
Get-Content ".\MetaTrader 5\logs\*.log" | Write-Host
throw "MT5 failed to start"
}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-cov MetaTrader5
pip install -e .
- name: Run tests with coverage
env:
HEADLESS_MODE: true
MT5_LOGIN: ${{ secrets.MT5_LOGIN }}
MT5_PASSWORD: ${{ secrets.MT5_PASSWORD }}
MT5_SERVER: "MetaQuotes-Demo"
MT5_PATH: "C:\\Program Files\\MetaTrader 5\\terminal64.exe"
run: |
pytest -k . --cov=mqpy --cov-append --junitxml=pytest.xml -x | tee pytest-coverage.txt
- name: Generate coverage summary
shell: pwsh
run: |
"## Test Coverage Summary" | Out-File -FilePath summary.md -Encoding utf8
'```' | Out-File -FilePath summary.md -Append -Encoding utf8
Get-Content pytest-coverage.txt | Out-File -FilePath summary.md -Append -Encoding utf8
'```' | Out-File -FilePath summary.md -Append -Encoding utf8
Get-Content summary.md | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append -Encoding utf8