Skip to content

Bump astral-sh/ruff-action from 3.5.1 to 3.6.1 (#287) #972

Bump astral-sh/ruff-action from 3.5.1 to 3.6.1 (#287)

Bump astral-sh/ruff-action from 3.5.1 to 3.6.1 (#287) #972

# Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
name: Build and Test, Release
on:
push:
branches:
- main
tags:
- v*
pull_request:
workflow_dispatch:
jobs:
build_wheels:
env:
CIBW_ARCHS_MACOS: universal2
MACOSX_DEPLOYMENT_TARGET: "10.15"
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
CIBW_BEFORE_ALL_LINUX: WD=`pwd` && /opt/python/cp39-cp39/bin/python -m pip install --target tmp_cmake cmake && cp tmp_cmake/bin/cmake /usr/local/bin/cmake && rm -rf tmp_cmake && /opt/python/cp39-cp39/bin/python -m pip install cmake && cmake --version && whereis cmake
CIBW_BEFORE_ALL_MACOS: WD=`pwd` && pip install cmake
CIBW_BEFORE_BUILD_LINUX: pip install protobuf
CIBW_BEFORE_BUILD_WINDOWS: python -m pip install protobuf
CIBW_BEFORE_BUILD_MACOS: pip install protobuf
CIBW_ENABLE: "cpython-freethreading"
CIBW_TEST_REQUIRES_LINUX: pytest pytest-xdist ruff mypy onnxruntime onnxscript
CIBW_TEST_REQUIRES_MACOS: pytest pytest-xdist
CIBW_TEST_REQUIRES_WINDOWS: pytest pytest-xdist
CIBW_BEFORE_TEST_LINUX: pip install torch==2.9.1 torchvision==0.24.1 --index-url https://download.pytorch.org/whl/cpu
CIBW_TEST_COMMAND: pytest {project}/onnxoptimizer/test
CIBW_TEST_COMMAND_LINUX: cd {project} && pytest
CIBW_TEST_SKIP: " *_arm64"
CIBW_ENVIRONMENT: CMAKE_ARGS="-DONNX_USE_LITE_PROTO=ON"
CIBW_BUILD: "${{ matrix.python }}-*"
CIBW_SKIP: "*-win32 *-manylinux_i686 *-musllinux_*"
name: Build whls ${{ matrix.os }}${{ matrix.python }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, windows-2022, macos-15]
python: ["cp313t", "cp312", "cp311", "cp310"] # because of abi3 we don't need to build separate whls for python 3.13, 3.14
steps:
- uses: actions/checkout@v6.0.1
with:
submodules: recursive
- name: Build wheels
uses: pypa/cibuildwheel@v3.3.1
- uses: actions/upload-artifact@v6
with:
name: wheels-${{ matrix.os }}-${{ matrix.python }}
path: ./wheelhouse/*.whl
- name: Check ABI3
run: |
pip install abi3audit
abi3audit --strict -v --report ./wheelhouse/*.whl
if: ${{ contains(fromJSON('["cp312", "cp313"]'), matrix.python) }}
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.1
with:
submodules: recursive
- name: Build sdist
run: pipx run build --sdist
- name: Install and test sdist
run: |
# It's important to leave the project directory where a 'onnxoptimizer' subdirectory exists
cd dist
python3 -m pip install *.tar.gz
python3 -c "import onnxoptimizer; print(onnxoptimizer.get_fuse_and_elimination_passes())"
- uses: actions/upload-artifact@v6
with:
name: sdist
path: dist/*.tar.gz
collect_dist:
name: Collect distributions
runs-on: ubuntu-latest
needs: [build_wheels, build_sdist]
steps:
- name: Download wheels
uses: actions/download-artifact@v7
with:
pattern: wheels-*
path: dist
merge-multiple: true
- name: Download sdist
uses: actions/download-artifact@v7
with:
name: sdist
path: dist
- name: Verify distributions
run: |
echo "Wheels:"
ls -lh dist/*.whl
echo
echo "Source distributions:"
ls -lh dist/*.tar.gz
- name: Twine check
run: |
pip install -U twine packaging
twine check dist/*
release:
name: Release
runs-on: ubuntu-latest
needs: collect_dist
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
permissions:
id-token: write
environment:
name: release
steps:
- name: Download wheels
uses: actions/download-artifact@v7
with:
pattern: wheels-*
path: dist
merge-multiple: true
- name: Download sdist
uses: actions/download-artifact@v7
with:
name: sdist
path: dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
attestations: true