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. #607

Merged
merged 8 commits into from
Mar 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-push-notifications'
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-push-notifications/upload
56 changes: 56 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Test

on: [push, pull_request]

jobs:
build:
name: build (Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9']
django-version: ['2.2', '3.0', '3.1']
include:
- django-version: 'main'
python-version: '3.8'
- django-version: 'main'
python-version: '3.9'

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.cfg') }}-${{ 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
env:
DJANGO: ${{ matrix.django-version }}

- name: Upload coverage
uses: codecov/codecov-action@v1
with:
name: Python ${{ matrix.python-version }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ build
# tox
.tox
*.egg-info/
.eggs

# coverage
.coverage
coverage.xml
39 changes: 0 additions & 39 deletions .travis.yml

This file was deleted.

20 changes: 13 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
django-push-notifications
=========================
.. image:: https://travis-ci.org/jazzband/django-push-notifications.svg?branch=master
:target: https://travis-ci.org/jazzband/django-push-notifications

.. image:: https://jazzband.co/static/img/badge.svg
:target: https://jazzband.co/
:alt: Jazzband
:target: https://jazzband.co/
:alt: Jazzband

.. image:: https://github.com/jazzband/django-push-notifications/workflows/Test/badge.svg
:target: https://github.com/jazzband/django-push-notifications/actions
:alt: GitHub Actions

.. image:: https://codecov.io/gh/jazzband/django-push-notifications/branch/main/graph/badge.svg?token=PcC594rhI4
:target: https://codecov.io/gh/jazzband/django-push-notifications
:alt: Code coverage

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

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

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


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

Expand Down
10 changes: 7 additions & 3 deletions push_notifications/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import pkg_resources
try:
# Python 3.8+
import importlib.metadata as importlib_metadata
except ImportError:
# <Python 3.7 and lower
import importlib_metadata


__version__ = pkg_resources.require("django-push-notifications")[0].version
__version__ = importlib_metadata.version("django-push-notifications")
4 changes: 2 additions & 2 deletions push_notifications/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.apps import apps
from django.contrib import admin, messages
from django.utils.encoding import force_text
from django.utils.encoding import force_str
from django.utils.translation import gettext_lazy as _

from .apns import APNSServerError
Expand Down Expand Up @@ -45,7 +45,7 @@ def send_messages(self, request, queryset, bulk=False):
except APNSServerError as e:
errors.append(e.status)
except WebPushError as e:
errors.append(force_text(e))
errors.append(force_str(e))

if bulk:
break
Expand Down
2 changes: 1 addition & 1 deletion push_notifications/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django import forms
from django.core.validators import MaxValueValidator, MinValueValidator, RegexValidator
from django.db import connection, models
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _


__all__ = ["HexadecimalField", "HexIntegerField"]
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[build-system]
requires = ["setuptools>=30.3.0", "wheel", "setuptools_scm"]

[tool.pytest.ini_options]
minversion = "6.0"
addopts = "--cov push_notifications --cov-append --cov-branch --cov-report term-missing --cov-report=xml"
8 changes: 4 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[metadata]
name = django-push-notifications
version = 2.0.0
description = Send push notifications to mobile devices through GCM, APNS or WNS and to WebPush (Chrome, Firefox and Opera) in Django
author = Jerome Leclanche
author_email = jerome@leclan.ch
Expand All @@ -25,15 +24,16 @@ classifiers =
Topic :: System :: Networking

[options]
python_requires = >= 3.6
packages = find:
install_requires =
apns2>=0.3.0,<0.6.0;python_version<"3.5"
apns2>=0.3.0;python_version>="3.5"
importlib-metadata;python_version < "3.8"
pywebpush>=1.3.0
Django>=2.2
setup_requires =
setuptools_scm

[options.packages.find]
exclude = tests

[bdist_wheel]
universal = 1
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env python

from setuptools import setup


setup()
setup(use_scm_version={"version_scheme": "post-release"})
63 changes: 41 additions & 22 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,35 +1,54 @@
[tox]
skipsdist = True
usedevelop = true
envlist =
py{36,37,38,39}-django{22}-apns{030,060}
py{36,37,38,39}-django{30,31}-apns{030,060}
py37-flake8
py{36,37,38,39}-dj{22,30,31}-apns{030,060}
py{38,39}-djmain-apns{030,060}
flake8

[gh-actions]
python =
3.6: py36
3.7: py37
3.8: py38
3.9: py39, flake8

[gh-actions:env]
DJANGO =
2.2: dj22
3.0: dj30
3.1: dj31
main: djmain

[testenv]
usedevelop = true
setenv =
PYTHONWARNINGS = all
DJANGO_SETTINGS_MODULE = tests.settings
PYTHONPATH = {toxinidir}
PYTHONWARNINGS = all
DJANGO_SETTINGS_MODULE = tests.settings
PYTHONPATH = {toxinidir}
commands =
pytest
pytest --ds=tests.settings_unique tests/tst_unique.py
pytest
pytest --ds=tests.settings_unique tests/tst_unique.py
deps =
pytest
pytest-django
mock
pywebpush
djangorestframework==3.11.0
django22: Django>=2.2,<3.0
django30: Django>=3.0,<3.1
django31: Django>=3.1,<3.2
apns030: apns2>=0.3.0,<0.6.0
apns060: apns2>=0.6.0
pytest
pytest-cov
pytest-django
mock
pywebpush
djangorestframework==3.11.0
dj22: Django>=2.2,<3.0
dj30: Django>=3.0,<3.1
dj31: Django>=3.1,<3.2
djmain: https://github.com/django/django/archive/main.tar.gz
apns030: apns2>=0.3.0,<0.6.0
apns060: apns2>=0.6.0

[testenv:py37-flake8]
[testenv:flake8]
commands = flake8 --exit-zero
deps =
flake8==3.5.0
flake8-isort
flake8-quotes
flake8==3.5.0
flake8-isort
flake8-quotes

[flake8]
ignore = W191,E503
Expand Down