name: CI
on:
push:
branches:
- master
pull_request:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
components: rustfmt, clippy
- run: |
cargo fmt --all -- --check
cargo clippy --tests
for example in examples/*; do (cd $example/; cargo clippy) || exit 1; done
test:
name: python${{ matrix.python-version }}-${{ matrix.platform.python-architecture }} ${{ matrix.platform.os }}
runs-on: ${{ matrix.platform.os }}
strategy:
max-parallel: 16
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
platform: [
{ os: "ubuntu-latest", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu" },
{ os: "macOS-latest", python-architecture: "x64", rust-target: "x86_64-apple-darwin" },
{ os: "windows-latest", python-architecture: "x64", rust-target: "x86_64-pc-windows-msvc" },
{ os: "windows-latest", python-architecture: "x86", rust-target: "i686-pc-windows-msvc" },
]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
- run: rustup set default-host ${{ matrix.platform.rust-target }}
- name: Build without default features
run: cargo build --no-default-features --verbose
- name: Build with default features
run: cargo build --verbose
- name: Install test dependencies
run: |
python -m pip install --upgrade pip
pip install maturin numpy poetry
- name: Run cargo test
run: cargo test --verbose
- name: Test Examples
run: |
for example_dir in 'examples/simple-extension'; do
pushd $example_dir && \
poetry install && \
poetry run maturin develop && \
poetry run pytest && \
popd
done
shell: bash
env:
RUST_BACKTRACE: 1
check-msrv:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install MSRV Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.41.1
- name: Install maturin, poetry, and toml
run: pip install maturin poetry toml
- name: Create an isolated example directory
run: cp -r examples/simple-extension/ ../simple-extension-msrv
- name: Edit Cargo.toml
run: |
import toml
cargo_toml = toml.load("Cargo.toml")
cargo_toml["dependencies"]["ndarray"] = "0.13.1"
cargo_toml["dependencies"]["num-complex"] = "0.2.4"
cargo_toml["dependencies"]["numpy"]["path"] = "../rust-numpy"
with open("Cargo.toml", "w") as f:
toml.dump(cargo_toml, f)
working-directory: ../simple-extension-msrv
shell: python
- name: Remove ndarray 0.14.0
run: cargo update -p ndarray:0.14.0 --precise 0.13.1
working-directory: ../simple-extension-msrv
- name: Test Example
run: |
poetry install && poetry run maturin develop && poetry run pytest
working-directory: ../simple-extension-msrv
shell: bash
linalg-example:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install gfortran
run: |
sudo apt install -y gfortran
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Install maturin and poetry
run: pip install maturin poetry
- name: Test Examples
run: |
cd examples/linalg && \
poetry install && \
poetry run maturin develop && \
poetry run pytest