pyalp CI (local-build smoke test) #128
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: pyalp CI | |
| # Run only on pushes that create tags starting with 'pyalp' | |
| on: | |
| push: | |
| tags: [ 'pyalp*' ] | |
| jobs: | |
| build-bindings: | |
| name: Build C++ bindings | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout (with submodules) | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: 'recursive' | |
| fetch-depth: 0 | |
| - name: Verify pinned pybind11 submodule commit | |
| # Fail early if the checked-out pybind11 is not the pinned commit | |
| run: | | |
| set -euo pipefail | |
| # Prefer top-level pinned file so it survives moves; fallback to submodule path | |
| if [ -f pyalp/PINNED_PYBIND11 ]; | |
| then | |
| PINNED_SHA=$(cat pyalp/PINNED_PYBIND11 | tr -d '\n') | |
| elif [ -f pyalp/extern/pybind11/PINNED_COMMIT ]; | |
| then | |
| PINNED_SHA=$(cat pyalp/extern/pybind11/PINNED_COMMIT | tr -d '\n') | |
| else | |
| echo "No pinned commit file found (tried pyalp/PINNED_PYBIND11 and pyalp/extern/pybind11/PINNED_COMMIT)" >&2 | |
| exit 2 | |
| fi | |
| echo "Expected pybind11 commit: $PINNED_SHA" | |
| ACTUAL=$(git -C pyalp/extern/pybind11 rev-parse HEAD || true) | |
| echo "Found pybind11 commit: $ACTUAL" | |
| if [ "$ACTUAL" != "$PINNED_SHA" ]; | |
| then | |
| echo "ERROR: pybind11 submodule commit does not match pinned commit" >&2 | |
| exit 2 | |
| fi | |
| - name: Install build dependencies | |
| run: | | |
| set -euo pipefail | |
| sudo apt-get update | |
| # libnuma-dev provides NUMA headers/libraries needed by FindNuma.cmake | |
| sudo apt-get install -y build-essential cmake ninja-build pkg-config python3-venv python3-dev python3-pip libnuma-dev | |
| - name: Configure and build pyalp bindings | |
| run: | | |
| set -euo pipefail | |
| mkdir -p build_alp | |
| cmake -S . -B build_alp -DENABLE_PYALP=ON | |
| # Only attempt to build pyalp targets if the pyalp CMake directory exists | |
| if [ -f pyalp/CMakeLists.txt ]; | |
| then | |
| echo "pyalp CMakeLists found — building pyalp targets" | |
| cmake --build build_alp --target pyalp_ref -- -j || true | |
| cmake --build build_alp --target pyalp_omp -- -j || true | |
| else | |
| echo "pyalp directory or CMakeLists not present — skipping pyalp targets" | |
| fi | |
| - name: Find and list built shared objects | |
| run: | | |
| set -euo pipefail | |
| echo "Searching for shared objects under build_alp and pyalp" | |
| find build_alp -name "*.so" -maxdepth 8 -print || true | |
| find pyalp -name "*.so" -maxdepth 8 -print || true | |
| - name: Collect built shared objects into artifacts/ | |
| run: | | |
| set -euo pipefail | |
| mkdir -p artifacts | |
| # copy any discovered .so files into a flat artifacts directory so upload-artifact can find them | |
| find build_alp -name "*.so" -print0 | xargs -0 -I{} bash -lc 'cp -v "{}" artifacts/ || true' || true | |
| find pyalp -name "*.so" -print0 | xargs -0 -I{} bash -lc 'cp -v "{}" artifacts/ || true' || true | |
| echo "Artifacts now contains:" && ls -la artifacts || true | |
| - name: Upload built bindings | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pyalp-so | |
| path: | | |
| build_alp/**/*.so | |
| artifacts/**/*.so | |
| pyalp/**/pyalp*.so | |
| pyalp/**/_pyalp*.so | |
| pyalp/**/libpyalp*.so | |
| pyalp/**/*.so | |
| build-wheel-and-test: | |
| name: Build wheel from prebuilt .so and smoke-test | |
| runs-on: ubuntu-latest | |
| needs: build-bindings | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Download built bindings | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: pyalp-so | |
| path: artifacts | |
| - name: Show downloaded artifacts | |
| run: ls -la artifacts || true | |
| - name: Prepare wheel inputs | |
| id: prep | |
| run: | | |
| set -euo pipefail | |
| # List candidate shared-object files for debugging | |
| echo "Candidate .so files in artifacts:" && find artifacts -type f -name "*.so" -print || true | |
| # Find likely candidates (prefer _pyalp, pyalp, libpyalp) | |
| SO_PATH=$(find artifacts \( -name "_pyalp*.so" -o -name "pyalp*.so" -o -name "libpyalp*.so" -o -name "*.so" \) | head -n1) | |
| if [ -z "$SO_PATH" ]; | |
| then | |
| echo "ERROR: no built .so artifact found to package" >&2 | |
| echo "Artifacts listing:" && ls -la artifacts || true | |
| exit 2 | |
| fi | |
| echo "so_path=$SO_PATH" >> "$GITHUB_OUTPUT" | |
| # Prefer helper located inside pyalp/ but fall back to top-level tools/ | |
| if [ -f pyalp/tools/make_wheel_from_so.py ]; then | |
| echo "builder=pyalp/tools/make_wheel_from_so.py" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "builder=tools/make_wheel_from_so.py" >> "$GITHUB_OUTPUT" | |
| fi | |
| # Derive Python version from the .so filename (e.g., cpython-311 -> 3.11, cp312 -> 3.12) | |
| PY_VER="" | |
| if [[ "$SO_PATH" =~ cpython-([0-9]{3}) ]]; | |
| then | |
| n=${BASH_REMATCH[1]} | |
| PY_VER="${n:0:1}.${n:1}" | |
| elif [[ "$SO_PATH" =~ cp([0-9]{2,3}) ]]; | |
| then | |
| n=${BASH_REMATCH[1]} | |
| PY_VER="${n:0:1}.${n:1}" | |
| fi | |
| echo "python_version=$PY_VER" >> "$GITHUB_OUTPUT" | |
| - name: Run wheel builder | |
| run: | | |
| set -euo pipefail | |
| echo "builder=${{ steps.prep.outputs.builder }}" | |
| echo "so=${{ steps.prep.outputs.so_path }}" | |
| python3 "${{ steps.prep.outputs.builder }}" "${{ steps.prep.outputs.so_path }}" --out-dir dist_wheel | |
| - name: Show wheel | |
| run: ls -la dist_wheel || true | |
| - name: Set up Python matching built extension | |
| if: ${{ steps.prep.outputs.python_version != '' }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ steps.prep.outputs.python_version }} | |
| - name: Smoke test wheel in venv | |
| run: | | |
| set -euo pipefail | |
| python3 -V | |
| which python3 | |
| python3 -m venv venv | |
| . venv/bin/activate | |
| pip install --upgrade pip wheel | |
| pip install dist_wheel/*.whl | |
| tools/smoke_test_pyalp.py |