pyo3/.github/workflows/ci.yml

369 lines
12 KiB
YAML
Raw Normal View History

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
2022-11-20 13:23:05 +00:00
# for bors r+
- staging
# for bors try
- trying
2020-08-16 13:36:15 +00:00
pull_request:
workflow_dispatch:
2019-11-16 12:39:59 +00:00
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}
cancel-in-progress: true
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:
2022-11-21 02:52:31 +00:00
if: github.ref != 'refs/heads/main'
2020-08-08 17:03:16 +00:00
runs-on: ubuntu-latest
steps:
2022-06-02 06:32:51 +00:00
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- run: python -m pip install --upgrade pip && pip install nox
- uses: dtolnay/rust-toolchain@stable
2020-08-08 17:03:16 +00:00
with:
2020-08-16 13:36:15 +00:00
components: rustfmt
2020-08-08 17:03:16 +00:00
- name: Check python formatting (black)
2022-02-12 09:37:46 +00:00
run: nox -s fmt-py
2020-08-08 17:03:16 +00:00
- name: Check rust formatting (rustfmt)
2022-02-12 09:37:46 +00:00
run: nox -s fmt-rust
2020-08-08 17:03:16 +00:00
clippy:
2021-08-30 08:13:43 +00:00
needs: [fmt]
2022-12-24 19:17:25 +00:00
runs-on: ${{ matrix.platform.os }}
if: github.ref != 'refs/heads/main'
2021-08-30 08:13:43 +00:00
strategy:
# If one platform fails, allow the rest to keep testing if `CI-no-fail-fast` label is present
fail-fast: ${{ !contains(github.event.pull_request.labels.*.name, 'CI-no-fail-fast') }}
2021-08-30 08:13:43 +00:00
matrix:
2022-12-24 19:17:25 +00:00
rust: [stable]
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: "ubuntu-latest",
python-architecture: "x64",
rust-target: "powerpc64le-unknown-linux-gnu",
},
{
os: "ubuntu-latest",
python-architecture: "x64",
rust-target: "s390x-unknown-linux-gnu",
},
{
os: "ubuntu-latest",
python-architecture: "x64",
rust-target: "wasm32-wasi",
},
{
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:
- rust: 1.48.0
python-version: "3.11"
platform:
{
os: "ubuntu-latest",
python-architecture: "x64",
rust-target: "x86_64-unknown-linux-gnu",
}
msrv: "MSRV"
name: clippy/${{ matrix.platform.rust-target }}/${{ matrix.rust }}
2021-08-30 08:13:43 +00:00
steps:
2022-06-02 06:32:51 +00:00
- uses: actions/checkout@v3
2022-12-24 19:17:25 +00:00
- uses: dtolnay/rust-toolchain@master
2021-08-30 08:13:43 +00:00
with:
2022-12-24 19:17:25 +00:00
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.platform.rust-target }}
components: clippy,rust-src
2022-12-24 19:17:25 +00:00
- uses: actions/setup-python@v4
with:
architecture: ${{ matrix.platform.python-architecture }}
- run: python -m pip install --upgrade pip && pip install nox
2022-12-24 19:17:25 +00:00
- if: matrix.msrv == 'MSRV'
name: Prepare minimal package versions (MSRV only)
run: nox -s set-minimal-package-versions
- run: nox -s clippy-all
env:
CARGO_BUILD_TARGET: ${{ matrix.platform.rust-target }}
2021-08-30 08:13:43 +00:00
2022-11-21 02:52:31 +00:00
build-pr:
if: github.event_name == 'pull_request'
name: python${{ matrix.python-version }}-${{ matrix.platform.python-architecture }} ${{ matrix.platform.os }} rust-${{ matrix.rust }}
2022-12-24 19:17:25 +00:00
needs: [fmt]
2022-11-21 02:52:31 +00:00
uses: ./.github/workflows/build.yml
with:
os: ${{ matrix.platform.os }}
python-version: ${{ matrix.python-version }}
python-architecture: ${{ matrix.platform.python-architecture }}
rust: ${{ matrix.rust }}
rust-target: ${{ matrix.platform.rust-target }}
msrv: ${{ matrix.msrv }}
extra-features: ${{ matrix.platform.extra-features }}
secrets: inherit
strategy:
# If one platform fails, allow the rest to keep testing if `CI-no-fail-fast` label is present
fail-fast: ${{ !contains(github.event.pull_request.labels.*.name, 'CI-no-fail-fast') }}
matrix:
extra-features: ["multiple-pymethods"]
rust: [stable]
2023-02-27 22:25:07 +00:00
python-version: ["3.11"]
2022-11-21 02:52:31 +00:00
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",
},
2022-12-24 19:17:25 +00:00
{
os: "windows-latest",
python-architecture: "x86",
rust-target: "i686-pc-windows-msvc",
}
2022-11-21 02:52:31 +00:00
]
build-full:
if: ${{ github.event_name != 'pull_request' && github.ref != 'refs/heads/main' }}
2022-02-14 21:47:39 +00:00
name: python${{ matrix.python-version }}-${{ matrix.platform.python-architecture }} ${{ matrix.platform.os }} rust-${{ matrix.rust }}
2022-12-24 19:17:25 +00:00
needs: [fmt]
2022-11-21 02:52:31 +00:00
uses: ./.github/workflows/build.yml
with:
os: ${{ matrix.platform.os }}
python-version: ${{ matrix.python-version }}
python-architecture: ${{ matrix.platform.python-architecture }}
rust: ${{ matrix.rust }}
rust-target: ${{ matrix.platform.rust-target }}
msrv: ${{ matrix.msrv }}
extra-features: ${{ matrix.platform.extra-features }}
secrets: inherit
2019-11-16 12:39:59 +00:00
strategy:
# If one platform fails, allow the rest to keep testing if `CI-no-fail-fast` label is present
fail-fast: ${{ !contains(github.event.pull_request.labels.*.name, 'CI-no-fail-fast') }}
2019-11-16 12:39:59 +00:00
matrix:
2022-11-21 02:52:31 +00:00
extra-features: ["multiple-pymethods"] # Because MSRV doesn't support this
2020-08-16 13:36:15 +00:00
rust: [stable]
2022-02-05 00:22:09 +00:00
python-version: [
"3.7",
"3.8",
"3.9",
"3.10",
2023-02-27 22:25:07 +00:00
"3.11",
2022-03-08 20:57:25 +00:00
"pypy-3.7",
2022-02-05 00:22:09 +00:00
"pypy-3.8",
2022-02-23 08:14:52 +00:00
"pypy-3.9"
2022-02-05 00:22:09 +00:00
]
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",
},
]
2020-08-16 13:36:15 +00:00
include:
# Test minimal supported Rust version
2021-11-18 11:38:47 +00:00
- rust: 1.48.0
python-version: "3.11"
platform:
{
os: "ubuntu-latest",
python-architecture: "x64",
rust-target: "x86_64-unknown-linux-gnu",
}
2020-08-16 13:36:15 +00:00
msrv: "MSRV"
2022-11-21 02:52:31 +00:00
extra-features: ""
# Test the `nightly` feature
- rust: nightly
python-version: "3.11"
platform:
{
os: "ubuntu-latest",
python-architecture: "x64",
rust-target: "x86_64-unknown-linux-gnu",
}
2022-11-21 02:52:31 +00:00
extra-features: "nightly multiple-pymethods"
# Test 32-bit Windows only with the latest Python version
- rust: stable
2023-02-27 22:25:07 +00:00
python-version: "3.11"
platform:
{
os: "windows-latest",
python-architecture: "x86",
rust-target: "i686-pc-windows-msvc",
}
2022-11-21 02:52:31 +00:00
extra-features: "multiple-pymethods"
2022-12-14 21:30:55 +00:00
valgrind:
2022-11-21 02:52:31 +00:00
if: ${{ github.event_name != 'pull_request' && github.ref != 'refs/heads/main' }}
needs: [fmt]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
2022-11-02 01:42:55 +00:00
- uses: Swatinem/rust-cache@v2
with:
key: cargo-valgrind
continue-on-error: true
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@valgrind
- run: python -m pip install --upgrade pip && pip install nox
- run: nox -s test-rust -- release skip-full
env:
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER: valgrind --leak-check=no --error-exitcode=1
RUST_BACKTRACE: 1
TRYBUILD: overwrite
careful:
2022-11-21 02:52:31 +00:00
if: ${{ github.event_name != 'pull_request' && github.ref != 'refs/heads/main' }}
needs: [fmt]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
2022-11-02 01:42:55 +00:00
- uses: Swatinem/rust-cache@v2
with:
key: cargo-careful
continue-on-error: true
- uses: dtolnay/rust-toolchain@nightly
with:
components: rust-src
- run: cargo install cargo-careful
- run: python -m pip install --upgrade pip && pip install nox
- run: nox -s test-rust -- careful skip-full
env:
RUST_BACKTRACE: 1
TRYBUILD: overwrite
coverage:
needs: [fmt]
name: coverage-${{ matrix.os }}
strategy:
matrix:
os: ["windows", "macos", "ubuntu"]
runs-on: ${{ matrix.os }}-latest
steps:
2022-11-21 02:52:31 +00:00
- if: ${{ github.event_name == 'pull_request' && matrix.os != 'ubuntu' }}
id: should-skip
shell: bash
run: echo 'skip=true' >> $GITHUB_OUTPUT
2022-06-02 06:32:51 +00:00
- uses: actions/checkout@v3
2022-11-21 02:52:31 +00:00
if: steps.should-skip.outputs.skip != 'true'
- uses: actions/setup-python@v4
2022-11-21 02:52:31 +00:00
if: steps.should-skip.outputs.skip != 'true'
2022-11-02 01:42:55 +00:00
- uses: Swatinem/rust-cache@v2
2022-11-21 02:52:31 +00:00
if: steps.should-skip.outputs.skip != 'true'
2021-04-04 07:49:27 +00:00
with:
2021-12-18 09:03:34 +00:00
key: coverage-cargo-${{ matrix.os }}
2021-04-19 08:50:25 +00:00
continue-on-error: true
- uses: dtolnay/rust-toolchain@stable
2022-11-21 02:52:31 +00:00
if: steps.should-skip.outputs.skip != 'true'
with:
components: llvm-tools-preview
2022-01-24 22:58:36 +00:00
- name: Install cargo-llvm-cov
2022-11-21 02:52:31 +00:00
if: steps.should-skip.outputs.skip != 'true'
2022-01-24 22:58:36 +00:00
uses: taiki-e/install-action@cargo-llvm-cov
- run: python -m pip install --upgrade pip && pip install nox
2022-11-21 02:52:31 +00:00
if: steps.should-skip.outputs.skip != 'true'
- run: nox -s coverage
2022-11-21 02:52:31 +00:00
if: steps.should-skip.outputs.skip != 'true'
- uses: codecov/codecov-action@v3
2022-11-21 02:52:31 +00:00
if: steps.should-skip.outputs.skip != 'true'
with:
2023-04-12 06:35:16 +00:00
file: coverage.json
name: ${{ matrix.os }}
emscripten:
name: emscripten
2022-11-21 02:52:31 +00:00
if: ${{ github.event_name != 'pull_request' && github.ref != 'refs/heads/main' }}
runs-on: ubuntu-latest
steps:
2022-11-05 10:41:09 +00:00
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
2022-06-08 07:09:42 +00:00
id: setup-python
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-emscripten
- uses: actions/setup-node@v3
with:
node-version: 14
- run: python -m pip install --upgrade pip && pip install nox
- uses: actions/cache@v3
id: cache
with:
path: |
.nox/emscripten
2022-06-08 07:09:42 +00:00
key: ${{ hashFiles('emscripten/*') }} - ${{ hashFiles('noxfile.py') }} - ${{ steps.setup-python.outputs.python-path }}
2022-11-02 01:42:55 +00:00
- uses: Swatinem/rust-cache@v2
with:
key: cargo-emscripten-wasm32
- name: Build
if: steps.cache.outputs.cache-hit != 'true'
2022-06-08 07:09:42 +00:00
run: nox -s build-emscripten
- name: Test
2022-06-08 07:09:42 +00:00
run: nox -s test-emscripten
2022-12-14 21:30:55 +00:00
2022-11-20 13:23:05 +00:00
conclusion:
needs:
- fmt
- clippy
2022-11-21 02:52:31 +00:00
- build-pr
- build-full
2022-11-20 13:23:05 +00:00
- valgrind
- careful
- coverage
- emscripten
if: always()
runs-on: ubuntu-latest
steps:
- name: Result
run: |
jq -C <<< "${needs}"
# Check if all needs were successful or skipped.
"$(jq -r 'all(.result as $result | (["success", "skipped"] | contains([$result])))' <<< "${needs}")"
env:
needs: ${{ toJson(needs) }}