-
-
Notifications
You must be signed in to change notification settings - Fork 9
215 lines (178 loc) · 7.33 KB
/
test-build.yml
File metadata and controls
215 lines (178 loc) · 7.33 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
name: Test Build Configuration
on:
workflow_dispatch:
inputs:
test_matrix:
description: 'Test full matrix or subset'
required: false
default: 'subset'
type: choice
options:
- 'full'
- 'subset'
pull_request:
paths:
- '.github/workflows/test-build.yml'
- '.github/workflows/pgo-validate.yml'
- '.github/workflows/publish.yml'
- 'pyproject.toml'
- 'tools/scripts/pgo_training.py'
jobs:
build-source:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Set up Python
run: uv python install 3.12
- name: Install dependencies
run: uv sync --extra performance --group build
- name: Build source distribution
run: uv build --sdist
- name: Upload source artifacts
uses: actions/upload-artifact@v4
with:
name: source-dist
path: dist/*.tar.gz
build-wheels-standard:
name: Build standard pure Python wheel
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Set up Python 3.12
run: uv python install 3.12
- name: Install dependencies
run: uv sync --extra performance --group build
- name: Build standard wheel
run: uv build --wheel
- name: Upload wheel artifacts
uses: actions/upload-artifact@v4
with:
name: wheels-standard
path: dist/*.whl
build-wheels-mypyc:
name: Build MyPyC wheels for all platforms
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ${{ github.event.inputs.test_matrix == 'full' && fromJSON('["3.10", "3.11", "3.12", "3.13", "3.14"]') || fromJSON('["3.12"]') }}
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Set up QEMU
if: github.event.inputs.test_matrix == 'full'
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install cibuildwheel
run: python -m pip install cibuildwheel
- name: Build wheels with cibuildwheel
run: python -m cibuildwheel --output-dir wheelhouse
env:
# Configure cibuildwheel
CIBW_BUILD: "cp${{ matrix.python-version == '3.10' && '310' || matrix.python-version == '3.11' && '311' || matrix.python-version == '3.12' && '312' || matrix.python-version == '3.13' && '313' || matrix.python-version == '3.14' && '314' }}-*"
CIBW_BUILD_VERBOSITY: 1
# Platform configuration - conditional ARM64 support with QEMU
CIBW_ARCHS_LINUX: ${{ github.event.inputs.test_matrix == 'full' && 'x86_64 aarch64' || 'x86_64' }}
CIBW_ARCHS_MACOS: ${{ github.event.inputs.test_matrix == 'full' && 'x86_64 arm64' || 'x86_64' }}
CIBW_ARCHS_WINDOWS: "AMD64"
# Skip problematic combinations
CIBW_SKIP: "cp39-win_arm64 *-musllinux*"
# Install build dependencies (base, overridden per-platform below)
CIBW_BEFORE_BUILD: "pip install hatch-mypyc hatchling"
# Test the built wheels
CIBW_TEST_REQUIRES: "cloud-sql-python-connector google-cloud-alloydb-connector"
CIBW_TEST_COMMAND: >-
python -c "import sqlspec; from sqlspec.driver._query_cache import QueryCache; print('MyPyC+PGO wheel test passed')"
# Linux PR validation should exercise the same three-stage PGO path as publish.yml.
CIBW_BEFORE_BUILD_LINUX: >-
pip install hatch-mypyc hatchling &&
PGO_DIR=/tmp/sqlspec-pgo &&
BUILD_DIR=/tmp/sqlspec-mypyc-build &&
mkdir -p "$PGO_DIR" "$BUILD_DIR" &&
CFLAGS="-fprofile-generate=$PGO_DIR"
HATCH_BUILD_HOOKS_ENABLE=1
HATCH_MYPYC_BUILD_DIR="$BUILD_DIR"
MYPYC_OPT_LEVEL=3 MYPYC_DEBUG_LEVEL=0 MYPYC_MULTI_FILE=1
pip install {package} --no-build-isolation &&
pip install anyio pyarrow aiosqlite duckdb adbc-driver-sqlite adbc-driver-manager &&
python /project/tools/scripts/pgo_training.py &&
pip uninstall -y sqlspec &&
rm -rf "$BUILD_DIR/build" "$BUILD_DIR/tmp"
CIBW_ENVIRONMENT_LINUX: >-
HATCH_BUILD_HOOKS_ENABLE=1
HATCH_MYPYC_BUILD_DIR=/tmp/sqlspec-mypyc-build
MYPYC_OPT_LEVEL=3 MYPYC_DEBUG_LEVEL=0 MYPYC_MULTI_FILE=1
CFLAGS="-fprofile-use=/tmp/sqlspec-pgo -fprofile-correction -Wno-error=missing-profile -Wno-error=coverage-mismatch"
- name: Upload wheel artifacts
uses: actions/upload-artifact@v4
with:
name: wheels-mypyc-py${{ matrix.python-version }}
path: wheelhouse/*.whl
test-wheels:
name: Test ${{ matrix.os }} py${{ matrix.python-version }}
needs: [build-wheels-standard, build-wheels-mypyc]
strategy:
fail-fast: false
matrix:
os: ${{ github.event.inputs.test_matrix == 'full' && fromJSON('["ubuntu-latest", "windows-latest", "macos-latest"]') || fromJSON('["ubuntu-latest"]') }}
python-version: ${{ github.event.inputs.test_matrix == 'full' && fromJSON('["3.10", "3.12", "3.14"]') || fromJSON('["3.12"]') }}
runs-on: ${{ matrix.os }}
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Download standard wheel artifacts
uses: actions/download-artifact@v4
with:
name: wheels-standard
path: dist-standard/
- name: Download mypyc wheel artifacts
uses: actions/download-artifact@v4
with:
pattern: wheels-mypyc-*
merge-multiple: true
path: dist-mypyc/
- name: Test standard wheel installation
run: |
uv venv test-standard --python ${{ matrix.python-version }}
uv pip install --python test-standard --find-links dist-standard/ sqlspec
uv run --python test-standard python -c "import sqlspec; print('Standard wheel OK')"
- name: Test mypyc wheel installation
run: |
uv venv test-mypyc --python ${{ matrix.python-version }}
uv pip install --python test-mypyc --find-links dist-mypyc/ sqlspec
uv run --python test-mypyc python -c "import sqlspec; print('MyPyC wheel OK')"
verify-packages:
name: Verify package integrity
needs: [build-source, build-wheels-standard, build-wheels-mypyc]
runs-on: ubuntu-latest
steps:
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
pattern: "*"
merge-multiple: true
path: dist/
- name: List all built packages
run: |
echo "=== All built packages ==="
find dist/ -name "*.whl" -o -name "*.tar.gz" | sort
echo "=== Package count ==="
find dist/ -name "*.whl" | wc -l
find dist/ -name "*.tar.gz" | wc -l