Skip to content

Commit f2f8069

Browse files
committed
cicd: make build-push workflow to be reusable
1 parent ae5dde0 commit f2f8069

File tree

2 files changed

+280
-214
lines changed

2 files changed

+280
-214
lines changed

.github/workflows/build-push.yml

+8-214
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ on:
66
- master
77
- 'branch-**'
88
pull_request:
9+
branches:
10+
- master
911
paths-ignore:
1012
- docs/*
1113
- examples/*
12-
- scripts/*
1314
- .gitignore
1415
- '*.rst'
1516
- '*.ini'
@@ -18,218 +19,11 @@ on:
1819
- .github/pull_request_template.md
1920
workflow_dispatch:
2021

21-
env:
22-
CIBW_TEST_COMMAND_LINUX: >
23-
pytest {project}/tests/unit &&
24-
EVENT_LOOP_MANAGER=gevent pytest {project}/tests/unit/io/test_geventreactor.py
25-
26-
CIBW_TEST_COMMAND_MACOS: "pytest {project}/tests/unit -k 'not (test_multi_timer_validation or test_empty_connections or test_timer_cancellation)' "
27-
CIBW_TEST_COMMAND_WINDOWS: "pytest {project}/tests/unit -k \"not (test_deserialize_date_range_year or test_datetype or test_libevreactor)\" "
28-
CIBW_BEFORE_TEST: "pip install -r {project}/test-requirements.txt"
29-
CIBW_BEFORE_BUILD_LINUX: "rm -rf ~/.pyxbld && rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux && yum install -y libffi-devel libev libev-devel openssl openssl-devel"
30-
CIBW_ENVIRONMENT: "CASS_DRIVER_BUILD_CONCURRENCY=2 CASS_DRIVER_BUILD_EXTENSIONS_ARE_MUST=yes CFLAGS='-g0 -O3'"
31-
CIBW_SKIP: cp36* cp37* pp*i686 *musllinux*
32-
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
33-
CIBW_MANYLINUX_PYPY_X86_64_IMAGE: manylinux_2_28
34-
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_28
35-
CIBW_MANYLINUX_PYPY_AARCH64_IMAGE: manylinux_2_28
36-
3722
jobs:
38-
build_wheels:
39-
name: Build wheels ${{ matrix.os }} (${{ matrix.platform }})
23+
build-and-publish:
4024
if: "(!contains(github.event.pull_request.labels.*.name, 'disable-test-build')) || github.event_name == 'push' && endsWith(github.event.ref, 'scylla')"
41-
runs-on: ${{ matrix.os }}
42-
strategy:
43-
fail-fast: false
44-
matrix:
45-
include:
46-
- os: ubuntu-24.04
47-
platform: x86_64
48-
49-
- os: ubuntu-24.04
50-
platform: PyPy
51-
52-
- os: windows-2022
53-
platform: win64
54-
55-
- os: windows-latest
56-
platform: PyPy
57-
58-
- os: macos-14
59-
platform: all
60-
61-
- os: macos-13
62-
platform: all
63-
64-
- os: macos-latest
65-
platform: PyPy
66-
67-
steps:
68-
- uses: actions/checkout@v4
69-
70-
- uses: actions/setup-python@v5
71-
name: Install Python
72-
with:
73-
python-version: '3.13'
74-
- name: Enable pip installing globally
75-
if: runner.os == 'MacOs' || runner.os == 'Windows'
76-
run: |
77-
echo "PIP_BREAK_SYSTEM_PACKAGES=1" >> $GITHUB_ENV
78-
79-
- name: Install cibuildwheel
80-
run: |
81-
python3 -m pip install cibuildwheel==2.22.0
82-
83-
- name: Install OpenSSL for Windows
84-
if: runner.os == 'Windows'
85-
run: |
86-
choco install openssl --version=3.3.2 -f -y
87-
88-
- name: Install Conan
89-
if: runner.os == 'Windows'
90-
uses: turtlebrowser/get-conan@main
91-
92-
- name: configure libev for Windows
93-
if: runner.os == 'Windows'
94-
run: |
95-
conan profile detect
96-
conan install conanfile.py
97-
98-
- name: Install OpenSSL for MacOS
99-
if: runner.os == 'MacOs'
100-
run: |
101-
brew install libev
102-
103-
- name: Overwrite for Linux 64
104-
if: runner.os == 'Linux' && matrix.platform == 'x86_64'
105-
run: |
106-
echo "CIBW_BUILD=cp3*_x86_64" >> $GITHUB_ENV
107-
108-
- name: Overwrite for Linux PyPy
109-
if: runner.os == 'Linux' && matrix.platform == 'PyPy'
110-
run: |
111-
echo "CIBW_BUILD=pp*" >> $GITHUB_ENV
112-
echo "CIBW_TEST_COMMAND_LINUX=" >> $GITHUB_ENV
113-
114-
- name: Overwrite for Windows 64
115-
if: runner.os == 'Windows' && matrix.platform == 'win64'
116-
run: |
117-
echo "CIBW_BUILD=cp*win_amd64" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
118-
echo "CIBW_ENVIRONMENT_WINDOWS= CC=clang CXX=clang++" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
119-
120-
- name: Overwrite for Windows PyPY
121-
if: runner.os == 'Windows' && matrix.platform == 'PyPy'
122-
run: |
123-
echo "CIBW_BUILD=pp*" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
124-
echo "CIBW_TEST_COMMAND_WINDOWS=" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
125-
126-
- name: Overwrite for MacOs
127-
if: runner.os == 'MacOs' && matrix.platform == 'all'
128-
run: |
129-
echo "CIBW_BUILD=cp39* cp310* cp311* cp312* cp313*" >> $GITHUB_ENV
130-
echo "CIBW_BEFORE_TEST_MACOS=pip install -r {project}/test-requirements.txt pytest" >> $GITHUB_ENV
131-
if [ "${{ matrix.os }}" == "macos-13" ]; then
132-
echo "MACOSX_DEPLOYMENT_TARGET=13.0" >> $GITHUB_ENV;
133-
echo "Enforcing target deployment for 13.0"
134-
elif [ "${{ matrix.os }}" == "macos-14" ]; then
135-
echo "MACOSX_DEPLOYMENT_TARGET=14.0" >> $GITHUB_ENV;
136-
echo "Enforcing target deployment for 14.0"
137-
else
138-
echo "Unknown macos version" && false;
139-
fi
140-
- name: Overwrite for MacOs PyPy
141-
if: runner.os == 'MacOs' && matrix.platform == 'PyPy'
142-
run: |
143-
echo "CIBW_BUILD=pp*" >> $GITHUB_ENV
144-
echo "CIBW_BEFORE_TEST_MACOS=pip install -r {project}/test-requirements.txt pytest" >> $GITHUB_ENV
145-
echo "CIBW_TEST_COMMAND_MACOS=" >> $GITHUB_ENV
146-
147-
- name: Build wheels
148-
run: |
149-
python3 -m cibuildwheel --output-dir wheelhouse
150-
151-
- uses: actions/upload-artifact@v4
152-
with:
153-
name: wheels-${{ matrix.os }}-${{ matrix.platform }}
154-
path: ./wheelhouse/*.whl
155-
156-
build_sdist:
157-
name: Build source distribution
158-
if: "(!contains(github.event.pull_request.labels.*.name, 'disable-test-build'))|| github.event_name == 'push' && endsWith(github.event.ref, 'scylla')"
159-
runs-on: ubuntu-24.04
160-
steps:
161-
- uses: actions/checkout@v4
162-
163-
- uses: actions/setup-python@v5
164-
name: Install Python
165-
166-
- name: Build sdist
167-
run: |
168-
pip install build
169-
python -m build --sdist
170-
171-
- uses: actions/upload-artifact@v4
172-
with:
173-
name: source-dist
174-
path: dist/*.tar.gz
175-
176-
build_wheels_extra_arch:
177-
if: "(!contains(github.event.pull_request.labels.*.name, 'disable-test-build'))|| github.event_name == 'push' && endsWith(github.event.ref, 'scylla')"
178-
# The host should always be linux
179-
runs-on: ubuntu-24.04
180-
name: Build extra arch ${{ matrix.archs }} wheels
181-
strategy:
182-
fail-fast: false
183-
matrix:
184-
archs: [ aarch64,] # ppc64le ]
185-
186-
steps:
187-
- uses: actions/checkout@v4
188-
189-
- name: Set up QEMU
190-
id: qemu
191-
uses: docker/setup-qemu-action@v3
192-
with:
193-
platforms: all
194-
image: 'docker.io/tonistiigi/binfmt:desktop-v8.1.5'
195-
if: runner.os == 'Linux'
196-
197-
- uses: actions/setup-python@v5
198-
name: Install Python
199-
with:
200-
python-version: '3.13'
201-
202-
- name: Install cibuildwheel
203-
run: |
204-
python -m pip install cibuildwheel==2.22.0
205-
206-
- name: Build wheels
207-
env:
208-
CIBW_BUILD: "cp39* cp310* cp311* cp312* cp313*" # limit to specific version since it take much more time than jobs limit
209-
run: |
210-
python -m cibuildwheel --archs ${{ matrix.archs }} --output-dir wheelhouse
211-
212-
- uses: actions/upload-artifact@v4
213-
with:
214-
name: wheels-${{ matrix.archs }}
215-
path: ./wheelhouse/*.whl
216-
217-
upload_pypi:
218-
needs: [build_wheels, build_wheels_extra_arch, build_sdist]
219-
runs-on: ubuntu-24.04
220-
permissions:
221-
id-token: write
222-
223-
# upload to PyPI on every tag starting with 'v'
224-
if: github.event_name == 'push' && endsWith(github.event.ref, 'scylla')
225-
# alternatively, to publish when a GitHub Release is created, use the following rule:
226-
# if: github.event_name == 'release' && github.event.action == 'published'
227-
steps:
228-
- uses: actions/download-artifact@v4
229-
with:
230-
path: dist
231-
merge-multiple: true
232-
233-
- uses: pypa/gh-action-pypi-publish@release/v1
234-
with:
235-
skip-existing: true
25+
uses: ./.github/workflows/lib-build-and-push.yml
26+
with:
27+
upload: ${{ github.event_name == 'push' && endsWith(github.event.ref, 'scylla') }}
28+
python-version: '3.13'
29+
target: linux,macos,windows

0 commit comments

Comments
 (0)