Skip to content

Commit 82b727d

Browse files
committed
pytest and pre-commit
1 parent e7015f5 commit 82b727d

File tree

3 files changed

+66
-37
lines changed

3 files changed

+66
-37
lines changed

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

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: Test | Integration Test
22

33
on:
44
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches: ['*']
58
schedule:
69
- cron: '0 0 * * 0' # Run every week monday at 00:00
710

@@ -66,14 +69,38 @@ jobs:
6669
throw "MT5 failed to start"
6770
}
6871
69-
- name: Install MetaTrader5 Python package
70-
run: pip install MetaTrader5
72+
# - name: Install MetaTrader5 Python package
73+
# run: pip install MetaTrader5
7174

72-
- name: Run MT5 Test
75+
# - name: Run MT5 Test
76+
# env:
77+
# MT5_LOGIN: ${{ secrets.MT5_LOGIN }}
78+
# MT5_PASSWORD: ${{ secrets.MT5_PASSWORD }}
79+
# MT5_SERVER: "MetaQuotes-Demo"
80+
# MT5_PATH: "C:\\Program Files\\MetaTrader 5\\terminal64.exe"
81+
# run: |
82+
# python tests/integration/test_mt5_connection.py
83+
84+
- name: Install dependencies
85+
run: |
86+
python -m pip install --upgrade pip
87+
pip install pytest pytest-cov MetaTrader5
88+
pip install -e .
89+
90+
- name: Run tests with coverage
7391
env:
7492
MT5_LOGIN: ${{ secrets.MT5_LOGIN }}
7593
MT5_PASSWORD: ${{ secrets.MT5_PASSWORD }}
7694
MT5_SERVER: "MetaQuotes-Demo"
7795
MT5_PATH: "C:\\Program Files\\MetaTrader 5\\terminal64.exe"
7896
run: |
79-
python tests/integration/test_mt5_connection.py
97+
pytest -k . --cov=mqpy --cov-append --cov-report=term-missing:skip-covered --junitxml=pytest.xml -x | tee pytest-coverage.txt
98+
99+
- name: Generate coverage summary
100+
shell: pwsh
101+
run: |
102+
"## Test Coverage Summary" | Out-File -FilePath summary.md -Encoding utf8
103+
'```' | Out-File -FilePath summary.md -Append -Encoding utf8
104+
Get-Content pytest-coverage.txt | Out-File -FilePath summary.md -Append -Encoding utf8
105+
'```' | Out-File -FilePath summary.md -Append -Encoding utf8
106+
Get-Content summary.md | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append -Encoding utf8

.github/workflows/test-pytest.yaml

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
1-
name: Test | Pytest
1+
# name: Test | Pytest
22

3-
on:
4-
pull_request:
5-
push:
6-
branches: ['*']
3+
# on:
4+
# pull_request:
5+
# push:
6+
# branches: ['*']
77

8-
jobs:
9-
pytest:
10-
runs-on: windows-latest
8+
# jobs:
9+
# pytest:
10+
# runs-on: windows-latest
1111

12-
steps:
13-
- name: Checkout repository
14-
uses: actions/checkout@v4
12+
# steps:
13+
# - name: Checkout repository
14+
# uses: actions/checkout@v4
1515

16-
- name: Set up Python
17-
uses: actions/setup-python@v4
18-
with:
19-
python-version: '3.11'
20-
cache: 'pip'
16+
# - name: Set up Python
17+
# uses: actions/setup-python@v4
18+
# with:
19+
# python-version: '3.11'
20+
# cache: 'pip'
2121

22-
- name: Install dependencies
23-
run: |
24-
python -m pip install --upgrade pip
25-
pip install pytest pytest-cov MetaTrader5
26-
pip install -e .
22+
# - name: Install dependencies
23+
# run: |
24+
# python -m pip install --upgrade pip
25+
# pip install pytest pytest-cov MetaTrader5
26+
# pip install -e .
2727

28-
- name: Run tests with coverage
29-
run: |
30-
pytest -k . --cov=mqpy --cov-append --cov-report=term-missing:skip-covered --junitxml=pytest.xml -x | tee pytest-coverage.txt
28+
# - name: Run tests with coverage
29+
# run: |
30+
# pytest -k . --cov=mqpy --cov-append --cov-report=term-missing:skip-covered --junitxml=pytest.xml -x | tee pytest-coverage.txt
3131

32-
- name: Generate coverage summary
33-
shell: pwsh
34-
run: |
35-
"## Test Coverage Summary" | Out-File -FilePath summary.md -Encoding utf8
36-
'```' | Out-File -FilePath summary.md -Append -Encoding utf8
37-
Get-Content pytest-coverage.txt | Out-File -FilePath summary.md -Append -Encoding utf8
38-
'```' | Out-File -FilePath summary.md -Append -Encoding utf8
39-
Get-Content summary.md | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append -Encoding utf8
32+
# - name: Generate coverage summary
33+
# shell: pwsh
34+
# run: |
35+
# "## Test Coverage Summary" | Out-File -FilePath summary.md -Encoding utf8
36+
# '```' | Out-File -FilePath summary.md -Append -Encoding utf8
37+
# Get-Content pytest-coverage.txt | Out-File -FilePath summary.md -Append -Encoding utf8
38+
# '```' | Out-File -FilePath summary.md -Append -Encoding utf8
39+
# Get-Content summary.md | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append -Encoding utf8

example.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@
4545
is_cross_below = short_ma < long_ma and current_tick.last < short_ma
4646

4747
# Execute trading positions based on signals
48-
trade.open_position(should_buy=is_cross_above, should_sell=is_cross_below, comment="Moving Average Crossover Strategy")
48+
trade.open_position(
49+
should_buy=is_cross_above, should_sell=is_cross_below, comment="Moving Average Crossover Strategy"
50+
)
4951

5052
prev_tick_time = current_tick.time_msc
5153

0 commit comments

Comments
 (0)