conda_tests.yml 8.58 KB
Newer Older
René Fritze's avatar
René Fritze committed
1
name: Conda Tests
2
3
4
5
6
7
8
on:
  # run tests on pull requests for main and release branches
  # and (after a merge) on the target branch
  push:
    branches:
      - main
      - 20*.*.x
René Fritze's avatar
René Fritze committed
9
      - create-pull-request/patch*
10
11
12
13
  pull_request:
    branches:
      - main
      - 20*.*.x
René Fritze's avatar
René Fritze committed
14
      - create-pull-request/patch*
René Fritze's avatar
René Fritze committed
15
16

jobs:
17
  bugout:
18
    name: Cancel superseded jobs
19
    runs-on: ubuntu-22.04
20
21
    steps:
      - name: Cancel Previous Runs
22
        uses: styfle/cancel-workflow-action@0.10.0
23
24
25
26
27
        with:
          all_but_latest: true
          # also works on 'pull_request' targets
          ignore_sha: true
          access_token: ${{ github.token }}
René Fritze's avatar
René Fritze committed
28
29
30
  event_file:
    # this is input for the pytest_results workflow
    name: "Event File"
31
    runs-on: ubuntu-22.04
René Fritze's avatar
René Fritze committed
32
33
    steps:
    - name: Upload
34
      uses: actions/upload-artifact@v3
René Fritze's avatar
René Fritze committed
35
36
37
      with:
        name: Event File
        path: ${{ github.event_path }}
René Fritze's avatar
René Fritze committed
38
  miniconda:
39
    name: ${{ matrix.os }} - Python ${{ matrix.python }}
René Fritze's avatar
René Fritze committed
40
    runs-on: ${{ matrix.os }}
41
    timeout-minutes: 55
René Fritze's avatar
René Fritze committed
42
43
    strategy:
        matrix:
44
            os: [ubuntu-22.04, macos-12, windows-2022]
45
            python: [3.8, 3.9]
René Fritze's avatar
René Fritze committed
46
            include:
47
              - os: ubuntu-22.04
René Fritze's avatar
René Fritze committed
48
                prefix: /usr/share/miniconda3/envs/pyMOR-ci
49
              - os: macos-12
René Fritze's avatar
René Fritze committed
50
                prefix: /Users/runner/miniconda3/envs/pyMOR-ci
51
              - os: macos-12
52
                python: 3.8
53
                prefix: /Users/runner/miniconda3/envs/pyMOR-ci
René Fritze's avatar
René Fritze committed
54
55
56
              - os: windows-2022
                prefix: C:\Miniconda3\envs\pyMOR-ci
            # avoid failure in one job immeadiately cancelling all others
René Fritze's avatar
René Fritze committed
57
58
59
60
61
62
        fail-fast: false
    steps:
      - name: Install required X libs (Linux)
        if: runner.os == 'Linux'
        run: |
          sudo apt-get install -y xvfb libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xinput0 libxcb-xfixes0
René Fritze's avatar
René Fritze committed
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
      - name: Install
        if: runner.os == 'Windows'
        run: |
          curl --output mesa.7z -L https://github.com/pal1000/mesa-dist-win/releases/download/20.3.4/mesa3d-20.3.4-release-msvc.7z
          7z x mesa.7z -omesa -y


          # The script requires user input (choice of options) so need to
          # fiddle to get it to run automatically. Not a clean way to do it,
          # but works.
          sed -i 's/@echo Please make a deployment choice:/@GOTO desktopgl/g' ./mesa/systemwidedeploy.cmd
          sed -i 's/@echo Desktop OpenGL drivers deploy complete./@exit/g' ./mesa/systemwidedeploy.cmd
          ./mesa/systemwidedeploy.cmd


78
      - uses: actions/checkout@v3
René Fritze's avatar
René Fritze committed
79
80
81
82
83
      - uses: conda-incubator/setup-miniconda@v2
        with:
          activate-environment: pyMOR-ci
          miniforge-variant: Mambaforge
          use-mamba: true
84
          python-version: ${{ matrix.python }}
René Fritze's avatar
René Fritze committed
85
86
87
88
          channels: conda-forge
          channel-priority: true
           # This needs to be set for caching to work properly!
          use-only-tar-bz2: true
89
90
91
92
      - name: Stop if dependencies changed
        shell: bash -l {0}
        run: |
          ./dependencies.py && git diff --exit-code requirements* pyproject.toml
René Fritze's avatar
René Fritze committed
93
      - name: Cache conda
94
        uses: martijnhols/actions-cache@v3.0.4
René Fritze's avatar
René Fritze committed
95
96
97
        id: cache
        env:
          # Increase this value to reset cache if .ci/conda-env.yml have not changed
René Fritze's avatar
René Fritze committed
98
          CACHE_NUMBER: 2
René Fritze's avatar
René Fritze committed
99
100
101
        with:
          path: ${{ matrix.prefix }}
          key:
102
            ${{ runner.os }}-${{ matrix.python }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('.ci/conda-env.yml') }}
René Fritze's avatar
René Fritze committed
103
104
105
      - name: Update environment
        run: mamba env update -n pyMOR-ci -f .ci/conda-env.yml
        if: steps.cache.outputs.cache-hit != 'true'
René Fritze's avatar
René Fritze committed
106
107
      - name: Export Conda Env
        shell: bash -l {0}
René Fritze's avatar
René Fritze committed
108
        run: |
René Fritze's avatar
René Fritze committed
109
          mamba env export > conda-env__${{ runner.os }}-${{ matrix.python }}.yml
René Fritze's avatar
René Fritze committed
110
111
112
113
114
      - name: Install pyMOR
        shell: bash -l {0}
        # this seems to be the most portable way of making sure everything is importable
        run: conda develop .
        # alas it still does not work everywhere, so manual PYTHONPATH it is
René Fritze's avatar
René Fritze committed
115
      - name: Platform env
René Fritze's avatar
René Fritze committed
116
117
        shell: bash -l {0}
        run: |
René Fritze's avatar
René Fritze committed
118
119
          if [[ ${{ runner.os }} == Linux ]]; then
            echo "PYTEST_PREFIX=xvfb-run -a" >> $GITHUB_ENV
120
            echo "QT_API=pyside2" >> $GITHUB_ENV
René Fritze's avatar
René Fritze committed
121
122
123
          fi
          # windows currently segfaults in first QT+MPL plot otherwise
          if [[ ${{ runner.os }} == Windows ]]; then
124
            echo "QT_API=pyside2" >> $GITHUB_ENV
René Fritze's avatar
René Fritze committed
125
          fi
126
          echo "QT_DEBUG_PLUGINS=1" >> $GITHUB_ENV
René Fritze's avatar
René Fritze committed
127
          echo "PYMOR_VERSION=$(python -c 'import pymor;print(pymor.__version__)')" >> $GITHUB_ENV
René Fritze's avatar
René Fritze committed
128
129
130
131
132
133
134
      - name: Sanity check
        shell: bash -l {0}
        run: |
          ${PYTEST_PREFIX} python -c "from matplotlib.pyplot import *"
          ${PYTEST_PREFIX} python -c "from qtpy.QtGui import *"
          ${PYTEST_PREFIX} python -c "import OpenGL"
          ${PYTEST_PREFIX} python -c "import OpenGL.GL as gl"
René Fritze's avatar
René Fritze committed
135
136
      - name: Run pytest
        shell: bash -l {0}
René Fritze's avatar
René Fritze committed
137
138
        env:
          PYTHONPATH: ./src
René Fritze's avatar
René Fritze committed
139
          PYMOR_HYPOTHESIS_PROFILE: "ci"
140
141
          # we may be able to limit this to macos
          PYMOR_ALLOW_DEADLINE_EXCESS: 1
René Fritze's avatar
René Fritze committed
142
143
          RESULTS_FILE: result_${{ runner.os }}-${{ matrix.python }}.xml
          COMMON_PYTEST_OPTS: "--cov-report=xml --cov --cov-config=setup.cfg --cov-context=test --junitxml=${RESULTS_FILE}"
René Fritze's avatar
René Fritze committed
144
        run: |
René Fritze's avatar
René Fritze committed
145
            ${PYTEST_PREFIX} pytest ${COMMON_PYTEST_OPTS}
146
      - uses: codecov/codecov-action@v3
147
        name: Upload coverage
René Fritze's avatar
René Fritze committed
148
149
        with:
          flags: github_actions,${{ matrix.os }}
René Fritze's avatar
René Fritze committed
150
          fail_ci_if_error: true
René Fritze's avatar
René Fritze committed
151
          verbose: true
René Fritze's avatar
René Fritze committed
152
153
      - name: Upload Unit Test Results
        if: always()
154
        uses: actions/upload-artifact@v3
René Fritze's avatar
René Fritze committed
155
        with:
René Fritze's avatar
René Fritze committed
156
          name: Unit Test Results (Python ${{ matrix.python }}, OS ${{ runner.os }})
René Fritze's avatar
René Fritze committed
157
          path: result_*.xml
René Fritze's avatar
René Fritze committed
158
159
      - name: Upload Conda Env Export
        if: always()
160
        uses: actions/upload-artifact@v3
René Fritze's avatar
René Fritze committed
161
162
163
        with:
          name: Conda Env Exports
          path: conda-env__${{ runner.os }}-${{ matrix.python }}.yml
164
  full_install:
165
    name: Install with on ${{ matrix.os }} - Python ${{ matrix.python }}
166
167
168
    runs-on: ${{ matrix.os }}
    strategy:
        matrix:
169
            os: [ubuntu-22.04, macos-12, windows-2022]
170
171
            python: [3.8, 3.9]
            include:
172
              - os: ubuntu-22.04
173
                prefix: /usr/share/miniconda3/envs/pyMOR-ci
174
              - os: macos-12
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
                prefix: /Users/runner/miniconda3/envs/pyMOR-ci
              - os: windows-2022
                prefix: C:\Miniconda3\envs\pyMOR-ci
            # avoid failure in one job immeadiately cancelling all others
        fail-fast: true
    steps:
      - name: Install required X libs (Linux)
        if: runner.os == 'Linux'
        run: |
          sudo apt-get install -y xvfb libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xinput0 libxcb-xfixes0
      - name: Install
        if: runner.os == 'Windows'
        run: |
          curl --output mesa.7z -L https://github.com/pal1000/mesa-dist-win/releases/download/20.3.4/mesa3d-20.3.4-release-msvc.7z
          7z x mesa.7z -omesa -y


          # The script requires user input (choice of options) so need to
          # fiddle to get it to run automatically. Not a clean way to do it,
          # but works.
          sed -i 's/@echo Please make a deployment choice:/@GOTO desktopgl/g' ./mesa/systemwidedeploy.cmd
          sed -i 's/@echo Desktop OpenGL drivers deploy complete./@exit/g' ./mesa/systemwidedeploy.cmd
          ./mesa/systemwidedeploy.cmd


      - uses: actions/checkout@v3
      - uses: conda-incubator/setup-miniconda@v2
        with:
          activate-environment: pyMOR-ci
          miniforge-variant: Mambaforge
          use-mamba: true
          python-version: ${{ matrix.python }}
          channels: conda-forge
          channel-priority: true
           # This needs to be set for caching to work properly!
          use-only-tar-bz2: true
      - name: Cache conda
212
213
214
        # only restore here, since pip install might bring things into the cache
        # that aren't controlled via the .ci/conda-env.yml file
        uses: martijnhols/actions-cache/restore@v3.0.4
215
216
217
        id: cache
        env:
          # Increase this value to reset cache if .ci/conda-env.yml have not changed
René Fritze's avatar
René Fritze committed
218
          CACHE_NUMBER: 2
219
220
221
222
223
224
225
        with:
          path: ${{ matrix.prefix }}
          key:
            ${{ runner.os }}-${{ matrix.python }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('.ci/conda-env.yml') }}
      - name: Install pyMOR
        shell: bash -l {0}
        run: pip install .[full]