-
Notifications
You must be signed in to change notification settings - Fork 43
277 lines (236 loc) · 8.52 KB
/
ci-pr-validation.yaml
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
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
name: PR validation
on:
pull_request:
branches: ['main']
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
check-and-lint:
name: Lint and check code
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Install deps
run: pip install -U pydoctor
- name: Check docs syntax
run: |
pydoctor --make-html \
--html-viewsource-base=https://github.com/apache/pulsar-client-python/tree/main \
--docformat=numpy --theme=readthedocs \
--intersphinx=https://docs.python.org/3/objects.inv \
--html-output=apidocs \
pulsar
unit-tests:
name: Run unit tests for Python ${{matrix.version}}
runs-on: ubuntu-22.04
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
version: ['3.8', '3.12']
steps:
- name: checkout
uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "${{matrix.version}}"
- name: Install Pulsar C++ client
run: build-support/install-dependencies.sh
- name: CMake
run: cmake .
- name: Build
run: make -j8
- name: Python install
run: |
python3 -m pip install -U pip setuptools wheel requests
python3 setup.py bdist_wheel
WHEEL=$(find dist -name '*.whl')
pip3 install ${WHEEL}[avro]
- name: Run Oauth2 tests
run: |
docker compose -f ./build-support/docker-compose-pulsar-oauth2.yml up -d
# Wait until the namespace is created, currently there is no good way to check it via CLI
sleep 10
python3 tests/oauth2_test.py
docker compose -f ./build-support/docker-compose-pulsar-oauth2.yml down
- name: Start Pulsar service
run: ./build-support/pulsar-test-service-start.sh
- name: Run unit tests
run: ./tests/run-unit-tests.sh
- name: Stop Pulsar service
run: ./build-support/pulsar-test-service-stop.sh
- name: Test functions install
run: |
WHEEL=$(find dist -name '*.whl')
pip3 install ${WHEEL}[all] --force-reinstall
linux-wheel:
name: Wheel ${{matrix.image.name}} - Py ${{matrix.python.version}} - ${{matrix.cpu.platform}}
needs: unit-tests
runs-on: ubuntu-22.04
timeout-minutes: 300
strategy:
fail-fast: false
matrix:
image:
- {name: 'manylinux2014', py_suffix: ''}
- {name: 'manylinux_musl', py_suffix: '-alpine'}
python:
- {version: '3.12', spec: 'cp312-cp312'}
cpu:
- {arch: 'x86_64', platform: 'x86_64'}
steps:
- name: checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- run: build-support/copy-deps-versionfile.sh
- name: Build Manylinux Docker image
uses: docker/build-push-action@v3
with:
context: ./pkg/${{matrix.image.name}}
load: true
tags: build:latest
platforms: linux/${{matrix.cpu.arch}}
build-args: |
PLATFORM=${{matrix.cpu.platform}}
ARCH=${{matrix.cpu.arch}}
PYTHON_VERSION=${{matrix.python.version}}
PYTHON_SPEC=${{matrix.python.spec}}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build wheel file
run: |
docker run -i -v $PWD:/pulsar-client-python build:latest \
/pulsar-client-python/pkg/build-wheel-inside-docker.sh
- name: Test wheel file
run: |
docker run -i -v $PWD:/pulsar-client-python python:${{matrix.python.version}}${{matrix.image.py_suffix}} \
/pulsar-client-python/pkg/test-wheel.sh
mac-wheels:
name: Wheel MacOS Universal2 - Py ${{matrix.py.version}}
needs: unit-tests
runs-on: macos-12
timeout-minutes: 300
strategy:
matrix:
py:
- {version: '3.12', version_long: '3.12.0'}
steps:
- name: checkout
uses: actions/checkout@v3
- name: Dependencies cache
uses: actions/cache@v3
id: cache-deps
with:
path: .pulsar-mac-build/deps/install
key: ${{matrix.py.version_long}}-${{ hashFiles('dependencies.yaml') }}-${{ hashFiles('pkg/mac/*') }}
- name: Install Python deps
run: pip3 install -U pyyaml
- name: Build dependencies
if: steps.cache-deps.outputs.cache-hit != 'true'
run: pkg/mac/build-dependencies.sh ${{matrix.py.version}} ${{matrix.py.version_long}}
- name: Pulsar C++ cache
uses: actions/cache@v3
id: cache-cpp
with:
path: .pulsar-mac-build/cpp/install
key: ${{ hashFiles('dependencies.yaml') }}-${{ hashFiles('pulsar-client-cpp-version.txt') }}-${{ hashFiles('pkg/mac/*') }}
- name: Build Pulsar C++ client
if: steps.cache-cpp.outputs.cache-hit != 'true'
run: pkg/mac/build-pulsar-cpp.sh
- name: Build and test Mac wheels
run: pkg/mac/build-mac-wheels.sh ${{matrix.py.version}}
windows-wheels:
name: "Python ${{ matrix.python.version }} Wheel on Windows x64"
needs: unit-tests
runs-on: windows-2019
timeout-minutes: 120
env:
PULSAR_CPP_DIR: 'C:\\pulsar-cpp'
strategy:
fail-fast: false
matrix:
python:
- version: '3.12'
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python.version }}
- name: Download Pulsar C++ client on Windows
shell: bash
run: |
source ./build-support/dep-url.sh
BASE_URL=$(pulsar_cpp_base_url $(grep pulsar-cpp dependencies.yaml | awk '{print $2}'))
mkdir -p ${{ env.PULSAR_CPP_DIR }}
cd ${{ env.PULSAR_CPP_DIR }}
curl -O -L ${BASE_URL}/x64-windows-static.tar.gz
tar zxf x64-windows-static.tar.gz
mv x64-windows-static/* .
ls -l ${{ env.PULSAR_CPP_DIR }}
- name: Configure CMake
shell: bash
run: |
pip3 install pyyaml
export PYBIND11_VERSION=$(./build-support/dep-version.py pybind11)
curl -L -O https://github.com/pybind/pybind11/archive/refs/tags/v${PYBIND11_VERSION}.tar.gz
tar zxf v${PYBIND11_VERSION}.tar.gz
rm -rf pybind11
mv pybind11-${PYBIND11_VERSION} pybind11
cmake -B build -A x64 \
-DCMAKE_PREFIX_PATH=${{ env.PULSAR_CPP_DIR }} \
-DLINK_STATIC=ON
- name: Build Python wheel
shell: bash
run: |
cmake --build build --config Release --target install
python -m pip install wheel setuptools
python setup.py bdist_wheel
python -m pip install ./dist/*.whl
python -c 'import pulsar; c = pulsar.Client("pulsar://localhost:6650"); c.close()'
check-completion:
name: Check Completion
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [
check-and-lint,
unit-tests,
linux-wheel,
mac-wheels,
windows-wheels
]
steps:
- run: |
if [[ ! ( \
"${{ needs.check-and-lint.result }}" == "success" \
&& "${{ needs.unit-tests.result }}" == "success" \
&& "${{ needs.linux-wheel.result }}" == "success" \
&& "${{ needs.mac-wheels.result }}" == "success" \
&& "${{ needs.windows-wheels.result }}" == "success" \
) ]]; then
echo "Required jobs haven't been completed successfully."
exit 1
fi