2020-08-11 21:32:59 +00:00
|
|
|
name: CI
|
2019-11-16 12:39:59 +00:00
|
|
|
|
2020-08-16 13:36:15 +00:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
2021-03-16 22:14:57 +00:00
|
|
|
- main
|
2020-08-16 13:36:15 +00:00
|
|
|
pull_request:
|
2019-11-16 12:39:59 +00:00
|
|
|
|
2020-09-01 19:59:28 +00:00
|
|
|
env:
|
|
|
|
CARGO_TERM_COLOR: always
|
|
|
|
|
2019-11-16 12:39:59 +00:00
|
|
|
jobs:
|
2020-08-08 17:03:16 +00:00
|
|
|
fmt:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
2020-08-16 13:36:15 +00:00
|
|
|
- uses: actions/setup-python@v2
|
2021-04-01 23:03:49 +00:00
|
|
|
- run: pip install black==20.8b1
|
2020-08-08 17:03:16 +00:00
|
|
|
- uses: actions-rs/toolchain@v1
|
|
|
|
with:
|
|
|
|
toolchain: stable
|
2020-08-16 13:36:15 +00:00
|
|
|
profile: minimal
|
|
|
|
components: rustfmt
|
2020-08-08 17:03:16 +00:00
|
|
|
- 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
|
2020-08-16 13:36:15 +00:00
|
|
|
profile: minimal
|
|
|
|
components: clippy
|
2020-08-08 17:03:16 +00:00
|
|
|
- run: make clippy
|
|
|
|
|
2019-11-16 12:39:59 +00:00
|
|
|
build:
|
2020-08-08 17:03:16 +00:00
|
|
|
needs: [fmt] # don't wait for clippy as fails rarely and takes longer
|
2020-08-16 13:36:15 +00:00
|
|
|
name: python${{ matrix.python-version }}-${{ matrix.platform.python-architecture }} ${{ matrix.platform.os }} ${{ matrix.msrv }}
|
2020-03-24 05:59:03 +00:00
|
|
|
runs-on: ${{ matrix.platform.os }}
|
2019-11-16 12:39:59 +00:00
|
|
|
strategy:
|
2020-09-01 19:56:13 +00:00
|
|
|
fail-fast: false # If one platform fails, allow the rest to keep testing.
|
2019-11-16 12:39:59 +00:00
|
|
|
matrix:
|
2020-08-16 13:36:15 +00:00
|
|
|
rust: [stable]
|
2021-04-19 22:49:12 +00:00
|
|
|
# Github actions has a "bogus" 3.10-beta.1 release which interacts badly
|
|
|
|
# with pytest (use 3.10-dev again once pytest has released a fix):
|
|
|
|
# https://github.com/actions/setup-python/issues/207
|
|
|
|
# https://github.com/pytest-dev/pytest/issues/8539
|
|
|
|
# python-version: [3.6, 3.7, 3.8, 3.9, 3.10-dev, pypy-3.6, pypy-3.7]
|
|
|
|
python-version: [3.6, 3.7, 3.8, 3.9, 3.10.0-alpha.7, pypy-3.6, pypy-3.7]
|
2020-03-24 05:59:03 +00:00
|
|
|
platform: [
|
2021-04-11 22:10:23 +00:00
|
|
|
{ os: "macos-latest", python-architecture: "x64", rust-target: "x86_64-apple-darwin" },
|
2020-08-11 21:32:59 +00:00
|
|
|
{ os: "ubuntu-latest", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu" },
|
2020-03-24 05:59:03 +00:00
|
|
|
{ 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" },
|
|
|
|
]
|
2020-08-07 00:50:11 +00:00
|
|
|
exclude:
|
2021-04-02 09:39:47 +00:00
|
|
|
# There is no 64-bit pypy on windows for pypy-3.6
|
2020-12-17 08:51:00 +00:00
|
|
|
- python-version: pypy-3.6
|
2020-11-21 01:40:29 +00:00
|
|
|
platform: { os: "windows-latest", python-architecture: "x64" }
|
2021-04-02 09:39:47 +00:00
|
|
|
# pypy on windows for pypy-3.7 coming in next PyPy release
|
|
|
|
- python-version: pypy-3.7
|
|
|
|
platform: { os: "windows-latest", python-architecture: "x64" }
|
2020-08-16 13:36:15 +00:00
|
|
|
include:
|
|
|
|
# Test minimal supported Rust version
|
2021-02-10 15:07:25 +00:00
|
|
|
- rust: 1.41.1
|
2020-10-10 09:34:37 +00:00
|
|
|
python-version: 3.9
|
2020-08-16 13:36:15 +00:00
|
|
|
platform: { os: "ubuntu-latest", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu" }
|
|
|
|
msrv: "MSRV"
|
2020-08-07 00:50:11 +00:00
|
|
|
|
2019-11-16 12:39:59 +00:00
|
|
|
steps:
|
2020-03-25 02:28:33 +00:00
|
|
|
- uses: actions/checkout@v2
|
2020-08-07 00:50:11 +00:00
|
|
|
|
2021-04-11 22:10:23 +00:00
|
|
|
# macos: install gnu-tar because BSD tar is buggy for github actions
|
2021-04-11 17:37:35 +00:00
|
|
|
# https://github.com/actions/cache/issues/403
|
2021-04-11 22:10:23 +00:00
|
|
|
- name: Install GNU tar (macOS only)
|
|
|
|
if: matrix.platform.os == 'macos-latest'
|
2021-04-11 17:37:35 +00:00
|
|
|
run: |
|
|
|
|
brew install gnu-tar
|
|
|
|
echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH
|
|
|
|
|
2021-04-03 20:59:03 +00:00
|
|
|
- uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
~/.cargo/registry
|
|
|
|
~/.cargo/git
|
|
|
|
target
|
2021-04-11 22:10:23 +00:00
|
|
|
key: cargo-${{ matrix.python-version }}-${{ matrix.platform.python-architecture }}-${{ matrix.platform.os }}-${{ matrix.msrv }}-${{ hashFiles('**/Cargo.toml') }}
|
2021-04-18 06:08:16 +00:00
|
|
|
continue-on-error: true
|
2021-04-03 20:59:03 +00:00
|
|
|
|
2019-12-28 11:36:20 +00:00
|
|
|
- name: Set up Python ${{ matrix.python-version }}
|
2020-08-11 21:32:59 +00:00
|
|
|
uses: actions/setup-python@v2
|
2019-12-28 11:36:20 +00:00
|
|
|
with:
|
|
|
|
python-version: ${{ matrix.python-version }}
|
2020-08-07 00:50:11 +00:00
|
|
|
architecture: ${{ matrix.platform.python-architecture }}
|
|
|
|
|
|
|
|
- name: Install Rust toolchain
|
2019-12-28 11:36:20 +00:00
|
|
|
uses: actions-rs/toolchain@v1
|
|
|
|
with:
|
2020-08-16 13:36:15 +00:00
|
|
|
toolchain: ${{ matrix.rust }}
|
2020-08-07 00:50:11 +00:00
|
|
|
target: ${{ matrix.platform.rust-target }}
|
2020-08-16 13:36:15 +00:00
|
|
|
profile: minimal
|
2020-10-12 13:51:45 +00:00
|
|
|
default: true
|
2020-08-07 00:50:11 +00:00
|
|
|
|
2020-08-16 13:36:15 +00:00
|
|
|
- if: matrix.platform.os == 'ubuntu-latest'
|
|
|
|
name: Prepare LD_LIBRARY_PATH (Ubuntu only)
|
2020-10-12 13:51:45 +00:00
|
|
|
run: echo LD_LIBRARY_PATH=${pythonLocation}/lib >> $GITHUB_ENV
|
2020-08-07 00:50:11 +00:00
|
|
|
|
2021-03-02 22:48:43 +00:00
|
|
|
- name: Prepare workflow settings
|
|
|
|
id: settings
|
|
|
|
shell: bash
|
|
|
|
run: |
|
2021-03-02 22:34:25 +00:00
|
|
|
echo "::set-output name=all_additive_features::macros num-bigint num-complex hashbrown serde multiple-pymethods"
|
2021-03-02 22:48:43 +00:00
|
|
|
|
2021-03-24 22:29:00 +00:00
|
|
|
- if: matrix.msrv == 'MSRV'
|
|
|
|
name: Prepare minimal package versions (MSRV only)
|
|
|
|
run: cargo update -p hashbrown --precise 0.9.1
|
|
|
|
|
2020-12-17 03:00:48 +00:00
|
|
|
- name: Build docs
|
2021-04-03 20:59:03 +00:00
|
|
|
run: cargo doc --no-deps --no-default-features --features "${{ steps.settings.outputs.all_additive_features }}"
|
2020-12-17 03:00:48 +00:00
|
|
|
|
2020-12-28 16:02:57 +00:00
|
|
|
- name: Build (no features)
|
2021-03-02 22:48:43 +00:00
|
|
|
run: cargo build --lib --tests --no-default-features
|
|
|
|
|
|
|
|
# Run tests (except on PyPy, because no embedding API).
|
2021-04-02 09:39:47 +00:00
|
|
|
- if: ${{ !startsWith(matrix.python-version, 'pypy') }}
|
2021-03-02 22:48:43 +00:00
|
|
|
name: Test (no features)
|
|
|
|
run: cargo test --no-default-features
|
2020-08-07 00:50:11 +00:00
|
|
|
|
2020-12-28 16:02:57 +00:00
|
|
|
- name: Build (all additive features)
|
2021-03-02 22:48:43 +00:00
|
|
|
run: cargo build --lib --tests --no-default-features --features "${{ steps.settings.outputs.all_additive_features }}"
|
2020-08-07 00:50:11 +00:00
|
|
|
|
|
|
|
# Run tests (except on PyPy, because no embedding API).
|
2021-04-02 09:39:47 +00:00
|
|
|
- if: ${{ !startsWith(matrix.python-version, 'pypy') }}
|
2020-08-07 00:50:11 +00:00
|
|
|
name: Test
|
2021-03-02 22:48:43 +00:00
|
|
|
run: cargo test --no-default-features --features "${{ steps.settings.outputs.all_additive_features }}"
|
2020-12-28 16:02:57 +00:00
|
|
|
|
2020-09-19 15:27:06 +00:00
|
|
|
# Run tests again, but in abi3 mode
|
2021-04-02 09:39:47 +00:00
|
|
|
- if: ${{ !startsWith(matrix.python-version, 'pypy') }}
|
2020-10-12 22:03:14 +00:00
|
|
|
name: Test (abi3)
|
2021-03-02 22:48:43 +00:00
|
|
|
run: cargo test --no-default-features --features "abi3 ${{ steps.settings.outputs.all_additive_features }}"
|
2020-08-07 00:50:11 +00:00
|
|
|
|
2020-12-15 13:57:09 +00:00
|
|
|
# Run tests again, for abi3-py36 (the minimal Python version)
|
2021-04-02 09:39:47 +00:00
|
|
|
- if: ${{ (!startsWith(matrix.python-version, 'pypy')) && (matrix.python-version != '3.6') }}
|
2020-12-15 13:57:09 +00:00
|
|
|
name: Test (abi3-py36)
|
2021-03-02 22:48:43 +00:00
|
|
|
run: cargo test --no-default-features --features "abi3-py36 ${{ steps.settings.outputs.all_additive_features }}"
|
2020-12-15 13:57:09 +00:00
|
|
|
|
2020-08-07 00:50:11 +00:00
|
|
|
- name: Test proc-macro code
|
2021-03-02 22:48:43 +00:00
|
|
|
run: cargo test --manifest-path=pyo3-macros-backend/Cargo.toml
|
2020-08-07 00:50:11 +00:00
|
|
|
|
|
|
|
- name: Install python test dependencies
|
2021-04-01 23:03:49 +00:00
|
|
|
run: python -m pip install -U pip tox
|
2020-08-07 00:50:11 +00:00
|
|
|
|
|
|
|
- name: Test example extension modules
|
2020-03-24 05:59:03 +00:00
|
|
|
shell: bash
|
2020-08-07 00:50:11 +00:00
|
|
|
run: |
|
|
|
|
for example_dir in examples/*; do
|
2021-04-01 23:03:49 +00:00
|
|
|
tox -c $example_dir -e py
|
2020-08-07 00:50:11 +00:00
|
|
|
done
|
2021-03-02 22:48:43 +00:00
|
|
|
env:
|
|
|
|
TOX_TESTENV_PASSENV: "CARGO_BUILD_TARGET"
|
2020-08-07 00:50:11 +00:00
|
|
|
|
2020-01-12 14:33:34 +00:00
|
|
|
env:
|
2021-03-02 22:48:43 +00:00
|
|
|
CARGO_TERM_VERBOSE: true
|
|
|
|
CARGO_BUILD_TARGET: ${{ matrix.platform.rust-target }}
|
2020-01-12 14:33:34 +00:00
|
|
|
RUST_BACKTRACE: 1
|
2020-12-26 08:11:19 +00:00
|
|
|
RUSTFLAGS: "-D warnings"
|
2021-03-04 19:41:11 +00:00
|
|
|
RUSTDOCFLAGS: "-D warnings"
|
2020-12-28 16:02:57 +00:00
|
|
|
# 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
|
2020-08-11 21:32:59 +00:00
|
|
|
|
|
|
|
coverage:
|
|
|
|
needs: [fmt]
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2020-08-16 13:36:15 +00:00
|
|
|
- uses: actions/checkout@v2
|
2021-04-04 07:49:27 +00:00
|
|
|
- uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
~/.cargo/registry
|
|
|
|
~/.cargo/git
|
|
|
|
target
|
|
|
|
key: coverage-cargo-${{ hashFiles('**/Cargo.toml') }}
|
2021-04-19 08:50:25 +00:00
|
|
|
continue-on-error: true
|
2021-04-04 07:49:27 +00:00
|
|
|
- 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
|
2020-08-11 21:32:59 +00:00
|
|
|
- uses: actions-rs/toolchain@v1
|
|
|
|
with:
|
|
|
|
toolchain: nightly
|
|
|
|
override: true
|
2020-08-16 13:36:15 +00:00
|
|
|
profile: minimal
|
2021-04-04 07:49:27 +00:00
|
|
|
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
|
2020-08-11 21:32:59 +00:00
|
|
|
- uses: codecov/codecov-action@v1
|
|
|
|
with:
|
2021-04-04 07:49:27 +00:00
|
|
|
file: coverage.lcov
|
|
|
|
|
2021-03-02 22:34:25 +00:00
|
|
|
env:
|
|
|
|
CARGO_TERM_VERBOSE: true
|
2021-04-04 07:49:27 +00:00
|
|
|
RUSTFLAGS: "-Zinstrument-coverage"
|
|
|
|
RUSTDOCFLAGS: "-Zinstrument-coverage"
|