Skip to content

Commit 8f1c90b

Browse files
committed
Add workflow
1 parent 0df0f45 commit 8f1c90b

2 files changed

Lines changed: 224 additions & 0 deletions

File tree

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: test-env
2+
channels:
3+
- conda-forge
4+
dependencies:
5+
- conda-build
6+
- conda-verify
7+
- pip
8+
# always build against NETLIB ('Generic') LAPACK/Blas
9+
# https://conda-forge.org/docs/maintainer/knowledge_base.html#blas
10+
- libblas * *netlib
11+
- libcblas * *netlib
12+
- liblapack * *netlib
13+
- numpy
14+
- scipy
15+
- matplotlib
16+
- pytest-cov
17+
- coverage

‎.github/workflows/test.yml‎

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
name: Tests
2+
on:
3+
push:
4+
pull_request:
5+
paths-ignore:
6+
- 'README.rst'
7+
8+
jobs:
9+
test:
10+
name: Py${{ matrix.python }}, ${{ matrix.os }}, ${{ matrix.distribution }}, ${{matrix.bla_vendor}} BLA_VENDOR
11+
runs-on: ${{ matrix.os }}-latest
12+
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: ['ubuntu', 'windows', 'macos']
17+
python: [ '3.9' ]
18+
distribution: [ 'pip', 'conda' ]
19+
bla_vendor: [ 'Generic', 'OpenBLAS', 'unset' ]
20+
exclude:
21+
- os: 'windows'
22+
distribution: 'pip'
23+
include:
24+
- os: 'ubuntu'
25+
python: '3.6'
26+
distribution: 'conda'
27+
bla_vendor: 'Generic'
28+
- os: "ubuntu"
29+
python: '3.7'
30+
distribution: 'conda'
31+
bla_vendor: 'Generic'
32+
- os: "ubuntu"
33+
python: '3.9'
34+
distribution: 'conda'
35+
bla_vendor: 'Intel10_64lp'
36+
- os: 'macos'
37+
python: '3.9'
38+
distribution: pip
39+
bla_vendor: "Apple"
40+
41+
defaults:
42+
run:
43+
shell: bash -l {0}
44+
45+
steps:
46+
- name: Checkout Slycot
47+
uses: actions/checkout@v2
48+
with:
49+
path: ./Slycot
50+
fetch-depth: 0
51+
- name: Set up Python
52+
uses: actions/setup-python@v2
53+
with:
54+
python-version: ${{ matrix.python }}
55+
- name: Install Ubuntu packages
56+
if: matrix.os == 'ubuntu' && matrix.distribution == 'pip'
57+
run: |
58+
set -xe
59+
sudo apt-get -y update
60+
sudo apt-get -y upgrade --fix-missing
61+
sudo apt-get -y install gfortran cmake
62+
case ${{ matrix.bla_vendor }} in
63+
unset | Generic ) sudo apt-get -y install libblas-dev liblapack-dev ;;
64+
OpenBLAS ) sudo apt-get -y install libopenblas-dev ;;
65+
*)
66+
echo "bla_vendor option ${{ matrix.bla_vendor }} not supported"
67+
exit 1 ;;
68+
esac
69+
echo 'CMAKE_GENERATOR=Unix Makefiles' >> $GITHUB_ENV
70+
- name: Setup macOS
71+
if: matrix.os == 'macos'
72+
run: |
73+
set -xe
74+
# still point to python2 on current macOS
75+
ln -sf $(which python3) /usr/local/bin/python
76+
ln -sf $(which pip3) /usr/local/bin/pip
77+
if [[ ${{ matrix.distribution }} == "pip" ]]; then
78+
case ${{ matrix.bla_vendor }} in
79+
unset | Generic | Apple ) ;; # Found in system
80+
OpenBLAS )
81+
brew install openblas
82+
echo "BLAS_ROOT=/usr/local/opt/openblas/" >> $GITHUB_ENV
83+
echo "LAPACK_ROOT=/usr/local/opt/openblas/" >> $GITHUB_ENV
84+
;;
85+
*)
86+
echo "bla_vendor option ${{ matrix.bla_vendor }} not supported"
87+
exit 1 ;;
88+
esac
89+
echo 'CMAKE_GENERATOR=Unix Makefiles' >> $GITHUB_ENV
90+
echo "FC=gfortran-10" >> $GITHUB_ENV
91+
fi
92+
- name: Setup Conda
93+
uses: conda-incubator/setup-miniconda@v2
94+
if: matrix.distribution == 'conda'
95+
with:
96+
channels: conda-forge
97+
auto-update-conda: true
98+
python-version: ${{ matrix.python }}
99+
activate-environment: test-env
100+
environment-file: ./Slycot/.github/conda-env/test-env.yml
101+
auto-activate-base: false
102+
- name: Conda build and install
103+
working-directory: ./Slycot
104+
if: matrix.distribution == 'conda'
105+
run: |
106+
echo "::group::conda build"
107+
set -e
108+
numpyversion=$(python -c 'import numpy; print(numpy.version.version)')
109+
conda-build --python "${{ matrix.python }}" --numpy $numpyversion conda-recipe
110+
echo "::endgroup::"
111+
echo "::group::conda install"
112+
# always conda build against reference NETLIB, but test against specific LAPACK/BLAS implementations
113+
case ${{ matrix.bla_vendor }} in
114+
unset ) # update will reinstall the conda default (os dependent)
115+
conda update --all
116+
;;
117+
Generic ) # stay on netlib
118+
echo "libblas * *netlib" >> $CONDA_PREFIX/conda-meta/pinned
119+
;;
120+
OpenBLAS )
121+
conda install 'libblas=*=*openblas'
122+
echo "libblas * *openblas" >> $CONDA_PREFIX/conda-meta/pinned
123+
;;
124+
Intel10_64lp )
125+
conda install 'libblas=*=*mkl'
126+
echo "libblas * *mkl" >> $CONDA_PREFIX/conda-meta/pinned
127+
;;
128+
* )
129+
echo "bla_vendor option ${{ matrix.bla_vendor }} not supported"
130+
exit 1 ;;
131+
esac
132+
slycot_pkg=$(find $CONDA_PREFIX -name 'slycot*.tar.bz2')
133+
if [[ ${{ matrix.os }} == 'windows' ]]; then conda install libflang; fi
134+
conda install --use-local $slycot_pkg
135+
echo "::endgroup::"
136+
echo "::group::conda env info"
137+
conda list
138+
echo "::endgroup::"
139+
- name: PIP build and install
140+
if: matrix.distribution == 'pip'
141+
working-directory: ./Slycot
142+
env:
143+
BLA_VENDOR: ${{ matrix.bla_vendor }}
144+
run: |
145+
set -xe
146+
if [ $BLA_VENDOR = "unset" ]; then unset BLA_VENDOR; fi
147+
python -m pip install --upgrade pip
148+
pip install scikit-build matplotlib scipy pytest pytest-cov
149+
pip install -v .
150+
pip show slycot
151+
- name: Slycot unit tests
152+
run: |
153+
set -xe
154+
mkdir slycot-coverage
155+
pushd slycot-coverage
156+
slycot_dir=$(python -c "import slycot; print(slycot.__path__[0])")
157+
echo " $slycot_dir" >> ../Slycot/.coveragerc
158+
echo "slycot_dir=$slycot_dir" >> $GITHUB_ENV
159+
pytest --pyargs slycot -v --cov=$slycot_dir --cov-config=../Slycot/.coveragerc
160+
# also test the .test() function. (no extra coverage)
161+
python -c 'import slycot; slycot.test()'
162+
popd
163+
- name: Checkout python-control
164+
uses: actions/checkout@v2
165+
with:
166+
repository: 'python-control/python-control'
167+
path: ./python-control
168+
- name: python-control unit tests
169+
working-directory: ./python-control
170+
run: |
171+
set -xe
172+
if [[ "${{ matrix.os }}" == "ubuntu" ]]; then
173+
if [[ "${{ matrix.distribtion}}" == "conda" ]]; then
174+
conda install pytest-xvfb
175+
else
176+
pip install pytest-xvfb
177+
fi
178+
fi
179+
# test_root_locus_zoom, test_sisotool: problems with the toolbar for MPL backends, not relevant to Slycot
180+
pytest -v \
181+
--cov=$slycot_dir --cov-config=../Slycot/.coveragerc \
182+
-k "not (test_root_locus_zoom or test_sisotool)" \
183+
control/tests
184+
- name: Combine coverage
185+
working-directory: ./Slycot
186+
env:
187+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
188+
COVERALLS_FLAG_NAME: ${{ matrix.test-name }}
189+
COVERALLS_PARALLEL: true
190+
run: |
191+
set -xe
192+
cp ../slycot-coverage/.coverage .coverage.slycot
193+
cp ../python-control/.coverage .coverage.control
194+
coverage combine
195+
coverage report
196+
pip install coveralls
197+
coveralls
198+
199+
coveralls-final:
200+
needs: test
201+
runs-on: ubuntu-latest
202+
steps:
203+
- name: Coveralls Finished
204+
uses: coverallsapp/github-action@master
205+
with:
206+
github-token: ${{ secrets.GITHUB_TOKEN }}
207+
parallel-finished: true

0 commit comments

Comments
 (0)