Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add tox test matrix #64

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading