-
Notifications
You must be signed in to change notification settings - Fork 54
483 lines (464 loc) · 18.5 KB
/
all.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
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
name: Compile, Test, and Deploy
on:
pull_request: {}
push:
branches:
- main
release:
types: [published]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
lint-java:
runs-on: 'ubuntu-latest'
continue-on-error: true
name: Lint Java
defaults:
run:
working-directory: java
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'corretto'
- name: Check Formatting
run: mvn --batch-mode com.spotify.fmt:fmt-maven-plugin:check
lint-cpp:
runs-on: 'ubuntu-latest'
continue-on-error: true
name: Lint C++
steps:
- uses: actions/checkout@v3
- name: Check C++ Formatting
uses: jidicula/[email protected]
with:
clang-format-version: 16
run-cpp-tests:
runs-on: ${{ matrix.os }}
continue-on-error: true
defaults:
run:
working-directory: cpp
strategy:
matrix:
# TODO: Switch back to macos-latest once https://github.com/actions/python-versions/pull/114 is fixed
os:
- 'ubuntu-latest'
- windows-latest
- macos-12
name: Test C++ on ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Install CMake (Windows)
if: matrix.os == 'windows-latest'
run: |
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System'
- name: Install CMake (MacOS)
if: matrix.os == 'macos-12'
run: brew install cmake
- name: Install CMake (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get install -y cmake
- name: Run tests
run: make test
run-java-tests:
continue-on-error: true
name: Test with Java ${{ matrix.java-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: java
strategy:
matrix:
os: ['ubuntu-latest', windows-latest, macos-12]
java-version: ['11', '17']
steps:
- uses: actions/checkout@v3
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java-version }}
distribution: 'corretto'
gpg-private-key: ${{ secrets.SONATYPE_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- uses: ilammy/msvc-dev-cmd@v1
if: runner.os == 'Windows'
- name: Compile
run: make
- name: Run Tests
run: mvn --batch-mode test
run-java-tests-with-address-sanitizer:
if: false # Disabled due to ASan log spam in output
continue-on-error: true
name: Test with Java ${{ matrix.java-version }} + Address Sanitizer
runs-on: ubuntu-latest
defaults:
run:
working-directory: java
strategy:
matrix:
java-version: ['11', '17']
steps:
- uses: actions/checkout@v3
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java-version }}
distribution: 'corretto'
gpg-private-key: ${{ secrets.SONATYPE_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Compile
env:
USE_ASAN: "1"
run: make target/classes/linux-x64/libvoyager.so
- name: Run Tests
run: |
ASAN_OPTIONS=detect_leaks=0
LD_PRELOAD=$(clang -print-file-name=libclang_rt.asan-x86_64.so) \
mvn --batch-mode test
run-python-tests:
runs-on: ${{ matrix.os }}
continue-on-error: true
defaults:
run:
working-directory: python
strategy:
matrix:
python-version:
# - '3.7'
- '3.8'
# - '3.9'
# - '3.10'
# - '3.11'
# TODO: Switch back to macos-latest once https://github.com/actions/python-versions/pull/114 is fixed
os: ['ubuntu-latest', windows-latest, macos-12]
name: Test with Python ${{ matrix.python-version }} on ${{ matrix.os }}
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Install Linux dependencies
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y pkg-config
- name: Install test dependencies
env:
# on macOS and with Python 3.10: building NumPy from source fails without these options:
NPY_BLAS_ORDER: ""
NPY_LAPACK_ORDER: ""
run: |
python -m pip install --upgrade pip
pip install wheel
pip install -r dev-requirements.txt
- name: Build voyager locally
run: python setup.py develop
- name: Run tox tests
run: tox
run-python-tests-with-address-sanitizer:
defaults:
run:
working-directory: python
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version:
# - '3.7'
- '3.8'
# - '3.9'
# - '3.10'
# - '3.11'
os: ['ubuntu-latest']
name: Test with Python ${{ matrix.python-version }} + Address Sanitizer
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Install Linux dependencies
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y pkg-config
- name: Install test dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
pip install -r dev-requirements.txt
- name: Build voyager locally
env:
DEBUG: "0"
USE_ASAN: "1"
CC: clang
CXX: clang++
run: python setup.py develop
- name: Run tox tests with ASan loaded
# pytest can exit before all Python objects have been destroyed,
# so we tell ASan to ignore leaks.
run: |
ASAN_OPTIONS=detect_leaks=0 \
LD_PRELOAD=$(clang -print-file-name=libclang_rt.asan-x86_64.so) \
tox
run-benchmarks:
strategy:
matrix:
os: ['ubuntu-latest']
runs-on: ${{ matrix.os }}
continue-on-error: true
if: github.event_name == 'pull_request'
name: Run benchmarks on ${{ matrix.os }}
steps:
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.9'
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- name: Install Linux dependencies
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y pkg-config
- name: Install dev dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
pip install -r python/dev-requirements.txt
- name: Run benchmarks
run: |
asv machine --yes
asv continuous --sort name --no-only-changed refs/remotes/origin/main ${{ github.sha }} | tee >(sed '1,/All benchmarks:/d' > $GITHUB_STEP_SUMMARY)
build-python-wheels:
needs: [run-python-tests, run-python-tests-with-address-sanitizer]
runs-on: ${{ matrix.os }}
continue-on-error: true
if: true # (github.event_name == 'release' && github.event.action == 'published') || contains(github.event.pull_request.labels.*.name, 'Also Test Wheels')
strategy:
matrix:
include:
- { os: macos-12, build: cp37-macosx_x86_64 }
- { os: macos-12, build: cp38-macosx_x86_64 }
- { os: macos-12, build: cp39-macosx_x86_64 }
- { os: macos-12, build: cp310-macosx_x86_64 }
- { os: macos-12, build: cp311-macosx_x86_64 }
- { os: macos-12, build: cp312-macosx_x86_64 }
- { os: macos-12, build: cp38-macosx_universal2 }
- { os: macos-12, build: cp39-macosx_universal2 }
- { os: macos-12, build: cp310-macosx_universal2 }
- { os: macos-12, build: cp311-macosx_universal2 }
- { os: macos-12, build: cp312-macosx_universal2 }
- { os: macos-12, build: cp38-macosx_arm64 }
- { os: macos-12, build: cp39-macosx_arm64 }
- { os: macos-12, build: cp310-macosx_arm64 }
- { os: macos-12, build: cp311-macosx_arm64 }
- { os: macos-12, build: cp312-macosx_arm64 }
# - { os: macos-12, build: pp37-macosx_x86_64 }
# - { os: macos-12, build: pp38-macosx_x86_64 }
# - { os: macos-12, build: pp39-macosx_x86_64 }
- { os: windows-latest, build: cp37-win_amd64 }
- { os: windows-latest, build: cp38-win_amd64 }
- { os: windows-latest, build: cp39-win_amd64 }
- { os: windows-latest, build: cp310-win_amd64 }
- { os: windows-latest, build: cp311-win_amd64 }
- { os: windows-latest, build: cp312-win_amd64 }
# - { os: windows-latest, build: pp37-win_amd64 }
# - { os: windows-latest, build: pp38-win_amd64 }
# - { os: windows-latest, build: pp39-win_amd64 }
- { os: 'ubuntu-latest', build: cp37-manylinux_x86_64 }
- { os: 'ubuntu-latest', build: cp37-manylinux_aarch64 }
- { os: 'ubuntu-latest', build: cp38-manylinux_x86_64 }
- { os: 'ubuntu-latest', build: cp38-manylinux_aarch64 }
- { os: 'ubuntu-latest', build: cp39-manylinux_x86_64 }
- { os: 'ubuntu-latest', build: cp39-manylinux_aarch64 }
- { os: 'ubuntu-latest', build: cp310-manylinux_x86_64 }
- { os: 'ubuntu-latest', build: cp310-manylinux_aarch64 }
- { os: 'ubuntu-latest', build: cp311-manylinux_x86_64 }
- { os: 'ubuntu-latest', build: cp311-manylinux_aarch64 }
- { os: 'ubuntu-latest', build: cp312-manylinux_x86_64 }
- { os: 'ubuntu-latest', build: cp312-manylinux_aarch64 }
# - { os: 'ubuntu-latest', build: pp37-manylinux_x86_64 }
# - { os: 'ubuntu-latest', build: pp37-manylinux_aarch64 }
# - { os: 'ubuntu-latest', build: pp38-manylinux_x86_64 }
# - { os: 'ubuntu-latest', build: pp38-manylinux_aarch64 }
# - { os: 'ubuntu-latest', build: pp39-manylinux_x86_64 }
# - { os: 'ubuntu-latest', build: pp39-manylinux_aarch64 }
name: Build wheel for ${{ matrix.build }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
# Used to host cibuildwheel, so version doesn't really matter
- uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install cibuildwheel
run: python -m pip install 'cibuildwheel>=2.11.0'
- name: Copy README into place
run: cp README.md python/
- name: Set up QEMU for aarch64 on Linux
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v1
with:
platforms: all
- name: Build wheels
run: cp -r cpp python/cpp && cd python && python -m cibuildwheel --output-dir ../wheelhouse
env:
CIBW_TEST_REQUIRES: -r dev-requirements.txt
CIBW_TEST_COMMAND: "pytest {project}/tests -x"
CIBW_BUILD: ${{ matrix.build }}
CIBW_ARCHS: auto64 # Only support building 64-bit wheels. It's 2022!
CIBW_ARCHS_LINUX: auto64 aarch64 # Useful for building linux images with Apple Silicon
CIBW_ARCHS_MACOS: x86_64 universal2 arm64 # Support Apple Silicon
CIBW_ARCHS_WINDOWS: AMD64
# on macOS and with Python 3.10: building NumPy from source fails without these options:
CIBW_ENVIRONMENT: NPY_BLAS_ORDER="" NPY_LAPACK_ORDER=""
CIBW_REPAIR_WHEEL_COMMAND_LINUX: pip install auditwheel-symbols && (auditwheel repair -w {dest_dir} {wheel} || auditwheel-symbols --manylinux 2010 {wheel})
# Use the minimum macOS deployment target that has C++17 support:
CIBW_TEST_SKIP: "*aarch64"
MACOSX_DEPLOYMENT_TARGET: "10.13"
- uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: python-wheels
path: ./wheelhouse/*.whl
build-java-jars:
continue-on-error: false
name: Build JAR with on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: java
strategy:
matrix:
os: ['ubuntu-latest', windows-latest, macos-12]
java-version: ['11']
steps:
- uses: actions/checkout@v3
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java-version }}
distribution: 'corretto'
gpg-private-key: ${{ secrets.SONATYPE_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Set up QEMU for aarch64 on Linux
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v1
with:
platforms: all
- uses: ilammy/msvc-dev-cmd@v1
if: runner.os == 'Windows'
- name: Compile
run: make
- name: Package
run: mvn --batch-mode package
env:
MAVEN_GPG_PASSPHRASE: ${{ secrets.SONATYPE_PASSPHRASE }}
- uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: java-${{ matrix.os }}
path: java/target/voyager-*.jar
combine-java-jars:
name: Combine JARs
runs-on: ubuntu-latest
needs: build-java-jars
steps:
- uses: actions/download-artifact@v3
with:
path: artifacts
- name: Unpack and Repack JARs
shell: bash
working-directory: artifacts
run: |
rm -fv java-*/*-sources.jar
rm -fv java-*/*-javadoc.jar
for artifact in java-*; do unzip -o $artifact/*.jar -d combined-jar; done
# Quick test that the JARs were built for the correct architectures
echo "Checking linux-x64/libvoyager.so for x86 architecture..."
file combined-jar/linux-x64/libvoyager.so | grep x86
echo "Checking mac-x64/libvoyager.dylib for x86 architecture..."
file combined-jar/mac-x64/libvoyager.dylib | grep x86
echo "Checking linux-aarch64/libvoyager.so for aarch64 architecture..."
file combined-jar/linux-aarch64/libvoyager.so | grep aarch64
echo "Checking mac-aarch64/libvoyager.dylib for arm64 architecture..."
file combined-jar/mac-aarch64/libvoyager.dylib | grep arm64
echo "Checking the Linux JARs to ensure a sufficiently old required GLIBC and GLIBCXX version in each..."
echo "Checking linux-aarch64/libvoyager.so (should require at most GLIBC 2.27...)"
objdump -T combined-jar/linux-aarch64/libvoyager.so | grep GLIBC | grep -v GLIBCXX | sed 's/.*GLIBC_\([.0-9]*\).*/\1/g' | cat - <(echo 2\.27) | sort -Vu | tail -n 1 | grep 2\.27 || (echo "Expected linux-aarch64 binary to require at most glibc 2.27. Ensure the dockcross container has not been updated." && false)
echo "Checking linux-aarch64/libvoyager.so (should require at most GLIBCXX 3.4.22...)"
objdump -T combined-jar/linux-aarch64/libvoyager.so | grep GLIBCXX | sed 's/.*GLIBCXX_\([.0-9]*\).*/\1/g' | cat - <(echo 3\.4\.22) | sort -Vu | tail -n 1 | grep 3\.4\.22 || (echo "Expected linux-aarch64 binary to require at most glibc++ 3.4.22. Ensure the dockcross container has not been updated." && false)
echo "Checking linux-x64/libvoyager.so (should require at most GLIBC 2.27...)"
objdump -T combined-jar/linux-x64/libvoyager.so | grep GLIBC | grep -v GLIBCXX | sed 's/.*GLIBC_\([.0-9]*\).*/\1/g' | cat - <(echo 2\.27) | sort -Vu | tail -n 1 | grep 2\.27 || (echo "Expected linux-x64 binary to require at most glibc 2.28. Ensure the dockcross container has not been updated." && false)
echo "Checking linux-x64/libvoyager.so (should require at most GLIBCXX 3.4.22...)"
objdump -T combined-jar/linux-x64/libvoyager.so | grep GLIBCXX | sed 's/.*GLIBCXX_\([.0-9]*\).*/\1/g' | cat - <(echo 3\.4\.22) | sort -Vu | tail -n 1 | grep 3\.4\.22 || (echo "Expected linux-x64 binary to require at most glibc++ 3.4.22. Ensure the dockcross container has not been updated." && false)
zip -r $(ls java-* | grep jar | tail -n 1) combined-jar/*
- uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: java-all-platforms
path: artifacts/*.jar
upload-pypi:
defaults:
run:
working-directory: python
needs: [build-python-wheels, run-python-tests-with-address-sanitizer, run-python-tests]
runs-on: 'ubuntu-latest'
name: "Upload wheels to PyPI"
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v3
with:
name: python-wheels
path: dist
- uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_DEPLOY_TOKEN }}
upload-maven:
name: Upload to Maven Central
runs-on: ubuntu-latest
needs: combine-java-jars
if: github.event_name == 'release' && github.event.action == 'published'
defaults:
run:
working-directory: java
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: java-all-platforms
path: combined-jar
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'corretto'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_USER_TOKEN
gpg-private-key: ${{ secrets.SONATYPE_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Deploy
# Note: this will re-run the build even though we already have the JAR file ready to deploy
run: |
# Copy the native artifacts built for each platform into the appropriate place:
unzip ../combined-jar/*.jar -d ../
mkdir -p target/classes/
cp -r ../combined-jar/linux* target/classes/
cp -r ../combined-jar/mac* target/classes/
cp -r ../combined-jar/win* target/classes/
mvn --batch-mode deploy -Dmaven.test.skip=true
env:
MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.SONATYPE_PASSPHRASE }}
MAVEN_USER_TOKEN: ${{ secrets.SONATYPE_USER_TOKEN }}