Skip to content

Commit 1201202

Browse files
committed
add OS/BLAS conda-based test matrix as GitHub workflow
1 parent 9d72d79 commit 1201202

File tree

4 files changed

+178
-0
lines changed

4 files changed

+178
-0
lines changed

.github/conda-env/build-env.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name: build-env
2+
dependencies:
3+
- boa
4+
- numpy !=1.23.0

.github/conda-env/test-env.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
name: test-env
22
dependencies:
3+
- conda-build # for conda index
34
- pip
45
- coverage
56
- coveralls
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
""" set-conda-test-matrix.py
2+
3+
Create test matrix for conda packages
4+
"""
5+
import json, re
6+
from pathlib import Path
7+
8+
osmap = {'linux': 'ubuntu',
9+
'osx': 'macos',
10+
'win': 'windows',
11+
}
12+
13+
blas_implementations = ['unset', 'Generic', 'OpenBLAS', 'Intel10_64lp']
14+
15+
combinations = {'ubuntu': blas_implementations,
16+
'macos': blas_implementations,
17+
'windows': ['unset', 'Intel10_64lp'],
18+
}
19+
20+
conda_jobs = []
21+
for conda_pkg_file in Path("slycot-conda-pkgs").glob("*/*.tar.bz2"):
22+
cos = osmap[conda_pkg_file.parent.name.split("-")[0]]
23+
m = re.search(r'py(\d)(\d+)_', conda_pkg_file.name)
24+
pymajor, pyminor = int(m[1]), int(m[2])
25+
cpy = f'{pymajor}.{pyminor}'
26+
for cbl in combinations[cos]:
27+
cjob = {'packagekey': f'{cos}-{cpy}',
28+
'os': cos,
29+
'python': cpy,
30+
'blas_lib': cbl}
31+
conda_jobs.append(cjob)
32+
33+
matrix = { 'include': conda_jobs }
34+
print(json.dumps(matrix))

.github/workflows/os-blas-test-matrix.yml

+139
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,57 @@ jobs:
8989
path: slycot-wheels
9090

9191

92+
build-conda:
93+
name: Build conda Py${{ matrix.python }}, ${{ matrix.os }}
94+
runs-on: ${{ matrix.os }}-latest
95+
strategy:
96+
fail-fast: false
97+
matrix:
98+
os:
99+
- 'ubuntu'
100+
- 'macos'
101+
- 'windows'
102+
python:
103+
- '3.9'
104+
- '3.11'
105+
106+
steps:
107+
- name: Checkout Slycot
108+
uses: actions/checkout@v3
109+
with:
110+
repository: python-control/Slycot
111+
fetch-depth: 0
112+
submodules: 'recursive'
113+
- name: Setup Conda
114+
uses: conda-incubator/setup-miniconda@v2
115+
with:
116+
python-version: ${{ matrix.python }}
117+
activate-environment: build-env
118+
environment-file: .github/conda-env/build-env.yml
119+
miniforge-version: latest
120+
miniforge-variant: Mambaforge
121+
channel-priority: strict
122+
auto-update-conda: false
123+
auto-activate-base: false
124+
- name: Conda build
125+
shell: bash -l {0}
126+
run: |
127+
set -e
128+
numpyversion=$(python -c 'import numpy; print(numpy.version.version)')
129+
conda mambabuild --python "${{ matrix.python }}" --numpy $numpyversion conda-recipe
130+
# preserve directory structure for custom conda channel
131+
find "${CONDA_PREFIX}/conda-bld" -maxdepth 2 -name 'slycot*.tar.bz2' | while read -r conda_pkg; do
132+
conda_platform=$(basename $(dirname "${conda_pkg}"))
133+
mkdir -p "slycot-conda-pkgs/${conda_platform}"
134+
cp "${conda_pkg}" "slycot-conda-pkgs/${conda_platform}/"
135+
done
136+
- name: Save to local conda pkg channel
137+
uses: actions/upload-artifact@v3
138+
with:
139+
name: slycot-conda-pkgs
140+
path: slycot-conda-pkgs
141+
142+
92143
create-wheel-test-matrix:
93144
name: Create wheel test matrix
94145
runs-on: ubuntu-latest
@@ -108,6 +159,25 @@ jobs:
108159
run: echo "matrix=$(python3 .github/scripts/set-pip-test-matrix.py)" >> $GITHUB_OUTPUT
109160

110161

162+
create-conda-test-matrix:
163+
name: Create conda test matrix
164+
runs-on: ubuntu-latest
165+
needs: build-conda
166+
if: always() # run tests for all successful builds, even if others failed
167+
outputs:
168+
matrix: ${{ steps.set-matrix.outputs.matrix }}
169+
steps:
170+
- name: Checkout python-control
171+
uses: actions/checkout@v3
172+
- name: Download conda packages
173+
uses: actions/download-artifact@v3
174+
with:
175+
name: slycot-conda-pkgs
176+
path: slycot-conda-pkgs
177+
- id: set-matrix
178+
run: echo "matrix=$(python3 .github/scripts/set-conda-test-matrix.py)" >> $GITHUB_OUTPUT
179+
180+
111181
test-wheel:
112182
name: Test wheel ${{ matrix.packagekey }}, ${{matrix.blas_lib}} BLAS lib ${{ matrix.failok }}
113183
needs: create-wheel-test-matrix
@@ -174,3 +244,72 @@ jobs:
174244
pip show slycot
175245
- name: Test with pytest
176246
run: pytest -v control/tests
247+
248+
249+
test-conda:
250+
name: Test conda ${{ matrix.packagekey }}, ${{matrix.blas_lib}} BLAS lib ${{ matrix.failok }}
251+
needs: create-conda-test-matrix
252+
runs-on: ${{ matrix.os }}-latest
253+
continue-on-error: ${{ matrix.failok == 'FAILOK' }}
254+
255+
strategy:
256+
fail-fast: false
257+
matrix: ${{ fromJSON(needs.create-conda-test-matrix.outputs.matrix) }}
258+
259+
defaults:
260+
run:
261+
shell: bash -l {0}
262+
263+
steps:
264+
- name: Checkout Slycot
265+
uses: actions/checkout@v3
266+
with:
267+
repository: 'python-control/Slycot'
268+
path: slycot-src
269+
- name: Checkout python-control
270+
uses: actions/checkout@v3
271+
- name: Setup macOS
272+
if: matrix.os == 'macos'
273+
run: brew install coreutils
274+
- name: Setup Conda
275+
uses: conda-incubator/setup-miniconda@v2
276+
with:
277+
python-version: ${{ matrix.python }}
278+
miniforge-version: latest
279+
miniforge-variant: Mambaforge
280+
activate-environment: test-env
281+
environment-file: .github/conda-env/test-env.yml
282+
channel-priority: strict
283+
auto-activate-base: false
284+
- name: Download conda packages
285+
uses: actions/download-artifact@v3
286+
with:
287+
name: slycot-conda-pkgs
288+
path: slycot-conda-pkgs
289+
- name: Install Conda package
290+
run: |
291+
set -e
292+
case ${{ matrix.blas_lib }} in
293+
unset ) # the conda-forge default (os dependent)
294+
mamba install libblas libcblas liblapack
295+
;;
296+
Generic )
297+
mamba install 'libblas=*=*netlib' 'libcblas=*=*netlib' 'liblapack=*=*netlib'
298+
echo "libblas * *netlib" >> $CONDA_PREFIX/conda-meta/pinned
299+
;;
300+
OpenBLAS )
301+
mamba install 'libblas=*=*openblas' openblas
302+
echo "libblas * *openblas" >> $CONDA_PREFIX/conda-meta/pinned
303+
;;
304+
Intel10_64lp )
305+
mamba install 'libblas=*=*mkl' mkl
306+
echo "libblas * *mkl" >> $CONDA_PREFIX/conda-meta/pinned
307+
;;
308+
esac
309+
conda index --no-progress ./slycot-conda-pkgs
310+
mamba install -c ./slycot-conda-pkgs slycot
311+
conda list
312+
- name: Test with pytest
313+
run: JOBNAME=$JOBNAME pytest control/tests
314+
env:
315+
JOBNAME: ${{ matrix.packagekey }} ${{ matrix.blas_lib }}

0 commit comments

Comments
 (0)