Switch to PyO3/maturin-action #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: tests | |
on: | |
push: | |
branches: | |
- "*" | |
pull_request: | |
jobs: | |
rust_impl: | |
name: "Rust impl: ${{ matrix.python-version }}, ${{ matrix.rust-toolchain }}, ${{ matrix.platform.name }}" | |
runs-on: ${{ matrix.platform.os }} | |
strategy: | |
matrix: | |
# This list needs to be kept in sync with: | |
# - tag.yml | |
# - maturin_build_wheel.py | |
# - the c_impl tests below | |
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] | |
rust-toolchain: [stable, beta, nightly] | |
platform: [ | |
# This list should be kept in sync with tag.yml. | |
{ os: "ubuntu-latest", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu", name: "Linux x64" }, | |
# macOS-latest is currently broken by https://github.com/actions/setup-python/issues/855 | |
{ os: "macOS-13", python-architecture: "x64", rust-target: "x86_64-apple-darwin", name: "macOS x64" }, | |
{ os: "macOS-11", python-architecture: "x64", rust-target: "aarch64-apple-darwin", name: "macOS ARM" }, | |
{ os: "windows-latest", python-architecture: "x86", rust-target: "i686-pc-windows-msvc", name: "Windows x86" }, | |
{ os: "windows-latest", python-architecture: "x64", rust-target: "x86_64-pc-windows-msvc", name: "Windows x64" }, | |
] | |
exclude: | |
# aarch64 macOS has no support for Python version lower than 3.8 | |
- python-version: 3.7 | |
platform: | |
os: "macOS-11" | |
rust-target: "aarch64-apple-darwin" | |
fail-fast: false | |
env: | |
CARGO_BUILD_TARGET: ${{ matrix.platform.rust-target }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
architecture: ${{ matrix.platform.python-architecture }} | |
- run: python tests/python_info.py | |
- name: Set up Rust | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ matrix.rust-toolchain }} | |
target: ${{ matrix.platform.rust-target }} | |
# We use numpy to test the error case of trying to hash a strided buffer. | |
- name: Install pytest and numpy | |
run: pip install pytest numpy | |
- name: Build and install the blake3 module | |
run: pip install . | |
- name: Run pytest | |
if: ${{ matrix.platform.rust-target != 'aarch64-apple-darwin' }} | |
run: python -u -m pytest --verbose | |
c_impl: | |
name: "C impl: ${{ matrix.python-version }}, ${{ matrix.platform.name }}" | |
runs-on: ${{ matrix.platform.os }} | |
strategy: | |
matrix: | |
# This list needs to be kept in sync with: | |
# - tag.yml | |
# - maturin_build_wheel.py | |
# - the rust_impl tests above | |
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
platform: [ | |
# This list should be kept in sync with tag.yml. | |
{ os: "ubuntu-latest", python-architecture: "x64", name: "Linux x64" }, | |
# macOS-latest is currently broken by https://github.com/actions/setup-python/issues/855 | |
{ os: "macOS-13", python-architecture: "x64", name: "macOS x64" }, | |
{ os: "windows-latest", python-architecture: "x86", name: "Windows x86" }, | |
{ os: "windows-latest", python-architecture: "x64", name: "Windows x64" }, | |
] | |
fail-fast: false | |
env: | |
CARGO_BUILD_TARGET: ${{ matrix.platform.rust-target }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
architecture: ${{ matrix.platform.python-architecture }} | |
- run: python tests/python_info.py | |
- run: pip install --upgrade setuptools | |
- name: build the C extension | |
run: python setup.py build | |
working-directory: c_impl | |
- run: git clean -dffx | |
- name: build the C extension with FORCE_INTRINSICS | |
run: python setup.py build | |
working-directory: c_impl | |
env: | |
FORCE_INTRINSICS: "1" | |
- run: git clean -dffx | |
- name: install the C extension | |
run: pip install . | |
working-directory: c_impl | |
- name: test import, __version__, __file__ | |
run: python -c "import blake3; print(blake3.__version__); print(blake3.__file__)" | |
# We use numpy to test the error case of trying to hash a strided buffer. | |
- name: Install pytest and numpy | |
run: pip install pytest numpy | |
- name: Run pytest | |
run: python -u -m pytest --verbose | |
mypy: | |
name: "mypy" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.12" | |
# We use numpy to test the error case of trying to hash a strided buffer. | |
- name: Install pytest, numpy, and mypy | |
run: pip install pytest numpy mypy | |
- name: Run mypy | |
run: python -u -m mypy --strict tests/test_blake3.py |