-
Notifications
You must be signed in to change notification settings - Fork 42
382 lines (365 loc) · 12.4 KB
/
slycot-build-and-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
name: Build and Test Slycot
on:
push:
pull_request:
paths-ignore:
- '.gitignore'
- 'AUTHORS'
- 'COPYING'
- 'gpl-2.0.txt'
- 'MANIFEST.in'
- 'README.rst'
jobs:
build-sdist:
# Super fast sniff build. If this fails, don't start the other jobs
name: Build sdist on Ubuntu
runs-on: ubuntu-latest
steps:
- name: Checkout Slycot
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: 'recursive'
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Setup Ubuntu
run: |
sudo apt-get -y install gfortran cmake --fix-missing
sudo apt-get -y install libblas-dev liblapack-dev
- name: Create Slycot sdist
run: |
pip install build
python -m build --sdist
- name: Install Slycot sdist
run: |
mkdir cleancwd
cd cleancwd
tar xfz ../dist/slycot-*.tar.gz
cd slycot-*
pip install -v .
- name: Run tests
run: |
pip install scipy pytest
pytest
build-pip:
name: Build pip Py${{ matrix.python }}, ${{ matrix.os }}, ${{ matrix.bla_vendor}} BLA_VENDOR
runs-on: ${{ matrix.os }}-latest
needs: build-sdist
strategy:
fail-fast: false
matrix:
os:
- 'ubuntu'
- 'macos'
python:
- '3.10'
- '3.12'
bla_vendor: [ 'unset' ]
include:
- os: 'ubuntu'
python: '3.12'
bla_vendor: 'Generic'
- os: 'ubuntu'
python: '3.12'
bla_vendor: 'OpenBLAS'
- os: 'macos'
python: '3.12'
bla_vendor: 'Apple'
- os: 'macos'
python: '3.12'
bla_vendor: 'Generic'
- os: 'macos'
python: '3.12'
bla_vendor: 'OpenBLAS'
steps:
- name: Checkout Slycot
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: 'recursive'
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Setup Ubuntu
if: matrix.os == 'ubuntu'
run: |
sudo apt-get -y update
sudo apt-get -y install gfortran cmake --fix-missing
case ${{ matrix.bla_vendor }} in
unset | Generic ) sudo apt-get -y install libblas-dev liblapack-dev ;;
OpenBLAS ) sudo apt-get -y install libopenblas-dev ;;
*)
echo "bla_vendor option ${{ matrix.bla_vendor }} not supported"
exit 1 ;;
esac
- name: Setup macOS
if: matrix.os == 'macos'
run: |
case ${{ matrix.bla_vendor }} in
unset | Generic | Apple ) ;; # Found in system
OpenBLAS )
brew install openblas
echo "BLAS_ROOT=/usr/local/opt/openblas/" >> $GITHUB_ENV
echo "LAPACK_ROOT=/usr/local/opt/openblas/" >> $GITHUB_ENV
;;
*)
echo "bla_vendor option ${{ matrix.bla_vendor }} not supported"
exit 1 ;;
esac
echo "FC=gfortran-14" >> $GITHUB_ENV
- name: Build wheel
env:
BLA_VENDOR: ${{ matrix.bla_vendor }}
CMAKE_GENERATOR: Unix Makefiles
run: |
if [[ $BLA_VENDOR = unset ]]; then unset BLA_VENDOR; fi
python -m pip install --upgrade pip
pip wheel -v -w . .
wheeldir=slycot-wheels/${{ matrix.os }}-${{ matrix.python }}-${{ matrix.bla_vendor }}
mkdir -p ${wheeldir}
cp ./slycot*.whl ${wheeldir}/
- name: Save wheel
uses: actions/upload-artifact@v3
with:
name: slycot-wheels
path: slycot-wheels
build-conda:
name: Build conda, ${{ matrix.os }}
runs-on: ${{ matrix.os }}-latest
needs: build-sdist
strategy:
fail-fast: false
matrix:
os:
- 'ubuntu'
- 'macos'
- 'windows'
python:
# this is not the packaged version, just the version conda-build runs on.
- '3.11'
steps:
- name: Checkout Slycot
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: 'recursive'
- name: Setup Conda
uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python }}
activate-environment: build-env
environment-file: .github/conda-env/build-env.yml
miniforge-version: latest
miniforge-variant: Mambaforge
channel-priority: strict
auto-update-conda: false
auto-activate-base: false
- name: Conda build
shell: bash -l {0}
run: |
set -e
conda mambabuild conda-recipe
# preserve directory structure for custom conda channel
find "${CONDA_PREFIX}/conda-bld" -maxdepth 2 -name 'slycot*.tar.bz2' | while read -r conda_pkg; do
conda_platform=$(basename $(dirname "${conda_pkg}"))
mkdir -p "slycot-conda-pkgs/${conda_platform}"
cp "${conda_pkg}" "slycot-conda-pkgs/${conda_platform}/"
done
python -m conda_index ./slycot-conda-pkgs
- name: Save to local conda pkg channel
uses: actions/upload-artifact@v3
with:
name: slycot-conda-pkgs
path: slycot-conda-pkgs
create-wheel-test-matrix:
name: Create wheel test matrix
runs-on: ubuntu-latest
needs: build-pip
if: always() # run tests for all successful builds, even if others failed
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout Slycot
uses: actions/checkout@v3
- name: Download wheels (if any)
uses: actions/download-artifact@v3
with:
name: slycot-wheels
path: slycot-wheels
- id: set-matrix
run: echo "matrix=$(python3 .github/scripts/set-pip-test-matrix.py)" >> $GITHUB_OUTPUT
create-conda-test-matrix:
name: Create conda test matrix
runs-on: ubuntu-latest
needs: build-conda
if: always() # run tests for all successful builds, even if others failed
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout Slycot
uses: actions/checkout@v3
- name: Download conda packages
uses: actions/download-artifact@v3
with:
name: slycot-conda-pkgs
path: slycot-conda-pkgs
- id: set-matrix
run: echo "matrix=$(python3 .github/scripts/set-conda-test-matrix.py)" >> $GITHUB_OUTPUT
test-wheel:
name: Test wheel ${{ matrix.packagekey }}, ${{matrix.blas_lib}} BLAS lib ${{ matrix.failok }}
needs: create-wheel-test-matrix
runs-on: ${{ matrix.os }}-latest
continue-on-error: ${{ matrix.failok == 'FAILOK' }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.create-wheel-test-matrix.outputs.matrix) }}
steps:
- name: Checkout Slycot
uses: actions/checkout@v3
with:
path: slycot-src
- name: Checkout python-control
uses: actions/checkout@v3
with:
repository: 'python-control/python-control'
path: python-control
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Setup Ubuntu
if: matrix.os == 'ubuntu'
run: |
set -xe
sudo apt-get -y update
case ${{ matrix.blas_lib }} in
Generic ) sudo apt-get -y install libblas3 liblapack3 ;;
unset | OpenBLAS ) sudo apt-get -y install libopenblas-base ;;
*)
echo "BLAS ${{ matrix.blas_lib }} not supported for wheels on Ubuntu"
exit 1 ;;
esac
update-alternatives --display libblas.so.3-x86_64-linux-gnu
update-alternatives --display liblapack.so.3-x86_64-linux-gnu
- name: Setup macOS
if: matrix.os == 'macos'
run: |
set -xe
brew install coreutils
case ${{ matrix.blas_lib }} in
unset | Generic | Apple ) ;; # system provided (Uses Apple Accelerate Framework)
OpenBLAS )
brew install openblas
echo "DYLIB_LIBRARY_PATH=/usr/local/opt/openblas/lib" >> $GITHUB_ENV
;;
*)
echo "BLAS option ${{ matrix.blas_lib }} not supported for wheels on MacOS"
exit 1 ;;
esac
- name: Download wheels
uses: actions/download-artifact@v3
with:
name: slycot-wheels
path: slycot-wheels
- name: Install Wheel
run: |
python -m pip install --upgrade pip
pip install matplotlib scipy pytest pytest-cov pytest-timeout coverage
pip install slycot-wheels/${{ matrix.packagekey }}/slycot*.whl
pip show slycot
- name: Slycot and python-control tests
run: JOBNAME="$JOBNAME" bash slycot-src/.github/scripts/run-tests.sh
env:
JOBNAME: wheel ${{ matrix.packagekey }} ${{ matrix.blas_lib }}
- name: report coverage
uses: coverallsapp/github-action@v2
with:
flag-name: wheel-${{ matrix.packagekey }}-${{matrix.blas_lib}}
parallel: true
file: slycot-src/coverage.xml
test-conda:
name: Test conda ${{ matrix.packagekey }}, ${{matrix.blas_lib}} BLAS lib ${{ matrix.failok }}
needs: create-conda-test-matrix
runs-on: ${{ matrix.os }}-latest
continue-on-error: ${{ matrix.failok == 'FAILOK' }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.create-conda-test-matrix.outputs.matrix) }}
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout Slycot
uses: actions/checkout@v3
with:
path: slycot-src
- name: Checkout python-control
uses: actions/checkout@v3
with:
repository: 'python-control/python-control'
path: python-control
- name: Setup macOS
if: matrix.os == 'macos'
run: brew install coreutils
- name: Setup Conda
uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python }}
miniforge-version: latest
miniforge-variant: Mambaforge
activate-environment: test-env
environment-file: slycot-src/.github/conda-env/test-env.yml
channel-priority: strict
auto-activate-base: false
- name: Download conda packages
uses: actions/download-artifact@v3
with:
name: slycot-conda-pkgs
path: slycot-conda-pkgs
- name: Install Conda package
run: |
set -e
case ${{ matrix.blas_lib }} in
unset ) # the conda-forge default (os dependent)
mamba install libblas libcblas liblapack
;;
Generic )
mamba install 'libblas=*=*netlib' 'libcblas=*=*netlib' 'liblapack=*=*netlib'
echo "libblas * *netlib" >> $CONDA_PREFIX/conda-meta/pinned
;;
OpenBLAS )
mamba install 'libblas=*=*openblas' openblas
echo "libblas * *openblas" >> $CONDA_PREFIX/conda-meta/pinned
;;
Intel10_64lp )
mamba install 'libblas=*=*mkl' mkl
echo "libblas * *mkl" >> $CONDA_PREFIX/conda-meta/pinned
;;
esac
mamba install -c ./slycot-conda-pkgs slycot
conda list
- name: Slycot and python-control tests
run: JOBNAME="$JOBNAME" bash slycot-src/.github/scripts/run-tests.sh
env:
JOBNAME: conda ${{ matrix.packagekey }} ${{ matrix.blas_lib }}
- name: report coverage
uses: coverallsapp/github-action@v2
with:
flag-name: wheel-${{ matrix.packagekey }}-${{matrix.blas_lib}}
parallel: true
file: slycot-src/coverage.xml
coveralls-final:
name: Finalize parallel coveralls
if: always()
needs:
- test-conda
- test-wheel
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
parallel-finished: true