@@ -2,250 +2,102 @@ name: Build and Test Wheels
22
33on :
44 push :
5- branches : [main, master]
6- tags :
7- - " v*"
5+ branches : [main, master, feature/ci-cd]
86 pull_request :
97 branches : [main, master]
10- release :
11- types : [published]
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)
148 workflow_dispatch :
15- inputs :
16- cfd_ref :
17- description : " CFD library ref (tag/branch/commit). Leave empty to auto-detect."
18- required : false
19- default : " "
209
2110jobs :
22- build_wheels :
23- name : Build wheels on ${{ matrix.os }}
24- runs-on : ${{ matrix.os }}
25- strategy :
26- matrix :
27- # Build only on Linux for now (simplified debugging)
28- os : [ubuntu-latest]
11+ build_wheel :
12+ name : Build wheel on Linux
13+ runs-on : ubuntu-latest
2914
3015 steps :
3116 - uses : actions/checkout@v4
3217 with :
3318 fetch-depth : 0
3419
35- # Determine which version of CFD library to use
36- # Priority: workflow_dispatch input > latest cfd release tag
37- # This ensures we always build against stable, tested cfd releases
38- - name : Determine CFD library version
39- id : cfd-version
40- shell : bash
41- env :
42- GH_TOKEN : ${{ github.token }}
43- run : |
44- # Check for workflow_dispatch input first
45- if [[ -n "${{ github.event.inputs.cfd_ref }}" ]]; then
46- echo "ref=${{ github.event.inputs.cfd_ref }}" >> $GITHUB_OUTPUT
47- echo "Using CFD library ref from input: ${{ github.event.inputs.cfd_ref }}"
48- else
49- # Fetch the latest release tag from cfd repo
50- LATEST_TAG=$(gh api repos/${{ github.repository_owner }}/cfd/releases/latest --jq '.tag_name' 2>/dev/null || echo "")
51-
52- if [[ -n "$LATEST_TAG" ]]; then
53- echo "ref=$LATEST_TAG" >> $GITHUB_OUTPUT
54- echo "Using latest CFD release: $LATEST_TAG"
55- else
56- # Fallback to master if no releases exist
57- echo "ref=master" >> $GITHUB_OUTPUT
58- echo "No CFD releases found, falling back to master branch"
59- fi
60- fi
61-
62- # Checkout the CFD C library into 'src/cfd_lib' subdirectory
63- # This location is inside the source tree so it's accessible from cibuildwheel
64- # build environments (including Linux Docker containers where source is mounted)
20+ # Checkout CFD C library
6521 - name : Checkout CFD C library
6622 uses : actions/checkout@v4
6723 with :
6824 repository : ${{ github.repository_owner }}/cfd
69- path : src/cfd_lib
70- ref : ${{ steps.cfd-version.outputs.ref }}
25+ path : cfd
7126 fetch-depth : 0
7227
73- # Build wheels using cibuildwheel
74- # Configuration is in pyproject.toml - we only override CFD_ROOT for CI
75- # (pyproject.toml defaults to ../cfd for local dev, CI uses ./src/cfd_lib)
76- - name : Build wheels
77- uses : pypa/cibuildwheel@v2.21.3
28+ - name : Set up Python 3.8
29+ uses : actions/setup-python@v5
30+ with :
31+ python-version : " 3.8"
32+
33+ - name : Install build dependencies
34+ run : |
35+ python -m pip install --upgrade pip
36+ pip install build scikit-build-core setuptools-scm
37+
38+ - name : Build CFD library
39+ run : |
40+ cmake -S cfd -B cfd/build -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON
41+ cmake --build cfd/build --config Release
42+ echo "=== CFD library built ==="
43+ ls -la cfd/build/lib/
44+
45+ - name : Build wheel
7846 env :
79- # Override CFD_ROOT to point to the cfd checkout inside the source tree
80- # All other settings (build flags, before-build, etc.) come from pyproject.toml
81- CIBW_ENVIRONMENT : " CMAKE_BUILD_TYPE=Release CFD_STATIC_LINK=ON CFD_USE_STABLE_ABI=ON CFD_ROOT=./src/cfd_lib"
82- # Enable verbose output to see CMake and compiler commands
83- CIBW_BUILD_VERBOSITY : " 3"
84-
85- - name : List wheel contents for debugging
86- shell : bash
47+ CFD_ROOT : ./cfd
48+ CFD_STATIC_LINK : " ON"
49+ CFD_USE_STABLE_ABI : " OFF"
50+ run : |
51+ python -m build --wheel
52+ echo "=== Wheel built ==="
53+ ls -la dist/
54+
55+ - name : Inspect wheel contents
8756 run : |
88- echo "=== Wheels built ==="
89- ls -la wheelhouse/
90- echo ""
91- echo "=== Inspecting wheel contents ==="
92- for wheel in wheelhouse/*.whl; do
93- echo "--- $wheel ---"
94- python -m zipfile -l "$wheel" | grep -E '\.(so|pyd|dylib)$' || echo "No extension found!"
57+ for wheel in dist/*.whl; do
58+ echo "=== Contents of $wheel ==="
59+ python -m zipfile -l "$wheel"
9560 done
9661
9762 - uses : actions/upload-artifact@v4
9863 with :
99- name : wheels-${{ matrix.os }}
100- path : ./wheelhouse /*.whl
64+ name : wheel
65+ path : dist /*.whl
10166
102- build_sdist :
103- name : Build source distribution
67+ test_wheel :
68+ name : Test wheel
69+ needs : [build_wheel]
10470 runs-on : ubuntu-latest
105- steps :
106- - uses : actions/checkout@v4
107- with :
108- fetch-depth : 0
109-
110- - name : Build sdist
111- run : pipx run build --sdist
112-
113- - uses : actions/upload-artifact@v4
114- with :
115- name : sdist
116- path : dist/*.tar.gz
117-
118- test_package :
119- name : Test package installation
120- needs : [build_wheels]
121- runs-on : ${{ matrix.os }}
122- strategy :
123- matrix :
124- # Test on Linux with Python 3.8 (matches abi3 wheel) and 3.12 (to verify abi3 compat)
125- os : [ubuntu-latest]
126- python-version : ["3.8", "3.12"]
12771
12872 steps :
12973 - uses : actions/checkout@v4
130- - uses : actions/setup-python@v5
74+
75+ - name : Set up Python 3.8
76+ uses : actions/setup-python@v5
13177 with :
132- python-version : ${{ matrix.python-version }}
78+ python-version : " 3.8 "
13379
13480 - uses : actions/download-artifact@v4
13581 with :
136- name : wheels-${{ matrix.os }}
137- path : wheelhouse
138-
139- - name : List available wheels
140- shell : bash
141- run : |
142- echo "=== Available wheels ==="
143- ls -la wheelhouse/
144- echo ""
145- echo "=== Python version ==="
146- python --version
147- echo ""
148- echo "=== Wheel contents (looking for .so/.pyd files) ==="
149- for wheel in wheelhouse/*.whl; do
150- echo "--- $wheel ---"
151- python -m zipfile -l "$wheel" | grep -E '\.(so|pyd|dylib)$' || echo "No extension found in wheel!"
152- done
82+ name : wheel
83+ path : dist
15384
154- - name : Install wheel and test dependencies
85+ - name : Install wheel
15586 run : |
15687 python -m pip install --upgrade pip
157- python -m pip install -v --find-links wheelhouse cfd-python
158- python -m pip install pytest numpy
88+ pip install dist/*.whl
89+ pip install pytest numpy
15990
160- - name : Verify installation
161- shell : bash
91+ - name : Test import
16292 run : |
163- echo "=== Installed package location ==="
164- python -c "import cfd_python; print('Package __file__:', cfd_python.__file__)"
165- echo ""
166- echo "=== Package directory contents ==="
167- python -c "import cfd_python, os; pkgdir=os.path.dirname(cfd_python.__file__); print('Contents:', os.listdir(pkgdir)); exts=[f for f in os.listdir(pkgdir) if '.so' in f or '.pyd' in f]; print('Extensions found:', exts)"
168- echo ""
169- echo "=== Try importing C extension directly ==="
17093 python -c "
171- import sys, os
17294 import cfd_python
173- pkgdir = os.path.dirname( cfd_python.__file__)
174- print('Package dir :', pkgdir )
95+ print('Package loaded:', cfd_python.__file__)
96+ print('Version :', cfd_python.__version__ )
17597 print('Has list_solvers:', hasattr(cfd_python, 'list_solvers'))
176- # Try direct import of the extension
177- try:
178- from cfd_python import cfd_python as ext
179- print('Direct extension import OK')
180- print('Extension has PyInit:', hasattr(ext, '__name__'))
181- print('list_solvers available:', hasattr(ext, 'list_solvers'))
182- except ImportError as e:
183- print('Direct extension import FAILED:', e)
184- # Check __all__
185- print('__all__:', getattr(cfd_python, '__all__', 'NOT DEFINED'))
186- print('__version__:', getattr(cfd_python, '__version__', 'NOT DEFINED'))
98+ if hasattr(cfd_python, 'list_solvers'):
99+ print('Solvers:', cfd_python.list_solvers())
187100 "
188101
189- - name : Run full test suite
102+ - name : Run tests
190103 run : pytest tests/ -v
191-
192- upload_pypi :
193- name : Upload to PyPI
194- needs : [build_wheels, build_sdist, test_package]
195- runs-on : ubuntu-latest
196- # Publish on: release event, tag push (v*), or workflow_dispatch on a tag
197- if : |
198- github.event_name == 'release' ||
199- (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) ||
200- (github.event_name == 'workflow_dispatch' && startsWith(github.ref, 'refs/tags/v'))
201- environment :
202- name : pypi
203- url : https://pypi.org/p/cfd-python
204- permissions :
205- id-token : write
206-
207- steps :
208- - uses : actions/download-artifact@v4
209- with :
210- pattern : wheels-*
211- path : dist
212- merge-multiple : true
213-
214- - uses : actions/download-artifact@v4
215- with :
216- name : sdist
217- path : dist
218-
219- - name : Publish to PyPI
220- uses : pypa/gh-action-pypi-publish@v1.12.4 # Pin to specific version for security
221- with :
222- packages-dir : dist/
223-
224- upload_test_pypi :
225- name : Upload to Test PyPI
226- needs : [build_wheels, build_sdist, test_package]
227- runs-on : ubuntu-latest
228- if : github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
229- environment :
230- name : testpypi
231- url : https://test.pypi.org/p/cfd-python
232- permissions :
233- id-token : write
234-
235- steps :
236- - uses : actions/download-artifact@v4
237- with :
238- pattern : wheels-*
239- path : dist
240- merge-multiple : true
241-
242- - uses : actions/download-artifact@v4
243- with :
244- name : sdist
245- path : dist
246-
247- - name : Publish to Test PyPI
248- uses : pypa/gh-action-pypi-publish@v1.12.4 # Pin to specific version for security
249- with :
250- repository-url : https://test.pypi.org/legacy/
251- packages-dir : dist/
0 commit comments