From 50da34125cd078a1b10ad8d956a8c6e1697ad2e2 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Wed, 25 Nov 2020 22:15:14 +0100 Subject: [PATCH] Simplified travis config and added Jazzband release config. (#281) * Simplified travis config and added Jazzband release config. * Migrate to travis-ci.com. * Split requirements to prevent env spoilage. * Add docs requirements. * Huh * type * Add psycopg2 doc requirements. --- .travis.yml | 70 ++++++++++++++++-------------------- auditlog/__init__.py | 8 ++++- auditlog_tests/tests.py | 1 + docs/requirements.txt | 4 +++ docs/source/conf.py | 9 ++--- docs/source/installation.rst | 2 +- requirements.txt | 17 --------- setup.py | 5 ++- tox.ini | 22 ++++++++++-- 9 files changed, 69 insertions(+), 69 deletions(-) create mode 100644 docs/requirements.txt delete mode 100644 requirements.txt diff --git a/.travis.yml b/.travis.yml index 53170ee..d5d29d8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,48 +1,38 @@ -# Config file for automatic testing at travis-ci.org - dist: xenial sudo: required language: python services: - - postgresql - +- postgresql addons: - postgresql: "10" - -matrix: + postgresql: '10' +cache: + pip: true +python: + - 3.5 + - 3.6 + - 3.7 + - 3.8 +jobs: include: - - python: 3.5 - env: TOXENV=py35-django-22 - - - python: 3.6 - env: TOXENV=py36-django-22 - - python: 3.6 - env: TOXENV=py36-django-30 - - - python: 3.7 - env: TOXENV=py37-django-22 - - python: 3.7 - env: TOXENV=py37-django-30 - - - python: 3.8 - env: TOXENV=py38-django-22 - - python: 3.8 - env: TOXENV=py38-django-30 - + - stage: deploy + if: tag IS present + python: 3.8 + script: skip + deploy: + provider: pypi + user: jazzband + server: https://jazzband.co/projects/django-auditlog/upload + distributions: sdist bdist_wheel + password: + secure: AD22a73v//OXpP8WgFscTQHQxpNE5Rup9+NhoxNRNYXszc+g9Z9yNO5cokPHD0HUL7pma/V31xK1tavFO7jHfvidcnx8mNwezoW7lQctNErxhtuAUN59654IaTPmTOU6vvdslmtNT1W/M/LDsp5hWyzaCbTNbl5Ag4+spUpSCq8= + skip_existing: true + on: + tags: true + repo: jazzband/django-auditlog fast_finish: true - -install: pip install -r requirements.txt - -script: tox - +install: + - travis_retry pip install -U pip + - travis_retry pip install tox-travis codecov +script: tox -v after_success: - - codecov -e TOX_ENV - -deploy: - provider: pypi - # PyPI credentials supplied with environment variables from repository settings - on: - repo: jazzband/django-auditlog - branch: stable - condition: $TOXENV = py38-django-30 - edge: true +- codecov diff --git a/auditlog/__init__.py b/auditlog/__init__.py index b1dd7f3..e369079 100644 --- a/auditlog/__init__.py +++ b/auditlog/__init__.py @@ -1,3 +1,9 @@ -__version__ = '1.0a1' +from pkg_resources import get_distribution, DistributionNotFound + +try: + __version__ = get_distribution("django-auditlog").version +except DistributionNotFound: + # package is not installed + pass default_app_config = 'auditlog.apps.AuditlogConfig' diff --git a/auditlog_tests/tests.py b/auditlog_tests/tests.py index 9993f76..edd0670 100644 --- a/auditlog_tests/tests.py +++ b/auditlog_tests/tests.py @@ -259,6 +259,7 @@ class AdditionalDataModelTest(TestCase): log_entry = obj_with_additional_data.history.get() self.assertIsNotNone(log_entry.additional_data) extra_data = log_entry.additional_data + print(type(extra_data), extra_data) self.assertTrue(extra_data['related_model_text'] == related_model.text, msg="Related model's text is logged") self.assertTrue(extra_data['related_model_id'] == related_model.id, diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 0000000..f516c7c --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,4 @@ +# Docs requirements +sphinx +sphinx_rtd_theme +psycopg2-binary diff --git a/docs/source/conf.py b/docs/source/conf.py index 8855625..9f3c37f 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -9,6 +9,7 @@ import os import sys from datetime import date +from pkg_resources import get_distribution # -- Path setup -------------------------------------------------------------- @@ -30,9 +31,9 @@ project = 'django-auditlog' author = 'Jan-Jelle Kester and contributors' copyright = f'2013-{date.today().year}, {author}' -# The full version, including alpha/beta/rc tags -import auditlog -release = auditlog.__version__ +release = get_distribution('django-auditlog').version +# for example take major/minor +version = '.'.join(release.split('.')[:2]) # -- General configuration --------------------------------------------------- @@ -65,4 +66,4 @@ html_theme = 'sphinx_rtd_theme' # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +# html_static_path = ['_static'] diff --git a/docs/source/installation.rst b/docs/source/installation.rst index 149e2fa..fd63125 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -15,7 +15,7 @@ The repository can be found at https://github.com/jazzband/django-auditlog/. - Django 2.2 or higher Auditlog is currently tested with Python 3.5 - 3.8 and Django 2.2, 3.0 and 3.1. The latest test report can be found -at https://travis-ci.org/jazzband/django-auditlog. +at https://travis-ci.com/jazzband/django-auditlog. Adding Auditlog to your Django application ------------------------------------------ diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 7616965..0000000 --- a/requirements.txt +++ /dev/null @@ -1,17 +0,0 @@ -# Library requirements -django-jsonfield -python-dateutil - -# Build requirements -setuptools -wheel - -# Docs requirements -sphinx -sphinx_rtd_theme - -# Test requirements -coverage -tox -codecov -psycopg2-binary diff --git a/setup.py b/setup.py index 03c3c78..956dd80 100644 --- a/setup.py +++ b/setup.py @@ -2,15 +2,14 @@ import os from setuptools import setup -import auditlog - # Readme as long description with open(os.path.join(os.path.dirname(__file__), "README.md"), "r") as readme_file: long_description = readme_file.read() setup( name='django-auditlog', - version=auditlog.__version__, + use_scm_version={"version_scheme": "post-release"}, + setup_requires=["setuptools_scm"], packages=['auditlog', 'auditlog.migrations', 'auditlog.management', 'auditlog.management.commands'], url='https://github.com/jazzband/django-auditlog', license='MIT', diff --git a/tox.ini b/tox.ini index 39fbea2..7afa09d 100644 --- a/tox.ini +++ b/tox.ini @@ -3,17 +3,33 @@ envlist = {py35,py36,py37,py38}-django-22 {py36,py37,py38}-django-30 {py36,py37,py38}-django-31 + py38-docs [testenv] -setenv = - PYTHONPATH = {toxinidir}:{toxinidir}/auditlog commands = coverage run --source auditlog runtests.py deps = django-22: Django>=2.2,<2.3 django-30: Django>=3.0,<3.1 - -r{toxinidir}/requirements.txt + # Test requirements + coverage + codecov + psycopg2-binary + basepython = py38: python3.8 py37: python3.7 py36: python3.6 py35: python3.5 + +[testenv:py38-docs] +changedir = docs/source +deps = -rdocs/requirements.txt +commands = sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html + +[travis] +python = + 2.7: py27 + 3.5: py35 + 3.6: py36 + 3.7: py37 + 3.8: py38