Skip to content

Commit 012fe06

Browse files
jezdezhugovk
andauthored
Migrate to GitHub Actions. (jazzband#112)
* Add GitHub Actions test workflow. * Update version map. * Fix flake8 * Write coverage file. * Fix typo. * Add release workflow. * Removed Travis cruft and updated other files. * Update trove classifiers. * Black setup. * Remove unneeded twine check. * Extend changelog. * Fix six issue. * Update tox.ini Co-authored-by: Hugo van Kemenade <[email protected]> * Add 3.9. * Add base python Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent 68ac54a commit 012fe06

File tree

12 files changed

+158
-108
lines changed

12 files changed

+158
-108
lines changed

.github/workflows/release.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
build:
10+
if: github.repository == 'jazzband/django-dbtemplates'
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v2
20+
with:
21+
python-version: 3.8
22+
23+
- name: Install dependencies
24+
run: |
25+
python -m pip install -U pip
26+
python -m pip install -U setuptools twine wheel
27+
28+
- name: Build package
29+
run: |
30+
python setup.py --version
31+
python setup.py sdist --format=gztar bdist_wheel
32+
twine check dist/*
33+
34+
- name: Upload packages to Jazzband
35+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
36+
uses: pypa/gh-action-pypi-publish@master
37+
with:
38+
user: jazzband
39+
password: ${{ secrets.JAZZBAND_RELEASE_KEY }}
40+
repository_url: https://jazzband.co/projects/django-dbtemplates/upload

.github/workflows/test.yml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Test
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
fail-fast: false
10+
max-parallel: 5
11+
matrix:
12+
python-version: ['3.6', '3.7', '3.8', '3.9']
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
17+
- name: Set up Python ${{ matrix.python-version }}
18+
uses: actions/setup-python@v2
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
22+
- name: Get pip cache dir
23+
id: pip-cache
24+
run: |
25+
echo "::set-output name=dir::$(pip cache dir)"
26+
27+
- name: Cache
28+
uses: actions/cache@v2
29+
with:
30+
path: ${{ steps.pip-cache.outputs.dir }}
31+
key:
32+
${{ matrix.python-version }}-v1-${{ hashFiles('**/setup.py') }}-${{ hashFiles('**/tox.ini') }}
33+
restore-keys: |
34+
${{ matrix.python-version }}-v1-
35+
36+
- name: Install dependencies
37+
run: |
38+
python -m pip install --upgrade pip
39+
python -m pip install --upgrade tox tox-gh-actions
40+
41+
- name: Tox tests
42+
run: |
43+
tox -v
44+
45+
- name: Upload coverage
46+
uses: codecov/codecov-action@v1
47+
with:
48+
name: Python ${{ matrix.python-version }}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ docs/_build
88
.tox/
99
*.egg/
1010
.coverage
11+
coverage.xml

.travis.yml

-30
This file was deleted.

README.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ django-dbtemplates
55
:alt: Jazzband
66
:target: https://jazzband.co/
77

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

1212
.. image:: https://codecov.io/github/jazzband/django-dbtemplates/coverage.svg?branch=master
1313
:alt: Codecov

dbtemplates/__init__.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1-
__version__ = "3.0"
1+
from pkg_resources import get_distribution, DistributionNotFound
2+
3+
try:
4+
__version__ = get_distribution("django-dbtemplates").version
5+
except DistributionNotFound:
6+
# package is not installed
7+
__version__ = None
8+
29

310
default_app_config = 'dbtemplates.apps.DBTemplatesConfig'

dbtemplates/conf.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from django.core.exceptions import ImproperlyConfigured
44
from django.conf import settings
5-
from six import string_types
65

76
from appconf import AppConf
87

@@ -33,7 +32,7 @@ def configure_cache_backend(self, value):
3332
return "dbtemplates"
3433
else:
3534
return "default"
36-
if isinstance(value, string_types) and value.startswith("dbtemplates."):
35+
if isinstance(value, str) and value.startswith("dbtemplates."):
3736
raise ImproperlyConfigured("Please upgrade to one of the "
3837
"supported backends as defined "
3938
"in the Django docs.")

dbtemplates/management/commands/sync_templates.py

-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
import io
22
import os
3-
import sys
43
from django.contrib.sites.models import Site
54
from django.core.management.base import CommandError, BaseCommand
65
from django.template.utils import get_app_template_dirs
76
from django.template.loader import _engine_list
8-
try:
9-
from six import input
10-
except ImportError:
11-
pass
127

138
from dbtemplates.models import Template
149

dbtemplates/models.py

-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
from django.db import models
99
from django.db.models import signals
1010
from django.template import TemplateDoesNotExist
11-
from six import python_2_unicode_compatible
1211
from django.utils.translation import ugettext_lazy as _
1312
from django.utils.timezone import now
1413

1514

16-
@python_2_unicode_compatible
1715
class Template(models.Model):
1816
"""
1917
Defines a template model for use with the database template loader.

docs/changelog.txt

+15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
Changelog
22
=========
33

4+
v4.0 (unreleased)
5+
-----------------
6+
7+
.. warning::
8+
9+
This is a backwards-incompatible release!
10+
11+
* Dropped support for Python 2.7.
12+
13+
* Added support for Python 3.8.
14+
15+
* Moved test runner to GitHub Actions:
16+
17+
http://github.com/jazzband/django-dbtemplates/actions
18+
419
v3.0 (2019-01-27)
520
-----------------
621

setup.py

+26-43
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,45 @@
1-
import ast
21
import os
32
import io
43
from setuptools import setup, find_packages
54

65

7-
class VersionFinder(ast.NodeVisitor):
8-
def __init__(self):
9-
self.version = None
10-
11-
def visit_Assign(self, node):
12-
if node.targets[0].id == '__version__':
13-
self.version = node.value.s
14-
15-
166
def read(*parts):
177
filename = os.path.join(os.path.dirname(__file__), *parts)
18-
with io.open(filename, encoding='utf-8') as fp:
8+
with io.open(filename, encoding="utf-8") as fp:
199
return fp.read()
2010

2111

22-
def find_version(*parts):
23-
finder = VersionFinder()
24-
finder.visit(ast.parse(read(*parts)))
25-
return finder.version
26-
27-
2812
setup(
29-
name='django-dbtemplates',
30-
version=find_version('dbtemplates', '__init__.py'),
31-
description='Template loader for templates stored in the database',
32-
long_description=read('README.rst'),
33-
author='Jannis Leidel',
34-
author_email='[email protected]',
35-
url='https://django-dbtemplates.readthedocs.io/',
13+
name="django-dbtemplates",
14+
use_scm_version={"version_scheme": "post-release"},
15+
setup_requires=["setuptools_scm"],
16+
description="Template loader for templates stored in the database",
17+
long_description=read("README.rst"),
18+
author="Jannis Leidel",
19+
author_email="[email protected]",
20+
url="https://django-dbtemplates.readthedocs.io/",
3621
packages=find_packages(),
3722
zip_safe=False,
3823
package_data={
39-
'dbtemplates': [
40-
'locale/*/LC_MESSAGES/*',
41-
'static/dbtemplates/css/*.css',
42-
'static/dbtemplates/js/*.js',
24+
"dbtemplates": [
25+
"locale/*/LC_MESSAGES/*",
26+
"static/dbtemplates/css/*.css",
27+
"static/dbtemplates/js/*.js",
4328
],
4429
},
4530
classifiers=[
46-
'Development Status :: 5 - Production/Stable',
47-
'Environment :: Web Environment',
48-
'Intended Audience :: Developers',
49-
'License :: OSI Approved :: BSD License',
50-
'Operating System :: OS Independent',
51-
'Programming Language :: Python',
52-
'Programming Language :: Python :: 2',
53-
'Programming Language :: Python :: 2.7',
54-
'Programming Language :: Python :: 3',
55-
'Programming Language :: Python :: 3.4',
56-
'Programming Language :: Python :: 3.5',
57-
'Programming Language :: Python :: 3.6',
58-
'Programming Language :: Python :: 3.7',
59-
'Framework :: Django',
31+
"Development Status :: 5 - Production/Stable",
32+
"Environment :: Web Environment",
33+
"Intended Audience :: Developers",
34+
"License :: OSI Approved :: BSD License",
35+
"Operating System :: OS Independent",
36+
"Programming Language :: Python",
37+
"Programming Language :: Python :: 3",
38+
"Programming Language :: Python :: 3.5",
39+
"Programming Language :: Python :: 3.6",
40+
"Programming Language :: Python :: 3.7",
41+
"Programming Language :: Python :: 3.8",
42+
"Framework :: Django",
6043
],
61-
install_requires=['django-appconf >= 0.4', 'six'],
44+
install_requires=["django-appconf >= 0.4"],
6245
)

tox.ini

+16-22
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,26 @@ skipsdist = True
33
usedevelop = True
44
minversion = 1.8
55
envlist =
6-
flake8-py{27,37},
7-
twine-check-py{27,37},
8-
py{27,35,36}-dj111
6+
flake8
7+
py{35,36}-dj111
98
py{35,36,37}-dj21
10-
py{35,36,37}-dj22
9+
py{35,36,37,38,39}-dj22
10+
11+
[gh-actions]
12+
python =
13+
3.5: py36
14+
3.6: py36
15+
3.7: py37
16+
3.8: py38, flake8
17+
3.9: py39
1118

1219
[testenv]
1320
basepython =
14-
py27: python2.7
1521
py35: python3.5
1622
py36: python3.6
1723
py37: python3.7
24+
py38: python3.8
25+
py39: python3.9
1826
usedevelop = true
1927
setenv =
2028
DJANGO_SETTINGS_MODULE = dbtemplates.test_settings
@@ -30,24 +38,10 @@ commands =
3038
python --version
3139
coverage run {envbindir}/django-admin.py test -v2 {posargs:dbtemplates}
3240
coverage report
41+
coverage xml
3342

34-
[testenv:twine-check-py27]
35-
commands =
36-
python setup.py sdist bdist_wheel
37-
twine check dist/*
38-
deps = twine
39-
40-
[testenv:twine-check-py37]
41-
commands =
42-
python setup.py sdist bdist_wheel
43-
twine check dist/*
44-
deps = twine
45-
46-
[testenv:flake8-py27]
47-
commands = flake8 dbtemplates
48-
deps = flake8
49-
50-
[testenv:flake8-py37]
43+
[testenv:flake8]
44+
basepython = python3.8
5145
commands = flake8 dbtemplates
5246
deps = flake8
5347

0 commit comments

Comments
 (0)