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