]> git.phdru.name Git - sqlconvert.git/blob - .github/workflows/run-tests.yaml
CI(GHActions): More descriptive step names
[sqlconvert.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, 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: windows-latest
17           os-name: w32
18           pip-cache-path: ~\AppData\Local\pip\Cache
19
20     name: Python ${{ matrix.python-version }} @ ${{ matrix.os-name }}
21     runs-on: ${{ matrix.os }}
22
23     steps:
24
25       # Setup PostgreSQL
26       - uses: ankane/setup-postgres@v1
27       - name: Setup Postgres user @ Linux
28         run: |
29           sudo -u postgres psql --command="ALTER USER runner CREATEDB PASSWORD 'test'"
30         if: ${{ runner.os == 'Linux' }}
31       - name: Setup Postgres user @ w32
32         run: |
33           psql --command="CREATE USER runner CREATEDB PASSWORD 'test'"
34         if: ${{ runner.os == 'Windows' }}
35
36       # Setup Python/pip
37       - uses: actions/checkout@v2
38       - uses: s-weigand/setup-conda@v1
39         with:
40           python-version: ${{ matrix.python-version }}
41         if: ${{ runner.os == 'Linux' && matrix.python-version != '3.11' }}
42       - uses: actions/setup-python@v4
43         with:
44           python-version: ${{ matrix.python-version }}
45         if: ${{ runner.os != 'Linux' || matrix.python-version == '3.11' }}
46       - name: Cache pip
47         uses: actions/cache@v3
48         with:
49           path: ${{ matrix.pip-cache-path }}
50           key: ${{ runner.os }}-pip
51
52       # Setup tox
53       - name: Install dependencies
54         run: |
55           python --version
56           python -m pip install --upgrade pip setuptools wheel
57           pip --version
58           pip install --upgrade virtualenv "tox < 4"
59       - name: Set TOXENV
60         run: |
61           import os, sys
62           ld_library_path = None
63           pyver = '%d%d' % tuple(sys.version_info[:2])
64           toxenv = 'py%s' % pyver
65           toxenv += ',py%s-sqlite' % pyver
66           if os.name == 'nt':
67             toxenv += '-w32'
68           toxenv += ',py%s-postgres' % pyver
69           if os.name == 'posix':
70             if pyver == '27':  # Python 2.7 on Linux requires `$LD_LIBRARY_PATH`
71               ld_library_path = os.path.join(
72                 os.path.dirname(os.path.dirname(sys.executable)), 'lib')
73             toxenv += ',py%s-flake8' % pyver
74           elif os.name == 'nt':
75             toxenv += '-w32'
76           with open(os.environ['GITHUB_ENV'], 'a') as f:
77             if ld_library_path:
78               f.write('LD_LIBRARY_PATH=' + ld_library_path + '\n')
79             f.write('TOXENV=' + toxenv + '\n')
80             f.write('PGPASSWORD=test\n')
81         shell: python
82
83       - name: Run tox
84         run: |
85           python -c "import os; print(os.environ['TOXENV'])"
86           tox --version
87           tox