-
Notifications
You must be signed in to change notification settings - Fork 0
421 lines (354 loc) · 13.3 KB
/
ci.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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
name: CI
on:
push:
branches:
- main
tags:
- '**'
pull_request: {}
jobs:
test-py:
name: test ${{ matrix.python-version }} on ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu, macos, windows]
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
runs-on: ${{ matrix.os }}-latest
env:
PYTHON: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v3
- name: set up python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: install rust
uses: dtolnay/rust-toolchain@nightly
- id: cache-rust
name: cache rust
uses: Swatinem/rust-cache@v2
with:
key: v1
# TODO: some actual testing!
- run: pip install -vvv -e .
test-rust:
name: test against ${{ matrix.rust-toolchain }} rust
strategy:
fail-fast: true
matrix:
rust-toolchain: ['stable', 'nightly']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- run: pip install --upgrade pip
- name: install rust ${{ matrix.rust-toolchain }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust-toolchain }}
- id: cache-rust-tests
name: cache rust
uses: Swatinem/rust-cache@v2
with:
key: v1
- name: test rust
run: cargo test
lint-rust:
name: perform rust lint and style checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- run: pip install --upgrade pip
- name: install rust nightly
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt, clippy
- id: cache-rust-lint
name: cache rust
uses: Swatinem/rust-cache@v2
with:
key: v1
- name: fmt rust
run: cargo fmt --check
- name: clippy rust
run: cargo clippy
lint-py:
name: perform python lint and style checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- run: pip install --upgrade pip
- uses: isort/isort-action@master
with:
sortPaths: "py"
check-versions:
name: ensure package versions all correspond to the most recent tag
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- run: pip install --upgrade pip
- run: sudo apt install jq
- name: install rust nightly
uses: dtolnay/rust-toolchain@nightly
- name: extract python setup requires in order to extract the version (lol)
run: |
python -c 'import tomllib; t = tomllib.load(open("pyproject.toml", "rb")); print("\n".join(t["build-system"]["requires"]));' > build-requires.txt
pip install -r build-requires.txt
- name: extract all the versions from across the repo
run: |
set -o pipefail
git describe --tags --abbrev=0 > latest-tag.version
printf 'v%s\n' "$(python setup.py --dry-run --version 2>/dev/null)" > pypi-medusa-zip.version
cargo metadata --format-version 1 | jq -r '.packages[] | select(.name == "libmedusa-zip") | "v" + .version' > libmedusa-zip.version
cargo metadata --format-version 1 | jq -r '.packages[] | select(.name == "pymedusa-zip") | "v" + .version' > pymedusa-zip.version
cargo metadata --format-version 1 | jq -r '.packages[] | select(.name == "medusa-zip") | "v" + .version' > cli-medusa-zip.version
cargo metadata --format-version 1 | jq -r '.packages[] | .dependencies[] | select(.name == "libmedusa-zip") | .req' | sed -re 's#^\^#v#' > internal-deps.version
- name: check that all the versions match up across the workspace
run: |
num_separate_versions="$(cat *.version | sort -u | wc -l)"
if [[ "$num_separate_versions" -gt 1 ]]; then
echo '::error::versions are out of sync:'
for f in *.version; do
echo "::error::${f} => $(<"$f" tr '\n' ',' | sed -re "s#,\$#\n#")"
done
exit 1
fi
# https://github.com/marketplace/actions/alls-green#why used for branch protection checks
check:
if: always()
needs: [test-py, test-rust, lint-rust, lint-py, check-versions]
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
build-sdist:
name: Build source distribution
# NB: we have decided that releases are tags starting with a 'v'!
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build sdist
run: pipx run build --sdist
- uses: actions/upload-artifact@v3
with:
name: sdist-artifact
path: dist/*.tar.gz
if-no-files-found: error
build-bdists-ubuntu:
name: build bdist for ${{ matrix.python-version }}/${{ matrix.py-impl }}/${{ matrix.libc-type }} on linux
# run on releases, and on PRs with the label 'Full Build'
if: success() && (startsWith(github.ref, 'refs/tags/') || contains(github.event.pull_request.labels.*.name, 'Full Build'))
strategy:
fail-fast: true
matrix:
python-version: ['37', '38', '39', '310', '311']
py-impl: ['cp', 'pp']
libc-type: ['manylinux', 'musllinux']
exclude:
# PyPy does not appear to support musl: https://cibuildwheel.readthedocs.io/en/stable/options/#build-skip.
- py-impl: pp
libc-type: musllinux
# PyPy only goes up to 3.10: https://cibuildwheel.readthedocs.io/en/stable/options/#build-skip.
- py-impl: pp
python-version: 311
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: set up python
uses: actions/setup-python@v4
with:
python-version: 3.11
- run: pip install --upgrade pip
- name: build wheels
uses: pypa/cibuildwheel@v2.14.1
env:
CIBW_ARCHS_LINUX: x86_64
CIBW_BUILD: ${{ matrix.py-impl }}${{ matrix.python-version }}-${{ matrix.libc-type }}*
- uses: actions/upload-artifact@v3
with:
name: linux-bdist-artifacts
path: ./wheelhouse/*.whl
if-no-files-found: error
build-bdists-macos-x86_64:
name: build bdist for ${{ matrix.python-version }}/${{ matrix.py-impl }} on macos x86_64
# run on releases, and on PRs with the label 'Full Build'
if: success() && (startsWith(github.ref, 'refs/tags/') || contains(github.event.pull_request.labels.*.name, 'Full Build'))
strategy:
fail-fast: true
matrix:
python-version: ['37', '38', '39', '310', '311']
py-impl: ['cp', 'pp']
exclude:
# PyPy only goes up to 3.10: https://cibuildwheel.readthedocs.io/en/stable/options/#build-skip.
- py-impl: pp
python-version: 311
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: set up python
uses: actions/setup-python@v4
with:
python-version: 3.11
- run: pip install --upgrade pip
- name: build wheels
uses: pypa/cibuildwheel@v2.14.1
env:
CIBW_ARCHS_MACOS: x86_64
CIBW_BUILD: ${{ matrix.py-impl }}${{ matrix.python-version }}-*
- uses: actions/upload-artifact@v3
with:
name: macos-bdist-artifacts
path: ./wheelhouse/*.whl
if-no-files-found: error
build-bdists-macos-arm64:
name: build bdist for ${{ matrix.python-version }}/${{ matrix.py-impl }} on macos arm64
# run on releases, and on PRs with the label 'Full Build'
if: success() && (startsWith(github.ref, 'refs/tags/') || contains(github.event.pull_request.labels.*.name, 'Full Build'))
strategy:
fail-fast: true
matrix:
# "Only CPython 3.8 and newer support universal2 and arm64 wheels."
# See https://cibuildwheel.readthedocs.io/en/stable/faq/#how-to-cross-compile
python-version: ['38', '39', '310', '311']
py-impl: ['cp']
# PyPy currently cannot be built for arm64 on macos! We get this extremely obtuse and frustrating error when we try:
# https://github.com/pypa/cibuildwheel/blob/4135c0a01dc11910ce118f58acc7caf4ac5c524a/cibuildwheel/macos.py#L92-L112
# py-impl: ['cp', 'pp']
# exclude:
# # PyPy only goes up to 3.10: https://cibuildwheel.readthedocs.io/en/stable/options/#build-skip.
# - py-impl: pp
# python-version: 311
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: set up python
uses: actions/setup-python@v4
with:
python-version: 3.11
- run: pip install --upgrade pip
- name: build wheels
uses: pypa/cibuildwheel@v2.14.1
env:
CIBW_ARCHS_MACOS: arm64
# This target isn't added by the rustup command in tool.cibuildwheel.before-all.
CIBW_BEFORE_ALL_MACOS: rustup target add aarch64-apple-darwin
CIBW_BUILD: ${{ matrix.py-impl }}${{ matrix.python-version }}-*
- uses: actions/upload-artifact@v3
with:
name: macos-bdist-artifacts
path: ./wheelhouse/*.whl
if-no-files-found: error
build-bdists-windows:
name: build bdist for ${{ matrix.python-version }}/${{ matrix.py-impl }}/${{ matrix.arch }} on windows
# run on releases, and on PRs with the label 'Full Build'
if: success() && (startsWith(github.ref, 'refs/tags/') || contains(github.event.pull_request.labels.*.name, 'Full Build'))
strategy:
fail-fast: true
matrix:
python-version: ['37', '38', '39', '310', '311']
py-impl: ['cp', 'pp']
arch: ['AMD64']
# FIXME: figure out how to get ARM64 windows builds working!
# arch: ['AMD64', 'ARM64']
exclude:
# PyPy only goes up to 3.10: https://cibuildwheel.readthedocs.io/en/stable/options/#build-skip.
- py-impl: pp
python-version: 311
# FIXME: figure out how to get ARM64 windows builds working!
# Windows does not support ARM64 until 3.8: https://cibuildwheel.readthedocs.io/en/stable/options/#build-skip.
# - python-version: 37
# arch: ARM64
# - python-version: 38
# arch: ARM64
# # Windows PyPy does not support ARM64: https://cibuildwheel.readthedocs.io/en/stable/options/#build-skip.
# - py-impl: pp
# arch: ARM64
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: set up python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: build wheels
uses: pypa/cibuildwheel@v2.14.1
env:
CIBW_ARCHS_WINDOWS: ${{ matrix.arch }}
CIBW_BUILD: ${{ matrix.py-impl }}${{ matrix.python-version }}-win_${{ matrix.arch }}
# CIBW_BEFORE_ALL: "rmdir C:\\Users\\runneradmin\\.cargo /s /q && curl.exe --url https://static.rust-lang.org/rustup/dist/i686-pc-windows-gnu/rustup-init.exe --output rustup-init.exe && .\\rustup-init.exe --default-toolchain nightly --default-host aarch64-pc-windows-msvc -y && rustup.exe target add aarch64-pc-windows-msvc"
- uses: actions/upload-artifact@v3
with:
name: windows-bdist-artifacts
path: ./wheelhouse/*.whl
if-no-files-found: error
upload-pypi-assets:
name: upload it to pypi
# NB: we have decided that releases are tags starting with a 'v'!
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs: [check, build-sdist, build-bdists-ubuntu, build-bdists-macos-x86_64, build-bdists-macos-arm64, build-bdists-windows]
environment: pypi
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- name: get sdist artifact
uses: actions/download-artifact@v3
with:
name: sdist-artifact
path: dist
- name: get linux bdist artifacts
uses: actions/download-artifact@v3
with:
name: linux-bdist-artifacts
path: dist
- name: get macos bdist artifacts
uses: actions/download-artifact@v3
with:
name: macos-bdist-artifacts
path: dist
- name: get windows bdist artifacts
uses: actions/download-artifact@v3
with:
name: windows-bdist-artifacts
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
publish-cargo-packages:
name: publish cargo packages
# NB: we have decided that releases are tags starting with a 'v'!
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs: [check]
environment: crates-io
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: install rust nightly
uses: dtolnay/rust-toolchain@nightly
- id: cache-rust-publish
name: cache rust
uses: Swatinem/rust-cache@v2
with:
key: v1
- env:
CARGO_REGISTRY_TOKEN: ${{ secrets.MEDUSA_ONLY_TOKEN }}
run: |
cargo publish -p libmedusa-zip
cargo publish -p pymedusa-zip
cargo publish -p medusa-zip