From f3ea30704044349d0c690262469abeb87b1eeaae Mon Sep 17 00:00:00 2001 From: Daniel Prange Date: Tue, 16 Apr 2024 10:30:53 +0300 Subject: [PATCH] ci: add tox test matrix --- .github/workflows/test.yml | 47 ++++++++++++++++++++++++++++++++++++++ requirements.txt | 1 + tox.ini | 28 +++++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 .github/workflows/test.yml create mode 100644 tox.ini diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..06eb771 --- /dev/null +++ b/.github/workflows/test.yml @@ -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 diff --git a/requirements.txt b/requirements.txt index 208c56c..edc01f0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,6 +7,7 @@ djangorestframework isort psycopg2 pytest +pytest-cov pyyaml requests requests-cache diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..0c336ff --- /dev/null +++ b/tox.ini @@ -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