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

Merged
merged 7 commits into from
Mar 22, 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
6 changes: 6 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[run]
source = menu
branch = 1

[report]
omit = *migrations*,.tox/*,setup.py,*settings.py
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-simple-menu'
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-simple-menu/upload
51 changes: 51 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
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', 'main']

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

- name: Upload coverage
uses: codecov/codecov-action@v1
with:
name: Python ${{ matrix.python-version }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ docs/_build/

# example db
example/example.sqlite3

coverage.xml
.coverage
.tox
54 changes: 0 additions & 54 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
django-simple-menu was initially developed by Evan Borgstom.

See https://github.com/borgstrom/django-simple-menu/graphs/contributors for the full list of
See https://github.com/jazzband/django-simple-menu/graphs/contributors for the full list of
contributors to the code base.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
django-simple-menu changelog
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Version 2.0.0 - Released ...
- Dropped support for Django < 2.2
- Dropped support for Python < 3.6

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obviously this is quite the step, but the old Python and Django versions aren't really supported anymore and we should use the oppurtunity to make the jump.

Version 1.2.1 - Released May 1st, 2016
- Fixing sdist packaging

Expand Down
14 changes: 8 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
Simple Django Menus
===================

.. image:: https://img.shields.io/travis/borgstrom/django-simple-menu.svg
:target: https://travis-ci.org/borgstrom/django-simple-menu
.. image:: https://github.com/jazzband/django-simple-menu/workflows/Test/badge.svg
:target: https://github.com/jazzband/django-simple-menu/actions
:alt: GitHub Actions

.. image:: https://img.shields.io/codecov/c/github/borgstrom/django-simple-menu.svg
:target: https://codecov.io/github/borgstrom/django-simple-menu
.. image:: https://img.shields.io/codecov/c/github/jazzband/django-simple-menu.svg
:target: https://codecov.io/github/jazzband/django-simple-menu

.. image:: https://img.shields.io/pypi/v/django-simple-menu.svg
:target: https://pypi.python.org/pypi/django-simple-menu
Expand Down Expand Up @@ -42,7 +43,7 @@ over this ``menus`` object to render your menus.
To quickly see everything in action and evaluate django-simple-menut please check out the
`example project`_.

.. _example project: https://github.com/borgstrom/django-simple-menu/tree/master/example
.. _example project: https://github.com/jazzband/django-simple-menu/tree/master/example


Documentation
Expand All @@ -56,4 +57,5 @@ https://django-simple-menu.readthedocs.org
Requirements
------------

Django 1.6+
Django 2.2+
Python 3.6+
2 changes: 1 addition & 1 deletion docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -175,5 +175,5 @@ This assumes you have a ``utils`` package.
children=reports_children))


.. _menu __init__.py source file: https://github.com/borgstrom/django-simple-menu/blob/master/menu/__init__.py
.. _menu __init__.py source file: https://github.com/jazzband/django-simple-menu/blob/master/menu/__init__.py
.. _Twitter Bootstrap Navbar Component: http://twitter.github.com/bootstrap/components.html#navbar
12 changes: 9 additions & 3 deletions menu/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
from .menu import Menu, MenuItem
from pkg_resources import get_distribution, DistributionNotFound
from .menu import Menu, MenuItem # noqa

__version__ = '1.2.1'
__url__ = 'https://github.com/borgstrom/django-simple-menu'
try:
__version__ = get_distribution("django-simple-menu").version
except DistributionNotFound:
# package is not installed
__version__ = None

__url__ = 'https://github.com/jazzband/django-simple-menu'
26 changes: 8 additions & 18 deletions menu/menu.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import copy
import re
import sys

from django.apps import apps
from django.conf import settings
from django.utils.text import slugify

try:
from django.apps import apps
except ImportError:
apps = False


class Menu(object):
class Menu:
"""
Menu is a class that generates menus

Expand Down Expand Up @@ -56,12 +51,10 @@ def load_menus(c):
return

# Fetch all installed app names
app_names = settings.INSTALLED_APPS
if apps:
app_names = [
app_config.name
for app_config in apps.get_app_configs()
]
app_names = [
app_config.name
for app_config in apps.get_app_configs()
]

# loop through our INSTALLED_APPS
for app in app_names:
Expand Down Expand Up @@ -143,7 +136,7 @@ def is_child_selected(item):
return visible


class MenuItem(object):
class MenuItem:
"""
MenuItem represents an item in a menu, possibly one that has a sub-menu (children).
"""
Expand Down Expand Up @@ -209,10 +202,7 @@ def process(self, request):
if self.slug is None:
# in python3 we don't need to convert to unicode, in python2 slugify
# requires a unicode string
if sys.version_info > (3, 0):
self.slug = slugify(self.title)
else:
self.slug = slugify(unicode(self.title))
self.slug = slugify(self.title)

# evaluate children
if callable(self.children):
Expand Down
37 changes: 24 additions & 13 deletions menu/test_settings.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,35 @@
import os

TEST_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'tests')
TEST_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), "tests")

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:',
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": ":memory:",
}
}

INSTALLED_APPS = [
'menu'
]

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(TEST_DIR, 'static')
INSTALLED_APPS = ["menu"]

TEMPLATE_DIRS = (
os.path.join(TEST_DIR, 'test_templates'),
)
STATIC_URL = "/static/"
STATIC_ROOT = os.path.join(TEST_DIR, "static")

SECRET_KEY = "testing-menus-is-so-much-fun"

TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [
os.path.join(TEST_DIR, "test_templates"),
],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
},
]
12 changes: 3 additions & 9 deletions menu/tests/test_menu.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import signal
import threading
import unittest
import sys

if sys.version_info > (3, 0):
from queue import Queue
else:
from Queue import Queue
from queue import Queue

from django.conf import settings
from django.template import Template, Context
Expand Down Expand Up @@ -54,10 +48,10 @@ def kids2_2_check(request):
# Ensure we can pass children as tuples (or other iterables, like generators)
# Following the implementation of sorted children there was a bug reported due to children
# being passed as a tuple, which has no .sort method
# See: https://github.com/borgstrom/django-simple-menu/issues/38
# See: https://github.com/jazzband/django-simple-menu/issues/38
def kids2():
"Generator for kids2"
class RepeatIterator(object):
class RepeatIterator:
"We need this to be reusable -- http://stackoverflow.com/a/1985733"
def __iter__(self):
yield MenuItem("kids2-1", "/parent2/kids2-1", weight=999)
Expand Down
Loading