-
Notifications
You must be signed in to change notification settings - Fork 429
296 lines (283 loc) · 9.84 KB
/
build.yml
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
name: Build
on:
workflow_dispatch:
push:
branches: [ master ]
tags:
- v*
pull_request:
branches: [ master ]
env:
CARGO_TERM_COLOR: always
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: pre-commit/[email protected]
build-linux-armv7:
runs-on: [self-hosted, linux, arm]
needs: [lint]
steps:
- name: Setup python
run: |
pyenv global system
python --version
- uses: actions/checkout@v3
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test
build:
runs-on: ${{ matrix.os }}
needs: [lint]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v3
- name: Install Dependencies
run: sudo apt install libunwind-dev
if: runner.os == 'Linux'
- name: Build
run: cargo build --release --verbose --examples
- name: Test
id: test
continue-on-error: true
run: cargo test --release
- name: Test (retry#1)
id: test1
run: cargo test --release
if: steps.test.outcome=='failure'
continue-on-error: true
- name: Test (retry#2)
run: cargo test --release
if: steps.test1.outcome=='failure'
- uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Build Wheel
run: |
pip install --upgrade maturin
maturin build --release -o dist
if: runner.os != 'Linux'
- name: Build Wheel - universal2
env:
DEVELOPER_DIR: /Applications/Xcode.app/Contents/Developer
SDKROOT: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
MACOSX_DEPLOYMENT_TARGET: 10.9
run: |
rustup target add aarch64-apple-darwin
pip install --upgrade maturin
maturin build --release -o dist --target universal2-apple-darwin
if: matrix.os == 'macos-latest'
- name: Rename Wheels
run: |
python3 -c "import shutil; import glob; wheels = glob.glob('dist/*.whl'); [shutil.move(wheel, wheel.replace('py3', 'py2.py3')) for wheel in wheels if 'py2' not in wheel]"
if: runner.os != 'Linux'
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist
if: runner.os != 'Linux'
build-linux-cross:
runs-on: ubuntu-latest
needs: [lint]
strategy:
fail-fast: false
matrix:
target: [i686-musl, armv7-musleabihf, aarch64-musl, x86_64-musl]
container:
image: docker://benfred/rust-musl-cross:${{ matrix.target }}
env:
RUSTUP_HOME: /root/.rustup
CARGO_HOME: /root/.cargo
steps:
- uses: actions/checkout@v3
- name: Build
run: |
python3 -m pip install --upgrade maturin
maturin build --release -o dist --target $RUST_MUSL_CROSS_TARGET
maturin sdist -o dist
- name: Rename Wheels
run: |
python3 -c "import shutil; import glob; wheels = glob.glob('dist/*.whl'); [shutil.move(wheel, wheel.replace('py3', 'py2.py3')) for wheel in wheels if 'py2' not in wheel]"
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist
build-freebsd:
runs-on: macos-latest
needs: [lint]
timeout-minutes: 30
strategy:
matrix:
include:
- box: fbsd_13_1
release: FreeBSD-13.1-STABLE
url: https://github.com/rbspy/freebsd-vagrant-box/releases/download/20221112/fbsd_13_1.box
steps:
- uses: actions/checkout@v3
- name: Cache Vagrant box
uses: actions/[email protected]
with:
path: ~/.vagrant.d
key: ${{ matrix.box }}-vagrant-boxes-20221112-${{ hashFiles('ci/Vagrantfile') }}
restore-keys: |
${{ matrix.box }}-vagrant-boxes-20221112-
- name: Cache Cargo and build artifacts
uses: actions/[email protected]
with:
path: build-artifacts.tar
key: ${{ matrix.box }}-cargo-20221112-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ matrix.box }}-cargo-20221112-
- name: Set up VM
run: |
brew install vagrant
vagrant plugin install vagrant-vbguest
vagrant plugin install vagrant-scp
ln -sf ci/Vagrantfile Vagrantfile
if [ ! -d ~/.vagrant.d/boxes/rbspy-VAGRANTSLASH-${{ matrix.release }} ]; then
vagrant box add --no-tty rbspy/${{ matrix.release }} ${{ matrix.url }}
fi
vagrant up ${{ matrix.box }}
- name: Build and test
run: vagrant ssh ${{ matrix.box }} -- bash /vagrant/ci/test_freebsd.sh
- name: Retrieve build artifacts for caching purposes
run: |
vagrant scp ${{ matrix.box }}:/vagrant/build-artifacts.tar build-artifacts.tar
ls -ahl build-artifacts.tar
- name: Prepare binary for upload
run: |
tar xf build-artifacts.tar target/release/py-spy
mv target/release/py-spy py-spy-x86_64-unknown-freebsd
- name: Upload Binaries
uses: actions/upload-artifact@v3
with:
name: py-spy-x86_64-unknown-freebsd
path: py-spy-x86_64-unknown-freebsd
test-wheels:
name: Test Wheels
needs: [build, build-linux-cross]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: [2.7.17, 2.7.18, 3.5.4, 3.5.9, 3.5.10, 3.6.7, 3.6.8, 3.6.9, 3.6.10, 3.6.11, 3.6.12, 3.6.13, 3.6.14, 3.6.15, 3.7.1, 3.7.2, 3.7.3, 3.7.4, 3.7.5, 3.7.6, 3.7.7, 3.7.8, 3.7.9, 3.7.10, 3.7.11, 3.7.12, 3.7.13, 3.7.14, 3.7.15, 3.7.16, 3.7.17, 3.8.0, 3.8.1, 3.8.2, 3.8.3, 3.8.4, 3.8.5, 3.8.6, 3.8.7, 3.8.8, 3.8.9, 3.8.10, 3.8.11, 3.8.12, 3.8.13, 3.8.14, 3.8.15, 3.8.16, 3.8.17, 3.9.0, 3.9.1, 3.9.2, 3.9.3, 3.9.4, 3.9.5, 3.9.6, 3.9.7, 3.9.8, 3.9.9, 3.9.10, 3.9.11, 3.9.12, 3.9.13, 3.9.14, 3.9.15, 3.9.16, 3.9.17, 3.10.0, 3.10.1, 3.10.2, 3.10.3, 3.10.4, 3.10.5, 3.10.6, 3.10.7, 3.10.8, 3.10.9, 3.10.10, 3.10.11, 3.10.12, 3.11.0, 3.11.1, 3.11.2, 3.11.3, 3.11.4]
# TODO: also test windows
os: [ubuntu-20.04, macos-latest]
# some versions of python can't be tested on GHA with osx because of SIP:
exclude:
- os: macos-latest
python-version: 3.11.0
- os: macos-latest
python-version: 3.11.1
- os: macos-latest
python-version: 3.11.2
- os: macos-latest
python-version: 3.11.3
- os: macos-latest
python-version: 3.11.4
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v3
with:
name: wheels
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install wheel
run: |
pip install --force-reinstall --no-index --find-links . py-spy
- name: Test Wheel
id: test
run: python tests/integration_test.py
if: runner.os != 'macOS'
continue-on-error: true
- name: Test Wheel (Retry#1)
id: test1
run: python tests/integration_test.py
if: steps.test.outcome=='failure'
continue-on-error: true
- name: Test Wheel (Retry#2)
id: test2
run: python tests/integration_test.py
if: steps.test1.outcome=='failure'
- name: Test macOS Wheel
id: osx_test
run: sudo "PATH=$PATH" python tests/integration_test.py
if: runner.os == 'macOS'
continue-on-error: true
- name: Test macOS Wheel (Retry#1)
id: osx_test1
run: sudo "PATH=$PATH" python tests/integration_test.py
if: steps.osx_test.outcome=='failure'
continue-on-error: true
- name: Test macOS Wheel (Retry#2)
id: osx_test2
run: sudo "PATH=$PATH" python tests/integration_test.py
if: steps.osx_test1.outcome=='failure'
test-wheel-linux-armv7:
name: Test ARMv7 Wheel
needs: [build-linux-cross]
runs-on: [self-hosted, linux, arm]
strategy:
matrix:
# we're installing the manylinux2014 wheel, so can
# only test out relatively recent versions of python
pyenv-python-version: [3.7.10, 3.8.9, 3.9.4]
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: wheels
- name: Setup pyenv
run: |
# build the version of python if not installed already
# (note this relies on pyenv being setup already)
pyenv install -s ${{ matrix.pyenv-python-version }}
pyenv global ${{ matrix.pyenv-python-version }}
python --version
- name: Install wheel
run: |
pip install --force-reinstall --no-index --find-links . py-spy
- name: Test Wheel
run: python tests/integration_test.py
release:
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [test-wheels, test-wheel-linux-armv7]
steps:
- uses: actions/download-artifact@v3
with:
name: wheels
- name: Create GitHub Release
uses: fnkr/[email protected]
env:
GHR_PATH: .
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install Dependencies
run: sudo apt install libunwind-dev
if: runner.os == 'Linux'
- uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Push to PyPi
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
pip install --upgrade wheel pip setuptools twine
twine upload *
rm *
- uses: actions/checkout@v3
- name: Push to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish