Skip to content

Commit df4cba6

Browse files
Enable windows basic unit tests
* Fix missing dlls for windows build and test * Run unit tests for windows * Skip integration tests for windows * Fix workflows * Enable windows code coverage upload
1 parent d571f58 commit df4cba6

12 files changed

Lines changed: 107 additions & 66 deletions

.github/workflows/build-windows.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,11 @@ jobs:
103103
-DPython3_FIND_REGISTRY=NEVER
104104
cmake --build .
105105
mkdir -p ../dist
106+
cp ../external/monero-cpp/build/libmonero-cpp.dll ../dist
106107
cp *.pyd ../dist/monero.pyd
108+
cd ../dist
107109
ntldd -R *.pyd | grep mingw64 | awk '{print $3}' | while read -r line; do
108-
cp "$(cygpath -u "$line")" ../dist/
110+
cp "$(cygpath -u "$line")" .
109111
done
110112
111113
- name: Upload artifacts

.github/workflows/codacy.yml

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -49,40 +49,39 @@ jobs:
4949
language: c
5050
coverage-reports: coverage.info
5151

52-
# TODO build docker monero image for windows
53-
# report-coverage-windows:
54-
# if: github.repository == 'everoddandeven/monero-python'
55-
# runs-on: ubuntu-latest
56-
# steps:
57-
# - name: Checkout code
58-
# uses: actions/checkout@v4
59-
# with:
60-
# fetch-depth: 0
52+
report-coverage-windows:
53+
if: github.repository == 'everoddandeven/monero-python'
54+
runs-on: ubuntu-latest
55+
steps:
56+
- name: Checkout code
57+
uses: actions/checkout@v4
58+
with:
59+
fetch-depth: 0
6160

62-
# - name: Download coverage report
63-
# uses: actions/download-artifact@v4
64-
# with:
65-
# name: coverage-reports-windows
66-
# github-token: ${{ secrets.API_GITHUB }}
67-
# run-id: ${{ github.event.workflow_run.id }}
61+
- name: Download coverage report
62+
uses: actions/download-artifact@v4
63+
with:
64+
name: coverage-reports-windows
65+
github-token: ${{ secrets.API_GITHUB }}
66+
run-id: ${{ github.event.workflow_run.id }}
6867

69-
# - name: Report python coverage
70-
# uses: codacy/codacy-coverage-reporter-action@v1
71-
# with:
72-
# project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
73-
# language: python
74-
# coverage-reports: coverage.xml
68+
- name: Report python coverage
69+
uses: codacy/codacy-coverage-reporter-action@v1
70+
with:
71+
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
72+
language: python
73+
coverage-reports: coverage.xml
7574

76-
# - name: Report c++ coverage
77-
# uses: codacy/codacy-coverage-reporter-action@v1
78-
# with:
79-
# project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
80-
# language: cpp
81-
# coverage-reports: coverage.info
75+
- name: Report c++ coverage
76+
uses: codacy/codacy-coverage-reporter-action@v1
77+
with:
78+
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
79+
language: cpp
80+
coverage-reports: coverage.info
8281

83-
# - name: Report c coverage
84-
# uses: codacy/codacy-coverage-reporter-action@v1
85-
# with:
86-
# project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
87-
# language: c
88-
# coverage-reports: coverage.info
82+
- name: Report c coverage
83+
uses: codacy/codacy-coverage-reporter-action@v1
84+
with:
85+
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
86+
language: c
87+
coverage-reports: coverage.info

.github/workflows/test.yml

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ jobs:
140140
- name: Install pytest
141141
shell: bash
142142
run: |
143-
python -m pip install pytest pytest-rerunfailures pytest-cov gcovr
143+
python -m pip install pytest pytest-rerunfailures pytest-cov gcovr typing_extensions
144144
145145
- name: Setup MSYS2 MINGW64
146146
uses: msys2/setup-msys2@v2
@@ -227,9 +227,11 @@ jobs:
227227
-DPython3_FIND_REGISTRY=NEVER
228228
cmake --build .
229229
mkdir -p ../dist
230+
cp ../external/monero-cpp/build/libmonero-cpp.dll ../dist
230231
cp *.pyd ../dist/monero.pyd
232+
cd ../dist
231233
ntldd -R *.pyd | grep mingw64 | awk '{print $3}' | while read -r line; do
232-
cp "$(cygpath -u "$line")" ../dist/
234+
cp "$(cygpath -u "$line")" .
233235
done
234236
cd ..
235237
@@ -239,29 +241,29 @@ jobs:
239241
# run: |
240242
# docker compose -f tests/docker-compose.yml up -d node_1 node_2 xmr_wallet_1 xmr_wallet_2
241243

242-
# - name: Run tests
243-
# shell: bash
244-
# env:
245-
# IN_CONTAINER: "true"
246-
# PYTHONPATH: ${{ github.workspace }}/dist
247-
# PATH: "${{ github.workspace }}/dist:/usr/bin:$PATH"
248-
# run: |
249-
# python -m pytest --cov=tests --cov-report=xml
244+
- name: Run tests
245+
shell: bash
246+
env:
247+
IN_CONTAINER: "true"
248+
PYTHONPATH: ${{ github.workspace }}/dist
249+
PATH: "${{ github.workspace }}/dist:/usr/bin:$PATH"
250+
run: |
251+
python -m pytest --cov=tests --cov-report=xml
250252
251253
# - name: Cleanup test environment
252254
# if: always()
253255
# shell: bash
254256
# run: docker compose -f tests/docker-compose.yml down -v
255257

256-
# - name: Generate coverage report
257-
# shell: bash
258-
# run: |
259-
# gcovr -r . --filter src/ --lcov coverage.info
260-
261-
# - name: Upload coverage report
262-
# uses: actions/upload-artifact@v4
263-
# with:
264-
# name: coverage-reports-windows
265-
# path: |
266-
# coverage.info
267-
# coverage.xml
258+
- name: Generate coverage report
259+
shell: bash
260+
run: |
261+
gcovr -r . --filter src/ --lcov coverage.info
262+
263+
- name: Upload coverage report
264+
uses: actions/upload-artifact@v4
265+
with:
266+
name: coverage-reports-windows
267+
path: |
268+
coverage.info
269+
coverage.xml

tests/test_monero_daemon_rpc.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,29 @@
1111
MoneroHardForkInfo, MoneroAltChain, MoneroTx, MoneroSubmitTxResult,
1212
MoneroTxPoolStats, MoneroBan, MoneroTxConfig, MoneroDestination
1313
)
14-
from utils import TestUtils as Utils, TestContext, BinaryBlockContext, MiningUtils
14+
from utils import (
15+
TestUtils as Utils, TestContext,
16+
BinaryBlockContext, MiningUtils,
17+
OsUtils
18+
)
1519

1620
logger: logging.Logger = logging.getLogger("TestMoneroDaemonRpc")
1721

1822

23+
@pytest.mark.skipif(OsUtils.is_windows(), reason="TODO setup test environment for windows")
1924
class TestMoneroDaemonRpc:
2025
_daemon: MoneroDaemonRpc = Utils.get_daemon_rpc()
21-
_wallet: MoneroWallet = Utils.get_wallet_rpc()
26+
_wallet: MoneroWallet = Utils.get_wallet_rpc() # type: ignore
2227
BINARY_BLOCK_CTX: BinaryBlockContext = BinaryBlockContext()
2328

2429
#region Fixtures
2530

2631
@pytest.fixture(scope="class", autouse=True)
2732
def before_all(self):
28-
MiningUtils.wait_until_blockchain_ready()
29-
MiningUtils.try_stop_mining()
33+
# TODO setup test environment for windows
34+
if not OsUtils.is_windows():
35+
MiningUtils.wait_until_blockchain_ready()
36+
MiningUtils.try_stop_mining()
3037

3138
@pytest.fixture(autouse=True)
3239
def before_each(self, request: pytest.FixtureRequest):

tests/test_monero_rpc_connection.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
import logging
33

44
from monero import MoneroRpcConnection
5-
from utils import TestUtils as Utils
5+
from utils import TestUtils as Utils, OsUtils
66

77
logger: logging.Logger = logging.getLogger("TestMoneroRpcConnection")
88

99

10+
@pytest.mark.skipif(OsUtils.is_windows(), reason="TODO setup test environment for windows")
1011
class TestMoneroRpcConnection:
1112

1213
@pytest.fixture(autouse=True)

tests/test_monero_wallet_common.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
MoneroTxConfig, MoneroDestination, MoneroRpcConnection, MoneroError,
1212
MoneroKeyImage, MoneroTxQuery, MoneroUtils, MoneroWalletFull
1313
)
14-
from utils import TestUtils, WalletEqualityUtils, MiningUtils
14+
from utils import TestUtils, WalletEqualityUtils, MiningUtils, OsUtils
1515

1616
logger: logging.Logger = logging.getLogger("TestMoneroWalletCommon")
1717

@@ -86,8 +86,10 @@ def test_config(self) -> BaseTestMoneroWallet.Config:
8686

8787
@pytest.fixture(scope="class", autouse=True)
8888
def before_all(self):
89-
MiningUtils.wait_until_blockchain_ready()
90-
MiningUtils.try_stop_mining()
89+
# TODO setup test environment for windows
90+
if not OsUtils.is_windows():
91+
MiningUtils.wait_until_blockchain_ready()
92+
MiningUtils.try_stop_mining()
9193

9294
@pytest.fixture(autouse=True)
9395
def before_each(self, request: pytest.FixtureRequest):

tests/test_monero_wallet_full.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
MoneroSubaddress, MoneroDaemonRpc, MoneroWallet
99
)
1010

11-
from utils import TestUtils as Utils
11+
from utils import TestUtils as Utils, OsUtils
1212
from test_monero_wallet_common import BaseTestMoneroWallet
1313

1414
logger: logging.Logger = logging.getLogger("TestMoneroWalletFull")
1515

1616

17+
@pytest.mark.skipif(OsUtils.is_windows(), reason="TODO setup test environment for windows")
1718
class TestMoneroWalletFull(BaseTestMoneroWallet):
1819

1920
_daemon: MoneroDaemonRpc = Utils.get_daemon_rpc()

tests/test_monero_wallet_keys.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ def before_each(self, request: pytest.FixtureRequest):
2727
yield
2828
logger.info(f"After test {request.node.name}") # type: ignore
2929

30+
@pytest.fixture(scope="class", autouse=True)
31+
@override
32+
def before_all(self):
33+
pass
34+
3035
#region Overrides
3136

3237
@classmethod

tests/test_monero_wallet_rpc.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
from monero import MoneroWallet, MoneroWalletConfig, MoneroDaemonRpc, MoneroWalletRpc
55

66
from typing_extensions import override
7-
from utils import TestUtils as Utils
7+
from utils import TestUtils as Utils, OsUtils
88
from test_monero_wallet_common import BaseTestMoneroWallet
99

1010
logger: logging.Logger = logging.getLogger("TestMoneroWalletRpc")
1111

1212

13+
@pytest.mark.skipif(OsUtils.is_windows(), reason="TODO setup test environment for windows")
1314
class TestMoneroWalletRpc(BaseTestMoneroWallet):
1415

1516
_daemon: MoneroDaemonRpc = Utils.get_daemon_rpc()

tests/utils/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from .test_utils import TestUtils
22
from .mining_utils import MiningUtils
3+
from .os_utils import OsUtils
34
from .wallet_sync_printer import WalletSyncPrinter
45
from .connection_change_collector import ConnectionChangeCollector
56
from .address_book import AddressBook
@@ -16,6 +17,7 @@
1617
__all__ = [
1718
'TestUtils',
1819
'MiningUtils',
20+
'OsUtils',
1921
'WalletSyncPrinter',
2022
'ConnectionChangeCollector',
2123
'AddressBook',

0 commit comments

Comments
 (0)