]> git.phdru.name Git - m_librarian.git/blob - .github/workflows/run-tests.yaml
CI(GHActions): Use `conda` to install older Pythons
[m_librarian.git] / .github / workflows / run-tests.yaml
1 name: Run tests
2
3 on: [push, pull_request]
4
5 jobs:
6   run-tests:
7
8     strategy:
9       matrix:
10         os: [ubuntu-latest, macos-latest, windows-latest]
11         python-version: ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]
12         include:
13         - os: ubuntu-latest
14           os-name: Linux
15           pip-cache-path: ~/.cache/pip
16         - os: macos-latest
17           os-name: OSX
18           pip-cache-path: ~/Library/Caches/pip
19         - os: windows-latest
20           os-name: w32
21           pip-cache-path: ~\AppData\Local\pip\Cache
22
23     name: Python ${{ matrix.python-version }} @ ${{ matrix.os-name }}
24     runs-on: ${{ matrix.os }}
25
26     steps:
27
28       # Setup Python/pip
29       - uses: actions/checkout@v2
30       - uses: s-weigand/setup-conda@v1
31         with:
32           python-version: ${{ matrix.python-version }}
33         if: ${{ runner.os == 'Linux' && matrix.python-version != '3.11' }}
34       - uses: actions/setup-python@v4
35         with:
36           python-version: ${{ matrix.python-version }}
37         if: ${{ runner.os != 'Linux' || matrix.python-version == '3.11' }}
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 install --upgrade pip setuptools wheel
49           pip --version
50           pip install --upgrade virtualenv tox
51       - name: Set TOXENV
52         run: |
53           import os, sys
54           pyver = '%d%d' % tuple(sys.version_info[:2])
55           toxenv = 'py%s-sqlite' % pyver
56           if os.name == 'posix':
57             toxenv += ',py%s-flake8' % pyver
58           elif os.name == 'nt':
59             toxenv += '-w32'
60           with open(os.environ['GITHUB_ENV'], 'a') as f:
61             f.write('TOXENV=' + toxenv + '\n')
62         shell: python
63
64       - name: Run tox
65         run: |
66           python -c "import os; print(os.environ['TOXENV'])"
67           tox --version
68           tox