]> git.phdru.name Git - sqlconvert.git/blob - .github/workflows/run-tests.yaml
CI(GHActions): Run tests on w32
[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]
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       - uses: ankane/setup-postgres@v1
26       - name: Setup Postgres user
27         run: |
28           sudo -u postgres psql --command="ALTER USER runner CREATEDB PASSWORD 'test'"
29         if: ${{ runner.os == 'Linux' }}
30       - name: Setup Postgres user
31         run: |
32           psql --command="CREATE USER runner CREATEDB PASSWORD 'test'"
33         if: ${{ runner.os == 'Windows' }}
34
35       - uses: actions/checkout@v2
36       - uses: actions/setup-python@v2
37         with:
38           python-version: ${{ matrix.python-version }}
39       - name: Cache pip
40         uses: actions/cache@v2
41         with:
42           path: ${{ matrix.pip-cache-path }}
43           key: ${{ runner.os }}-pip
44       - name: Install dependencies
45         run: |
46           python --version
47           python -m pip install --upgrade "pip<21.0" "setuptools<45" wheel
48           pip --version
49           pip install --upgrade virtualenv tox
50       - name: Set TOXENV
51         run: |
52           import os, sys
53           pyver = '%d%d' % tuple(sys.version_info[:2])
54           toxenv = 'py%s' % pyver
55           toxenv += ',py%s-sqlite' % pyver
56           if os.name == 'nt':
57             toxenv += '-w32'
58           toxenv += ',py%s-postgres' % pyver
59           if os.name == 'posix':
60             toxenv += ',py%s-flake8' % pyver
61           elif os.name == 'nt':
62             toxenv += '-w32'
63           with open(os.environ['GITHUB_ENV'], 'a') as f:
64             f.write('TOXENV=' + toxenv + '\n')
65             f.write('PGPASSWORD=test\n')
66         shell: python
67       - name: Run tox
68         run: |
69           python -c "import os; print(os.environ['TOXENV'])"
70           tox