Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Test | Pytest and Integration Test #52

Test | Pytest and Integration Test

Test | Pytest and Integration Test #52

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@v4
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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.