Repository navigation
240 lines (224 loc) · 10.9 KB
/
Copy pathpython.yml
File metadata and controls
240 lines (224 loc) · 10.9 KB
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
name: Python Foundation
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
jobs:
foundation:
name: CPython 3.12 (${{ matrix.os }}, shared=${{ matrix.shared }})
runs-on: ${{ matrix.os }}
timeout-minutes: 25
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
shared: ["OFF", "ON"]
defaults: &foundation-defaults
run:
shell: bash
env: &foundation-env
CC: clang
CMAKE_BUILD_PARALLEL_LEVEL: "3"
PIP_DISABLE_PIP_VERSION_CHECK: "1"
steps: &foundation-steps
- name: Select macOS qualification deployment target
if: runner.os == 'macOS'
run: echo 'MACOSX_DEPLOYMENT_TARGET=13.0' >> "$GITHUB_ENV"
- uses: actions/checkout@v5
with:
persist-credentials: false
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Provision build dependencies
run: |
python -m venv "$RUNNER_TEMP/python-build-venv"
source "$RUNNER_TEMP/python-build-venv/bin/activate"
echo "$RUNNER_TEMP/python-build-venv/bin" >> "$GITHUB_PATH"
python -m pip download --only-binary=:all: \
--dest "$RUNNER_TEMP/python-build-deps" \
'build>=1.2,<2' 'scikit-build-core>=0.11,<2' 'cmake>=3.26,<4' ninja
python -m pip install --no-index --find-links="$RUNNER_TEMP/python-build-deps" \
'build>=1.2,<2' 'scikit-build-core>=0.11,<2' 'cmake>=3.26,<4' ninja
- name: Configure service SDK (no adapters, warnings as errors)
env:
SDK_SHARED: ${{ matrix.shared }}
run: |
mkdir -p "$RUNNER_TEMP/python-logs"
cat > "$RUNNER_TEMP/python-logs/consumer-context.cmake" <<'CMAKE'
include("${PROJECT_SOURCE_DIR}/tests/cmake/ConsumerBuildContext.cmake")
moq_write_consumer_abi_context("${PROJECT_BINARY_DIR}/consumer-abi-context.cmake")
CMAKE
trap 'rc=$?; scripts/check_macos_deploy_lane.sh probe-logs build/python-sdk/CMakeFiles || rc=$?; exit "$rc"' EXIT
cmake -S . -B build/python-sdk -G Ninja \
-DCMAKE_PROJECT_libmoq_INCLUDE="$RUNNER_TEMP/python-logs/consumer-context.cmake" \
-Werror=dev -Werror=deprecated \
-DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS="$SDK_SHARED" \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DCMAKE_INSTALL_PREFIX="$RUNNER_TEMP/python-sdk" \
-DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_SKIP_INSTALL_RPATH=ON \
-DMOQ_WARNINGS_AS_ERRORS=ON \
-DMOQ_BUILD_TESTS=OFF -DMOQ_BUILD_SIM=OFF -DMOQ_BUILD_EXAMPLES=OFF \
-DMOQ_BUILD_MSF=ON -DMOQ_BUILD_MEDIA_OBJECT=ON -DMOQ_BUILD_SERVICE=ON \
-DMOQ_BUILD_ADAPTER_PICOQUIC=OFF -DMOQ_BUILD_ADAPTER_PICO_WT=OFF \
-DMOQ_BUILD_ADAPTER_MVFST=OFF -DMOQ_BUILD_ADAPTER_PROXYGEN=OFF \
-DMOQ_BUILD_ADAPTER_MSQUIC=OFF -DMOQ_BUILD_ADAPTER_WTQUIC=OFF \
-DMOQ_BUILD_PQ_THREADED=OFF -DMOQ_BUILD_PICO_WT_MANAGED=OFF \
-DMOQ_BUILD_MSQUIC_MANAGED=OFF \
-DMOQ_BUILD_WTQUIC_NETWORK_MANAGED=OFF \
-DMOQ_BUILD_WTQUIC_MSQUIC_MANAGED=OFF
- name: Build and install service SDK
run: |
cmake --build build/python-sdk
cmake --install build/python-sdk
if [[ "$RUNNER_OS" == macOS && "${{ matrix.shared }}" == ON ]]; then
shopt -s nullglob
dylibs=("$RUNNER_TEMP/python-sdk/lib/"*.dylib)
test "${#dylibs[@]}" -gt 0
audit=()
for dylib in "${dylibs[@]}"; do audit+=("$dylib=13.0"); done
python scripts/macho_deploy_audit.py binaries "${audit[@]}" \
| tee "$RUNNER_TEMP/python-logs/sdk-minos.log"
fi
- name: Debug bridge tests (fake C provider, warnings as errors)
run: |
trap 'rc=$?; scripts/check_macos_deploy_lane.sh probe-logs build/python-foundation/CMakeFiles || rc=$?; exit "$rc"' EXIT
cmake -S bindings/python -B build/python-foundation -G Ninja \
-C "$GITHUB_WORKSPACE/build/python-sdk/consumer-abi-context.cmake" \
-Werror=dev -Werror=deprecated \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_PREFIX_PATH="$RUNNER_TEMP/python-sdk" \
-DPython3_EXECUTABLE="$(command -v python)" \
-DMOQ_PYTHON_BUILD_TESTS=ON -DMOQ_PYTHON_WARNINGS_AS_ERRORS=ON \
-DCMAKE_SKIP_INSTALL_RPATH=ON
cmake --build build/python-foundation
ctest --test-dir build/python-foundation -C Debug --output-on-failure \
--no-tests=error -R '^python_foundation$'
- name: Build wheel, sdist, and source archive
run: |
trap 'rc=$?; scripts/check_macos_deploy_lane.sh probe-logs "$RUNNER_TEMP/python-wheel-build/CMakeFiles" || rc=$?; exit "$rc"' EXIT
python -m build --no-isolation --wheel --sdist \
--outdir "$RUNNER_TEMP/python-artifacts" \
-C "build-dir=$RUNNER_TEMP/python-wheel-build" \
-C "cmake.args=-C;$GITHUB_WORKSPACE/build/python-sdk/consumer-abi-context.cmake" \
-C cmake.build-type=Debug \
-C "cmake.define.CMAKE_PREFIX_PATH=$RUNNER_TEMP/python-sdk" \
-C cmake.define.MOQ_PYTHON_WARNINGS_AS_ERRORS=ON \
-C cmake.define.MOQ_PYTHON_BUILD_TESTS=OFF \
-C cmake.define.CMAKE_SKIP_INSTALL_RPATH=ON \
bindings/python
# A plain source artifact has no .git, parent sources, or sibling SDK.
git archive --format=tar --prefix=moq5-source/ \
--output="$RUNNER_TEMP/python-artifacts/moq5-source.tar" \
HEAD:bindings/python
- name: Install each artifact in a fresh external venv and smoke the real SDK
env:
SDK_SHARED: ${{ matrix.shared }}
run: |
package_version="$(python -c \
'import pathlib, sys, tomllib; print(tomllib.loads(pathlib.Path(sys.argv[1]).read_text())["project"]["version"])' \
"$GITHUB_WORKSPACE/bindings/python/pyproject.toml")"
sdk_version="$(awk '$1 == "#define" && $2 == "MOQ_VERSION_STRING" {gsub(/"/, "", $3); print $3}' \
"$RUNNER_TEMP/python-sdk/include/moq/version.h")"
test -n "$package_version"
test -n "$sdk_version"
shopt -s nullglob
wheels=("$RUNNER_TEMP/python-artifacts/"*.whl)
sdists=("$RUNNER_TEMP/python-artifacts/"*.tar.gz)
test "${#wheels[@]}" -eq 1
test "${#sdists[@]}" -eq 1
artifacts=("${wheels[0]}" "${sdists[0]}" "$RUNNER_TEMP/python-artifacts/moq5-source.tar")
labels=(wheel sdist source)
mkdir -p "$RUNNER_TEMP/python-smoke"
cp bindings/python/tests/installed_smoke.py "$RUNNER_TEMP/python-smoke/"
cd "$RUNNER_TEMP/python-smoke"
# Test-process loader paths only; installed modules must have no RPATH.
if [[ "$SDK_SHARED" == "ON" ]]; then
case "$RUNNER_OS" in
Linux) export LD_LIBRARY_PATH="$RUNNER_TEMP/python-sdk/lib" ;;
macOS) export DYLD_LIBRARY_PATH="$RUNNER_TEMP/python-sdk/lib" ;;
esac
fi
for index in 0 1 2; do
venv="$RUNNER_TEMP/python-venv-${labels[$index]}"
python -m venv "$venv"
if [[ "${labels[$index]}" != "wheel" ]]; then
"$venv/bin/python" -m pip install --no-index \
--find-links="$RUNNER_TEMP/python-build-deps" \
'scikit-build-core>=0.11,<2' 'cmake>=3.26,<4' ninja
fi
native_settings=()
if [[ "${labels[$index]}" != "wheel" ]]; then
native_build="$RUNNER_TEMP/python-${labels[$index]}-build"
native_settings=(-C "build-dir=$native_build"
-C "cmake.args=-C;$GITHUB_WORKSPACE/build/python-sdk/consumer-abi-context.cmake")
trap 'rc=$?; "$GITHUB_WORKSPACE/scripts/check_macos_deploy_lane.sh" probe-logs "$native_build/CMakeFiles" || rc=$?; exit "$rc"' EXIT
fi
"$venv/bin/python" -m pip install --no-index --no-deps \
--no-build-isolation --no-cache-dir \
"${native_settings[@]}" \
-C cmake.build-type=Debug \
-C "cmake.define.CMAKE_PREFIX_PATH=$RUNNER_TEMP/python-sdk" \
-C cmake.define.MOQ_PYTHON_WARNINGS_AS_ERRORS=ON \
-C cmake.define.MOQ_PYTHON_BUILD_TESTS=OFF \
-C cmake.define.CMAKE_SKIP_INSTALL_RPATH=ON \
"${artifacts[$index]}"
if [[ "${labels[$index]}" != "wheel" ]]; then
"$GITHUB_WORKSPACE/scripts/check_macos_deploy_lane.sh" probe-logs "$native_build/CMakeFiles"
trap - EXIT
fi
"$venv/bin/python" -I -W error installed_smoke.py \
--artifact "${artifacts[$index]}" \
--expected-package-version "$package_version" \
--expected-sdk-version "$sdk_version"
if [[ "$RUNNER_OS" == macOS ]]; then
module="$("$venv/bin/python" -I -c '
from importlib.metadata import distribution
dist = distribution("moq5")
matches = [p for p in (dist.files or ()) if str(p) == "moq5/_native.abi3.so"]
if len(matches) != 1:
raise SystemExit("expected exactly one recorded moq5/_native.abi3.so")
module = dist.locate_file(matches[0]).resolve(strict=True)
if not module.is_file():
raise SystemExit("recorded native module is not a file")
print(module)
')"
"$venv/bin/python" "$GITHUB_WORKSPACE/scripts/macho_deploy_audit.py" \
binaries "$module=13.0" \
| tee "$RUNNER_TEMP/python-logs/${labels[$index]}-minos.log"
fi
done
- name: Retain Python configure evidence
if: always()
uses: actions/upload-artifact@v4
with:
name: python-configure-${{ matrix.os }}-${{ matrix.shared }}
if-no-files-found: error
path: |
build/python-sdk/consumer-abi-context.cmake*
build/python-sdk/CMakeFiles/CMakeConfigureLog.yaml
build/python-foundation/CMakeFiles/CMakeConfigureLog.yaml
${{ runner.temp }}/python-logs/
${{ runner.temp }}/python-wheel-build/CMakeFiles/CMakeConfigureLog.yaml
${{ runner.temp }}/python-sdist-build/CMakeFiles/CMakeConfigureLog.yaml
${{ runner.temp }}/python-source-build/CMakeFiles/CMakeConfigureLog.yaml
foundation-macos:
name: CPython 3.12 (${{ matrix.os }}, shared=${{ matrix.shared }})
runs-on: ${{ matrix.os }}
timeout-minutes: 25
strategy:
fail-fast: false
max-parallel: 1
matrix:
os: [macos-latest]
shared: ["OFF", "ON"]
defaults: *foundation-defaults
env: *foundation-env
steps: *foundation-steps