]> git.phdru.name Git - sqlconvert.git/blob - .github/workflows/run-tests.yaml
a4d5fd791446b9600b36deb75c844409044c7c7e
[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
28         run: |
29           sudo -u postgres psql --command="ALTER USER runner CREATEDB PASSWORD 'test'"
30         if: ${{ runner.os == 'Linux' }}
31       - name: Setup Postgres user
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
59       - name: Set TOXENV
60         run: |
61           import os, sys
62           pyver = '%d%d' % tuple(sys.version_info[:2])
63           toxenv = 'py%s' % pyver
64           toxenv += ',py%s-sqlite' % pyver
65           if os.name == 'nt':
66             toxenv += '-w32'
67           toxenv += ',py%s-postgres' % pyver
68           if os.name == 'posix':
69             toxenv += ',py%s-flake8' % pyver
70           elif os.name == 'nt':
71             toxenv += '-w32'
72           with open(os.environ['GITHUB_ENV'], 'a') as f:
73             f.write('TOXENV=' + toxenv + '\n')
74             f.write('PGPASSWORD=test\n')
75         shell: python
76
77       - name: Run tox
78         run: |
79           python -c "import os; print(os.environ['TOXENV'])"
80           tox --version
81           tox