]> git.phdru.name Git - sqlconvert.git/blob - .github/workflows/run-tests.yaml
CI(GHActions): Setup PostgreSQL, run postgres tests
[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         python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9]
11
12     name: Python ${{ matrix.python-version }}
13     runs-on: ubuntu-latest
14
15     steps:
16
17       # Use preinstalled PostgreSQL
18       - name: Start PostgreSQL on Ubuntu
19         run: |
20           sudo systemctl start postgresql
21           pg_isready
22       - name: Create user
23         run: |
24           echo 'localhost:*:test:runner:test' > ~/.pgpass
25           chmod u=rw,go= ~/.pgpass
26           sudo -u postgres psql --command="CREATE USER runner CREATEDB ENCRYPTED PASSWORD 'test'"
27
28       - uses: actions/checkout@v2
29       - uses: actions/setup-python@v2
30         with:
31           python-version: ${{ matrix.python-version }}
32       - name: Cache pip
33         uses: actions/cache@v2
34         with:
35           # This path is specific to Linux/Unix
36           path: ~/.cache/pip
37           key: ${{ runner.os }}-pip
38       - name: Install dependencies
39         run: |
40           python --version
41           python -m pip install --upgrade "pip<21.0" "setuptools<45" wheel
42           pip --version
43           pip install --upgrade virtualenv tox
44       - name: Set TOXENV
45         run: |
46           import os, sys
47           pyver = '%d%d' % tuple(sys.version_info[:2])
48           toxenv = 'py%s' % pyver
49           toxenv += ',py%s-sqlite' % pyver
50           toxenv += ',py%s-postgres' % pyver
51           toxenv += ',py%s-flake8' % pyver
52           with open(os.environ['GITHUB_ENV'], 'a') as f:
53             f.write('TOXENV=' + toxenv + '\n')
54         shell: python
55       - name: Run tox
56         run: |
57           python -c "import os; print(os.environ['TOXENV'])"
58           tox