1
1
# This workflow will install Python dependencies, run tests and lint with all currently supported python versions on all major plattforms
2
2
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3
3
4
- name : build
4
+ name : GitHub CI
5
5
6
6
on :
7
7
push :
8
- branches : [ main, dev ]
8
+ branches : [ main, dev, release ]
9
+ tags :
10
+ - ' *'
9
11
pull_request :
10
- branches : [ main, dev ]
12
+ branches : [ main, dev, release ]
11
13
schedule :
12
14
- cron : ' 0 0 1 * *'
13
15
14
16
jobs :
15
-
16
- build :
17
+ build_wheels :
18
+ name : Build wheels
17
19
runs-on : ${{ matrix.os }}
18
20
strategy :
19
21
matrix :
20
- python-version : ['3.9', '3.10', '3.11', '3.12']
21
- os : [windows-latest, macOS-13, macos-latest, ubuntu-latest]
22
+ os : [ubuntu-latest, windows-latest, macOS-13, macos-latest]
22
23
fail-fast : false
23
24
steps :
24
- - name : Macos debug and set deployment target variable
25
+ - name : Set env variables to handle macOS-13
25
26
if : ${{ matrix.os == 'macOS-13'}}
26
27
run : |
27
- xcodebuild -version
28
- echo $MACOSX_DEPLOYMENT_TARGET
29
- export MACOSX_DEPLOYMENT_TARGET=13.0
30
- echo $MACOSX_DEPLOYMENT_TARGET
31
- - uses : actions/checkout@v4
32
- - name : Set up Python
33
- uses : actions/setup-python@v5
34
- with :
35
- python-version : ${{ matrix.python-version }}
36
- - name : Install dependencies
37
- run : |
38
- python --version
39
- python -m pip install --upgrade pip
40
- pip install wheel
41
- pip install -r requirements.txt
42
- - name : Build macOS-13 # Special case due to unresolved wheel naming bug.
43
- if : ${{ matrix.os == 'macOS-13'}}
28
+ echo "MACOSX_DEPLOYMENT_TARGET=13.0" >> $GITHUB_ENV
29
+ echo "PLAT=macosx-13.0-universal2" >> $GITHUB_ENV
30
+ - name : Checkout repository
31
+ uses : actions/checkout@v4
32
+ - name : Install libomp on macos
33
+ if : ${{ matrix.os == 'macos-latest' || matrix.os == 'macOS-13'}}
44
34
run : |
45
- python setup.py bdist_wheel --plat-name macosx-13.0-universal2 --verbose
46
- ls dist/*
47
- - name : Build all other OS
48
- if : ${{ matrix.os != 'macOS-13'}}
35
+ brew reinstall --build-from-source --formula wntr/epanet/libepanet/darwin-formula/libomp.rb
36
+ - name : Build wheels
37
+ uses : pypa/cibuildwheel@79b0dd328794e1180a7268444d46cdf12e1abd01 # v2.21.0
38
+ env :
39
+ CIBW_ENVIRONMENT : BUILD_WNTR_EXTENSIONS='true'
40
+ CIBW_BUILD : cp39-* cp310-* cp311-* cp312-*
41
+ CIBW_SKIP : " *-win32 *-manylinux_i686 pp* *-musllinux*"
42
+ CIBW_REPAIR_WHEEL_COMMAND : ' ' # Skip repair step
43
+ - name : Fix macos13 wheel names # For some reason, they come out as macos14 instead of macos13
44
+ if : ${{ matrix.os == 'macOS-13'}}
49
45
run : |
50
- python setup.py bdist_wheel --verbose
51
- ls dist/*
52
- - name : Save wheel
53
- uses : actions/upload-artifact@v4
46
+ for file in ./wheelhouse/*.whl; do
47
+ new_name=$(echo "$file" | sed 's/macosx_14_0/macosx_13_0/')
48
+ mv "$file" "$new_name"
49
+ done
50
+ - name : Upload wheels
51
+ uses : actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
54
52
with :
55
- name : wntr_ ${{ matrix.python-version }}_ ${{ matrix.os }}.whl
56
- path : dist/wntr*
53
+ name : cibw-wheels- ${{ matrix.os }}- ${{ strategy.job-index }}
54
+ path : ./wheelhouse/*.whl
57
55
58
- install_import :
59
- needs : build
56
+ test_wheels :
57
+ name : Test wheels
58
+ needs : build_wheels
60
59
runs-on : ${{ matrix.os }}
61
60
strategy :
62
61
matrix :
71
70
- name : Download wheel
72
71
uses : actions/download-artifact@v4
73
72
with :
74
- name : wntr_${{ matrix.python-version }}_${{ matrix.os }}.whl
73
+ # name: wntr_${{ matrix.python-version }}_${{ matrix.os }}.whl
74
+ pattern : " cibw-wheels-*"
75
+ merge-multiple : true
75
76
- name : Install wntr
76
77
run : |
77
78
python -m pip install --upgrade pip
97
98
run : |
98
99
pip install -r requirements.txt
99
100
pytest wntr/tests/ --ignore=wntr/tests/test_demos.py --ignore=wntr/tests/test_examples.py
100
- pytest_coverage :
101
+
102
+ run_coverage :
101
103
runs-on : ${{ matrix.os }}
102
104
strategy :
103
105
matrix :
@@ -143,7 +145,7 @@ jobs:
143
145
include-hidden-files : true
144
146
145
147
combine_reports :
146
- needs : [ pytest_coverage ]
148
+ needs : [ run_coverage ]
147
149
runs-on : ubuntu-latest
148
150
steps :
149
151
- name : Set up Python
@@ -190,3 +192,45 @@ jobs:
190
192
run : coveralls --service=github --rcfile=.coveragerc
191
193
env :
192
194
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
195
+
196
+ build_sdist :
197
+ name : Build SDist artifact 📦
198
+ runs-on : ubuntu-latest
199
+ steps :
200
+ - uses : actions/checkout@v4
201
+ - uses : actions/setup-python@v5
202
+ with :
203
+ python-version : ' 3.11'
204
+ - name : Build SDist
205
+ run : pipx run build --sdist
206
+ - uses : actions/upload-artifact@v4
207
+ with :
208
+ name : sdist
209
+ path : dist/*.tar.gz
210
+
211
+ publish-to-pypi :
212
+ name : Publish Python 🐍 distribution 📦 to TestPyPI
213
+ if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
214
+ needs : [build_wheels, build_sdist]
215
+ runs-on : ubuntu-latest
216
+ environment :
217
+ name : testpypi
218
+ url : https://test.pypi.org/p/kbonney-wntr
219
+ permissions :
220
+ id-token : write
221
+ steps :
222
+ - name : Download wheel artifacts from build
223
+ uses : actions/download-artifact@v4
224
+ with :
225
+ pattern : wntr_*
226
+ path : dist
227
+ merge-multiple : true
228
+ - name : Download SDist artifact
229
+ uses : actions/download-artifact@v4
230
+ with :
231
+ name : sdist
232
+ path : dist
233
+ - name : Publish distribution 📦 to TestPyPI
234
+ uses : pypa/gh-action-pypi-publish@release/v1
235
+ with :
236
+ repository-url : https://test.pypi.org/legacy/
0 commit comments