]> git.phdru.name Git - sqlconvert.git/blob - .github/workflows/run-tests.yaml
CI(GHActions): Show `tox`/`pytest` version
[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"]
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: actions/setup-python@v2
39         with:
40           python-version: ${{ matrix.python-version }}
41       - name: Cache pip
42         uses: actions/cache@v2
43         with:
44           path: ${{ matrix.pip-cache-path }}
45           key: ${{ runner.os }}-pip
46
47       # Setup tox
48       - name: Install dependencies
49         run: |
50           python --version
51           python -m pip install --upgrade pip setuptools wheel
52           pip --version
53           pip install --upgrade virtualenv tox
54       - name: Set TOXENV
55         run: |
56           import os, sys
57           pyver = '%d%d' % tuple(sys.version_info[:2])
58           toxenv = 'py%s' % pyver
59           toxenv += ',py%s-sqlite' % pyver
60           if os.name == 'nt':
61             toxenv += '-w32'
62           toxenv += ',py%s-postgres' % pyver
63           if os.name == 'posix':
64             toxenv += ',py%s-flake8' % pyver
65           elif os.name == 'nt':
66             toxenv += '-w32'
67           with open(os.environ['GITHUB_ENV'], 'a') as f:
68             f.write('TOXENV=' + toxenv + '\n')
69             f.write('PGPASSWORD=test\n')
70         shell: python
71
72       - name: Run tox
73         run: |
74           python -c "import os; print(os.environ['TOXENV'])"
75           tox --version
76           tox