forked from DamengDB/dmPython
-
Notifications
You must be signed in to change notification settings - Fork 0
233 lines (204 loc) · 8.53 KB
/
Copy pathbuild-wheels.yml
File metadata and controls
233 lines (204 loc) · 8.53 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
name: Build macOS wheels
on:
push:
branches: [main]
tags: ["v*"]
pull_request:
branches: [main]
workflow_dispatch:
jobs:
build:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
runs-on: macos-14
name: "arm64 — Python ${{ matrix.python-version }}"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21"
cache-dependency-path: dpi_bridge/go.sum
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Decode DPI headers
env:
DPI_HEADERS_TAR_B64: ${{ secrets.DPI_HEADERS_TAR_B64 }}
run: |
mkdir -p dpi_include
echo "$DPI_HEADERS_TAR_B64" | base64 -d | tar xzf - -C dpi_include/
- name: Build Go bridge library
run: |
cd dpi_bridge && go build -buildmode=c-shared -o libdmdpi.dylib .
install_name_tool -id @rpath/libdmdpi.dylib libdmdpi.dylib
- name: Install build tools
run: pip install build delocate
- name: Build wheel
env:
MACOSX_DEPLOYMENT_TARGET: "14.0"
_PYTHON_HOST_PLATFORM: "macosx-14.0-arm64"
run: DMPYTHON_SKIP_GO_BUILD=1 python -m build --wheel
- name: Delocate wheel
run: |
mkdir -p dist_fixed
DYLD_LIBRARY_PATH=dpi_bridge delocate-wheel -w dist_fixed dist/*.whl -v
- name: Verify wheel
run: |
python -m venv /tmp/test_venv
/tmp/test_venv/bin/pip install dist_fixed/*.whl
/tmp/test_venv/bin/python -c "import dmPython; print('dmPython version:', dmPython.version)"
- name: Check DM secrets availability
id: dm_ready
if: ${{ matrix.python-version == '3.10' }}
env:
DM_TEST_HOST: ${{ secrets.DM_TEST_HOST }}
DM_TEST_PORT: ${{ secrets.DM_TEST_PORT }}
DM_TEST_USER: ${{ secrets.DM_TEST_USER }}
DM_TEST_PASSWORD: ${{ secrets.DM_TEST_PASSWORD }}
run: |
if [ -n "$DM_TEST_HOST" ] && [ -n "$DM_TEST_PORT" ] && [ -n "$DM_TEST_USER" ] && [ -n "$DM_TEST_PASSWORD" ]; then
echo "available=true" >> "$GITHUB_OUTPUT"
else
echo "available=false" >> "$GITHUB_OUTPUT"
fi
- name: Build extension for optional integration tests
if: ${{ matrix.python-version == '3.10' && steps.dm_ready.outputs.available == 'true' }}
run: DMPYTHON_SKIP_GO_BUILD=1 python setup.py build_ext --inplace
- name: Run optional DM integration tests
if: ${{ matrix.python-version == '3.10' && steps.dm_ready.outputs.available == 'true' }}
env:
DYLD_LIBRARY_PATH: ${{ github.workspace }}/dpi_bridge
DM_TEST_HOST: ${{ secrets.DM_TEST_HOST }}
DM_TEST_PORT: ${{ secrets.DM_TEST_PORT }}
DM_TEST_USER: ${{ secrets.DM_TEST_USER }}
DM_TEST_PASSWORD: ${{ secrets.DM_TEST_PASSWORD }}
DM_TEST_BOUNDARY_SIZES: ${{ secrets.DM_TEST_BOUNDARY_SIZES }}
DM_TEST_STRESS_ROWS: ${{ secrets.DM_TEST_STRESS_ROWS }}
DM_TEST_STRESS_WORKERS: ${{ secrets.DM_TEST_STRESS_WORKERS }}
DM_TEST_CHURN_LOOPS: ${{ secrets.DM_TEST_CHURN_LOOPS }}
DM_TEST_GC_LOOPS: ${{ secrets.DM_TEST_GC_LOOPS }}
run: |
python -m pip install pytest pytest-timeout pytest-cov
python -m pytest -q -m requires_dm tests --cov=. --cov-report=term-missing --cov-report=xml:coverage.xml
- name: Upload optional integration coverage
if: ${{ matrix.python-version == '3.10' && steps.dm_ready.outputs.available == 'true' }}
uses: actions/upload-artifact@v4
with:
name: coverage-wheel-baseline-py${{ matrix.python-version }}
path: coverage.xml
- name: Skip optional integration tests (missing DM secrets)
if: ${{ matrix.python-version == '3.10' && steps.dm_ready.outputs.available != 'true' }}
run: |
echo "::notice::SKIP_DM_INTEGRATION: DM_TEST_HOST/PORT/USER/PASSWORD secrets are not fully configured."
- uses: actions/upload-artifact@v4
with:
name: wheel-arm64-py${{ matrix.python-version }}
path: dist_fixed/*.whl
release:
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: macos-14
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: dist_fixed
pattern: wheel-*
merge-multiple: true
- name: Validate wheel set and generate release metadata
env:
TAG_NAME: ${{ github.ref_name }}
run: |
python - <<'PY'
import glob
import json
import os
import re
import subprocess
import sys
wheels = sorted(glob.glob("dist_fixed/*.whl"))
if len(wheels) != 5:
print(f"Expected 5 wheels, got {len(wheels)}")
print("\n".join(wheels))
sys.exit(1)
expected_tags = {"cp39-cp39", "cp310-cp310", "cp311-cp311", "cp312-cp312", "cp313-cp313"}
found_tags = set()
for wheel in wheels:
name = os.path.basename(wheel)
if "arm64.whl" not in name:
print(f"Non-arm64 wheel found: {name}")
sys.exit(1)
match = re.search(r"-(cp\d{2,3}-cp\d{2,3})-macosx_.*_arm64\.whl$", name)
if not match:
print(f"Unrecognized wheel naming pattern: {name}")
sys.exit(1)
found_tags.add(match.group(1))
if found_tags != expected_tags:
print(f"Wheel tag mismatch. expected={sorted(expected_tags)} found={sorted(found_tags)}")
sys.exit(1)
with open("dist_fixed/build-metadata.json", "w", encoding="utf-8") as f:
json.dump(
{
"tag": os.environ["TAG_NAME"],
"commit": os.environ.get("GITHUB_SHA", ""),
"workflow": os.environ.get("GITHUB_WORKFLOW", ""),
"run_id": os.environ.get("GITHUB_RUN_ID", ""),
"run_attempt": os.environ.get("GITHUB_RUN_ATTEMPT", ""),
"wheels": [os.path.basename(w) for w in wheels],
},
f,
ensure_ascii=False,
indent=2,
)
subprocess.check_call("shasum -a 256 dist_fixed/*.whl > dist_fixed/checksums.txt", shell=True)
PY
- name: Upsert GitHub Release
env:
GH_TOKEN: ${{ github.token }}
TAG_NAME: ${{ github.ref_name }}
run: |
if gh release view "$TAG_NAME" >/dev/null 2>&1; then
echo "Release $TAG_NAME already exists, uploading artifacts with --clobber"
gh release upload "$TAG_NAME" dist_fixed/*.whl dist_fixed/checksums.txt dist_fixed/build-metadata.json --clobber
else
echo "Creating release $TAG_NAME"
gh release create "$TAG_NAME" --generate-notes dist_fixed/*.whl dist_fixed/checksums.txt dist_fixed/build-metadata.json
fi
- name: Verify release assets completeness
env:
GH_TOKEN: ${{ github.token }}
TAG_NAME: ${{ github.ref_name }}
run: |
python - <<'PY'
import json
import os
import re
import subprocess
import sys
tag = os.environ["TAG_NAME"]
raw = subprocess.check_output(
["gh", "release", "view", tag, "--json", "assets"],
text=True,
)
assets = [a["name"] for a in json.loads(raw)["assets"]]
expected_tags = {"cp39-cp39", "cp310-cp310", "cp311-cp311", "cp312-cp312", "cp313-cp313"}
found_tags = set()
for name in assets:
m = re.search(r"-(cp\d{2,3}-cp\d{2,3})-macosx_.*_arm64\.whl$", name)
if m:
found_tags.add(m.group(1))
missing_tags = sorted(expected_tags - found_tags)
required_files = {"checksums.txt", "build-metadata.json"}
missing_files = sorted(f for f in required_files if f not in assets)
if missing_tags or missing_files:
print("Release assets are incomplete.")
print(f"missing wheel tags: {missing_tags}")
print(f"missing files: {missing_files}")
print(f"assets: {assets}")
sys.exit(1)
print("Release assets verified:", assets)
PY