From 9c6069e389e34b8ebc917ee621c72b03b929460f Mon Sep 17 00:00:00 2001 From: thunderbiscuit Date: Wed, 1 Mar 2023 10:52:02 -0500 Subject: [PATCH] Run tests in Python CI workflow --- ...ld-python-wheels.yaml => test-python.yaml} | 86 ++++++++++++------- bdk-python/README.md | 11 +-- bdk-python/generate.sh | 3 - bdk-python/tox.ini | 6 +- 4 files changed, 62 insertions(+), 44 deletions(-) rename .github/workflows/{build-python-wheels.yaml => test-python.yaml} (59%) diff --git a/.github/workflows/build-python-wheels.yaml b/.github/workflows/test-python.yaml similarity index 59% rename from .github/workflows/build-python-wheels.yaml rename to .github/workflows/test-python.yaml index 184dc58..938fddd 100644 --- a/.github/workflows/build-python-wheels.yaml +++ b/.github/workflows/test-python.yaml @@ -1,4 +1,4 @@ -name: Build Python wheels +name: Test Python on: push: paths: @@ -16,7 +16,7 @@ on: jobs: build-manylinux2014-x86_64-wheel: - name: 'Build Manylinux 2014 x86_64 wheels' + name: "Build and test Manylinux 2014 x86_64 wheels" runs-on: ubuntu-22.04 defaults: run: @@ -34,29 +34,32 @@ jobs: # - cp38-cp38 # - cp39-cp39 - cp310-cp310 - # - pp37-pypy37_pp73 - # - pp38-pypy38_pp73 steps: - - name: checkout + - name: Checkout uses: actions/checkout@v2 with: submodules: true - uses: actions-rs/toolchain@v1 with: toolchain: stable - - name: install requirements + + - name: Install requirements run: ${PYBIN}/pip install -r requirements.txt - - name: generate bindings + + - name: Generate bindings run: bash generate.sh - - name: build wheel + + - name: Build wheel run: ${PYBIN}/python setup.py bdist_wheel --verbose - - uses: actions/upload-artifact@v2 - with: - name: bdkpython-manylinux2014-x86_64-${{ matrix.python }} - path: ./dist/*.whl + + - name: Install wheel + run: ${PYBIN}/pip install ./dist/*.whl + + - name: Run tests + run: ${PYBIN}/python -m unittest tests/test_bdk.py --verbose build-macos-universal-wheel: - name: 'Build macOS universal wheels' + name: "Build and test macOS wheels" runs-on: macos-12 defaults: run: @@ -69,28 +72,34 @@ jobs: # - '3.9' - '3.10' steps: - - name: checkout + - name: Checkout uses: actions/checkout@v2 with: submodules: true - uses: actions/setup-python@v2 with: python-version: ${{ matrix.python }} - - run: python3 --version - - run: rustup target add aarch64-apple-darwin - - run: pip3 install --user -r requirements.txt - - run: bash generate.sh - - name: build wheel + + - name: Generate bdk.py + run: | + python3 --version + rustup target add aarch64-apple-darwin + pip3 install --user -r requirements.txt + bash generate.sh + + - name: Build wheel env: ARCHFLAGS: "-arch x86_64 -arch arm64" run: python3 setup.py bdist_wheel --verbose - - uses: actions/upload-artifact@v2 - with: - name: bdkpython-macos-${{ matrix.python }} - path: /Users/runner/work/bdk-ffi/bdk-ffi/bdk-python/dist/*.whl + + - name: Install wheel + run: pip3 install ./dist/*.whl + + - name: Run tests + run: python3 -m unittest tests/test_bdk.py --verbose build-windows-wheel: - name: 'Build Windows wheels' + name: "Build and test Windows wheels" runs-on: windows-2022 defaults: run: @@ -103,19 +112,30 @@ jobs: # - '3.9' - '3.10' steps: - - name: checkout + - name: Checkout uses: actions/checkout@v2 with: submodules: true - uses: actions/setup-python@v2 with: python-version: ${{ matrix.python }} - - run: python --version - - run: pip install --user -r requirements.txt - - run: bash generate.sh - - name: build wheel + + - name: Generate bdk.py + run: | + python --version + pip install --user -r requirements.txt + bash generate.sh + + - name: Build wheel run: python setup.py bdist_wheel --verbose - - uses: actions/upload-artifact@v2 - with: - name: bdkpython-win-${{ matrix.python }} - path: D:\a\bdk-ffi\bdk-ffi\bdk-python\dist\*.whl + + # TODO: On Windows the pip install ./dist/*.whl step fails with the following error: + # Run pip install ./dist/*.whl + # WARNING: Requirement './dist/*.whl' looks like a filename, but the file does not exist + # ERROR: *.whl is not a valid wheel filename.*.whl is not a valid wheel name + # So we skip the installing and the tests and simply test that the wheel builds + + # - name: Install wheel + # run: pip install ./dist/*.whl + # - name: Run tests + # run: python -m unittest tests/test_bdk.py --verbose diff --git a/bdk-python/README.md b/bdk-python/README.md index 33f2105..45cf3c6 100644 --- a/bdk-python/README.md +++ b/bdk-python/README.md @@ -11,9 +11,10 @@ pip install bdkpython ## Run the tests ```shell -pip3 install --requirement requirements.txt +pip install --requirement requirements.txt bash ./generate.sh -pip3 install ./dist/bdkpython--py3-none-any.whl --force-reinstall +python setup.py bdist_wheel --verbose +pip install ./dist/bdkpython--py3-none-any.whl --force-reinstall python -m unittest --verbose tests/test_bdk.py ``` @@ -22,11 +23,11 @@ python -m unittest --verbose tests/test_bdk.py # Install dependencies pip install --requirement requirements.txt -# Generate the bindings first +# Generate the bindings bash generate.sh # Build the wheel -python3 setup.py --verbose bdist_wheel +python setup.py --verbose bdist_wheel ``` ## Run tox to build and test locally @@ -34,7 +35,7 @@ python3 setup.py --verbose bdist_wheel # install dev requirements pip install --requirement requirements-dev.txt -# build bindings glue code (located at .bdk-python/src/bdkpython/bdk.py) +# build bindings glue code (located at ./src/bdkpython/bdk.py) source ./generate.sh # build and test diff --git a/bdk-python/generate.sh b/bdk-python/generate.sh index d3dafca..90a5f65 100644 --- a/bdk-python/generate.sh +++ b/bdk-python/generate.sh @@ -19,9 +19,6 @@ case $OS in cp ../target/release-smaller/libbdkffi.so ../bdk-python/src/bdkpython/libbdkffi.so ;; esac - -# echo "Bundling bdkpython..." cd ../bdk-python/ -# python setup.py --verbose bdist_wheel echo "All done!" diff --git a/bdk-python/tox.ini b/bdk-python/tox.ini index c01a149..32ced94 100644 --- a/bdk-python/tox.ini +++ b/bdk-python/tox.ini @@ -10,7 +10,7 @@ deps = -rrequirements.txt -rrequirements-dev.txt commands = - python3 setup.py -v build - python3 setup.py -v install + python3 setup.py build --verbose + python3 setup.py install --verbose pytest --verbose --override-ini console_output_style=count - python3 setup.py --verbose bdist_wheel + python3 setup.py bdist_wheel --verbose