diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index 6927224..94086cf 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -103,9 +103,11 @@ jobs: -DPython3_FIND_REGISTRY=NEVER cmake --build . mkdir -p ../dist + cp ../external/monero-cpp/build/libmonero-cpp.dll ../dist cp *.pyd ../dist/monero.pyd + cd ../dist ntldd -R *.pyd | grep mingw64 | awk '{print $3}' | while read -r line; do - cp "$(cygpath -u "$line")" ../dist/ + cp "$(cygpath -u "$line")" . done - name: Upload artifacts diff --git a/.github/workflows/codacy.yml b/.github/workflows/codacy.yml index e465d6f..f31015b 100644 --- a/.github/workflows/codacy.yml +++ b/.github/workflows/codacy.yml @@ -49,40 +49,39 @@ jobs: language: c coverage-reports: coverage.info -# TODO build docker monero image for windows -# report-coverage-windows: -# if: github.repository == 'everoddandeven/monero-python' -# runs-on: ubuntu-latest -# steps: -# - name: Checkout code -# uses: actions/checkout@v4 -# with: -# fetch-depth: 0 + report-coverage-windows: + if: github.repository == 'everoddandeven/monero-python' + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 -# - name: Download coverage report -# uses: actions/download-artifact@v4 -# with: -# name: coverage-reports-windows -# github-token: ${{ secrets.API_GITHUB }} -# run-id: ${{ github.event.workflow_run.id }} + - name: Download coverage report + uses: actions/download-artifact@v4 + with: + name: coverage-reports-windows + github-token: ${{ secrets.API_GITHUB }} + run-id: ${{ github.event.workflow_run.id }} -# - name: Report python coverage -# uses: codacy/codacy-coverage-reporter-action@v1 -# with: -# project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} -# language: python -# coverage-reports: coverage.xml + - name: Report python coverage + uses: codacy/codacy-coverage-reporter-action@v1 + with: + project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} + language: python + coverage-reports: coverage.xml -# - name: Report c++ coverage -# uses: codacy/codacy-coverage-reporter-action@v1 -# with: -# project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} -# language: cpp -# coverage-reports: coverage.info + - name: Report c++ coverage + uses: codacy/codacy-coverage-reporter-action@v1 + with: + project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} + language: cpp + coverage-reports: coverage.info -# - name: Report c coverage -# uses: codacy/codacy-coverage-reporter-action@v1 -# with: -# project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} -# language: c -# coverage-reports: coverage.info + - name: Report c coverage + uses: codacy/codacy-coverage-reporter-action@v1 + with: + project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} + language: c + coverage-reports: coverage.info diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f41058b..9ef3597 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -140,7 +140,7 @@ jobs: - name: Install pytest shell: bash run: | - python -m pip install pytest pytest-rerunfailures pytest-cov gcovr + python -m pip install pytest pytest-rerunfailures pytest-cov gcovr typing_extensions - name: Setup MSYS2 MINGW64 uses: msys2/setup-msys2@v2 @@ -227,9 +227,11 @@ jobs: -DPython3_FIND_REGISTRY=NEVER cmake --build . mkdir -p ../dist + cp ../external/monero-cpp/build/libmonero-cpp.dll ../dist cp *.pyd ../dist/monero.pyd + cd ../dist ntldd -R *.pyd | grep mingw64 | awk '{print $3}' | while read -r line; do - cp "$(cygpath -u "$line")" ../dist/ + cp "$(cygpath -u "$line")" . done cd .. @@ -239,29 +241,29 @@ jobs: # run: | # docker compose -f tests/docker-compose.yml up -d node_1 node_2 xmr_wallet_1 xmr_wallet_2 -# - name: Run tests -# shell: bash -# env: -# IN_CONTAINER: "true" -# PYTHONPATH: ${{ github.workspace }}/dist -# PATH: "${{ github.workspace }}/dist:/usr/bin:$PATH" -# run: | -# python -m pytest --cov=tests --cov-report=xml + - name: Run tests + shell: bash + env: + IN_CONTAINER: "true" + PYTHONPATH: ${{ github.workspace }}/dist + PATH: "${{ github.workspace }}/dist:/usr/bin:$PATH" + run: | + python -m pytest --cov=tests --cov-report=xml # - name: Cleanup test environment # if: always() # shell: bash # run: docker compose -f tests/docker-compose.yml down -v -# - name: Generate coverage report -# shell: bash -# run: | -# gcovr -r . --filter src/ --lcov coverage.info - -# - name: Upload coverage report -# uses: actions/upload-artifact@v4 -# with: -# name: coverage-reports-windows -# path: | -# coverage.info -# coverage.xml + - name: Generate coverage report + shell: bash + run: | + gcovr -r . --filter src/ --lcov coverage.info + + - name: Upload coverage report + uses: actions/upload-artifact@v4 + with: + name: coverage-reports-windows + path: | + coverage.info + coverage.xml diff --git a/tests/test_monero_daemon_rpc.py b/tests/test_monero_daemon_rpc.py index e320968..913ec26 100644 --- a/tests/test_monero_daemon_rpc.py +++ b/tests/test_monero_daemon_rpc.py @@ -11,22 +11,29 @@ MoneroHardForkInfo, MoneroAltChain, MoneroTx, MoneroSubmitTxResult, MoneroTxPoolStats, MoneroBan, MoneroTxConfig, MoneroDestination ) -from utils import TestUtils as Utils, TestContext, BinaryBlockContext, MiningUtils +from utils import ( + TestUtils as Utils, TestContext, + BinaryBlockContext, MiningUtils, + OsUtils +) logger: logging.Logger = logging.getLogger("TestMoneroDaemonRpc") +@pytest.mark.skipif(OsUtils.is_windows(), reason="TODO setup test environment for windows") class TestMoneroDaemonRpc: _daemon: MoneroDaemonRpc = Utils.get_daemon_rpc() - _wallet: MoneroWallet = Utils.get_wallet_rpc() + _wallet: MoneroWallet = Utils.get_wallet_rpc() # type: ignore BINARY_BLOCK_CTX: BinaryBlockContext = BinaryBlockContext() #region Fixtures @pytest.fixture(scope="class", autouse=True) def before_all(self): - MiningUtils.wait_until_blockchain_ready() - MiningUtils.try_stop_mining() + # TODO setup test environment for windows + if not OsUtils.is_windows(): + MiningUtils.wait_until_blockchain_ready() + MiningUtils.try_stop_mining() @pytest.fixture(autouse=True) def before_each(self, request: pytest.FixtureRequest): diff --git a/tests/test_monero_rpc_connection.py b/tests/test_monero_rpc_connection.py index d95fa32..2f31043 100644 --- a/tests/test_monero_rpc_connection.py +++ b/tests/test_monero_rpc_connection.py @@ -2,11 +2,12 @@ import logging from monero import MoneroRpcConnection -from utils import TestUtils as Utils +from utils import TestUtils as Utils, OsUtils logger: logging.Logger = logging.getLogger("TestMoneroRpcConnection") +@pytest.mark.skipif(OsUtils.is_windows(), reason="TODO setup test environment for windows") class TestMoneroRpcConnection: @pytest.fixture(autouse=True) diff --git a/tests/test_monero_wallet_common.py b/tests/test_monero_wallet_common.py index a21bd0c..2abfeba 100644 --- a/tests/test_monero_wallet_common.py +++ b/tests/test_monero_wallet_common.py @@ -11,7 +11,7 @@ MoneroTxConfig, MoneroDestination, MoneroRpcConnection, MoneroError, MoneroKeyImage, MoneroTxQuery, MoneroUtils, MoneroWalletFull ) -from utils import TestUtils, WalletEqualityUtils, MiningUtils +from utils import TestUtils, WalletEqualityUtils, MiningUtils, OsUtils logger: logging.Logger = logging.getLogger("TestMoneroWalletCommon") @@ -86,8 +86,10 @@ def test_config(self) -> BaseTestMoneroWallet.Config: @pytest.fixture(scope="class", autouse=True) def before_all(self): - MiningUtils.wait_until_blockchain_ready() - MiningUtils.try_stop_mining() + # TODO setup test environment for windows + if not OsUtils.is_windows(): + MiningUtils.wait_until_blockchain_ready() + MiningUtils.try_stop_mining() @pytest.fixture(autouse=True) def before_each(self, request: pytest.FixtureRequest): diff --git a/tests/test_monero_wallet_full.py b/tests/test_monero_wallet_full.py index 90662f3..847d74b 100644 --- a/tests/test_monero_wallet_full.py +++ b/tests/test_monero_wallet_full.py @@ -8,12 +8,13 @@ MoneroSubaddress, MoneroDaemonRpc, MoneroWallet ) -from utils import TestUtils as Utils +from utils import TestUtils as Utils, OsUtils from test_monero_wallet_common import BaseTestMoneroWallet logger: logging.Logger = logging.getLogger("TestMoneroWalletFull") +@pytest.mark.skipif(OsUtils.is_windows(), reason="TODO setup test environment for windows") class TestMoneroWalletFull(BaseTestMoneroWallet): _daemon: MoneroDaemonRpc = Utils.get_daemon_rpc() diff --git a/tests/test_monero_wallet_keys.py b/tests/test_monero_wallet_keys.py index 376e2fc..90ab9c7 100644 --- a/tests/test_monero_wallet_keys.py +++ b/tests/test_monero_wallet_keys.py @@ -27,6 +27,11 @@ def before_each(self, request: pytest.FixtureRequest): yield logger.info(f"After test {request.node.name}") # type: ignore + @pytest.fixture(scope="class", autouse=True) + @override + def before_all(self): + pass + #region Overrides @classmethod diff --git a/tests/test_monero_wallet_rpc.py b/tests/test_monero_wallet_rpc.py index 9a6596c..5fc58b3 100644 --- a/tests/test_monero_wallet_rpc.py +++ b/tests/test_monero_wallet_rpc.py @@ -4,12 +4,13 @@ from monero import MoneroWallet, MoneroWalletConfig, MoneroDaemonRpc, MoneroWalletRpc from typing_extensions import override -from utils import TestUtils as Utils +from utils import TestUtils as Utils, OsUtils from test_monero_wallet_common import BaseTestMoneroWallet logger: logging.Logger = logging.getLogger("TestMoneroWalletRpc") +@pytest.mark.skipif(OsUtils.is_windows(), reason="TODO setup test environment for windows") class TestMoneroWalletRpc(BaseTestMoneroWallet): _daemon: MoneroDaemonRpc = Utils.get_daemon_rpc() diff --git a/tests/utils/__init__.py b/tests/utils/__init__.py index 8868132..b41f406 100644 --- a/tests/utils/__init__.py +++ b/tests/utils/__init__.py @@ -1,5 +1,6 @@ from .test_utils import TestUtils from .mining_utils import MiningUtils +from .os_utils import OsUtils from .wallet_sync_printer import WalletSyncPrinter from .connection_change_collector import ConnectionChangeCollector from .address_book import AddressBook @@ -16,6 +17,7 @@ __all__ = [ 'TestUtils', 'MiningUtils', + 'OsUtils', 'WalletSyncPrinter', 'ConnectionChangeCollector', 'AddressBook', diff --git a/tests/utils/os_utils.py b/tests/utils/os_utils.py new file mode 100644 index 0000000..e5e28c8 --- /dev/null +++ b/tests/utils/os_utils.py @@ -0,0 +1,9 @@ +import sys +from abc import ABC + + +class OsUtils(ABC): + + @classmethod + def is_windows(cls) -> bool: + return sys.platform == 'win32' diff --git a/tests/utils/test_utils.py b/tests/utils/test_utils.py index b5e28a4..9fd62df 100644 --- a/tests/utils/test_utils.py +++ b/tests/utils/test_utils.py @@ -23,6 +23,7 @@ from .test_context import TestContext from .tx_context import TxContext from .binary_block_context import BinaryBlockContext +from .os_utils import OsUtils logger: logging.Logger = logging.getLogger("TestUtils") @@ -300,6 +301,9 @@ def create_test_wallets_dir(cls) -> None: @classmethod def get_daemon_rpc(cls) -> MoneroDaemonRpc: + if OsUtils.is_windows(): # TODO enable windows integration test env + return None # type: ignore + if cls._DAEMON_RPC is None: cls._DAEMON_RPC = MoneroDaemonRpc(cls.DAEMON_RPC_URI, cls.DAEMON_RPC_USERNAME, cls.DAEMON_RPC_PASSWORD) @@ -334,6 +338,9 @@ def get_wallet_full_config(cls, daemon_connection: MoneroRpcConnection) -> Moner @classmethod def get_wallet_full(cls) -> MoneroWalletFull: + if OsUtils.is_windows(): # TODO enable windows integration test env + return None # type: ignore + if cls._WALLET_FULL is None: # create wallet from seed if it doesn't exist if not MoneroWalletFull.wallet_exists(cls.WALLET_FULL_PATH): @@ -371,6 +378,9 @@ def get_wallet_full(cls) -> MoneroWalletFull: @classmethod def get_wallet_rpc(cls) -> MoneroWalletRpc: + if OsUtils.is_windows(): # TODO enable windows integration test env + return None # type: ignore + if cls._WALLET_RPC is None: # construct wallet rpc instance with daemon connection