-
Notifications
You must be signed in to change notification settings - Fork 102
145 lines (127 loc) · 4.3 KB
/
build-and-test.yml
File metadata and controls
145 lines (127 loc) · 4.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# 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
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
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