-
Notifications
You must be signed in to change notification settings - Fork 111
543 lines (473 loc) · 17.1 KB
/
build-wheels.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
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
name: Build wheels
run-name: Build wheels (use-server-rc=${{ inputs.use-server-rc }}, should-bump-version=${{ inputs.should-bump-version }}, bump-rc-or-release=${{ inputs.bump-rc-or-release }}, server-tag=${{ inputs.server-tag }})
# Builds wheels and optionally sends artifacts to Jfrog Artifactory
on:
workflow_dispatch:
inputs:
use-server-rc:
type: boolean
required: true
default: false
description: 'Test against server release candidate?'
# Override the default server version to test against
# This is helpful if you need to create a backport from an older client major version
# And that older client major version does not accomodate for breaking changes in the latest server version
server-tag:
required: true
default: 'latest'
description: 'Server docker image tag'
should-bump-version:
type: boolean
required: true
default: true
description: 'Bump version and upload to JFrog?'
bump-rc-or-release:
type: choice
options:
- rc
- release
default: 'rc'
required: true
description: 'If bumping version, what type of bump?'
jobs:
update-version:
if: ${{ inputs.should-bump-version }}
runs-on: ubuntu-latest
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- run: pip install python-semantic-release==7.34.6
- run: |
latest_tag=$(cat VERSION)
echo "Bumping off of latest tag $latest_tag"
# If creating release wheels, bump rc version to release version
if [[ ${{ inputs.bump-rc-or-release }} == "rc" ]]; then
new_tag=$(pysemver bump prerelease $latest_tag)
else
new_tag=$(pysemver nextver $latest_tag patch)
fi
echo "NEW_TAG=$new_tag" >> $GITHUB_ENV
echo "The new tag for this build is $new_tag"
- name: Update version
run: |
sed -i "s/const char version\[] = \".*\";/const char version\[] = \"${{ env.NEW_TAG }}\";/" src/main/aerospike.c
echo -e "${{ env.NEW_TAG }}" > VERSION
- name: Commit new version
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Bump version to ${{ env.NEW_TAG }}
build-sdist:
name: Build and install sdist
runs-on: ubuntu-latest
# Need to replace default success() condition because skipped job is not "successful"
# always() will cause this job to become uncancellable, so we check if current job hasn't been cancelled yet
# Run if update version workflow was skipped or succeeds
if: ${{ !cancelled() && (needs.update-version.result == 'skipped' || needs.update-version.result == 'success') }}
needs: update-version
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
# Use branch instead of hash that triggered workflow
ref: ${{ github.ref_name }}
- uses: actions/setup-python@v2
with:
python-version: 3.9
architecture: 'x64'
- run: sudo apt update
- name: Install build dependencies (apt packages)
run: sudo apt install python3-dev libssl-dev -y
- name: Install build dependencies (pip packages)
run: python3 -m pip install -r requirements.txt
- name: Build source distribution
run: python3 -m build --sdist
- name: Upload sdist to GitHub
uses: actions/upload-artifact@v3
with:
path: ./dist/*.tar.gz
# Artifact name, not the file name
name: sdist
source-installs:
strategy:
matrix:
distros: [
# Image name, build-<name> and container name
# ["alpine", "alpine"],
["redhat/ubi9", "rpm-based"],
["amazonlinux:2023", "rpm-based"]
]
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Run Aerospike server release candidate with latest tag
if: ${{ inputs.use-server-rc }}
run: docker run -d --name aerospike -p 3000-3002:3000-3002 aerospike.jfrog.io/docker/aerospike/aerospike-server-rc:latest
- name: Run Aerospike server
if: ${{ !inputs.use-server-rc }}
run: docker run -d --name aerospike -p 3000-3002:3000-3002 aerospike/aerospike-server
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Run distro container
run: docker run --name ${{ matrix.distros[1] }} --network host --detach ${{ matrix.distros[0] }} tail -f /dev/null
- name: Copy repo to container
run: docker cp . ${{ matrix.distros[1] }}:/aerospike-client-python
- name: Build and test
run: docker exec -w /aerospike-client-python ${{ matrix.distros[1] }} ./.github/workflows/build-${{ matrix.distros[1] }}.sh
manylinux_arm64:
runs-on: ubuntu-latest
needs: update-version
if: ${{ !cancelled() && (needs.update-version.result == 'skipped' || needs.update-version.result == 'success') }}
strategy:
fail-fast: false
matrix:
# Python versions to build wheels on
python: [
"cp38",
"cp39",
"cp310",
"cp311"
]
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
ref: ${{ github.ref_name }}
- name: Set up QEMU for cross compiling arm64
uses: docker/setup-qemu-action@v2
with:
platforms: all
- uses: ./.github/actions/run-ee-server
with:
use-server-rc: ${{ inputs.use-server-rc }}
server-tag: ${{ inputs.server-tag }}
- name: Set config.conf to use Docker IP address of Aerospike server
# config.conf should be copied into the cibuildwheel Docker container
run: |
export SERVER_DOCKER_IP=$(docker container inspect -f '{{ .NetworkSettings.IPAddress }}' aerospike)
pip install crudini==0.9.4
sed -i "s/127.0.0.1:3000//" config.conf
crudini --set config.conf enterprise-edition hosts ${SERVER_DOCKER_IP}:3000
working-directory: test
- name: Build wheel
uses: pypa/[email protected]
env:
CIBW_BUILD: ${{ matrix.python }}-manylinux_aarch64
CIBW_BUILD_FRONTEND: build
CIBW_BEFORE_ALL_LINUX: >
yum install openssl-devel -y &&
yum install python-devel -y &&
yum install python-setuptools -y
CIBW_ARCHS: "aarch64"
CIBW_TEST_COMMAND: >
cd {project}/test/ &&
pip install -r requirements.txt &&
python -m pytest new_tests/
- name: Upload wheels to GitHub
uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
# Artifact name, not the file name
name: manylinux-aarch64-${{ matrix.python }}
manylinux_x86_64:
runs-on: ubuntu-latest
needs: update-version
if: ${{ !cancelled() && (needs.update-version.result == 'skipped' || needs.update-version.result == 'success') }}
strategy:
fail-fast: false
matrix:
# Python versions to build wheels on
python: [
["cp38", "3.8"],
["cp39", "3.9"],
["cp310", "3.10"],
["cp311", "3.11"]
]
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
ref: ${{ github.ref_name }}
- uses: ./.github/actions/run-ee-server
with:
use-server-rc: ${{ inputs.use-server-rc }}
server-tag: ${{ inputs.server-tag }}
- name: Wait for server to start
run: sleep 5
- name: Set config.conf to use Docker IP address of Aerospike server
# config.conf should be copied into the cibuildwheel Docker container
run: |
export SERVER_DOCKER_IP=$(docker container inspect -f '{{ .NetworkSettings.IPAddress }}' aerospike)
pip install crudini==0.9.4
sed -i "s/127.0.0.1:3000//" config.conf
crudini --set config.conf enterprise-edition hosts ${SERVER_DOCKER_IP}:3000
working-directory: test
- name: Build wheel
uses: pypa/[email protected]
env:
CIBW_BUILD: ${{ matrix.python[0] }}-manylinux_x86_64
CIBW_BUILD_FRONTEND: build
CIBW_BEFORE_ALL_LINUX: >
yum install openssl-devel -y &&
yum install python-devel -y &&
yum install python-setuptools -y
CIBW_ARCHS: "x86_64"
CIBW_TEST_COMMAND: >
cd {project}/test/ &&
pip install -r requirements.txt &&
python -m pytest new_tests/
- name: Upload wheels to GitHub
uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
# Artifact name, not the file name
name: manylinux-x86_64-${{ matrix.python[0] }}
manylinux_x86_64_no_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Build wheel
uses: pypa/[email protected]
env:
CIBW_BUILD: cp39-manylinux_x86_64
CIBW_BUILD_FRONTEND: build
CIBW_BEFORE_ALL_LINUX: >
yum install openssl-devel -y &&
yum install python-devel -y &&
yum install python-setuptools -y
CIBW_ARCHS: "x86_64"
- name: Upload wheels to GitHub
uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
# Artifact name, not the file name
name: manylinux-x86_64-cp39-distros
# Test RPM-based Linux OS's
manylinux_x86_64_rpm_based:
needs: manylinux_x86_64_no_test
strategy:
matrix:
image: [
"redhat/ubi8",
"amazonlinux:2023"
]
fail-fast: false
runs-on: ubuntu-latest
services:
aerospike:
image: ${{ inputs.use-server-rc && 'aerospike.jfrog.io/docker/aerospike/aerospike-server-rc:latest' || 'aerospike/aerospike-server' }}
container:
image: ${{ matrix.image }}
steps:
- run: dnf -y update
- run: dnf -y install git
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: actions/download-artifact@v3
with:
name: manylinux-x86_64-cp39-distros
- run: dnf -y install python3.9
# Amazon Linux 2023 doesn't come with pip
- run: python3.9 -m ensurepip
- run: python3.9 -m pip install *.whl
- name: Install test dependencies
run: python3.9 -m pip install -r requirements.txt
working-directory: test
- run: sed -i "s/127.0.0.1/$AEROSPIKE_HOST/" config.conf
working-directory: test
env:
AEROSPIKE_HOST: aerospike
- name: Run tests
run: python3.9 -m pytest new_tests/
working-directory: test
manylinux_x86_64_debian:
needs: manylinux_x86_64_no_test
runs-on: ubuntu-latest
services:
aerospike:
image: ${{ inputs.use-server-rc && 'aerospike.jfrog.io/docker/aerospike/aerospike-server-rc:latest' || 'aerospike/aerospike-server' }}
strategy:
matrix:
debian-name: [
"buster",
"bookworm"
]
container:
image: python:3.9-${{ matrix.debian-name }}
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v3
with:
name: manylinux-x86_64-cp39-distros
- run: python3 -m pip install *.whl
- name: Install test dependencies
run: python3 -m pip install -r requirements.txt
working-directory: test
- run: sed -i "s/127.0.0.1/$AEROSPIKE_HOST/" config.conf
working-directory: test
env:
AEROSPIKE_HOST: aerospike
- name: Run tests
run: python3 -m pytest new_tests/
working-directory: test
manylinux_x86_64_ubuntu2204:
needs: manylinux_x86_64_no_test
runs-on: ubuntu-22.04
services:
aerospike:
image: ${{ inputs.use-server-rc && 'aerospike.jfrog.io/docker/aerospike/aerospike-server-rc:latest' || 'aerospike/aerospike-server' }}
ports:
- 3000:3000
- 3001:3001
- 3002:3002
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v3
with:
name: manylinux-x86_64-cp39-distros
- name: Set up Python 3.9
uses: actions/setup-python@v3
with:
python-version: "3.9"
- run: python3 -m pip install *.whl
- name: Install test dependencies
run: python3 -m pip install -r requirements.txt
working-directory: test
- name: Run tests
run: python3 -m pytest new_tests/
working-directory: test
macOS-x86:
needs: update-version
if: ${{ !cancelled() && (needs.update-version.result == 'skipped' || needs.update-version.result == 'success') }}
strategy:
fail-fast: false
matrix:
python-version: [
["cp38", "3.8"],
["cp39", "3.9"],
["cp310", "3.10"],
["cp311", "3.11"]
]
os: [macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
ref: ${{ github.ref_name }}
- name: Set up Python ${{ matrix.python-version[1] }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version[1] }}
- name: Build wheel
uses: pypa/[email protected]
env:
CIBW_BUILD: ${{ matrix.python-version[0] }}-macosx_x86_64
CIBW_BUILD_FRONTEND: build
CIBW_ENVIRONMENT: SSL_LIB_PATH="$(brew --prefix [email protected])/lib/" CPATH="$(brew --prefix [email protected])/include/" STATIC_SSL=1
CIBW_ARCHS: "x86_64"
CIBW_BEFORE_TEST: >
export USE_SERVER_RC=${{ inputs.use-server-rc }} &&
SERVER_TAG=${{ inputs.server-tag }} vagrant up &&
sleep 3 &&
pip install -r test/requirements.txt
CIBW_TEST_COMMAND: >
cd {project}/test/ &&
python -m pytest new_tests/
- name: Save macOS wheel
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os }}-x86_64-${{ matrix.python-version[0] }}-wheel
path: wheelhouse/*.whl
macOS-m1:
runs-on: [self-hosted, macOS, ARM64]
needs: update-version
if: ${{ !cancelled() && (needs.update-version.result == 'skipped' || needs.update-version.result == 'success') }}
strategy:
fail-fast: false
matrix:
python-version: [
"3.8",
"3.9",
"3.10",
"3.11"
]
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
ref: ${{ github.ref_name }}
# Update dependencies if needed
- name: Add brew to path
run: echo PATH=$PATH:/opt/homebrew/bin/ >> $GITHUB_ENV
- run: brew install python@${{ matrix.python-version }}
- run: brew install [email protected]
- run: |
openssl_path=$(brew --prefix [email protected])
echo SSL_LIB_PATH="$openssl_path/lib/" >> $GITHUB_ENV
echo CPATH="$openssl_path/include/" >> $GITHUB_ENV
echo STATIC_SSL=1 >> $GITHUB_ENV
- run: python${{ matrix.python-version }} -m pip install build delocate==0.10.4
- name: Use server rc
if: ${{ inputs.use-server-rc }}
run: echo IMAGE_NAME="aerospike.jfrog.io/docker/aerospike/aerospike-server-rc:${{ inputs.server-tag }}" >> $GITHUB_ENV
- name: Use server release
if: ${{ !inputs.use-server-rc }}
run: echo IMAGE_NAME="aerospike/aerospike-server:${{ inputs.server-tag }}" >> $GITHUB_ENV
- name: Run server
run: docker run -d -p 3000:3000 --name aerospike ${{ env.IMAGE_NAME }}
- run: python${{ matrix.python-version }} -m build
- run: delocate-wheel --require-archs "arm64" -w wheelhouse/ -v dist/*.whl
- run: python${{ matrix.python-version }} -m pip install --find-links=wheelhouse/ --no-index --force-reinstall aerospike
- run: python${{ matrix.python-version }} -m pip install -r requirements.txt
working-directory: test
- run: python${{ matrix.python-version }} -m pytest new_tests/
working-directory: test
- name: Save macOS wheel
uses: actions/upload-artifact@v3
with:
name: macos-amd64-${{ matrix.python-version }}-wheel
path: wheelhouse/*.whl
- name: Stop server
if: ${{ always() }}
run: |
docker container stop aerospike
docker container prune -f
upload-artifacts-to-jfrog:
if: ${{ inputs.should-bump-version }}
needs: [
# Cat 1 tests
source-installs,
# Wheel installs (cat 2 tests)
manylinux_x86_64_rpm_based,
manylinux_x86_64_ubuntu2204,
manylinux_x86_64_debian,
# CentOS 7 Linux cat 2 tests (for all wheels)
manylinux_x86_64,
manylinux_arm64,
macOS-x86,
macOS-m1,
]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
- name: Reorganize artifacts
run: |
mkdir artifacts
find . -type f -exec mv {} artifacts \;
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: ${{ secrets.JFROG_URL }}
user: ${{ secrets.JFROG_USERNAME }}
password: ${{ secrets.JFROG_ACCESS_TOKEN }}
packages-dir: artifacts/
verbose: true