Skip to content

Merge pull request #14 from shaia/refactor/split-init #81

Merge pull request #14 from shaia/refactor/split-init

Merge pull request #14 from shaia/refactor/split-init #81

Workflow file for this run

name: Build and Test Wheels
on:
push:
branches: [main, master]
pull_request:
workflow_dispatch:
workflow_call:
jobs:
build_wheel:
name: Build wheel on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Checkout CFD C library
uses: actions/checkout@v4
with:
repository: ${{ github.repository_owner }}/cfd
path: cfd
fetch-depth: 0
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
- name: Install build dependencies
run: uv pip install --system build scikit-build-core setuptools-scm
- name: Build CFD library (Unix)
if: runner.os != 'Windows'
run: |
cmake -S cfd -B cfd/build -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON
cmake --build cfd/build --config Release
echo "=== CFD library built ==="
ls -la cfd/build/lib/
- name: Build CFD library (Windows)
if: runner.os == 'Windows'
run: |
cmake -S cfd -B cfd/build -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF
cmake --build cfd/build --config Release
echo "=== CFD library built ==="
dir cfd\build\lib\Release
- name: Build wheel (Unix)
if: runner.os != 'Windows'
env:
CFD_ROOT: ${{ github.workspace }}/cfd
CFD_STATIC_LINK: "ON"
CFD_USE_STABLE_ABI: "ON"
run: |
pip wheel . --no-deps --wheel-dir dist/
echo "=== Wheel built ==="
ls -la dist/
- name: Build wheel (Windows)
if: runner.os == 'Windows'
env:
CFD_ROOT: ${{ github.workspace }}/cfd
CFD_STATIC_LINK: "ON"
CFD_USE_STABLE_ABI: "ON"
run: |
pip wheel . --no-deps --wheel-dir dist/
echo "=== Wheel built ==="
dir dist
- name: Inspect wheel contents
run: |
python -c "
import glob, zipfile
for wheel in glob.glob('dist/*.whl'):
print(f'=== Contents of {wheel} ===')
with zipfile.ZipFile(wheel) as zf:
for name in zf.namelist():
print(name)
"
- uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.os }}
path: dist/*.whl
test_wheel:
name: Test wheel on ${{ matrix.os }} with Python ${{ matrix.python }}
needs: [build_wheel]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python: ["3.9", "3.13"]
steps:
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: "${{ matrix.python }}"
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
cache-dependency-glob: ""
- uses: actions/download-artifact@v4
with:
name: wheel-${{ matrix.os }}
path: dist
- name: Install wheel (Unix)
if: runner.os != 'Windows'
run: |
uv pip install --system dist/*.whl
uv pip install --system pytest numpy
- name: Install wheel (Windows)
if: runner.os == 'Windows'
run: |
uv pip install --system (Get-ChildItem dist/*.whl).FullName
uv pip install --system pytest numpy
- name: Test import (Unix)
if: runner.os != 'Windows'
run: |
cd /tmp
python -c "
import cfd_python
print('Package loaded:', cfd_python.__file__)
print('Version:', cfd_python.__version__)
print('Has list_solvers:', hasattr(cfd_python, 'list_solvers'))
if hasattr(cfd_python, 'list_solvers'):
print('Solvers:', cfd_python.list_solvers())
"
- name: Test import (Windows)
if: runner.os == 'Windows'
run: |
cd $env:TEMP
python -c "import cfd_python; print('Package loaded:', cfd_python.__file__); print('Version:', cfd_python.__version__); print('Has list_solvers:', hasattr(cfd_python, 'list_solvers')); print('Solvers:', cfd_python.list_solvers()) if hasattr(cfd_python, 'list_solvers') else None"
- uses: actions/checkout@v4
with:
sparse-checkout: tests
sparse-checkout-cone-mode: false
- name: Run tests (Unix)
if: runner.os != 'Windows'
run: |
cd /tmp
pytest $GITHUB_WORKSPACE/tests/ -v
- name: Run tests (Windows)
if: runner.os == 'Windows'
run: |
cd $env:TEMP
pytest "$env:GITHUB_WORKSPACE\tests" -v