Skip to content

Commit 7678151

Browse files
committed
Simplify build-wheels workflow and improve testing
- Remove duplicate cibuildwheel config, rely on pyproject.toml - Use CIBW_ENVIRONMENT_PASS_* to override CFD_ROOT for CI - Remove redundant CFD library build steps (handled by before-build) - Use pattern: wheels-* for explicit artifact download - Download wheels and sdist separately for clarity - Add id-token: write permission for Test PyPI - Replace smoke tests with full pytest suite
1 parent f7eabff commit 7678151

1 file changed

Lines changed: 31 additions & 60 deletions

File tree

.github/workflows/build-wheels.yml

Lines changed: 31 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ on:
99
branches: [main, master]
1010
release:
1111
types: [published]
12-
# Allow triggering from cfd repo or manually
12+
# Allow manual triggering or remote triggering via GitHub CLI/API
13+
# (used by cfd repo's version-release.yml via: gh workflow run build-wheels.yml)
1314
workflow_dispatch:
1415
inputs:
1516
cfd_ref:
@@ -44,7 +45,7 @@ jobs:
4445
# Use the release tag
4546
echo "ref=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT
4647
echo "Using CFD library tag: ${{ github.event.release.tag_name }}"
47-
elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
48+
elif [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
4849
# Push of a tag
4950
TAG=${GITHUB_REF#refs/tags/}
5051
echo "ref=$TAG" >> $GITHUB_OUTPUT
@@ -68,46 +69,18 @@ jobs:
6869
ref: ${{ steps.cfd-version.outputs.ref }}
6970
fetch-depth: 0
7071

71-
# Build CFD C library (static)
72-
- name: Build CFD C library (Linux/macOS)
73-
if: runner.os != 'Windows'
74-
run: |
75-
cd cfd
76-
cmake -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF
77-
cmake --build build --config Release
78-
79-
- name: Build CFD C library (Windows)
80-
if: runner.os == 'Windows'
81-
run: |
82-
cd cfd
83-
cmake -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF
84-
cmake --build build --config Release
85-
72+
# Build wheels using cibuildwheel
73+
# Configuration is in pyproject.toml - only override CFD_ROOT for CI
74+
# (pyproject.toml uses ../cfd for local dev, CI uses ./cfd)
8675
- name: Build wheels
8776
uses: pypa/cibuildwheel@v2.21.3
8877
env:
89-
CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-*
90-
CIBW_SKIP: "*-musllinux_* pp*"
91-
CIBW_ARCHS_WINDOWS: AMD64
92-
CIBW_ARCHS_MACOS: x86_64 arm64
93-
CIBW_ARCHS_LINUX: x86_64
94-
95-
# Environment for static linking and stable ABI
96-
# CFD_ROOT points to the cfd subdirectory in the workspace
97-
CIBW_ENVIRONMENT: "CMAKE_BUILD_TYPE=Release CFD_STATIC_LINK=ON CFD_USE_STABLE_ABI=ON CFD_ROOT=./cfd"
98-
99-
# Test the built wheels
100-
CIBW_TEST_COMMAND: >
101-
python -c "import cfd_python; print('CFD Python version:', cfd_python.__version__); print('Solvers:', cfd_python.list_solvers())"
102-
103-
# macOS wheel repair (static linking handles most deps)
104-
CIBW_REPAIR_WHEEL_COMMAND_MACOS: delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel}
105-
106-
# Linux wheel repair
107-
CIBW_REPAIR_WHEEL_COMMAND_LINUX: auditwheel repair -w {dest_dir} {wheel}
108-
109-
# Windows - no repair needed with static linking
110-
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: ""
78+
# Override CFD_ROOT to point to the cfd subdirectory in CI workspace
79+
# All other settings come from pyproject.toml [tool.cibuildwheel]
80+
CIBW_ENVIRONMENT_PASS_LINUX: CFD_ROOT
81+
CIBW_ENVIRONMENT_PASS_MACOS: CFD_ROOT
82+
CIBW_ENVIRONMENT_PASS_WINDOWS: CFD_ROOT
83+
CFD_ROOT: ./cfd
11184

11285
- uses: actions/upload-artifact@v4
11386
with:
@@ -150,30 +123,14 @@ jobs:
150123
name: wheels-${{ matrix.os }}
151124
path: wheelhouse
152125

153-
- name: Install wheel
126+
- name: Install wheel and test dependencies
154127
run: |
155128
python -m pip install --upgrade pip
156129
python -m pip install --find-links wheelhouse cfd-python
130+
python -m pip install pytest numpy
157131
158-
- name: Test import and version
159-
run: |
160-
python -c "import cfd_python; print('Version:', cfd_python.__version__)"
161-
162-
- name: Test solver discovery
163-
run: |
164-
python -c "import cfd_python; solvers = cfd_python.list_solvers(); print('Solvers:', solvers); assert len(solvers) > 0"
165-
166-
- name: Test simulation
167-
run: |
168-
python -c "import cfd_python; result = cfd_python.run_simulation(5, 5, steps=3); assert len(result) == 25; print('Simulation OK')"
169-
170-
- name: Test grid creation
171-
run: |
172-
python -c "import cfd_python; grid = cfd_python.create_grid(5, 5, 0, 1, 0, 1); assert grid['nx'] == 5; print('Grid OK')"
173-
174-
- name: Test solver params
175-
run: |
176-
python -c "import cfd_python; params = cfd_python.get_default_solver_params(); assert 'dt' in params; print('Params OK')"
132+
- name: Run full test suite
133+
run: pytest tests/ -v
177134

178135
upload_pypi:
179136
name: Upload to PyPI
@@ -193,9 +150,15 @@ jobs:
193150
steps:
194151
- uses: actions/download-artifact@v4
195152
with:
153+
pattern: wheels-*
196154
path: dist
197155
merge-multiple: true
198156

157+
- uses: actions/download-artifact@v4
158+
with:
159+
name: sdist
160+
path: dist
161+
199162
- name: Publish to PyPI
200163
uses: pypa/gh-action-pypi-publish@release/v1
201164
with:
@@ -205,17 +168,25 @@ jobs:
205168
name: Upload to Test PyPI
206169
needs: [build_wheels, build_sdist, test_package]
207170
runs-on: ubuntu-latest
208-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
171+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
209172
environment:
210173
name: testpypi
211174
url: https://test.pypi.org/p/cfd-python
175+
permissions:
176+
id-token: write
212177

213178
steps:
214179
- uses: actions/download-artifact@v4
215180
with:
181+
pattern: wheels-*
216182
path: dist
217183
merge-multiple: true
218184

185+
- uses: actions/download-artifact@v4
186+
with:
187+
name: sdist
188+
path: dist
189+
219190
- name: Publish to Test PyPI
220191
uses: pypa/gh-action-pypi-publish@release/v1
221192
with:

0 commit comments

Comments
 (0)