337 lines
11 KiB
YAML
337 lines
11 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
# for bors r+
|
|
- staging
|
|
# for bors try
|
|
- trying
|
|
pull_request:
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
jobs:
|
|
fmt:
|
|
if: github.ref != 'refs/heads/main'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions/setup-python@v4
|
|
- run: pip install nox
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
components: rustfmt
|
|
- name: Check python formatting (black)
|
|
run: nox -s fmt-py
|
|
- name: Check rust formatting (rustfmt)
|
|
run: nox -s fmt-rust
|
|
|
|
clippy:
|
|
if: github.ref != 'refs/heads/main'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions/setup-python@v4
|
|
- run: pip install nox
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
components: clippy
|
|
- run: nox -s clippy
|
|
|
|
check-target:
|
|
needs: [fmt]
|
|
runs-on: ubuntu-latest
|
|
if: ${{ github.event_name != 'pull_request' && github.ref != 'refs/heads/main' }}
|
|
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:
|
|
target: [powerpc64le-unknown-linux-gnu, s390x-unknown-linux-gnu, wasm32-wasi]
|
|
name: check-${{ matrix.target }}
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- name: Install Rust toolchain
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: ${{ matrix.target }}
|
|
- name: Run cargo checks
|
|
run: |
|
|
set -x
|
|
VERSIONS=("3.7" "3.8" "3.9" "3.10" "3.11")
|
|
for VERSION in ${VERSIONS[@]}; do
|
|
echo "version=$VERSION" > config.txt
|
|
echo "suppress_build_script_link_lines=true" >> config.txt
|
|
PYO3_BUILD_CONFIG=$(pwd)/config.txt cargo check --all-targets --no-default-features
|
|
PYO3_BUILD_CONFIG=$(pwd)/config.txt cargo check --all-targets --no-default-features --features "abi3"
|
|
PYO3_BUILD_CONFIG=$(pwd)/config.txt cargo check --all-targets --features "full multiple-pymethods"
|
|
PYO3_BUILD_CONFIG=$(pwd)/config.txt cargo check --all-targets --features "abi3 full multiple-pymethods"
|
|
done
|
|
|
|
build-pr:
|
|
if: github.event_name == 'pull_request'
|
|
name: python${{ matrix.python-version }}-${{ matrix.platform.python-architecture }} ${{ matrix.platform.os }} rust-${{ matrix.rust }}
|
|
needs: [fmt] # don't wait for clippy as fails rarely and takes longer
|
|
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]
|
|
# FIXME - pinned to 3.11.0 because 3.11.1 breaks CI on windows, see PyO3 issue 2817
|
|
python-version: ["3.11.0"]
|
|
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",
|
|
},
|
|
]
|
|
|
|
build-full:
|
|
if: ${{ github.event_name != 'pull_request' && github.ref != 'refs/heads/main' }}
|
|
name: python${{ matrix.python-version }}-${{ matrix.platform.python-architecture }} ${{ matrix.platform.os }} rust-${{ matrix.rust }}
|
|
needs: [fmt] # don't wait for clippy as fails rarely and takes longer
|
|
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"] # Because MSRV doesn't support this
|
|
rust: [stable]
|
|
python-version: [
|
|
"3.7",
|
|
"3.8",
|
|
"3.9",
|
|
"3.10",
|
|
# FIXME - pinned to 3.11.0 because 3.11.1 breaks CI on windows, see PyO3 issue 2817
|
|
"3.11.0",
|
|
"pypy-3.7",
|
|
"pypy-3.8",
|
|
"pypy-3.9"
|
|
]
|
|
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",
|
|
},
|
|
]
|
|
include:
|
|
# Test minimal supported Rust version
|
|
- rust: 1.48.0
|
|
python-version: "3.11"
|
|
platform:
|
|
{
|
|
os: "ubuntu-latest",
|
|
python-architecture: "x64",
|
|
rust-target: "x86_64-unknown-linux-gnu",
|
|
}
|
|
msrv: "MSRV"
|
|
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",
|
|
}
|
|
extra-features: "nightly multiple-pymethods"
|
|
|
|
# Test 32-bit Windows only with the latest Python version
|
|
- rust: stable
|
|
# FIXME - pinned to 3.11.0 because 3.11.1 breaks CI on windows, see PyO3 issue 2817
|
|
python-version: "3.11.0"
|
|
platform:
|
|
{
|
|
os: "windows-latest",
|
|
python-architecture: "x86",
|
|
rust-target: "i686-pc-windows-msvc",
|
|
}
|
|
extra-features: "multiple-pymethods"
|
|
|
|
valgrind:
|
|
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
|
|
- uses: Swatinem/rust-cache@v2
|
|
with:
|
|
key: cargo-valgrind
|
|
continue-on-error: true
|
|
# FIXME(adamreichold): Switch to stable when Valgrind understands DWARF5 as generated by LLVM 14,
|
|
# c.f. https://bugs.kde.org/show_bug.cgi?id=452758#c35
|
|
- uses: dtolnay/rust-toolchain@1.61.0
|
|
- uses: taiki-e/install-action@valgrind
|
|
- run: python -m pip install -U pip 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:
|
|
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
|
|
- 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 -U pip 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:
|
|
- if: ${{ github.event_name == 'pull_request' && matrix.os != 'ubuntu' }}
|
|
id: should-skip
|
|
shell: bash
|
|
run: echo 'skip=true' >> $GITHUB_OUTPUT
|
|
- uses: actions/checkout@v3
|
|
if: steps.should-skip.outputs.skip != 'true'
|
|
- uses: actions/setup-python@v4
|
|
if: steps.should-skip.outputs.skip != 'true'
|
|
- uses: Swatinem/rust-cache@v2
|
|
if: steps.should-skip.outputs.skip != 'true'
|
|
with:
|
|
key: coverage-cargo-${{ matrix.os }}
|
|
continue-on-error: true
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
if: steps.should-skip.outputs.skip != 'true'
|
|
with:
|
|
components: llvm-tools-preview
|
|
- name: Install cargo-llvm-cov
|
|
if: steps.should-skip.outputs.skip != 'true'
|
|
uses: taiki-e/install-action@cargo-llvm-cov
|
|
- run: python -m pip install -U pip nox
|
|
if: steps.should-skip.outputs.skip != 'true'
|
|
- run: nox -s coverage
|
|
if: steps.should-skip.outputs.skip != 'true'
|
|
- uses: codecov/codecov-action@v3
|
|
if: steps.should-skip.outputs.skip != 'true'
|
|
with:
|
|
file: coverage.lcov
|
|
name: ${{ matrix.os }}
|
|
|
|
emscripten:
|
|
name: emscripten
|
|
if: ${{ github.event_name != 'pull_request' && github.ref != 'refs/heads/main' }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions/setup-python@v4
|
|
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: pip install nox
|
|
- uses: actions/cache@v3
|
|
id: cache
|
|
with:
|
|
path: |
|
|
.nox/emscripten
|
|
key: ${{ hashFiles('emscripten/*') }} - ${{ hashFiles('noxfile.py') }} - ${{ steps.setup-python.outputs.python-path }}
|
|
- uses: Swatinem/rust-cache@v2
|
|
with:
|
|
key: cargo-emscripten-wasm32
|
|
- name: Build
|
|
if: steps.cache.outputs.cache-hit != 'true'
|
|
run: nox -s build-emscripten
|
|
- name: Test
|
|
run: nox -s test-emscripten
|
|
|
|
conclusion:
|
|
needs:
|
|
- fmt
|
|
- clippy
|
|
- check-target
|
|
- build-pr
|
|
- build-full
|
|
- 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) }}
|