|
| 1 | +name: Build Wheel Check |
| 2 | + |
| 3 | +# Dry-run the wheel build on PRs so we catch packaging regressions |
| 4 | +# before a release, instead of discovering them at publish time. |
| 5 | +on: |
| 6 | + pull_request: |
| 7 | + paths: |
| 8 | + - 'scripts/build_wheel.py' |
| 9 | + - 'scripts/download_cli.py' |
| 10 | + - '.github/workflows/build-and-publish.yml' |
| 11 | + - '.github/workflows/build-wheel-check.yml' |
| 12 | + - 'pyproject.toml' |
| 13 | + - 'MANIFEST.in' |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + runs-on: ${{ matrix.os }} |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + matrix: |
| 21 | + include: |
| 22 | + - os: ubuntu-latest |
| 23 | + expected_tag: manylinux_2_17_x86_64 |
| 24 | + - os: ubuntu-24.04-arm |
| 25 | + expected_tag: manylinux_2_17_aarch64 |
| 26 | + - os: macos-latest |
| 27 | + expected_tag: macosx_11_0_arm64 |
| 28 | + - os: macos-15-intel |
| 29 | + expected_tag: macosx_11_0_x86_64 |
| 30 | + - os: windows-latest |
| 31 | + expected_tag: win_amd64 |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v4 |
| 34 | + |
| 35 | + - uses: actions/setup-python@v5 |
| 36 | + with: |
| 37 | + python-version: '3.12' |
| 38 | + |
| 39 | + - name: Install build dependencies |
| 40 | + run: pip install build twine wheel |
| 41 | + shell: bash |
| 42 | + |
| 43 | + - name: Build wheel with bundled CLI |
| 44 | + run: python scripts/build_wheel.py --skip-sdist --clean |
| 45 | + shell: bash |
| 46 | + |
| 47 | + - name: Verify wheel filename contains expected platform tag |
| 48 | + shell: bash |
| 49 | + run: | |
| 50 | + set -euo pipefail |
| 51 | + ls -la dist/ |
| 52 | + wheel=$(ls dist/*.whl) |
| 53 | + echo "Built wheel: $wheel" |
| 54 | + if [[ "$wheel" != *"${{ matrix.expected_tag }}"* ]]; then |
| 55 | + echo "::error::Expected platform tag '${{ matrix.expected_tag }}' in wheel filename, got: $wheel" |
| 56 | + exit 1 |
| 57 | + fi |
| 58 | +
|
| 59 | + - name: Verify wheel contains bundled CLI binary |
| 60 | + shell: bash |
| 61 | + run: | |
| 62 | + set -euo pipefail |
| 63 | + wheel=$(ls dist/*.whl) |
| 64 | + python -m zipfile -l "$wheel" > wheel_contents.txt |
| 65 | + cat wheel_contents.txt |
| 66 | + if [[ "${{ runner.os }}" == "Windows" ]]; then |
| 67 | + grep -q "_bundled/claude.exe" wheel_contents.txt || { |
| 68 | + echo "::error::Bundled CLI (claude.exe) not found in wheel" |
| 69 | + exit 1 |
| 70 | + } |
| 71 | + else |
| 72 | + grep -q "_bundled/claude" wheel_contents.txt || { |
| 73 | + echo "::error::Bundled CLI (claude) not found in wheel" |
| 74 | + exit 1 |
| 75 | + } |
| 76 | + fi |
| 77 | + echo "Bundled CLI found in wheel ✓" |
| 78 | +
|
| 79 | + - name: Smoke-test install and import |
| 80 | + shell: bash |
| 81 | + run: | |
| 82 | + pip install dist/*.whl |
| 83 | + python -c "import claude_agent_sdk; print('import ok')" |
| 84 | + python -c "import claude_agent_sdk, pathlib, platform; cli_name = 'claude.exe' if platform.system() == 'Windows' else 'claude'; p = pathlib.Path(claude_agent_sdk.__file__).parent / '_bundled' / cli_name; assert p.exists() and p.is_file(), f'bundled CLI missing after install: {p}'; print('bundled CLI at', p)" |
| 85 | +
|
| 86 | + - uses: actions/upload-artifact@v4 |
| 87 | + with: |
| 88 | + name: wheel-check-${{ matrix.expected_tag }} |
| 89 | + path: dist/*.whl |
| 90 | + retention-days: 7 |
| 91 | + |
| 92 | + verify-matrix-sync: |
| 93 | + # Guard against the build matrix here drifting from the publish matrix. |
| 94 | + runs-on: ubuntu-latest |
| 95 | + steps: |
| 96 | + - uses: actions/checkout@v4 |
| 97 | + - name: Check build matrices are in sync |
| 98 | + run: | |
| 99 | + set -euo pipefail |
| 100 | + publish=$(grep -oP 'os:\s*\[\K[^\]]+' .github/workflows/build-and-publish.yml | tr -d ' ' | tr ',' '\n' | sort) |
| 101 | + check=$(python3 -c "import yaml; d = yaml.safe_load(open('.github/workflows/build-wheel-check.yml')); print('\n'.join(sorted(i['os'] for i in d['jobs']['build']['strategy']['matrix']['include'])))") |
| 102 | + echo "publish matrix:"; echo "$publish" |
| 103 | + echo "check matrix:"; echo "$check" |
| 104 | + diff <(echo "$publish") <(echo "$check") || { |
| 105 | + echo "::error::build-wheel-check.yml matrix is out of sync with build-and-publish.yml" |
| 106 | + exit 1 |
| 107 | + } |
0 commit comments