|
| 1 | +name: Tests |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +jobs: |
| 6 | + build: |
| 7 | + name: ${{ matrix.variant}} py=${{ matrix.python-version }} dj=${{ matrix.django-version }} drf=${{ matrix.drf-version }} |
| 8 | + runs-on: ubuntu-20.04 |
| 9 | + env: |
| 10 | + TEST_VARIANT: ${{ matrix.variant }} |
| 11 | + strategy: |
| 12 | + matrix: |
| 13 | + variant: [default, spatialite, postgis] |
| 14 | + python-version: [3.9] |
| 15 | + django-version: [2.2.17, 3.1.5] |
| 16 | + drf-version: [3.12.2] |
| 17 | + include: |
| 18 | + - python-version: 3.9 |
| 19 | + django-version: 3.1.5 |
| 20 | + drf-version: 3.11.2 |
| 21 | + variant: default |
| 22 | + - python-version: 3.9 |
| 23 | + django-version: 3.1.5 |
| 24 | + drf-version: 3.12.2 |
| 25 | + variant: nonroot |
| 26 | + - python-version: 3.8 |
| 27 | + django-version: 3.1.5 |
| 28 | + drf-version: 3.12.2 |
| 29 | + variant: default |
| 30 | + - python-version: 3.7 |
| 31 | + django-version: 3.1.5 |
| 32 | + drf-version: 3.12.2 |
| 33 | + variant: default |
| 34 | + - python-version: 3.6 |
| 35 | + django-version: 3.1.5 |
| 36 | + drf-version: 3.12.2 |
| 37 | + variant: default |
| 38 | + steps: |
| 39 | + - uses: actions/checkout@v2 |
| 40 | + - name: Set up Python ${{ matrix.python-version }} |
| 41 | + uses: actions/setup-python@v2 |
| 42 | + with: |
| 43 | + python-version: ${{ matrix.python-version }} |
| 44 | + - name: Install dependencies |
| 45 | + run: | |
| 46 | + python -m pip install --upgrade pip |
| 47 | + python -m pip install flake8 pytest wheel |
| 48 | + python -m pip install django==${{ matrix.django-version }} |
| 49 | + python -m pip install djangorestframework==${{ matrix.drf-version }} |
| 50 | + python -m pip install . |
| 51 | + - name: Lint with flake8 |
| 52 | + run: | |
| 53 | + # stop the build if there are Python syntax errors or undefined names |
| 54 | + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics |
| 55 | + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide |
| 56 | + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics |
| 57 | + - name: Set up SpatiaLite |
| 58 | + if: ${{ matrix.variant == 'spatialite' }} |
| 59 | + run: sudo apt install libsqlite3-mod-spatialite gdal-bin |
| 60 | + - name: Set up PostgreSQL |
| 61 | + if: ${{ matrix.variant == 'postgis' }} |
| 62 | + run: | |
| 63 | + sudo apt install postgresql-13-postgis-3 |
| 64 | + # postgresql is already installed on image |
| 65 | + sudo systemctl start postgresql.service |
| 66 | + sudo -u postgres createuser --superuser $USER |
| 67 | + createdb wqdb_test |
| 68 | + psql wqdb_test -c "CREATE EXTENSION postgis;" |
| 69 | + python -m pip install psycopg2-binary |
| 70 | + - name: Test with unittest |
| 71 | + run: python setup.py test |
0 commit comments