Skip to content

Commit ce2140f

Browse files
authored
Migrate to GitHub Actions. (jazzband#607)
* Migrate to GitHub Actions. * Use importlib for __version__. * Add release workflow. * Remove Travis config. * Update badges. * Update Python requirements. * Fix ImportError on Django main. * More Django main fixes.
1 parent f2490ba commit ce2140f

File tree

12 files changed

+176
-81
lines changed

12 files changed

+176
-81
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-push-notifications'
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-push-notifications/upload

.github/workflows/test.yml

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

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,8 @@ build
1616
# tox
1717
.tox
1818
*.egg-info/
19+
.eggs
20+
21+
# coverage
22+
.coverage
23+
coverage.xml

.travis.yml

-39
This file was deleted.

README.rst

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
django-push-notifications
22
=========================
3-
.. image:: https://travis-ci.org/jazzband/django-push-notifications.svg?branch=master
4-
:target: https://travis-ci.org/jazzband/django-push-notifications
53

64
.. image:: https://jazzband.co/static/img/badge.svg
7-
:target: https://jazzband.co/
8-
:alt: Jazzband
5+
:target: https://jazzband.co/
6+
:alt: Jazzband
7+
8+
.. image:: https://github.com/jazzband/django-push-notifications/workflows/Test/badge.svg
9+
:target: https://github.com/jazzband/django-push-notifications/actions
10+
:alt: GitHub Actions
11+
12+
.. image:: https://codecov.io/gh/jazzband/django-push-notifications/branch/main/graph/badge.svg?token=PcC594rhI4
13+
:target: https://codecov.io/gh/jazzband/django-push-notifications
14+
:alt: Code coverage
915

1016
A minimal Django app that implements Device models that can send messages through APNS, FCM/GCM and WNS.
1117

@@ -25,8 +31,8 @@ UPDATE_ON_DUPLICATE_REG_ID: Transform create of an existing Device (based on reg
2531

2632
Dependencies
2733
------------
28-
- Python 3.5+
29-
- Django 1.11+
34+
- Python 3.6+
35+
- Django 2.2+
3036
- For the API module, Django REST Framework 3.7+ is required.
3137
- For WebPush (WP), pywebpush 1.3.0+ is required. py-vapid 1.3.0+ is required for generating the WebPush private key; however this
3238
step does not need to occur on the application server.
@@ -66,7 +72,7 @@ Edit your settings.py file:
6672
.. note::
6773
If you are planning on running your project with ``APNS_USE_SANDBOX=True``, then make sure you have set the
6874
*development* certificate as your ``APNS_CERTIFICATE``. Otherwise the app will not be able to connect to the correct host. See settings_ for details.
69-
75+
7076

7177
For more information about how to generate certificates, see `docs/APNS <https://github.com/jazzband/django-push-notifications/blob/master/docs/APNS.rst>`_.
7278

push_notifications/__init__.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import pkg_resources
1+
try:
2+
# Python 3.8+
3+
import importlib.metadata as importlib_metadata
4+
except ImportError:
5+
# <Python 3.7 and lower
6+
import importlib_metadata
27

3-
4-
__version__ = pkg_resources.require("django-push-notifications")[0].version
8+
__version__ = importlib_metadata.version("django-push-notifications")

push_notifications/admin.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from django.apps import apps
22
from django.contrib import admin, messages
3-
from django.utils.encoding import force_text
3+
from django.utils.encoding import force_str
44
from django.utils.translation import gettext_lazy as _
55

66
from .apns import APNSServerError
@@ -45,7 +45,7 @@ def send_messages(self, request, queryset, bulk=False):
4545
except APNSServerError as e:
4646
errors.append(e.status)
4747
except WebPushError as e:
48-
errors.append(force_text(e))
48+
errors.append(force_str(e))
4949

5050
if bulk:
5151
break

push_notifications/fields.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from django import forms
55
from django.core.validators import MaxValueValidator, MinValueValidator, RegexValidator
66
from django.db import connection, models
7-
from django.utils.translation import ugettext_lazy as _
7+
from django.utils.translation import gettext_lazy as _
88

99

1010
__all__ = ["HexadecimalField", "HexIntegerField"]

pyproject.toml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[build-system]
2+
requires = ["setuptools>=30.3.0", "wheel", "setuptools_scm"]
3+
4+
[tool.pytest.ini_options]
5+
minversion = "6.0"
6+
addopts = "--cov push_notifications --cov-append --cov-branch --cov-report term-missing --cov-report=xml"

setup.cfg

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[metadata]
22
name = django-push-notifications
3-
version = 2.0.0
43
description = Send push notifications to mobile devices through GCM, APNS or WNS and to WebPush (Chrome, Firefox and Opera) in Django
54
author = Jerome Leclanche
65
author_email = [email protected]
@@ -25,15 +24,16 @@ classifiers =
2524
Topic :: System :: Networking
2625

2726
[options]
27+
python_requires = >= 3.6
2828
packages = find:
2929
install_requires =
3030
apns2>=0.3.0,<0.6.0;python_version<"3.5"
3131
apns2>=0.3.0;python_version>="3.5"
32+
importlib-metadata;python_version < "3.8"
3233
pywebpush>=1.3.0
3334
Django>=2.2
35+
setup_requires =
36+
setuptools_scm
3437

3538
[options.packages.find]
3639
exclude = tests
37-
38-
[bdist_wheel]
39-
universal = 1

setup.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#!/usr/bin/env python
2-
32
from setuptools import setup
43

5-
6-
setup()
4+
setup(use_scm_version={"version_scheme": "post-release"})

tox.ini

+41-22
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,54 @@
11
[tox]
2+
skipsdist = True
3+
usedevelop = true
24
envlist =
3-
py{36,37,38,39}-django{22}-apns{030,060}
4-
py{36,37,38,39}-django{30,31}-apns{030,060}
5-
py37-flake8
5+
py{36,37,38,39}-dj{22,30,31}-apns{030,060}
6+
py{38,39}-djmain-apns{030,060}
7+
flake8
8+
9+
[gh-actions]
10+
python =
11+
3.6: py36
12+
3.7: py37
13+
3.8: py38
14+
3.9: py39, flake8
15+
16+
[gh-actions:env]
17+
DJANGO =
18+
2.2: dj22
19+
3.0: dj30
20+
3.1: dj31
21+
main: djmain
622

723
[testenv]
24+
usedevelop = true
825
setenv =
9-
PYTHONWARNINGS = all
10-
DJANGO_SETTINGS_MODULE = tests.settings
11-
PYTHONPATH = {toxinidir}
26+
PYTHONWARNINGS = all
27+
DJANGO_SETTINGS_MODULE = tests.settings
28+
PYTHONPATH = {toxinidir}
1229
commands =
13-
pytest
14-
pytest --ds=tests.settings_unique tests/tst_unique.py
30+
pytest
31+
pytest --ds=tests.settings_unique tests/tst_unique.py
1532
deps =
16-
pytest
17-
pytest-django
18-
mock
19-
pywebpush
20-
djangorestframework==3.11.0
21-
django22: Django>=2.2,<3.0
22-
django30: Django>=3.0,<3.1
23-
django31: Django>=3.1,<3.2
24-
apns030: apns2>=0.3.0,<0.6.0
25-
apns060: apns2>=0.6.0
33+
pytest
34+
pytest-cov
35+
pytest-django
36+
mock
37+
pywebpush
38+
djangorestframework==3.11.0
39+
dj22: Django>=2.2,<3.0
40+
dj30: Django>=3.0,<3.1
41+
dj31: Django>=3.1,<3.2
42+
djmain: https://github.com/django/django/archive/main.tar.gz
43+
apns030: apns2>=0.3.0,<0.6.0
44+
apns060: apns2>=0.6.0
2645

27-
[testenv:py37-flake8]
46+
[testenv:flake8]
2847
commands = flake8 --exit-zero
2948
deps =
30-
flake8==3.5.0
31-
flake8-isort
32-
flake8-quotes
49+
flake8==3.5.0
50+
flake8-isort
51+
flake8-quotes
3352

3453
[flake8]
3554
ignore = W191,E503

0 commit comments

Comments
 (0)