forked from python-control/python-control
-
Notifications
You must be signed in to change notification settings - Fork 0
345 lines (326 loc) · 11.6 KB
/
os-blas-test-matrix.yml
File metadata and controls
345 lines (326 loc) · 11.6 KB
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
name: OS/BLAS test matrix
on:
workflow_dispatch:
pull_request:
paths:
- .github/workflows/os-blas-test-matrix.yml
- .github/scripts/set-conda-test-matrix.py
- .github/scripts/set-conda-pip-matrix.py
- .github/conda-env/build-env.yml
- .github/conda-env/test-env.yml
jobs:
build-pip:
name: Build pip Py${{ matrix.python }}, ${{ matrix.os }}, ${{ matrix.bla_vendor}} BLA_VENDOR
runs-on: ${{ matrix.os }}-latest
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: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Checkout Slycot
uses: actions/checkout@v3
with:
repository: python-control/Slycot
fetch-depth: 0
submodules: 'recursive'
- 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 "LDFLAGS=-L/opt/homebrew/opt/openblas/lib" >> $GITHUB_ENV
echo "CPPFLAGS=-I/opt/homebrew/opt/openblas/include" >> $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@v4
with:
name: slycot-wheels-${{ matrix.os }}-${{ matrix.python }}-${{ matrix.bla_vendor }}
path: slycot-wheels
retention-days: 5
build-conda:
name: Build conda Py${{ matrix.python }}, ${{ matrix.os }}
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os:
- 'ubuntu'
- 'macos'
python:
# build on one, expand matrix in conda-build from the Sylcot/conda-recipe/conda_build_config.yaml
- '3.11'
steps:
- name: Checkout Slycot
uses: actions/checkout@v3
with:
repository: python-control/Slycot
fetch-depth: 0
submodules: 'recursive'
- name: Setup Conda
uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python }}
activate-environment: build-env
environment-file: .github/conda-env/build-env.yml
miniforge-version: latest
channels: conda-forge,defaults
channel-priority: strict
auto-update-conda: false
auto-activate-base: false
- name: Conda build
shell: bash -el {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@v4
with:
name: slycot-conda-pkgs-${{ matrix.os }}-${{ matrix.python }}
path: slycot-conda-pkgs
retention-days: 5
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: Merge artifacts
uses: actions/upload-artifact/merge@v4
with:
name: slycot-wheels
pattern: slycot-wheels-*
- name: Checkout python-control
uses: actions/checkout@v3
- name: Download wheels (if any)
uses: actions/download-artifact@v4
with:
name: slycot-wheels
path: slycot-wheels
- id: set-matrix
run: |
TEMPFILE="$(mktemp)"
python3 .github/scripts/set-pip-test-matrix.py | tee $TEMPFILE
echo "matrix=$(cat $TEMPFILE)" >> $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: Merge artifacts
uses: actions/upload-artifact/merge@v4
with:
name: slycot-conda-pkgs
pattern: slycot-conda-pkgs-*
- name: Checkout python-control
uses: actions/checkout@v3
- name: Download conda packages
uses: actions/download-artifact@v4
with:
name: slycot-conda-pkgs
path: slycot-conda-pkgs
- id: set-matrix
run: |
TEMPFILE="$(mktemp)"
python3 .github/scripts/set-conda-test-matrix.py | tee $TEMPFILE
echo "matrix=$(cat $TEMPFILE)" >> $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:
repository: 'python-control/Slycot'
path: slycot-src
- name: Checkout python-control
uses: actions/checkout@v3
- 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 libopenblas0 ;;
*)
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@v4
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 numpydoc
pip install slycot-wheels/${{ matrix.packagekey }}/slycot*.whl
pip show slycot
- name: Test with pytest
run: JOBNAME="$JOBNAME" pytest control/tests
env:
JOBNAME: wheel ${{ matrix.packagekey }} ${{ matrix.blas_lib }}
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 -el {0}
steps:
- name: Checkout Slycot
uses: actions/checkout@v3
with:
repository: 'python-control/Slycot'
path: slycot-src
- name: Checkout python-control
uses: actions/checkout@v3
- name: Setup macOS
if: matrix.os == 'macos'
run: brew install coreutils
- name: Setup Conda
uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python }}
miniforge-version: latest
activate-environment: test-env
environment-file: .github/conda-env/test-env.yml
channels: conda-forge,defaults
channel-priority: strict
auto-activate-base: false
- name: Download conda packages
uses: actions/download-artifact@v4
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)
conda install libblas libcblas liblapack
;;
Generic )
conda install 'libblas=*=*netlib' 'libcblas=*=*netlib' 'liblapack=*=*netlib'
echo "libblas * *netlib" >> $CONDA_PREFIX/conda-meta/pinned
;;
OpenBLAS )
conda install 'libblas=*=*openblas' openblas
echo "libblas * *openblas" >> $CONDA_PREFIX/conda-meta/pinned
;;
Intel10_64lp )
conda install 'libblas=*=*mkl' mkl
echo "libblas * *mkl" >> $CONDA_PREFIX/conda-meta/pinned
;;
esac
if [ "${{ matrix.os }}" = "windows" ]; then
echo "Installing slycot from conda-forge on Windows"
conda install slycot
else
echo "Installing built conda package from local channel"
conda install -c ./slycot-conda-pkgs slycot
fi
conda list
- name: Test with pytest
run: JOBNAME="$JOBNAME" pytest control/tests
env:
JOBNAME: conda ${{ matrix.packagekey }} ${{ matrix.blas_lib }}