]> git.phdru.name Git - ppu.git/blob - .github/workflows/run-tests.yaml
53fc6044a5145435ccb00acf0fac7af625d11682
[ppu.git] / .github / workflows / run-tests.yaml
1 name: Run tests
2
3 on: [push, pull_request]
4
5 jobs:
6   run-tests:
7     env:
8       not_in_conda: "['3.11', 'pypy-3.7']"
9
10     strategy:
11       matrix:
12         os: [ubuntu-latest, windows-latest]
13         python-version: ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "pypy-3.7"]
14         include:
15         - os: ubuntu-latest
16           os-name: Linux
17           pip-cache-path: ~/.cache/pip
18         - os: windows-latest
19           os-name: w32
20           pip-cache-path: ~\AppData\Local\pip\Cache
21
22     name: Python ${{ matrix.python-version }} @ ${{ matrix.os-name }}
23     runs-on: ${{ matrix.os }}
24
25     steps:
26
27       # Setup Python/pip
28       - uses: actions/checkout@v2
29       - uses: s-weigand/setup-conda@v1
30         with:
31           python-version: ${{ matrix.python-version }}
32         if: ${{ runner.os == 'Linux' && !contains(fromJSON(env.not_in_conda), matrix.python-version) }}
33       - uses: actions/setup-python@v4
34         with:
35           python-version: ${{ matrix.python-version }}
36         if: ${{ runner.os != 'Linux' || contains(fromJSON(env.not_in_conda), matrix.python-version) }}
37       - name: Cache pip
38         uses: actions/cache@v3
39         with:
40           path: ${{ matrix.pip-cache-path }}
41           key: ${{ runner.os }}-pip
42
43       # Setup tox
44       - name: Install dependencies
45         run: |
46           python --version
47           python -m pip install --upgrade pip setuptools wheel
48           pip --version
49           pip install --upgrade virtualenv "tox < 4"
50       - name: Set TOXENV
51         run: |
52           import os, sys
53           ld_library_path = None
54           if hasattr(sys, 'pypy_version_info'):
55             toxenv = 'pypy3'
56           else:
57             pyver = '%d%d' % tuple(sys.version_info[:2])
58             if os.name == 'posix':
59               if pyver == '27':  # Python 2.7 on Linux requires `$LD_LIBRARY_PATH`
60                 ld_library_path = os.path.join(
61                   os.path.dirname(os.path.dirname(sys.executable)), 'lib')
62             toxenv = 'py%s' % pyver
63             if os.name == 'posix':
64               toxenv += ',py%s-flake8' % pyver
65           with open(os.environ['GITHUB_ENV'], 'a') as f:
66             if ld_library_path:
67               f.write('LD_LIBRARY_PATH=' + ld_library_path + '\n')
68             f.write('TOXENV=' + toxenv + '\n')
69         shell: python
70
71       - name: Run tox
72         run: |
73           python -c "import os; print(os.environ['TOXENV'])"
74           tox --version
75           tox