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

Migrate to GitHub Actions. #112

Merged
merged 16 commits into from
Dec 9, 2020
40 changes: 40 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Release

on:
push:
tags:
- '*'

jobs:
build:
if: github.repository == 'jazzband/django-dbtemplates'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install -U setuptools twine wheel

- name: Build package
run: |
python setup.py --version
python setup.py sdist --format=gztar bdist_wheel
twine check dist/*

- name: Upload packages to Jazzband
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
user: jazzband
password: ${{ secrets.JAZZBAND_RELEASE_KEY }}
repository_url: https://jazzband.co/projects/django-dbtemplates/upload
48 changes: 48 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Test

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 5
matrix:
python-version: ['3.6', '3.7', '3.8']
jezdez marked this conversation as resolved.
Show resolved Hide resolved

steps:
- uses: actions/checkout@v2

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

- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"

- name: Cache
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key:
${{ matrix.python-version }}-v1-${{ hashFiles('**/setup.py') }}-${{ hashFiles('**/tox.ini') }}
restore-keys: |
${{ matrix.python-version }}-v1-

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade tox tox-gh-actions

- name: Tox tests
run: |
tox -v

- name: Upload coverage
uses: codecov/codecov-action@v1
with:
name: Python ${{ matrix.python-version }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ docs/_build
.tox/
*.egg/
.coverage
coverage.xml
30 changes: 0 additions & 30 deletions .travis.yml

This file was deleted.

6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ django-dbtemplates
:alt: Jazzband
:target: https://jazzband.co/

.. image:: https://travis-ci.org/jazzband/django-dbtemplates.svg?branch=master
:alt: Build Status
:target: http://travis-ci.org/jazzband/django-dbtemplates
.. image:: https://github.com/jazzband/django-dbtemplates/workflows/Test/badge.svg
:target: https://github.com/jazzband/django-dbtemplates/actions
:alt: GitHub Actions

.. image:: https://codecov.io/github/jazzband/django-dbtemplates/coverage.svg?branch=master
:alt: Codecov
Expand Down
9 changes: 8 additions & 1 deletion dbtemplates/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
__version__ = "3.0"
from pkg_resources import get_distribution, DistributionNotFound

try:
__version__ = get_distribution("django-dbtemplates").version
except DistributionNotFound:
# package is not installed
__version__ = None


default_app_config = 'dbtemplates.apps.DBTemplatesConfig'
3 changes: 1 addition & 2 deletions dbtemplates/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from django.core.exceptions import ImproperlyConfigured
from django.conf import settings
from six import string_types

from appconf import AppConf

Expand Down Expand Up @@ -33,7 +32,7 @@ def configure_cache_backend(self, value):
return "dbtemplates"
else:
return "default"
if isinstance(value, string_types) and value.startswith("dbtemplates."):
if isinstance(value, str) and value.startswith("dbtemplates."):
raise ImproperlyConfigured("Please upgrade to one of the "
"supported backends as defined "
"in the Django docs.")
Expand Down
5 changes: 0 additions & 5 deletions dbtemplates/management/commands/sync_templates.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import io
import os
import sys
from django.contrib.sites.models import Site
from django.core.management.base import CommandError, BaseCommand
from django.template.utils import get_app_template_dirs
from django.template.loader import _engine_list
try:
from six import input
except ImportError:
pass

from dbtemplates.models import Template

Expand Down
2 changes: 0 additions & 2 deletions dbtemplates/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@
from django.db import models
from django.db.models import signals
from django.template import TemplateDoesNotExist
from six import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
from django.utils.timezone import now


@python_2_unicode_compatible
class Template(models.Model):
"""
Defines a template model for use with the database template loader.
Expand Down
15 changes: 15 additions & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
Changelog
=========

v4.0 (unreleased)
-----------------

.. warning::

This is a backwards-incompatible release!

* Dropped support for Python 2.7.

* Added support for Python 3.8.

* Moved test runner to GitHub Actions:

http://github.com/jazzband/django-dbtemplates/actions

v3.0 (2019-01-27)
-----------------

Expand Down
69 changes: 26 additions & 43 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,62 +1,45 @@
import ast
import os
import io
from setuptools import setup, find_packages


class VersionFinder(ast.NodeVisitor):
def __init__(self):
self.version = None

def visit_Assign(self, node):
if node.targets[0].id == '__version__':
self.version = node.value.s


def read(*parts):
filename = os.path.join(os.path.dirname(__file__), *parts)
with io.open(filename, encoding='utf-8') as fp:
with io.open(filename, encoding="utf-8") as fp:
return fp.read()


def find_version(*parts):
finder = VersionFinder()
finder.visit(ast.parse(read(*parts)))
return finder.version


setup(
name='django-dbtemplates',
version=find_version('dbtemplates', '__init__.py'),
description='Template loader for templates stored in the database',
long_description=read('README.rst'),
author='Jannis Leidel',
author_email='[email protected]',
url='https://django-dbtemplates.readthedocs.io/',
name="django-dbtemplates",
use_scm_version={"version_scheme": "post-release"},
setup_requires=["setuptools_scm"],
description="Template loader for templates stored in the database",
long_description=read("README.rst"),
author="Jannis Leidel",
author_email="[email protected]",
url="https://django-dbtemplates.readthedocs.io/",
packages=find_packages(),
zip_safe=False,
package_data={
'dbtemplates': [
'locale/*/LC_MESSAGES/*',
'static/dbtemplates/css/*.css',
'static/dbtemplates/js/*.js',
"dbtemplates": [
"locale/*/LC_MESSAGES/*",
"static/dbtemplates/css/*.css",
"static/dbtemplates/js/*.js",
],
},
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Framework :: Django',
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Framework :: Django",
],
install_requires=['django-appconf >= 0.4', 'six'],
install_requires=["django-appconf >= 0.4"],
)
33 changes: 12 additions & 21 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,24 @@ skipsdist = True
usedevelop = True
minversion = 1.8
envlist =
flake8-py{27,37},
twine-check-py{27,37},
py{27,35,36}-dj111
flake8-py37
py{35,36}-dj111
py{35,36,37}-dj21
py{35,36,37}-dj22
py{35,36,37,38}-dj22

[gh-actions]
python =
3.5: py36
3.6: py36
3.7: py37
3.8: py38

[testenv]
basepython =
py27: python2.7
py35: python3.5
py36: python3.6
py37: python3.7
py38: python3.8
usedevelop = true
setenv =
DJANGO_SETTINGS_MODULE = dbtemplates.test_settings
Expand All @@ -30,22 +36,7 @@ commands =
python --version
coverage run {envbindir}/django-admin.py test -v2 {posargs:dbtemplates}
coverage report

[testenv:twine-check-py27]
commands =
python setup.py sdist bdist_wheel
twine check dist/*
deps = twine

[testenv:twine-check-py37]
commands =
python setup.py sdist bdist_wheel
twine check dist/*
deps = twine

[testenv:flake8-py27]
commands = flake8 dbtemplates
deps = flake8
coverage xml

[testenv:flake8-py37]
commands = flake8 dbtemplates
Expand Down