]> git.phdru.name Git - mimedecode.git/blob - .github/workflows/run-tests.yaml
4ef1f825b3a8754614c60724d88a1e597a10c7d2
[mimedecode.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         python-version: ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.7"]
13
14     name: Python ${{ matrix.python-version }}
15     runs-on: ubuntu-latest
16
17     steps:
18
19       # Setup Python/pip
20       - uses: actions/checkout@v2
21       - uses: s-weigand/setup-conda@v1
22         with:
23           conda-channels: conda-forge
24           python-version: ${{ matrix.python-version }}
25         if: ${{ runner.os == 'Linux' && !contains(fromJSON(env.not_in_conda), matrix.python-version) }}
26       - uses: actions/setup-python@v4
27         with:
28           python-version: ${{ matrix.python-version }}
29         if: ${{ runner.os != 'Linux' || contains(fromJSON(env.not_in_conda), matrix.python-version) }}
30       - name: Cache pip
31         uses: actions/cache@v3
32         with:
33           # This path is specific to Linux/Unix
34           path: ~/.cache/pip
35           key: ${{ runner.os }}-pip
36
37       # Setup tox
38       - name: Install dependencies
39         run: |
40           python --version
41           python -m pip || python -m ensurepip --default-pip --upgrade
42           python -m pip install --upgrade pip setuptools wheel
43           pip --version
44           pip install --upgrade virtualenv "tox >= 2.0, < 4"
45       - name: Set TOXENV
46         run: |
47           import os, sys
48           ld_library_path = None
49           if hasattr(sys, 'pypy_version_info'):
50             toxenv = 'pypy3'
51           else:
52             pyver = '%d%d' % tuple(sys.version_info[:2])
53             if os.name == 'posix':
54               if pyver == '27':  # Python 2.7 on Linux requires `$LD_LIBRARY_PATH`
55                 ld_library_path = os.path.join(
56                   os.path.dirname(os.path.dirname(sys.executable)), 'lib')
57             toxenv = 'py%s' % pyver
58           with open(os.environ['GITHUB_ENV'], 'a') as f:
59             if ld_library_path:
60               f.write('LD_LIBRARY_PATH=' + ld_library_path + '\n')
61             f.write('TOXENV=' + toxenv + '\n')
62         shell: python
63
64       - name: Run tox targets for ${{ matrix.python-version }}
65         run: |
66           python -c "import os; print(os.environ['TOXENV'])"
67           tox --version
68           tox