|
1 | | -name: Python Package using Conda |
| 1 | +name: Conda-based pytest |
2 | 2 |
|
3 | | -on: [push] |
| 3 | +on: [push, pull_request] |
4 | 4 |
|
5 | 5 | jobs: |
6 | 6 | build-linux: |
7 | 7 | runs-on: ubuntu-latest |
| 8 | + |
8 | 9 | strategy: |
9 | 10 | max-parallel: 5 |
| 11 | + matrix: |
| 12 | + python-version: [2.7, 3.6, 3.9] |
| 13 | + slycot: ["", "conda"] |
| 14 | + array-and-matrix: [0] |
| 15 | + include: |
| 16 | + - python-version: 3.9 |
| 17 | + slycot: conda |
| 18 | + array-and-matrix: 1 |
10 | 19 |
|
11 | 20 | steps: |
12 | 21 | - uses: actions/checkout@v2 |
13 | | - - name: Set up Python 3.8 |
| 22 | + - name: Set up Python |
14 | 23 | uses: actions/setup-python@v2 |
15 | | - with: |
16 | | - python-version: 3.8 |
17 | | - - name: Add conda to system path |
| 24 | + - name: Set up conda |
18 | 25 | run: | |
19 | | - # $CONDA is an environment variable pointing to the root of the miniconda directory |
20 | 26 | echo $CONDA/bin >> $GITHUB_PATH |
| 27 | + conda create -q -n test-environment python=${{matrix.python-version}} |
21 | 28 | - name: Install dependencies |
22 | 29 | run: | |
23 | | - conda install numpy scipy matplotlib pytest |
| 30 | + source $CONDA/bin/activate test-environment |
| 31 | + conda install pip coverage pytest |
| 32 | + conda install numpy matplotlib scipy |
| 33 | + if [[ '${{matrix.python-version}}' == '2.7' ]]; then |
| 34 | + # matplotlib for Python 2.7 seems to require X11 to run correctly |
| 35 | + sudo apt install -y xvfb |
| 36 | + fi |
| 37 | + - name: Install slycot via conda (optional) |
| 38 | + if: ${{ matrix.slycot == 'conda' }} |
| 39 | + run: | |
| 40 | + source $CONDA/bin/activate test-environment |
24 | 41 | conda install -c conda-forge slycot |
25 | 42 | - name: Test with pytest |
| 43 | + env: |
| 44 | + PYTHON_CONTROL_ARRAY_AND_MATRIX: ${{ matrix.array-and-matrix }} |
26 | 45 | run: | |
27 | | - conda install pytest |
28 | | - pytest |
| 46 | + source $CONDA/bin/activate test-environment |
| 47 | + if [[ '${{matrix.python-version}}' == '2.7' ]]; then |
| 48 | + # Run within (virtual) X11 environment for Python 2.7/matplotlib |
| 49 | + xvfb-run pytest control/tests |
| 50 | + else |
| 51 | + coverage run -m pytest control/tests |
| 52 | + fi |
0 commit comments