211 lines
7.7 KiB
YAML
211 lines
7.7 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
jobs:
|
|
fmt:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- uses: actions/setup-python@v2
|
|
- run: pip install black==20.8b1
|
|
- uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
profile: minimal
|
|
components: rustfmt
|
|
- name: Check python formatting (black)
|
|
run: black --check .
|
|
- name: Check rust formatting (rustfmt)
|
|
run: cargo fmt --all -- --check
|
|
|
|
clippy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
profile: minimal
|
|
components: clippy
|
|
- run: make clippy
|
|
|
|
build:
|
|
needs: [fmt] # don't wait for clippy as fails rarely and takes longer
|
|
name: python${{ matrix.python-version }}-${{ matrix.platform.python-architecture }} ${{ matrix.platform.os }} ${{ matrix.msrv }}
|
|
runs-on: ${{ matrix.platform.os }}
|
|
strategy:
|
|
fail-fast: false # If one platform fails, allow the rest to keep testing.
|
|
matrix:
|
|
rust: [stable]
|
|
python-version: [3.6, 3.7, 3.8, 3.9, 3.10-dev, pypy-3.6, pypy-3.7]
|
|
platform: [
|
|
{ os: "macOS-latest", python-architecture: "x64", rust-target: "x86_64-apple-darwin" },
|
|
{ os: "ubuntu-latest", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu" },
|
|
{ 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" },
|
|
]
|
|
exclude:
|
|
# There is no 64-bit pypy on windows for pypy-3.6
|
|
- python-version: pypy-3.6
|
|
platform: { os: "windows-latest", python-architecture: "x64" }
|
|
# pypy on windows for pypy-3.7 coming in next PyPy release
|
|
- python-version: pypy-3.7
|
|
platform: { os: "windows-latest", python-architecture: "x64" }
|
|
include:
|
|
# Test minimal supported Rust version
|
|
- rust: 1.41.1
|
|
python-version: 3.9
|
|
platform: { os: "ubuntu-latest", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu" }
|
|
msrv: "MSRV"
|
|
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
# macOS: install gnu-tar because BSD tar is buggy for github actions
|
|
# https://github.com/actions/cache/issues/403
|
|
- name: Install GNU tar (Macos)
|
|
if: matrix.os == 'macOS-latest'
|
|
run: |
|
|
brew install gnu-tar
|
|
echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH
|
|
|
|
- uses: actions/cache@v2
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
target
|
|
key: ${{ matrix.python-version }}-${{ matrix.platform.python-architecture }}-${{ matrix.platform.os }}-${{ matrix.msrv }}-cargo-${{ hashFiles('**/Cargo.toml') }}
|
|
|
|
- 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 toolchain
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: ${{ matrix.rust }}
|
|
target: ${{ matrix.platform.rust-target }}
|
|
profile: minimal
|
|
default: true
|
|
|
|
- if: matrix.platform.os == 'ubuntu-latest'
|
|
name: Prepare LD_LIBRARY_PATH (Ubuntu only)
|
|
run: echo LD_LIBRARY_PATH=${pythonLocation}/lib >> $GITHUB_ENV
|
|
|
|
- name: Prepare workflow settings
|
|
id: settings
|
|
shell: bash
|
|
run: |
|
|
echo "::set-output name=all_additive_features::macros num-bigint num-complex hashbrown serde multiple-pymethods"
|
|
|
|
- if: matrix.msrv == 'MSRV'
|
|
name: Prepare minimal package versions (MSRV only)
|
|
run: cargo update -p hashbrown --precise 0.9.1
|
|
|
|
- name: Build docs
|
|
run: cargo doc --no-deps --no-default-features --features "${{ steps.settings.outputs.all_additive_features }}"
|
|
|
|
- name: Build (no features)
|
|
run: cargo build --lib --tests --no-default-features
|
|
|
|
# Run tests (except on PyPy, because no embedding API).
|
|
- if: ${{ !startsWith(matrix.python-version, 'pypy') }}
|
|
name: Test (no features)
|
|
run: cargo test --no-default-features
|
|
|
|
- name: Build (all additive features)
|
|
run: cargo build --lib --tests --no-default-features --features "${{ steps.settings.outputs.all_additive_features }}"
|
|
|
|
# Run tests (except on PyPy, because no embedding API).
|
|
- if: ${{ !startsWith(matrix.python-version, 'pypy') }}
|
|
name: Test
|
|
run: cargo test --no-default-features --features "${{ steps.settings.outputs.all_additive_features }}"
|
|
|
|
# Run tests again, but in abi3 mode
|
|
- if: ${{ !startsWith(matrix.python-version, 'pypy') }}
|
|
name: Test (abi3)
|
|
run: cargo test --no-default-features --features "abi3 ${{ steps.settings.outputs.all_additive_features }}"
|
|
|
|
# Run tests again, for abi3-py36 (the minimal Python version)
|
|
- if: ${{ (!startsWith(matrix.python-version, 'pypy')) && (matrix.python-version != '3.6') }}
|
|
name: Test (abi3-py36)
|
|
run: cargo test --no-default-features --features "abi3-py36 ${{ steps.settings.outputs.all_additive_features }}"
|
|
|
|
- name: Test proc-macro code
|
|
run: cargo test --manifest-path=pyo3-macros-backend/Cargo.toml
|
|
|
|
- name: Install python test dependencies
|
|
run: python -m pip install -U pip tox
|
|
|
|
- name: Test example extension modules
|
|
shell: bash
|
|
run: |
|
|
for example_dir in examples/*; do
|
|
tox -c $example_dir -e py
|
|
done
|
|
env:
|
|
TOX_TESTENV_PASSENV: "CARGO_BUILD_TARGET"
|
|
|
|
env:
|
|
CARGO_TERM_VERBOSE: true
|
|
CARGO_BUILD_TARGET: ${{ matrix.platform.rust-target }}
|
|
RUST_BACKTRACE: 1
|
|
RUSTFLAGS: "-D warnings"
|
|
RUSTDOCFLAGS: "-D warnings"
|
|
# TODO: this is a hack to workaround compile_error! warnings about auto-initialize on PyPy
|
|
# Once cargo's `resolver = "2"` is stable (~ MSRV Rust 1.52), remove this.
|
|
PYO3_CI: 1
|
|
|
|
coverage:
|
|
needs: [fmt]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- uses: actions/cache@v2
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
target
|
|
key: coverage-cargo-${{ hashFiles('**/Cargo.toml') }}
|
|
- name: install grcov
|
|
run: |
|
|
wget https://github.com/mozilla/grcov/releases/download/v${GRCOV_VERSION}/grcov-linux-x86_64.tar.bz2 -qO- | tar -xjvf -
|
|
mv grcov ~/.cargo/bin
|
|
env:
|
|
GRCOV_VERSION: 0.7.1
|
|
- uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: nightly
|
|
override: true
|
|
profile: minimal
|
|
components: llvm-tools-preview
|
|
- run: LLVM_PROFILE_FILE="coverage-%p-%m.profraw" cargo test --no-default-features --no-fail-fast
|
|
- run: LLVM_PROFILE_FILE="coverage-features-%p-%m.profraw" cargo test --no-default-features --no-fail-fast --features "macros num-bigint num-complex hashbrown serde multiple-pymethods"
|
|
# can't yet use actions-rs/grcov with source-based coverage: https://github.com/actions-rs/grcov/issues/105
|
|
# - uses: actions-rs/grcov@v0.1
|
|
# id: coverage
|
|
# - uses: codecov/codecov-action@v1
|
|
# with:
|
|
# file: ${{ steps.coverage.outputs.report }}
|
|
- run: grcov . --binary-path target/debug/deps/ -s . -t lcov --branch --ignore-not-existing -o coverage.lcov
|
|
- uses: codecov/codecov-action@v1
|
|
with:
|
|
file: coverage.lcov
|
|
|
|
env:
|
|
CARGO_TERM_VERBOSE: true
|
|
RUSTFLAGS: "-Zinstrument-coverage"
|
|
RUSTDOCFLAGS: "-Zinstrument-coverage"
|