Query default macOS deployment target from rustc --print deployment-target
#3566
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test | |
on: | |
pull_request: | |
paths-ignore: | |
- "guide/**" | |
- "sysconfig/**" | |
- "**.md" | |
- ".cirrus.yml" | |
- ".github/ISSUE_TEMPLATE/**" | |
- ".github/dependabot.yml" | |
merge_group: | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number }} | |
cancel-in-progress: true | |
jobs: | |
generate-matrix: | |
name: Generate Matrix | |
runs-on: ubuntu-latest | |
outputs: | |
os: ${{ steps.generate-matrix.outputs.os }} | |
python-version: ${{ steps.generate-matrix.outputs.python-version }} | |
fail-fast: ${{ steps.generate-matrix.outputs.fail-fast }} | |
steps: | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- run: npm install js-yaml | |
- name: Generate matrix | |
id: generate-matrix | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const yaml = require('js-yaml') | |
const OS = yaml.load(process.env.OS_MATRIX) | |
const PYTHON_VERSIONS = yaml.load(process.env.PYTHON_VERSION) | |
if (context.eventName == 'workflow_dispatch' || context.eventName == 'merge_group') { | |
// Run all of them on workflow dispatch or merge group | |
core.setOutput('os', OS) | |
core.setOutput('python-version', PYTHON_VERSIONS) | |
core.setOutput('fail-fast', 'false') | |
} else if (context.eventName == 'pull_request') { | |
const { data: { labels: labels } } = await github.rest.pulls.get({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: context.payload.pull_request.number | |
}) | |
const labelNames = labels.map(label => label.name) | |
if (labelNames.includes('CI-no-fail-fast')) { | |
core.setOutput('fail-fast', 'false') | |
} | |
// Only run latest CPython and PyPy tests on pull requests | |
const firstPyPy = PYTHON_VERSIONS.findIndex(version => version.startsWith('pypy')) | |
const pythonVersions = [PYTHON_VERSIONS[firstPyPy - 1], PYTHON_VERSIONS[PYTHON_VERSIONS.length - 1]] | |
core.setOutput('python-version', pythonVersions) | |
// Skip macOS tests on pull requests, it's slow and already partially covered by Cirrus CI | |
core.setOutput('os', OS.filter(os => !os.startsWith('macos'))) | |
} | |
env: | |
OS_MATRIX: | | |
- ubuntu-latest | |
- macos-13 | |
- windows-latest | |
PYTHON_VERSION: | | |
- '3.7' | |
- '3.8' | |
- '3.9' | |
- '3.10' | |
- '3.11' | |
- 'pypy3.9' | |
- 'pypy3.10' | |
test: | |
name: Test | |
needs: [generate-matrix] | |
strategy: | |
fail-fast: ${{ needs.generate-matrix.outputs.fail-fast != 'false' }} | |
matrix: | |
os: ${{ fromJson(needs.generate-matrix.outputs.os) }} | |
python-version: ${{ fromJson(needs.generate-matrix.outputs.python-version) }} | |
runs-on: ${{ matrix.os }} | |
env: | |
RUST_BACKTRACE: "1" | |
SCCACHE_GHA_ENABLED: "true" | |
RUSTC_WRAPPER: "sccache" | |
steps: | |
- name: Cleanup Disk | |
if: ${{ !startsWith(matrix.os, 'windows') }} | |
run: | | |
sudo rm -rf /usr/share/dotnet | |
sudo rm -rf /opt/ghc | |
- name: Sccache Setup | |
uses: mozilla-actions/sccache-action@v0.0.3 | |
with: | |
version: "v0.5.3" | |
- uses: actions/checkout@v3 | |
- uses: conda-incubator/setup-miniconda@v2 | |
with: | |
auto-activate-base: "false" | |
activate-environment: "" | |
miniconda-version: "latest" | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
architecture: "x64" | |
- name: Install cffi | |
if: ${{ !contains(matrix.python-version, 'pypy') }} | |
run: pip install cffi | |
- name: Install python packages | |
run: pip install virtualenv ziglang~=0.10.0 twine uniffi-bindgen==0.24.1 | |
- uses: dtolnay/rust-toolchain@stable | |
id: rustup | |
with: | |
targets: wasm32-wasi # Additional target | |
- name: Install cargo-nextest | |
uses: taiki-e/install-action@nextest | |
- name: Install aarch64-apple-darwin Rust target | |
if: startsWith(matrix.os, 'macos') | |
run: rustup target add aarch64-apple-darwin | |
- name: Setup Xcode env | |
if: startsWith(matrix.os, 'macos') | |
shell: bash | |
run: | | |
set -ex | |
sudo xcode-select -s /Applications/Xcode.app | |
bindir="$(xcode-select --print-path)/Toolchains/XcodeDefault.xctoolchain/usr/bin" | |
echo "CC=${bindir}/clang" >> "${GITHUB_ENV}" | |
echo "CXX=${bindir}/clang++" >> "${GITHUB_ENV}" | |
echo "SDKROOT=$(xcrun --sdk macosx --show-sdk-path)" >> "${GITHUB_ENV}" | |
# Caching | |
# Install gnu-tar because BSD tar is buggy | |
# https://github.com/actions/cache/issues/403 | |
- name: Install GNU tar (Macos) | |
if: startsWith(matrix.os, 'macos') | |
run: | | |
brew install gnu-tar | |
echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH | |
- name: Set MATURIN_TEST_PYTHON for PyPy | |
shell: bash | |
if: contains(matrix.python-version, 'pypy') | |
run: echo "MATURIN_TEST_PYTHON=pypy3" >> $GITHUB_ENV | |
# To save disk space | |
- name: Disable debuginfo on Windows | |
if: startsWith(matrix.os, 'windows') | |
run: echo "RUSTFLAGS="-C debuginfo=0"" >> $GITHUB_ENV | |
- name: cargo test | |
run: cargo nextest run --features password-storage | |
- name: test cross compiling with zig | |
shell: bash | |
run: | | |
set -ex | |
rustup target add aarch64-unknown-linux-gnu | |
rustup target add aarch64-unknown-linux-musl | |
rustup target add aarch64-apple-darwin | |
# abi3 | |
cargo run -- build -i ${{ matrix.python-version }} -m test-crates/pyo3-pure/Cargo.toml --target aarch64-unknown-linux-gnu --zig | |
cargo run -- build -i ${{ matrix.python-version }} -m test-crates/pyo3-pure/Cargo.toml --target aarch64-unknown-linux-musl --zig | |
if [[ "${{ matrix.python-version }}" != "pypy"* ]]; then | |
cargo run -- build -i ${{ matrix.python-version }} -m test-crates/pyo3-pure/Cargo.toml --target aarch64-apple-darwin --zig | |
fi | |
if [[ "${{ matrix.python-version }}" == "3.1"* ]]; then | |
# Check abi3 wheels with abi3audit on CPython only | |
pip install abi3audit | |
abi3audit test-crates/pyo3-pure/target/wheels/*.whl | |
fi | |
# Check wheels with twine | |
twine check --strict test-crates/pyo3-pure/target/wheels/*.whl | |
# non-abi3 | |
cargo run -- build -i ${{ matrix.python-version }} -m test-crates/pyo3-mixed/Cargo.toml --target aarch64-unknown-linux-gnu --zig | |
if [[ "${{ matrix.python-version }}" != "pypy"* ]]; then | |
cargo run -- build -i ${{ matrix.python-version }} -m test-crates/pyo3-mixed/Cargo.toml --target aarch64-apple-darwin --zig | |
fi | |
# Check wheels with twine | |
twine check --strict test-crates/pyo3-mixed/target/wheels/*.whl | |
- name: test cross compiling windows wheel | |
if: ${{ matrix.os == 'ubuntu-latest' && !contains(matrix.python-version, 'pypy') }} | |
run: | | |
set -ex | |
sudo apt-get install -y mingw-w64 | |
rustup component add llvm-tools-preview | |
rustup target add x86_64-pc-windows-gnu | |
rustup target add x86_64-pc-windows-msvc | |
# abi3 | |
cargo run -- build -m test-crates/pyo3-pure/Cargo.toml --target x86_64-pc-windows-gnu | |
cargo run -- build -m test-crates/pyo3-pure/Cargo.toml --target x86_64-pc-windows-msvc | |
# no-abi3 | |
cargo run -- build -i python${{ matrix.python-version }} -m test-crates/pyo3-mixed/Cargo.toml --target x86_64-pc-windows-msvc | |
- name: test compiling with PYO3_CONFIG_FILE | |
shell: bash | |
run: | | |
set -ex | |
rustup target add x86_64-unknown-linux-gnu | |
export PYO3_CONFIG_FILE=$(pwd)/test-crates/pyo3-mixed/pyo3-config.txt | |
cargo run -- build -m test-crates/pyo3-mixed/Cargo.toml --target x86_64-unknown-linux-gnu --zig | |
- name: test maturin new | |
shell: bash | |
run: | | |
set -ex | |
cargo run new -b pyo3 test-crates/pyo3-new | |
cargo run build -m test-crates/pyo3-new/Cargo.toml --target-dir test-crates/targets/ | |
cargo run new --mixed -b pyo3 test-crates/pyo3-new-mixed | |
cargo run build -m test-crates/pyo3-new-mixed/Cargo.toml --target-dir test-crates/targets/ | |
test-emscripten: | |
name: Test Emscripten | |
if: github.event_name != 'pull_request' | |
runs-on: ubuntu-latest | |
env: | |
PYODIDE_VERSION: "0.23.4" | |
PYTHON_VERSION: "3.11.2" | |
NODE_VERSION: 18 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
id: setup-python | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- uses: dtolnay/rust-toolchain@nightly | |
with: | |
components: rust-src | |
targets: wasm32-unknown-emscripten | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
shared-key: maturin-build | |
- run: pip install nox | |
- name: Setup Pyodide | |
run: nox -s setup-pyodide | |
- uses: mymindstorm/setup-emsdk@v12 | |
with: | |
version: ${{ env.EMSCRIPTEN_VERSION }} | |
actions-cache-folder: emsdk-cache | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Run tests | |
run: nox -s test-emscripten | |
test-alpine: | |
name: Test Alpine Linux | |
if: github.event_name != 'pull_request' | |
runs-on: ubuntu-latest | |
env: | |
RUST_BACKTRACE: "1" | |
CARGO_INCREMENTAL: "0" | |
CARGO_TERM_COLOR: always | |
container: alpine:latest | |
steps: | |
- name: Install build requirements | |
run: | | |
set -ex | |
apk add cargo python3-dev libffi-dev py3-pip curl bash tar zstd git patchelf | |
pip3 install cffi virtualenv | |
- uses: actions/checkout@v3 | |
- name: Fix git permissions | |
run: git config --global --add safe.directory $GITHUB_WORKSPACE | |
- name: Cache cargo build | |
uses: Swatinem/rust-cache@v2 | |
with: | |
shared-key: maturin-build | |
- name: Install cargo-nextest | |
uses: taiki-e/install-action@nextest | |
- name: cargo test | |
run: | | |
# unset GITHUB_ACTIONS env var to disable zig related tests | |
env -u GITHUB_ACTIONS cargo nextest run --features password-storage | |
test-auditwheel: | |
name: Test Auditwheel | |
if: github.event_name != 'pull_request' | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: ${{ !contains(github.event.pull_request.labels.*.name, 'CI-no-fail-fast') }} | |
matrix: | |
# manylinux2014 fails with `/lib64/libc.so.6: version `GLIBC_2.18'` not found recently | |
# could be an upstream Rust issue, disable it for now | |
# | |
# manylinux: [ 'manylinux2014', 'manylinux_2_24' ] | |
manylinux: ["manylinux_2_24"] | |
container: quay.io/pypa/${{ matrix.manylinux }}_x86_64 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dtolnay/rust-toolchain@stable | |
id: rustup | |
# Caching | |
- name: Cache cargo build | |
uses: Swatinem/rust-cache@v2 | |
with: | |
shared-key: maturin-build | |
- name: Compliant Build | |
run: tests/manylinux_compliant.sh ${{ matrix.manylinux }} | |
- name: Incompliant Build | |
if: matrix.manylinux == 'manylinux_2_24' | |
run: tests/manylinux_incompliant.sh ${{ matrix.manylinux }} | |
test-docker: | |
name: Test Docker | |
if: github.event_name != 'pull_request' | |
runs-on: ubuntu-latest | |
env: | |
CARGO_INCREMENTAL: "0" | |
CARGO_TERM_COLOR: always | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.11" | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- uses: docker/setup-buildx-action@v2 | |
- name: Build | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: false | |
tags: maturin | |
load: true | |
cache-from: type=registry,ref=ghcr.io/pyo3/maturin:buildcache | |
cache-to: type=registry,ref=ghcr.io/pyo3/maturin:buildcache,mode=max | |
- name: Test the Docker container | |
run: ./test-dockerfile.sh | |
test-cross-compile: | |
name: Test Cross Compile | |
if: github.event_name != 'pull_request' | |
runs-on: ubuntu-latest | |
container: ${{ matrix.platform.container }} | |
strategy: | |
fail-fast: ${{ !contains(github.event.pull_request.labels.*.name, 'CI-no-fail-fast') }} | |
matrix: | |
platform: | |
# CPython | |
- target: aarch64-unknown-linux-gnu | |
abi: cp37-cp37m | |
python: python3.7 | |
container: ghcr.io/rust-cross/manylinux2014-cross:aarch64 | |
- target: armv7-unknown-linux-gnueabihf | |
abi: cp39-cp39 | |
python: python3.9 | |
container: ghcr.io/rust-cross/manylinux2014-cross:armv7 | |
- target: s390x-unknown-linux-gnu | |
abi: cp310-cp310 | |
python: python3.10 | |
container: ghcr.io/rust-cross/manylinux2014-cross:s390x | |
# PyPy | |
- target: aarch64-unknown-linux-gnu | |
abi: pp39-pypy39_pp73 | |
python: pypy3.9 | |
container: ghcr.io/rust-cross/manylinux2014-cross:aarch64 | |
- target: aarch64-unknown-linux-gnu | |
abi: pp310-pypy310_pp73 | |
python: pypy3.10 | |
container: ghcr.io/rust-cross/manylinux2014-cross:aarch64 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ matrix.platform.target }} | |
- name: Build wheels | |
run: | | |
set -ex | |
# Use bundled sysconfig | |
cargo run --target x86_64-unknown-linux-gnu -- build -i ${{ matrix.platform.python }} --release --out dist --target ${{ matrix.platform.target }} -m test-crates/pyo3-mixed/Cargo.toml | |
# Use PYO3_CROSS_LIB_DIR | |
export PYO3_CROSS_LIB_DIR=/opt/python/${{ matrix.platform.abi }} | |
cargo run --target x86_64-unknown-linux-gnu -- build -i python3.9 --release --out dist --target ${{ matrix.platform.target }} -m test-crates/pyo3-mixed/Cargo.toml | |
unset PYO3_CROSS_LIB_DIR | |
# Test abi3 | |
cargo run --target x86_64-unknown-linux-gnu -- build -i ${{ matrix.platform.python }} --release --out dist --target ${{ matrix.platform.target }} -m test-crates/pyo3-pure/Cargo.toml | |
# --find-interpreter | |
cargo run --target x86_64-unknown-linux-gnu -- build --find-interpreter --release --out dist --target ${{ matrix.platform.target }} -m test-crates/pyo3-mixed/Cargo.toml | |
test-bootstrap: | |
name: Test Bootstrap | |
runs-on: ${{ matrix.os }} | |
env: | |
SCCACHE_GHA_ENABLED: "true" | |
RUSTC_WRAPPER: "sccache" | |
strategy: | |
fail-fast: ${{ !contains(github.event.pull_request.labels.*.name, 'CI-no-fail-fast') }} | |
matrix: | |
os: [ubuntu-latest, macos-13, windows-latest] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dorny/paths-filter@v2 | |
id: changes | |
with: | |
filters: | | |
changed: | |
- 'maturin/**' | |
- 'pyproject.toml' | |
- 'setup.py' | |
- 'MANIFEST.in' | |
- 'Cargo.toml' | |
- '.github/workflows/test.yml' | |
- uses: dtolnay/rust-toolchain@stable | |
if: ${{ steps.changes.outputs.changed == 'true' || contains(github.event.pull_request.labels.*.name, 'release') }} | |
# Caching | |
- name: Sccache Setup | |
if: ${{ steps.changes.outputs.changed == 'true' || contains(github.event.pull_request.labels.*.name, 'release') }} | |
uses: mozilla-actions/sccache-action@v0.0.3 | |
with: | |
version: "v0.5.3" | |
- uses: actions/setup-python@v4 | |
if: ${{ steps.changes.outputs.changed == 'true' || contains(github.event.pull_request.labels.*.name, 'release') }} | |
with: | |
python-version: "3.10" | |
- name: Build and install | |
shell: bash | |
run: | | |
set -ex | |
cargo run sdist -o dist | |
pip install -v dist/maturin-*.tar.gz | |
if: ${{ steps.changes.outputs.changed == 'true' || contains(github.event.pull_request.labels.*.name, 'release') }} | |
- run: maturin --version | |
if: ${{ steps.changes.outputs.changed == 'true' || contains(github.event.pull_request.labels.*.name, 'release') }} | |
- run: python3 -m maturin --version | |
if: ${{ steps.changes.outputs.changed == 'true' || contains(github.event.pull_request.labels.*.name, 'release') }} | |
- name: Upload wheel artifacts | |
if: ${{ steps.changes.outputs.changed == 'true' || contains(github.event.pull_request.labels.*.name, 'release') }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheels | |
path: dist | |
test-msrv: | |
name: Test MSRV | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dtolnay/rust-toolchain@1.64.0 | |
# Caching | |
- name: Cache cargo build | |
uses: Swatinem/rust-cache@v2 | |
- run: cargo build --no-default-features | |
- name: cargo build | |
run: cargo build --all | |
test-pyston: | |
name: Test Pyston | |
if: github.event_name != 'pull_request' | |
runs-on: ubuntu-latest | |
container: pyston/pyston:2.3.5 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Fix git permissions | |
run: git config --global --add safe.directory $GITHUB_WORKSPACE | |
- uses: dtolnay/rust-toolchain@stable | |
id: rustup | |
with: | |
targets: wasm32-wasi | |
- name: Install cargo-nextest | |
uses: taiki-e/install-action@nextest | |
- name: Install python packages | |
run: pip install virtualenv cffi | |
# Caching | |
- name: Cache cargo build | |
uses: Swatinem/rust-cache@v2 | |
with: | |
shared-key: maturin-build | |
- name: cargo test | |
env: | |
MATURIN_TEST_PYTHON: pyston | |
run: | | |
# unset GITHUB_ACTIONS env var to disable zig and conda related tests | |
env -u GITHUB_ACTIONS cargo nextest run --features password-storage | |
check: | |
name: Check ${{ matrix.platform.target }} | |
if: github.event_name != 'pull_request' | |
strategy: | |
fail-fast: ${{ !contains(github.event.pull_request.labels.*.name, 'CI-no-fail-fast') }} | |
matrix: | |
platform: | |
- target: armv5te-unknown-linux-gnueabi | |
apt-packages: gcc-arm-linux-gnueabi | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install packages | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y ${{ matrix.platform.apt-packages }} | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ matrix.platform.target }} | |
- name: Cache cargo build | |
uses: Swatinem/rust-cache@v2 | |
- name: cargo check | |
run: cargo check --target ${{ matrix.platform.target }} | |
conclusion: | |
needs: | |
- test | |
- test-emscripten | |
- test-alpine | |
- test-auditwheel | |
- test-docker | |
- test-cross-compile | |
- test-bootstrap | |
- test-msrv | |
- test-pyston | |
- check | |
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) }} |