Skip to content

Commit

Permalink
Merge pull request #72 from jazzband/gha
Browse files Browse the repository at this point in the history
Migrate to GitHub Actions
  • Loading branch information
jezdez authored Nov 26, 2020
2 parents 6c82e3d + 28b6e4c commit bcb3216
Show file tree
Hide file tree
Showing 9 changed files with 137 additions and 33 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Release

on:
push:
tags:
- '*'

jobs:
build:
if: github.repository == 'jazzband/django-authority'
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: 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: release-${{ hashFiles('**/setup.py') }}
restore-keys: |
release-
- 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-authority/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: ['2.7', '3.6', '3.7', '3.8']

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') }}
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 }}
24 changes: 0 additions & 24 deletions .travis.yml

This file was deleted.

12 changes: 10 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ django-authority
:target: https://jazzband.co/
:alt: Jazzband

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

.. image:: https://codecov.io/gh/jazzband/django-authority/branch/master/graph/badge.svg
:target: https://codecov.io/gh/jazzband/django-authority
Expand Down Expand Up @@ -57,6 +58,13 @@ html version using the setup.py::
Changelog:
==========

0.15 (unreleased):
------------------

* Moved CI to GitHub Actions.
* Add Django 3.0 and 3.1 support.
* Add Python 3.6 and 3.8 support.

0.14 (2020-02-07):
------------------

Expand Down
4 changes: 2 additions & 2 deletions authority/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django import forms
from django.http import HttpResponseRedirect
from django.utils.translation import ugettext, ungettext, ugettext_lazy as _
from django.shortcuts import render_to_response
from django.shortcuts import render
from django.utils.safestring import mark_safe
from django.forms.formsets import all_valid
from django.contrib import admin
Expand Down Expand Up @@ -127,7 +127,7 @@ def edit_permissions(modeladmin, request, queryset):
"admin/permission_change_form.html",
],
)
return render_to_response(template_name, context, request)
return render(request, template_name, context)


edit_permissions.short_description = _(
Expand Down
11 changes: 8 additions & 3 deletions authority/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from django.http import HttpResponseRedirect
from django.utils.http import urlquote
from django.utils.functional import wraps
from django.utils.six import string_types
from django.db.models import Model
from django.apps import apps
from django.shortcuts import get_object_or_404
Expand All @@ -13,6 +12,12 @@
from authority.views import permission_denied


try:
basestring
except NameError:
basestring = str


def permission_required(perm, *lookup_variables, **kwargs):
"""
Decorator for views that checks whether a user has a particular permission
Expand All @@ -27,7 +32,7 @@ def decorated(request, *args, **kwargs):
if request.user.is_authenticated:
params = []
for lookup_variable in lookup_variables:
if isinstance(lookup_variable, string_types):
if isinstance(lookup_variable, basestring):
value = kwargs.get(lookup_variable, None)
if value is None:
continue
Expand All @@ -37,7 +42,7 @@ def decorated(request, *args, **kwargs):
value = kwargs.get(varname, None)
if value is None:
continue
if isinstance(model, string_types):
if isinstance(model, basestring):
model_class = apps.get_model(*model.split("."))
else:
model_class = model
Expand Down
4 changes: 2 additions & 2 deletions authority/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.shortcuts import render_to_response, get_object_or_404
from django.shortcuts import render, get_object_or_404
from django.http import HttpResponseRedirect, HttpResponseForbidden
from django.apps import apps
from django.utils.translation import ugettext as _
Expand Down Expand Up @@ -78,7 +78,7 @@ def add_permission(
}
if extra_context:
context.update(extra_context)
return render_to_response(template_name, context, request)
return render(request, template_name, context)


@login_required
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ def read(fname):
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Framework :: Django",
],
install_requires=["django"],
Expand Down
12 changes: 12 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@ minversion = 1.8
envlist =
py27-dj111
py37-dj{111,22}
{py36,py37,py38}-dj{30,31}
py37-check

[testenv]
usedevelop = true
commands =
coverage run -a example/manage.py test authority exampleapp
coverage report
coverage xml
deps =
coverage
dj111: Django>=1.11,<2.0
dj22: Django>=2.2,<2.3
dj30: Django>=3.0,<3.1
dj31: Django>=3.1,<3.2


[testenv:py37-check]
Expand All @@ -25,3 +29,11 @@ deps =
commands =
python setup.py sdist bdist_wheel
twine check dist/*


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

0 comments on commit bcb3216

Please sign in to comment.