Replace Travis CI configuration with GitHub Actions (#561)

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
This commit is contained in:
Aarni Koskela 2023-12-12 12:50:15 +02:00 committed by GitHub
parent 1a5f26d889
commit 0ead3b6d6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 108 additions and 70 deletions

26
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,26 @@
name: Release
on:
push:
branches:
- master
tags:
- '*'
jobs:
Build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3"
cache: pip
cache-dependency-path: setup.cfg
# TODO: look into using python-babel instead of requiring gettext as system dependency
- run: sudo apt-get update && sudo apt-get install -y --no-install-recommends gettext
- run: pip install -U build
- run: python -m build
- uses: actions/upload-artifact@v3
with:
name: dist
path: dist/

60
.github/workflows/test.yml vendored Normal file
View File

@ -0,0 +1,60 @@
name: Test
on:
- pull_request
- push
- workflow_dispatch
jobs:
Build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3"
cache: pip
cache-dependency-path: setup.cfg
# TODO: look into using python-babel instead of requiring gettext as system dependency
- run: sudo apt-get update && sudo apt-get install -y --no-install-recommends gettext
- run: pip install -U build
- run: python -m build
- uses: actions/upload-artifact@v3
with:
name: dist
path: dist/
Test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
include:
- os: ubuntu-20.04
python-version: "3.6"
- os: ubuntu-20.04
python-version: "3.7"
- os: ubuntu-22.04
python-version: "3.8"
- os: ubuntu-22.04
python-version: "3.9"
- os: ubuntu-22.04
python-version: "3.10"
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: setup.cfg
# TODO: look into using python-babel instead of requiring gettext as system dependency
- run: sudo apt-get update && sudo apt-get install -y --no-install-recommends gettext
# TODO: look into using python-babel instead of requiring django to be ambiently installed
# so tox can build messages
- run: pip install -U tox tox-gh-actions django
# TODO: postgres setup and proper djangomain testing
- run: python -m tox
- run: |
mkdir /tmp/coverage
find .tox -type f -name 'coverage*xml' -exec mv '{}' /tmp/coverage ';'
- uses: codecov/codecov-action@v3
with:
directory: /tmp/coverage

View File

@ -1,62 +0,0 @@
language: python
services:
- postgres
addons:
postgresql: "9.6"
matrix:
fast_finish: true
include:
# Django 2.1: Python 3.5, 3.6, or 3.7
- { env: TOXENV=py35-django21, python: 3.5 }
- { env: TOXENV=py36-django21, python: 3.6 }
- { env: TOXENV=py37-django21, python: 3.7 }
- { env: TOXENV=py37-django21-postgres DB=postgres, python: 3.7 }
# Django 2.2: Python 3.5, 3.6, 3.7 or 3.8
- { env: TOXENV=py35-django22, python: 3.5 }
- { env: TOXENV=py36-django22, python: 3.6 }
- { env: TOXENV=py37-django22, python: 3.7 }
- { env: TOXENV=py38-django22, python: 3.8 }
- { env: TOXENV=py38-django22-postgres DB=postgres, python: 3.8 }
# Django 3.0: Python 3.6, 3.7 or 3.8
- { env: TOXENV=py36-django30, python: 3.6 }
- { env: TOXENV=py37-django30, python: 3.7 }
- { env: TOXENV=py38-django30, python: 3.8 }
- { env: TOXENV=py38-django30-postgres DB=postgres, python: 3.8 }
# Django 3.1: Python 3.6, 3.7 or 3.8
- { env: TOXENV=py36-django31, python: 3.6 }
- { env: TOXENV=py37-django31, python: 3.7 }
- { env: TOXENV=py38-django31, python: 3.8 }
- { env: TOXENV=py38-django31-postgres DB=postgres, python: 3.8 }
# Django development master (direct from GitHub source):
- { env: TOXENV=py36-djangomaster, python: 3.6 }
- { env: TOXENV=py37-djangomaster, python: 3.7 }
- { env: TOXENV=py38-djangomaster, python: 3.8 }
- { env: TOXENV=py38-djangomaster-postgres DB=postgres, python: 3.8 }
allow_failures:
- env: TOXENV=py36-djangomaster
- env: TOXENV=py37-djangomaster
- env: TOXENV=py38-djangomaster
- env: TOXENV=py38-djangomaster-postgres DB=postgres
cache:
directories:
- $HOME/.cache/pip
- $TRAVIS_BUILD_DIR/.tox
before_install:
- psql -c 'CREATE DATABASE default;' -U postgres || true
- psql -c 'CREATE DATABASE secondary;' -U postgres || true
install:
- pip install --upgrade pip wheel setuptools
- pip install codecov coverage tox
script:
- tox
after_success:
- coverage xml -i
- codecov

View File

@ -1,5 +1,5 @@
.. image:: https://travis-ci.org/jazzband/django-polymorphic.svg?branch=master
:target: http://travis-ci.org/jazzband/django-polymorphic
.. image:: https://github.com/jazzband/django-polymorphic/actions/workflows/test.yml/badge.svg
:target: https://github.com/jazzband/django-polymorphic/actions/workflows/test.yml
.. image:: https://img.shields.io/pypi/v/django-polymorphic.svg
:target: https://pypi.python.org/pypi/django-polymorphic/
.. image:: https://img.shields.io/codecov/c/github/jazzband/django-polymorphic/master.svg

View File

@ -1,3 +1,10 @@
[build-system]
requires = [
"setuptools",
# TODO: look into using python-babel instead of requiring django at build time
"django>=2.1", # for makemessages
]
[tool.isort]
profile = "black"
line_length = 99

19
tox.ini
View File

@ -3,7 +3,8 @@ envlist =
py36-django{22,30,31}
py37-django{22,30,31}
py38-django{22,30,31,32}
py39-django{40}
py{39,310}-django{40,41,42}
# TODO: reinstate running on postgres: py39-django{40}-postgres
docs
[testenv]
@ -14,11 +15,12 @@ setenv =
deps =
coverage
dj-database-url
django21: Django ~= 2.1
django22: Django ~= 2.2
django30: Django ~= 3.0
django31: Django ~= 3.1
django40: Django==4.0b1
django40: Django ~= 4.0
django41: Django ~= 4.1
django42: Django ~= 4.2
djangomain: https://github.com/django/django/archive/main.tar.gz
postgres: psycopg2
commands =
@ -32,6 +34,11 @@ deps =
changedir = docs
commands = sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html
[flake8]
# ignore line size
max-line-length = 300
[gh-actions]
python =
3.6: py36
3.7: py37
3.8: py38
3.9: py39
3.10: py310
3.11: py311