diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index 5155bc7e..c07479e8 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -11,8 +11,9 @@ on: jobs: build: strategy: + fail-fast: false matrix: - os: [macos-11, macos-12, ubuntu-20.04, ubuntu-22.04] + os: [macos-11, macos-12, macos-13, macos-14, ubuntu-20.04, ubuntu-22.04, ubuntu-24.04] runs-on: ${{ matrix.os }} steps: @@ -52,17 +53,22 @@ jobs: - name: Install Hatch run: | - python3 -m pip install --upgrade hatch + python3 -m venv /tmp/venv + /tmp/venv/bin/python3 -m pip install --upgrade hatch - name: Build source and wheel packages run: | - python3 -m hatch build + /tmp/venv/bin/python3 -m hatch build - name: Install the Python wheel run: | - python3 -m pip install dist/aleph_sdk_python-*.whl + /tmp/venv/bin/python3 -m pip install dist/aleph_sdk_python-*.whl + + - name: Install `setuptools` on systems where it is missing by default + run: /tmp/venv/bin/python3 -m pip install --upgrade setuptools + if: matrix.os == 'ubuntu-24.04' - name: Import and use the package run: | - python3 -c "import aleph.sdk" - python3 -c "from aleph.sdk.chains.ethereum import get_fallback_account; get_fallback_account()" + /tmp/venv/bin/python3 -c "import aleph.sdk" + /tmp/venv/bin/python3 -c "from aleph.sdk.chains.ethereum import get_fallback_account; get_fallback_account()" diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 79a3ac5b..16ec4e91 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -8,7 +8,7 @@ on: jobs: code-quality: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 @@ -16,10 +16,9 @@ jobs: - name: Workaround github issue https://github.com/actions/runner-images/issues/7192 run: sudo echo RESET grub-efi/install_devices | sudo debconf-communicate grub-pc - - name: Install pip and hatch + - name: Install system dependencies run: | - sudo apt-get install -y python3-pip - pip3 install hatch + sudo apt-get install -y python3-pip libsecp256k1-dev - name: Cache dependencies uses: actions/cache@v4 @@ -29,8 +28,10 @@ jobs: restore-keys: | ${{ runner.os }}-code-quality- - - name: Install required system packages only for Ubuntu Linux - run: sudo apt-get install -y libsecp256k1-dev + - name: Install python dependencies + run: | + python3 -m venv /tmp/venv + /tmp/venv/bin/pip install hatch - name: Run Hatch lint - run: hatch run linting:all + run: /tmp/venv/bin/hatch run linting:all diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 89c3dabd..efe667ea 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -2,13 +2,11 @@ name: Test/Coverage with Python on: push: - branches: - - main pull_request: branches: - main schedule: - # Run every night at 04:00 (GitHub Actions timezone) + # Run every night at 04:00 (GitHub Actions timezone) # in order to catch when unfrozen dependency updates # break the use of the library. - cron: '4 0 * * *' @@ -17,7 +15,7 @@ jobs: build: strategy: matrix: - python-version: [ "3.8", "3.9", "3.10", "3.11" ] + python-version: [ "3.9", "3.10", "3.11", "3.12" ] runs-on: ubuntu-latest steps: @@ -25,12 +23,22 @@ jobs: - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + - run: sudo apt-get install -y python3-pip libsecp256k1-dev - - run: python -m pip install --upgrade pip hatch coverage - - run: hatch run testing:test + + - run: | + python3 -m venv /tmp/venv + /tmp/venv/bin/python -m pip install --upgrade pip hatch coverage + + - run: | + /tmp/venv/bin/pip freeze + /tmp/venv/bin/hatch run testing:pip freeze + /tmp/venv/bin/hatch run testing:test if: matrix.python-version != '3.11' - - run: hatch run testing:cov + + - run: /tmp/venv/bin/hatch run testing:cov if: matrix.python-version == '3.11' + - uses: codecov/codecov-action@v4.0.1 if: matrix.python-version == '3.11' with: diff --git a/pyproject.toml b/pyproject.toml index f21f7ece..b7d7abc8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,7 +25,7 @@ dependencies = [ "aiohttp>=3.8.3", "aleph-message~=0.4.4", "coincurve; python_version<\"3.11\"", - "coincurve>=17.0.0; python_version>=\"3.11\"", + "coincurve>=19.0.0; python_version>=\"3.11\"", "eth_abi>=4.0.0; python_version>=\"3.11\"", "eth_account>=0.4.0,<0.11.0", "python-magic", @@ -67,13 +67,18 @@ tezos = [ "pynacl", ] encryption = [ - "eciespy; python_version<\"3.11\"", - "eciespy>=0.3.13; python_version>=\"3.11\"", + # Blocked by https://github.com/ecies/py/issues/356 + # "eciespy; python_version<'3.11'", + # "eciespy @ git+https://github.com/ecies/py.git@4b4256cde1d8acd773dff76fd8ab855a8e9faa4f#egg=eciespy; python_version>='3.11'" + "eciespy@git+https://github.com/ecies/py.git@4b4256cde1d8acd773dff76fd8ab855a8e9faa4f#egg=eciespy" ] all = [ "aleph-sdk-python[cosmos,dns,docs,ledger,mqtt,nuls2,polkadot,solana,tezos,encryption]", ] +[tool.hatch.metadata] +allow-direct-references = true + [project.urls] Documentation = "https://aleph.im/" Homepage = "https://github.com/aleph-im/aleph-sdk-python" @@ -231,4 +236,4 @@ exclude_lines = [ # Don't complain about ineffective code: "pass", -] \ No newline at end of file +] diff --git a/tests/unit/test_asynchronous.py b/tests/unit/test_asynchronous.py index f31274fd..0fa0df38 100644 --- a/tests/unit/test_asynchronous.py +++ b/tests/unit/test_asynchronous.py @@ -33,7 +33,7 @@ async def test_create_post(mock_session_with_post_success): sync=False, ) - assert mock_session_with_post_success.http_session.post.called_once + assert mock_session_with_post_success.http_session.post.assert_called_once assert isinstance(post_message, PostMessage) assert message_status == MessageStatus.PENDING @@ -47,7 +47,7 @@ async def test_create_aggregate(mock_session_with_post_success): channel="TEST", ) - assert mock_session_with_post_success.http_session.post.called_once + assert mock_session_with_post_success.http_session.post.assert_called_once assert isinstance(aggregate_message, AggregateMessage) @@ -83,7 +83,7 @@ async def test_create_store(mock_session_with_post_success): storage_engine=StorageEnum.storage, ) - assert mock_session_with_post_success.http_session.post.called + assert mock_session_with_post_success.http_session.post.assert_called assert isinstance(store_message, StoreMessage) @@ -98,7 +98,7 @@ async def test_create_program(mock_session_with_post_success): metadata={"tags": ["test"]}, ) - assert mock_session_with_post_success.http_session.post.called_once + assert mock_session_with_post_success.http_session.post.assert_called_once assert isinstance(program_message, ProgramMessage) @@ -118,7 +118,7 @@ async def test_create_instance(mock_session_with_post_success): hypervisor=HypervisorType.qemu, ) - assert mock_session_with_post_success.http_session.post.called_once + assert mock_session_with_post_success.http_session.post.assert_called_once assert isinstance(instance_message, InstanceMessage) @@ -139,7 +139,7 @@ async def test_create_instance_no_payment(mock_session_with_post_success): assert instance_message.content.payment.type == PaymentType.hold assert instance_message.content.payment.chain == Chain.ETH - assert mock_session_with_post_success.http_session.post.called_once + assert mock_session_with_post_success.http_session.post.assert_called_once assert isinstance(instance_message, InstanceMessage) @@ -159,7 +159,7 @@ async def test_create_instance_no_hypervisor(mock_session_with_post_success): assert instance_message.content.environment.hypervisor == HypervisorType.firecracker - assert mock_session_with_post_success.http_session.post.called_once + assert mock_session_with_post_success.http_session.post.assert_called_once assert isinstance(instance_message, InstanceMessage) @@ -172,7 +172,7 @@ async def test_forget(mock_session_with_post_success): channel="TEST", ) - assert mock_session_with_post_success.http_session.post.called_once + assert mock_session_with_post_success.http_session.post.assert_called_once assert isinstance(forget_message, ForgetMessage)