Skip to content

Commit

Permalink
Improve CI testing
Browse files Browse the repository at this point in the history
- Move tox config into pyproject.toml
- Update github actions workflow
  • Loading branch information
jacklinke committed Jan 21, 2023
1 parent 5840537 commit b5544fd
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 97 deletions.
97 changes: 16 additions & 81 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
- run: flake8 --max-line-length=119

test:
name: tox on ${{ matrix.python-version }}
runs-on: ubuntu-latest

services:
Expand All @@ -47,97 +48,31 @@ jobs:
strategy:
fail-fast: false
matrix:
include:
# Django 2.2
- django-version: "2.2.0"
python-version: "3.7"
psycopg2-version: "2.8.6"
- django-version: "2.2.0"
python-version: "3.8"
psycopg2-version: "2.8.6"
- django-version: "2.2.0"
python-version: "3.9"
psycopg2-version: "2.8.6"
# Django 3.0
- django-version: "3.0.0"
python-version: "3.7"
psycopg2-version: "2.8.6"
- django-version: "3.0.0"
python-version: "3.8"
psycopg2-version: "2.8.6"
- django-version: "3.0.0"
python-version: "3.9"
psycopg2-version: "2.8.6"
# Django 3.1
- django-version: "3.1.0"
python-version: "3.7"
psycopg2-version: "2.9.3"
- django-version: "3.1.0"
python-version: "3.8"
psycopg2-version: "2.9.3"
- django-version: "3.1.0"
python-version: "3.9"
psycopg2-version: "2.9.3"
# Django 3.2
- django-version: "3.2.0"
python-version: "3.7"
psycopg2-version: "2.9.3"
- django-version: "3.2.0"
python-version: "3.8"
psycopg2-version: "2.9.3"
- django-version: "3.2.0"
python-version: "3.9"
psycopg2-version: "2.9.3"
- django-version: "3.2.0"
python-version: "3.10"
psycopg2-version: "2.9.3"
# Django 4.0
- django-version: "4.0.0"
python-version: "3.8"
psycopg2-version: "2.9.3"
- django-version: "4.0.0"
python-version: "3.9"
psycopg2-version: "2.9.3"
- django-version: "4.0.0"
python-version: "3.10"
psycopg2-version: "2.9.3"
python-version: ["3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Upgrade pip version
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry==1.3.2 tox tox-gh-actions==3.0.0
- name: Install Dependencies
run: |
pip install -r ./tests/requirements.txt
- name: Install specific django version
run: |
python -m pip install "Django~=${{ matrix.django-version }}"
- name: Install correct django version
run: poetry export --dev --without-hashes -f requirements.txt | grep -v "^[dD]jango==" | poetry run pip install --no-deps -r /dev/stdin
shell: bash

- name: Install specific psycopg2 version
# Django 2.2 & 3.0 do not like newer versions of psycopg2
# See https://github.com/psycopg/psycopg2/issues/1293#issuecomment-862835147
- name: Check versions
run: |
python -m pip install "psycopg2-binary~=${{ matrix.psycopg2-version }}"
- name: Echo Python and Django versions
run: |
echo "Python ${{ matrix.python-version }} -> Django ${{ matrix.django-version }}"
python --version
echo "Django: `django-admin --version`"
python -VV
python -m site
poetry run django-admin --version
- name: Run Migrations
run: |
python manage.py migrate
run: python manage.py migrate

- name: Run Tests
run: |
pytest
- name: Run tox
- run: python -m tox
35 changes: 35 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,41 @@ Werkzeug = "^2.0"
wheel = "^0.37"
"zest.releaser" = "^6.22"

[tool.tox]
legacy_tox_ini = """
[tox]
isolated_build = true
envlist = {py38,py39,py310}-django{32,40,41}
[gh-actions]
python =
3.8: py38-django32, py38-django40, py38-django41
3.9: py39-django32, py39-django40, py39-django41
3.10: py310-django32, py310-django40, py310-django41
[testenv]
deps =
django32: Django>=3.2,<4.0
django40: Django>=4.0,<4.1
django41: Django>=4.1,<4.2
basepython =
py38: python3.8
py39: python3.9
py310: python3.10
whitelist_externals =
poetry
bash
extras =
dev
skip_install = true
# Recommended in discussion at https://github.com/python-poetry/poetry/issues/1745#issuecomment-648365339
commands =
bash -c 'poetry export --dev --without-hashes -f requirements.txt | grep -v "^[dD]jango==" | poetry run pip install --no-deps -r /dev/stdin'
# Show we have the right Django version
poetry run django-admin --version
poetry run pytest tests/
"""

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
16 changes: 0 additions & 16 deletions tox.ini

This file was deleted.

0 comments on commit b5544fd

Please sign in to comment.