]> git.phdru.name Git - ppu.git/blob - .github/workflows/run-tests.yaml
Build(GHActions): Use `checkout@v4` instead of outdated `v2`
[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: "[]"
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", "3.12", "pypy3.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@v4
29       - uses: s-weigand/setup-conda@v1
30         with:
31           conda-channels: conda-forge
32           python-version: ${{ matrix.python-version }}
33         if: ${{ !contains(fromJSON(env.not_in_conda), matrix.python-version) }}
34       - uses: actions/setup-python@v4
35         with:
36           python-version: ${{ matrix.python-version }}
37         if: ${{ contains(fromJSON(env.not_in_conda), matrix.python-version) }}
38       - name: Cache pip
39         uses: actions/cache@v3
40         with:
41           path: ${{ matrix.pip-cache-path }}
42           key: ${{ runner.os }}-pip
43
44       # Setup tox
45       - name: Install dependencies
46         run: |
47           python --version
48           python -m pip || python -m ensurepip --default-pip --upgrade
49           python -m pip install --upgrade pip setuptools wheel
50           pip --version
51           pip install --upgrade virtualenv "tox >= 3.15, < 4"
52       - name: Set TOXENV
53         run: |
54           import os, sys
55           ld_library_path = None
56           if hasattr(sys, 'pypy_version_info'):
57             toxenv = 'pypy3'
58           else:
59             pyver = '%d%d' % tuple(sys.version_info[:2])
60             if os.name == 'posix':
61               if pyver == '27':  # Python 2.7 on Linux requires `$LD_LIBRARY_PATH`
62                 ld_library_path = os.path.join(
63                   os.path.dirname(os.path.dirname(sys.executable)), 'lib')
64             toxenv = 'py%s' % pyver
65             if os.name == 'posix':
66               toxenv += ',py%s-flake8' % pyver
67           with open(os.environ['GITHUB_ENV'], 'a') as f:
68             if ld_library_path:
69               f.write('LD_LIBRARY_PATH=' + ld_library_path + '\n')
70             f.write('TOXENV=' + toxenv + '\n')
71         shell: python
72
73       - name: Run tox
74         run: |
75           python -c "import os; print(os.environ['TOXENV'])"
76           tox --version
77           tox