Skip to content

Commit

Permalink
ci: add tox test matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
danipran committed Apr 16, 2024
1 parent 1c92ef2 commit f3ea307
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Run tests

env:
DEFAULT_PYTHON: 3.9

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
test:
name: Python ${{ matrix.python_version }}
runs-on: ubuntu-latest
env:
TOX_POSARGS: -- --cov=. --cov-report=xml
strategy:
matrix:
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python_version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
cache: "pip"
cache-dependency-path: "requirements.txt"

- name: Upgrade packaging tools
run: python -m pip install --upgrade pip setuptools wheel

- name: Install dependencies
run: |
sudo apt-add-repository ppa:ubuntugis/ppa
sudo apt-get update
sudo apt-get install gdal-bin libgdal-dev
python -m pip install --upgrade codecov tox
- name: Run tox targets for Python ${{ matrix.python_version }}
run: tox run -f py$(echo ${{ matrix.python_version }} | tr -d .) ${{ env.TOX_POSARGS }}

- name: Upload Coverage to Codecov
if: ${{ matrix.python_version == env.DEFAULT_PYTHON }}
uses: codecov/codecov-action@v4
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ djangorestframework
isort
psycopg2
pytest
pytest-cov
pyyaml
requests
requests-cache
Expand Down
28 changes: 28 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[tox]
envlist =
py38-django{32,40,41,42}
py39-django{32,40,41,42}
py310-django{32,40,41,42,main}
py311-django{40,41,42,main}
py312-django{40,41,42,main}

[testenv]
description = run unit tests
commands =
pytest {posargs}
setenv =
PYTHONDONTWRITEBYTECODE=1
PYTHONWARNINGS=once
# Use constraints to ensure that the Django version doesn't get overridden when installing
# package requirements, e.g. DRF might override it.
constrain_package_deps = true
deps =
django32: Django>=3.2,<4.0
django40: Django>=4.0,<4.1
django41: Django>=4.1,<4.2
django42: Django>=4.2,<5.0
djangomain: https://github.com/django/django/archive/main.tar.gz
-rrequirements.txt

[testenv:{py310,py311,py312}-djangomain]
ignore_outcome = true

0 comments on commit f3ea307

Please sign in to comment.