forked from crossbario/autobahn-python
-
Notifications
You must be signed in to change notification settings - Fork 0
492 lines (435 loc) · 20.1 KB
/
Copy pathwheels-docker.yml
File metadata and controls
492 lines (435 loc) · 20.1 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
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
name: wheels-docker
on:
# Build wheels on feature branches and PRs (test only)
push:
branches: ["**"]
tags:
- 'v*'
pull_request:
branches: [master]
# Publish to GitHub Releases when merged to master
# Publish to PyPI when tagged
workflow_dispatch:
env:
# Registry for caching build images
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/wheel-builder
jobs:
identifiers:
# GitHub needs to know where .cicd/workflows/identifiers.yml lives at parse time,
# and submodules aren't included in that context! thus the following does NOT work:
# uses: ./.cicd/workflows/identifiers.yml
# we MUST reference the remote repo directly:
uses: wamp-proto/wamp-cicd/.github/workflows/identifiers.yml@main
# IMPORTANT: we still need .cicd as a Git submodule in the using repo though!
# because e.g. identifiers.yml wants to access scripts/sanitize.sh !
build-wheels:
name: Build wheels (${{ matrix.target.name }})
needs: identifiers
runs-on: ubuntu-latest
container: ${{ matrix.target.base_image }}
env:
BASE_REPO: ${{ needs.identifiers.outputs.base_repo }}
BASE_BRANCH: ${{ needs.identifiers.outputs.base_branch }}
PR_NUMBER: ${{ needs.identifiers.outputs.pr_number }}
PR_REPO: ${{ needs.identifiers.outputs.pr_repo }}
PR_BRANCH: ${{ needs.identifiers.outputs.pr_branch }}
strategy:
fail-fast: false
matrix:
target:
# manylinux_2_28 (glibc 2.28+) - PEP 600 compliant, wide compatibility
# IMPORTANT: manylinux_2_28 uses baseline x86_64 ISA level (no SSE4.2/POPCNT)
# which is required for auditwheel to repair binaries like flatc.
# manylinux_2_34 uses x86_64_v2 which causes auditwheel failures.
# Matches zlmdb which also uses manylinux_2_28.
# see: https://github.com/pypa/manylinux
- name: "manylinux_2_28_x86_64"
base_image: "quay.io/pypa/manylinux_2_28_x86_64"
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install system dependencies
run: |
# manylinux images use yum/dnf and come with many build tools pre-installed
if command -v yum >/dev/null 2>&1; then
# manylinux images (CentOS-based)
yum update -y
yum install -y \
curl \
git \
openssl-devel \
libffi-devel \
zlib-devel \
bzip2-devel \
readline-devel \
sqlite-devel \
ncurses-devel
# Note: snappy-devel may not be available in manylinux base images
yum install -y snappy-devel || echo "snappy-devel not available, skipping"
elif command -v dnf >/dev/null 2>&1; then
# Newer manylinux images might use dnf
dnf update -y
dnf install -y \
curl \
git \
openssl-devel \
libffi-devel \
zlib-devel \
bzip2-devel \
readline-devel \
sqlite-devel \
ncurses-devel
dnf install -y snappy-devel || echo "snappy-devel not available, skipping"
fi
- name: Setup Python environment
run: |
# manylinux images come with multiple Python versions pre-installed in /opt/python/
echo "==> Available Python versions:"
ls -la /opt/python/*/bin/python* 2>/dev/null || echo "No /opt/python found"
# Add all Python versions to PATH for uv/just to discover
for pyver in /opt/python/*/bin; do
if [ -d "$pyver" ]; then
echo "Adding $pyver to PATH"
export PATH="$pyver:$PATH"
fi
done
# Also ensure we have a working python3 symlink
which python3 || ln -sf $(find /opt/python -name python3 | head -1) /usr/local/bin/python3
echo ""
echo "==> Current Python version:"
python3 --version
echo "==> pip version:"
python3 -m pip --version
# Save the updated PATH for subsequent steps
echo "PATH=$PATH" >> $GITHUB_ENV
- name: Install Just
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to /usr/local/bin
just --version
- name: Install uv
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
# Add to both GITHUB_PATH and current environment
echo "/root/.cargo/bin" >> $GITHUB_PATH
echo "PATH=/root/.cargo/bin:$PATH" >> $GITHUB_ENV
export PATH="/root/.cargo/bin:$PATH"
uv --version
- name: Install Rust
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
# Source the Rust environment (as recommended by installer)
source "$HOME/.cargo/env"
# Add to both GITHUB_PATH and current environment
echo "/root/.cargo/bin" >> $GITHUB_PATH
echo "PATH=/root/.cargo/bin:$PATH" >> $GITHUB_ENV
export PATH="/root/.cargo/bin:$PATH"
rustc --version
- name: Verify toolchain
run: |
# Source Rust environment and ensure PATH is set
source "$HOME/.cargo/env" 2>/dev/null || true
export PATH="/root/.cargo/bin:$PATH"
echo "==> Build environment summary:"
echo "Container: ${{ matrix.target.base_image }}"
echo "Just: $(just --version)"
echo "uv: $(uv --version)"
echo "Rust: $(rustc --version)"
echo "Python: $(python3 --version)"
echo "GCC: $(gcc --version | head -1)"
echo "glibc: $(ldd --version 2>/dev/null | head -1 || echo 'N/A')"
- name: Build manylinux wheels with NVX native extension
env:
AUTOBAHN_USE_NVX: 1
run: |
# Source Rust environment and ensure tools are in PATH
source "$HOME/.cargo/env" 2>/dev/null || true
export PATH="/root/.cargo/bin:$PATH"
# Verify environment
echo "==> Environment verification:"
echo "AUTOBAHN_USE_NVX=$AUTOBAHN_USE_NVX"
echo "PATH=$PATH"
echo "Python: $(python3 --version)"
echo "uv: $(uv --version)"
echo "just: $(just --version)"
echo "rustc: $(rustc --version)"
echo "auditwheel: $(auditwheel --version || echo 'not available')"
# Build binary wheels WITH NVX acceleration for manylinux
just build-all
command -v auditwheel >/dev/null || { echo "auditwheel missing, aborting"; exit 1; }
mkdir -p wheelhouse
# Convert linux_x86_64 wheels to manylinux_2_28_x86_64 using auditwheel
echo ""
echo "==> Converting wheels to manylinux_2_28_x86_64 format..."
for wheel in dist/*.whl; do
if [[ "$wheel" == *"linux_x86_64"* ]]; then
echo "Converting: $(basename $wheel)"
auditwheel show "$wheel"
auditwheel repair "$wheel" -w wheelhouse/
else
echo "Copying non-linux wheel: $(basename $wheel)"
cp "$wheel" wheelhouse/
fi
done
echo ""
echo "==> Final wheel inventory after manylinux conversion:"
echo ""
ls -la wheelhouse/
for wheel in wheelhouse/*.whl; do
auditwheel show "$wheel"
done
echo ""
echo " Note: auditwheel adds multiple manylinux tags into the filename."
echo " This is expected and pip will resolve correctly."
echo " Do NOT try to simplify by renaming."
echo ""
- name: Force file system sync (post-build, pre-validation)
run: |
echo "======================================================================"
echo "==> Forcing File System Sync (Post-Build)"
echo "======================================================================"
echo ""
echo "Flushing all file system buffers to disk to ensure wheels are fully"
echo "written before validation and checksumming."
echo ""
sync
echo "✅ All buffers flushed to disk"
echo ""
- name: Validate wheels integrity
run: |
set -o pipefail
echo "======================================================================"
echo "==> Validating Wheel Integrity (Fail Fast)"
echo "======================================================================"
echo ""
echo "Installing twine for validation..."
# Ensure pip is available for the Python being used
python3 -m ensurepip --upgrade 2>/dev/null || true
# Install both packaging and twine from master for PEP 639 (Core Metadata 2.4) support
# Note: No --break-system-packages needed in containers (isolated environment)
python3 -m pip install git+https://github.com/pypa/packaging.git
python3 -m pip install git+https://github.com/pypa/twine.git
echo ""
echo "==> Validation environment:"
echo "Python: $(python3 --version)"
echo "setuptools: $(python3 -m pip show setuptools | grep '^Version:' || echo 'not installed')"
echo "packaging: $(python3 -m pip show packaging | grep '^Version:' || echo 'not installed')"
echo "twine: $(twine --version)"
echo ""
# Initialize validation output file
VALIDATION_FILE="wheelhouse/VALIDATION.txt"
echo "Wheel Validation Results - Build Time" > "$VALIDATION_FILE"
echo "======================================" >> "$VALIDATION_FILE"
echo "" >> "$VALIDATION_FILE"
echo "Validation Date: $(date -u +"%Y-%m-%d %H:%M:%S UTC")" >> "$VALIDATION_FILE"
echo "Python: $(python3 --version)" >> "$VALIDATION_FILE"
echo "twine: $(twine --version)" >> "$VALIDATION_FILE"
echo "" >> "$VALIDATION_FILE"
HAS_ERRORS=0
for wheel in wheelhouse/*.whl; do
if [ ! -f "$wheel" ]; then
echo "⚠️ No wheels found in wheelhouse/"
HAS_ERRORS=1
continue
fi
WHEEL_NAME=$(basename "$wheel")
echo "==> Validating: $WHEEL_NAME"
echo "" >> "$VALIDATION_FILE"
echo "Wheel: $WHEEL_NAME" >> "$VALIDATION_FILE"
echo "---" >> "$VALIDATION_FILE"
# Test 1: Can unzip read the wheel?
echo " [1/3] ZIP integrity test..."
if unzip -t "$wheel" > /dev/null 2>&1; then
echo " ✅ ZIP test PASS"
echo " ZIP test: PASS" >> "$VALIDATION_FILE"
else
echo " ❌ ZIP test FAIL - wheel is corrupted!"
echo " This wheel cannot be unzipped and is unusable."
echo " ZIP test: FAIL - wheel is corrupted!" >> "$VALIDATION_FILE"
HAS_ERRORS=1
fi
# Test 2: Python zipfile module validation
echo " [2/3] Python zipfile test..."
if python3 -m zipfile -t "$wheel" > /dev/null 2>&1; then
echo " ✅ Python zipfile test PASS"
echo " Python zipfile test: PASS" >> "$VALIDATION_FILE"
else
echo " ❌ Python zipfile test FAIL - wheel is corrupted!"
echo " Python zipfile test: FAIL - wheel is corrupted!" >> "$VALIDATION_FILE"
HAS_ERRORS=1
fi
# Test 3: twine check (validates wheel metadata and structure)
echo " [3/3] Twine validation..."
twine check "$wheel" 2>&1 | tee /tmp/twine_output.txt
TWINE_EXIT=${PIPESTATUS[0]}
# Fail on nonzero exit or any error-like output
if [ "$TWINE_EXIT" -eq 0 ] && ! grep -Eqi "ERROR|FAILED|InvalidDistribution" /tmp/twine_output.txt; then
echo " ✅ Twine check PASS"
echo " Twine check: PASS" >> "$VALIDATION_FILE"
else
echo " ❌ Twine check FAIL"
cat /tmp/twine_output.txt
echo " Twine check: FAIL" >> "$VALIDATION_FILE"
cat /tmp/twine_output.txt >> "$VALIDATION_FILE"
HAS_ERRORS=1
fi
rm -f /tmp/twine_output.txt
echo ""
done
if [ $HAS_ERRORS -eq 1 ]; then
echo "" >> "$VALIDATION_FILE"
echo "RESULT: VALIDATION FAILED" >> "$VALIDATION_FILE"
echo "======================================================================"
echo "❌ WHEEL VALIDATION FAILED"
echo "======================================================================"
echo ""
echo "One or more wheels failed integrity checks."
echo "This indicates a build or packaging problem."
echo ""
echo "DO NOT PROCEED - corrupted wheels must NOT become artifacts!"
echo ""
exit 1
else
echo "" >> "$VALIDATION_FILE"
echo "RESULT: ALL VALIDATIONS PASSED" >> "$VALIDATION_FILE"
echo "======================================================================"
echo "✅ All wheels validated successfully"
echo "======================================================================"
echo ""
echo "All integrity checks passed. Wheels are valid and ready for upload."
echo ""
echo "Validation results written to: $VALIDATION_FILE"
fi
- name: Generate SHA256 checksums (chain of custody)
run: |
echo "======================================================================"
echo "==> Generating SHA256 Checksums for Chain of Custody"
echo "======================================================================"
echo ""
echo "OpenSSL version:"
openssl version
echo ""
# Force sync before checksumming to ensure files are on disk
echo "Forcing sync before checksumming..."
sync
echo "✅ Buffers flushed"
echo ""
# Change to wheelhouse directory to generate relative paths (basename only)
cd wheelhouse
CHECKSUM_FILE="CHECKSUMS.sha256"
# Generate checksums for all wheels (using basename only)
echo "Generating checksums for wheels..."
for wheel in *.whl; do
if [ -f "$wheel" ]; then
# Sync before each checksum to ensure file is on disk
sync
openssl sha256 "$wheel" | tee -a "$CHECKSUM_FILE"
fi
done
echo ""
echo "==> Generated checksum file:"
cat "$CHECKSUM_FILE"
echo ""
echo "This file will be uploaded with artifacts to verify integrity"
echo "when artifacts are downloaded by the release workflow."
echo ""
# Return to project root
cd ..
- name: Force file system sync (post-checksum, pre-upload)
run: |
echo "======================================================================"
echo "==> Forcing File System Sync (Post-Checksum)"
echo "======================================================================"
echo ""
echo "Final sync to ensure validation results and checksums are on disk"
echo "before artifact packaging."
echo ""
sync
echo "✅ All buffers flushed to disk"
echo ""
- name: Generate build metadata
run: |
BUILD_INFO=wheelhouse/build-info.txt
echo "manylinux Build Information for ${{ matrix.target.name }}" > $BUILD_INFO
echo "========================================================" >> $BUILD_INFO
echo "" >> $BUILD_INFO
echo "Build Date: $(date -u +"%Y-%m-%d %H:%M:%S UTC")" >> $BUILD_INFO
echo "Container: ${{ matrix.target.base_image }}" >> $BUILD_INFO
echo "Platform: $(uname -m)" >> $BUILD_INFO
echo "Build Method: GitHub Actions + manylinux Docker Container" >> $BUILD_INFO
echo "NVX Acceleration: ENABLED (binary wheels with native extensions)" >> $BUILD_INFO
echo "" >> $BUILD_INFO
echo "Per-Wheel ABI / Platform Tags:" >> $BUILD_INFO
echo "------------------------------" >> $BUILD_INFO
for whl in wheelhouse/*.whl; do
echo "- $(basename "$whl")" >> $BUILD_INFO
auditwheel show "$whl" | grep "platform tag" | awk -F'"' '{print " * " $2}' >> $BUILD_INFO
echo "" >> $BUILD_INFO
done
echo "" >> $BUILD_INFO
echo "Global System Information:" >> $BUILD_INFO
echo "--------------------------" >> $BUILD_INFO
echo "- OS: $(cat /etc/os-release | grep PRETTY_NAME | cut -d'\"' -f2 2>/dev/null || echo 'manylinux container')" >> $BUILD_INFO
echo "- Kernel: $(uname -r)" >> $BUILD_INFO
echo "- glibc: $(ldd --version 2>/dev/null | head -1 || echo 'N/A')" >> $BUILD_INFO
echo "- Architecture: $(uname -m)" >> $BUILD_INFO
echo "" >> $BUILD_INFO
echo "Build Tools:" >> $BUILD_INFO
echo "------------" >> $BUILD_INFO
echo "- Just: $(just --version)" >> $BUILD_INFO
echo "- uv: $(uv --version)" >> $BUILD_INFO
echo "- Rust: $(rustc --version)" >> $BUILD_INFO
echo "- Python: $(python3 --version)" >> $BUILD_INFO
echo "- GCC: $(gcc --version | head -1)" >> $BUILD_INFO
echo ""
echo "==> Generated build-info.txt:"
cat $BUILD_INFO
- name: List built artifacts
run: |
echo "==> Built artifacts for ${{ matrix.target.name }}:"
ls -la wheelhouse/ 2>/dev/null || echo "No wheelhouse/ directory found"
echo ""
echo "==> Build metadata:"
cat wheelhouse/build-info.txt 2>/dev/null || echo "No build info found"
echo ""
echo "==> Wheel inventory:"
find wheelhouse/ -name "*.whl" -exec basename {} \; 2>/dev/null | sort || echo "No wheels found"
# ============================================================================
# IMPORTANT: Container Jobs Require RELATIVE Paths for Artifact Upload
# ============================================================================
#
# This job uses `container: <image>` which creates a "Split-Brain" scenario:
#
# 1. Shell steps (run:) execute INSIDE the container where:
# - Working directory = /__w/repo/repo (container mount point)
# - $GITHUB_WORKSPACE = /__w/repo/repo (correct for container)
#
# 2. Node.js actions (uses:) like upload-artifact run on the HOST where:
# - Working directory = /home/runner/work/repo/repo
# - ${{ github.workspace }} = /home/runner/work/repo/repo (host path)
#
# If we pass a container-resolved path (/__w/...) to upload-artifact,
# the action will fail because that path doesn't exist on the host.
#
# The ONLY path that works in BOTH contexts is a RELATIVE PATH.
# GitHub guarantees the CWD is the workspace root for both environments,
# so "wheelhouse/" resolves correctly in both container and host.
#
# For non-container jobs, we use absolute paths: ${{ github.workspace }}/...
# For container jobs, we MUST use relative paths: wheelhouse/
# ============================================================================
- name: Upload wheels, source dist and build metadata with cryptographic verification
uses: wamp-proto/wamp-cicd/actions/upload-artifact-verified@main
with:
name: artifacts-${{ matrix.target.name }}
path: wheelhouse/
retention-days: 30
# GitHub Releases, PyPI, and RTD publishing are now handled by the centralized 'release' workflow