name: CI
on:
push:
branches:
- main
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
components: rustfmt, clippy
default: true
- uses: Swatinem/rust-cache@v1
continue-on-error: true
- run: |
cargo fmt --all -- --check
cargo clippy --workspace --tests -- --deny warnings
test:
name: python${{ matrix.python-version }}-${{ matrix.platform.python-architecture }} ${{ matrix.platform.os }}
runs-on: ${{ matrix.platform.os }}
needs: [lint, check-msrv, examples]
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
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" },
]
include:
- python-version: pypy-3.7
platform: { os: "ubuntu-latest", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu" }
- python-version: pypy-3.8
platform: { os: "ubuntu-latest", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu" }
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.platform.python-architecture }}
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
target: ${{ matrix.platform.rust-target }}
default: true
- name: Install toml
run: pip install toml
- name: Edit Cargo.toml and enable new resolver
run: |
import toml
cargo_toml = toml.load("Cargo.toml")
cargo_toml["workspace"]["resolver"] = "2"
with open("Cargo.toml", "w") as f:
toml.dump(cargo_toml, f)
shell: python
- name: Test
run: |
pip install numpy
cargo test
if: ${{ !startsWith(matrix.python-version, 'pypy') }}
- name: Test example
run: |
pip install nox
nox -f examples/simple/noxfile.py
env:
CARGO_TERM_VERBOSE: true
CARGO_BUILD_TARGET: ${{ matrix.platform.rust-target }}
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 Rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.48.0
profile: minimal
default: true
- uses: Swatinem/rust-cache@v1
with:
working-directory: examples/simple
continue-on-error: true
- name: Install toml
run: pip install toml
- name: Edit Cargo.toml and detach from workspace
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["workspace"] = {}
with open("Cargo.toml", "w") as f:
toml.dump(cargo_toml, f)
working-directory: examples/simple
shell: python
- name: Generate lockfile
run: cargo generate-lockfile
working-directory: examples/simple
- name: Unify dependencies on ndarray to 0.13.1
run: |
import toml
import subprocess
cargo_lock = toml.load("Cargo.lock")
for pkg in cargo_lock["package"]:
if pkg["name"] == "ndarray" and pkg["version"] != "0.13.1":
pkg_id = pkg["name"] + ":" + pkg["version"]
subprocess.run(["cargo", "update", "--package", pkg_id, "--precise", "0.13.1"], check=True)
working-directory: examples/simple
shell: python
- name: Test example
run: |
pip install nox
nox -f examples/simple/noxfile.py
examples:
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 OpenBLAS
run: sudo apt install --yes libopenblas-dev
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
default: true
- uses: Swatinem/rust-cache@v1
continue-on-error: true
- name: Test examples
run: |
pip install nox
nox -f examples/linalg/noxfile.py
nox -f examples/parallel/noxfile.py
coverage:
runs-on: ubuntu-latest
needs: [lint, check-msrv, examples]
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
architecture: x64
- name: Install numpy
run: pip install numpy
- uses: Swatinem/rust-cache@v1
continue-on-error: true
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
profile: minimal
components: llvm-tools-preview
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Generate code coverage
run: cargo llvm-cov --lcov --output-path coverage.lcov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
file: coverage.lcov
fail_ci_if_error: true