Run tests in Python CI workflow

This commit is contained in:
thunderbiscuit 2023-03-01 10:52:02 -05:00
parent 488edf8bd2
commit 9c6069e389
No known key found for this signature in database
GPG Key ID: 88253696EB836462
4 changed files with 62 additions and 44 deletions

View File

@ -1,4 +1,4 @@
name: Build Python wheels name: Test Python
on: on:
push: push:
paths: paths:
@ -16,7 +16,7 @@ on:
jobs: jobs:
build-manylinux2014-x86_64-wheel: 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 runs-on: ubuntu-22.04
defaults: defaults:
run: run:
@ -34,29 +34,32 @@ jobs:
# - cp38-cp38 # - cp38-cp38
# - cp39-cp39 # - cp39-cp39
- cp310-cp310 - cp310-cp310
# - pp37-pypy37_pp73
# - pp38-pypy38_pp73
steps: steps:
- name: checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
submodules: true submodules: true
- uses: actions-rs/toolchain@v1 - uses: actions-rs/toolchain@v1
with: with:
toolchain: stable toolchain: stable
- name: install requirements
- name: Install requirements
run: ${PYBIN}/pip install -r requirements.txt run: ${PYBIN}/pip install -r requirements.txt
- name: generate bindings
- name: Generate bindings
run: bash generate.sh run: bash generate.sh
- name: build wheel
- name: Build wheel
run: ${PYBIN}/python setup.py bdist_wheel --verbose run: ${PYBIN}/python setup.py bdist_wheel --verbose
- uses: actions/upload-artifact@v2
with: - name: Install wheel
name: bdkpython-manylinux2014-x86_64-${{ matrix.python }} run: ${PYBIN}/pip install ./dist/*.whl
path: ./dist/*.whl
- name: Run tests
run: ${PYBIN}/python -m unittest tests/test_bdk.py --verbose
build-macos-universal-wheel: build-macos-universal-wheel:
name: 'Build macOS universal wheels' name: "Build and test macOS wheels"
runs-on: macos-12 runs-on: macos-12
defaults: defaults:
run: run:
@ -69,28 +72,34 @@ jobs:
# - '3.9' # - '3.9'
- '3.10' - '3.10'
steps: steps:
- name: checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
submodules: true submodules: true
- uses: actions/setup-python@v2 - uses: actions/setup-python@v2
with: with:
python-version: ${{ matrix.python }} python-version: ${{ matrix.python }}
- run: python3 --version
- run: rustup target add aarch64-apple-darwin - name: Generate bdk.py
- run: pip3 install --user -r requirements.txt run: |
- run: bash generate.sh python3 --version
- name: build wheel rustup target add aarch64-apple-darwin
pip3 install --user -r requirements.txt
bash generate.sh
- name: Build wheel
env: env:
ARCHFLAGS: "-arch x86_64 -arch arm64" ARCHFLAGS: "-arch x86_64 -arch arm64"
run: python3 setup.py bdist_wheel --verbose run: python3 setup.py bdist_wheel --verbose
- uses: actions/upload-artifact@v2
with: - name: Install wheel
name: bdkpython-macos-${{ matrix.python }} run: pip3 install ./dist/*.whl
path: /Users/runner/work/bdk-ffi/bdk-ffi/bdk-python/dist/*.whl
- name: Run tests
run: python3 -m unittest tests/test_bdk.py --verbose
build-windows-wheel: build-windows-wheel:
name: 'Build Windows wheels' name: "Build and test Windows wheels"
runs-on: windows-2022 runs-on: windows-2022
defaults: defaults:
run: run:
@ -103,19 +112,30 @@ jobs:
# - '3.9' # - '3.9'
- '3.10' - '3.10'
steps: steps:
- name: checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
submodules: true submodules: true
- uses: actions/setup-python@v2 - uses: actions/setup-python@v2
with: with:
python-version: ${{ matrix.python }} python-version: ${{ matrix.python }}
- run: python --version
- run: pip install --user -r requirements.txt - name: Generate bdk.py
- run: bash generate.sh run: |
- name: build wheel python --version
pip install --user -r requirements.txt
bash generate.sh
- name: Build wheel
run: python setup.py bdist_wheel --verbose run: python setup.py bdist_wheel --verbose
- uses: actions/upload-artifact@v2
with: # TODO: On Windows the pip install ./dist/*.whl step fails with the following error:
name: bdkpython-win-${{ matrix.python }} # Run pip install ./dist/*.whl
path: D:\a\bdk-ffi\bdk-ffi\bdk-python\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

View File

@ -11,9 +11,10 @@ pip install bdkpython
## Run the tests ## Run the tests
```shell ```shell
pip3 install --requirement requirements.txt pip install --requirement requirements.txt
bash ./generate.sh bash ./generate.sh
pip3 install ./dist/bdkpython-<yourversion>-py3-none-any.whl --force-reinstall python setup.py bdist_wheel --verbose
pip install ./dist/bdkpython-<yourversion>-py3-none-any.whl --force-reinstall
python -m unittest --verbose tests/test_bdk.py python -m unittest --verbose tests/test_bdk.py
``` ```
@ -22,11 +23,11 @@ python -m unittest --verbose tests/test_bdk.py
# Install dependencies # Install dependencies
pip install --requirement requirements.txt pip install --requirement requirements.txt
# Generate the bindings first # Generate the bindings
bash generate.sh bash generate.sh
# Build the wheel # Build the wheel
python3 setup.py --verbose bdist_wheel python setup.py --verbose bdist_wheel
``` ```
## Run tox to build and test locally ## Run tox to build and test locally
@ -34,7 +35,7 @@ python3 setup.py --verbose bdist_wheel
# install dev requirements # install dev requirements
pip install --requirement requirements-dev.txt 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 source ./generate.sh
# build and test # build and test

View File

@ -19,9 +19,6 @@ case $OS in
cp ../target/release-smaller/libbdkffi.so ../bdk-python/src/bdkpython/libbdkffi.so cp ../target/release-smaller/libbdkffi.so ../bdk-python/src/bdkpython/libbdkffi.so
;; ;;
esac esac
# echo "Bundling bdkpython..."
cd ../bdk-python/ cd ../bdk-python/
# python setup.py --verbose bdist_wheel
echo "All done!" echo "All done!"

View File

@ -10,7 +10,7 @@ deps =
-rrequirements.txt -rrequirements.txt
-rrequirements-dev.txt -rrequirements-dev.txt
commands = commands =
python3 setup.py -v build python3 setup.py build --verbose
python3 setup.py -v install python3 setup.py install --verbose
pytest --verbose --override-ini console_output_style=count pytest --verbose --override-ini console_output_style=count
python3 setup.py --verbose bdist_wheel python3 setup.py bdist_wheel --verbose