feat(test): add Python test for binding to improve CI #18
Workflow file for this run
This file contains hidden or 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: Python | |
on: | |
pull_request: | |
jobs: | |
build_and_test: | |
name: Check everything builds & tests | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-13, windows-latest] | |
# Lowest and highest, no version specified so that | |
# new releases get automatically tested against | |
version: [{torch: torch==1.10, python: "3.8", arch: "x64"}, {torch: torch, python: "3.12", arch: "x64"}] | |
# TODO this would include macos ARM target. | |
# however jax has an illegal instruction issue | |
# that exists only in CI (probably difference in instruction support). | |
# include: | |
# - os: macos-latest | |
# version: | |
# torch: torch | |
# python: "3.11" | |
include: | |
- os: ubuntu-latest | |
version: | |
torch: torch | |
python: "3.13" | |
arch: "x64-freethreaded" | |
defaults: | |
run: | |
working-directory: ./binding/python | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
components: rustfmt, clippy | |
- name: Cargo install audit | |
run: cargo install cargo-audit | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: "binding/python" | |
- name: Lint with RustFmt | |
run: cargo fmt -- --check | |
- name: Lint with Clippy | |
run: cargo clippy --all-targets --all-features -- -D warnings | |
- name: Run Audit | |
run: cargo audit -D warnings | |
- name: Install Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.version.python }} | |
architecture: ${{ matrix.version.arch }} | |
- name: Install | |
run: | | |
pip install -U pip | |
pip install numpy | |
pip install . | |
- name: Install (torch) | |
if: matrix.version.arch != 'x64-freethreaded' | |
run: | | |
pip install ${{ matrix.version.torch }} | |
shell: bash | |
- name: Install (torch freethreaded) | |
if: matrix.version.arch == 'x64-freethreaded' | |
run: | | |
pip install ${{ matrix.version.torch }} --index-url https://download.pytorch.org/whl/cu126 | |
shell: bash | |
- name: Check style | |
run: | | |
pip install .[quality] | |
black --check --line-length 119 --target-version py35 py/bintensors | |
# TODO: uncomment this after adding formal pytest | |
- name: Run tests | |
run: | | |
cargo test | |
pip install .[testing] | |
pytest -sv tests/ |