Skip to content

Commit

Permalink
Merge pull request #69 from cfpb/wagtail30
Browse files Browse the repository at this point in the history
Update for Wagtail 3.0
  • Loading branch information
willbarton authored Jul 8, 2022
2 parents 38e4ab9 + 40c7806 commit 0e274ee
Show file tree
Hide file tree
Showing 18 changed files with 230 additions and 155 deletions.
79 changes: 55 additions & 24 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ jobs:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: 3.9
python-version: "3.10"

- name: Install dependencies
run: |
Expand All @@ -32,30 +32,29 @@ jobs:
strategy:
matrix:
toxenv:
- py36-dj22-wag211
- py36-dj22-waglatest
- py39-dj22-wag211
- py39-dj22-waglatest
- py39-dj32-waglatest
# Legacy versions
- py39-dj32-wag215

# Current and latest versions
- py310-dj32-wag30
- py310-dj40-wag30
- py310-dj40-waglatest

include:
- toxenv: py36-dj22-wag211
python-version: 3.6
- toxenv: py36-dj22-waglatest
python-version: 3.6
- toxenv: py39-dj22-waglatest
python-version: 3.9
- toxenv: py39-dj22-wag211
python-version: 3.9
- toxenv: py39-dj22-waglatest
python-version: 3.9
- toxenv: py39-dj32-waglatest
python-version: 3.9
- toxenv: py39-dj32-wag215
python-version: "3.9"
- toxenv: py310-dj32-wag30
python-version: "3.10"
- toxenv: py310-dj40-wag30
python-version: "3.10"
- toxenv: py310-dj40-waglatest
python-version: "3.10"

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -67,7 +66,39 @@ jobs:
- name: Run tox
run: |
tox
coveralls
env:
TOXENV: ${{ matrix.toxenv }}
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}

- name: Store test coverage
uses: actions/upload-artifact@v2
with:
name: coverage
path: .coverage.*

coverage:
name: coverage
runs-on: ubuntu-latest
needs:
- test

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox
- name: Retrieve test coverage
uses: actions/download-artifact@v2
with:
name: coverage

- name: Check coverage
run: tox -e coverage
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ __pycache__/
#################
htmlcov/
.tox/
.coverage
.coverage*
.cache
nosetests.xml
coverage.xml
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Coverage Status](https://coveralls.io/repos/github/cfpb/wagtail-flags/badge.svg?branch=master)](https://coveralls.io/github/cfpb/wagtail-flags?branch=master)
[![Ethical open source](https://img.shields.io/badge/open-ethical-%234baaaa)](https://ethicalsource.dev/definition/)

Feature flags allow you to toggle functionality based on configurable conditions.
Feature flags allow you to toggle functionality based on configurable conditions.

Wagtail-Flags adds a Wagtail admin UI and Wagtail Site-based condition on top of [Django-Flags](https://github.com/cfpb/django-flags). For a more complete overview of feature flags and how to use them, please see the [Django-Flags documentation](https://cfpb.github.io/django-flags).

Expand All @@ -23,9 +23,9 @@ Wagtail-Flags adds a Wagtail admin UI and Wagtail Site-based condition on top of
## Dependencies

- Python 3.6+
- Django 2.2 (LTS), 3.1 (current)
- Django-Flags 4.2
- Wagtail 2.11 (LTS), <3
- Django 3.2 (LTS), 4.0 (current)
- Django-Flags 4.2
- Wagtail 2.15 (LTS), 3.0

It should be compatible at all intermediate versions, as well.
If you find that it is not, please [file an issue](https://github.com/cfpb/wagtail-flags/issues/new).
Expand Down Expand Up @@ -70,7 +70,7 @@ Then use the flag in a Django template (`mytemplate.html`):
{% if my_flag %}
<div class="flagged-banner">
I’m the result of a feature flag.
I’m the result of a feature flag.
</div>
{% endif %}
```
Expand Down
23 changes: 5 additions & 18 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,9 @@ exclude = '''
)
'''

[tool.isort]
profile = "black"
line_length = 79
lines_after_imports = 2
skip = [".tox", "migrations", ".venv", "venv"]
known_django = ["django"]
known_wagtail = ["wagtail"]
default_section = "THIRDPARTY"
sections = [
"STDLIB",
"DJANGO",
"WAGTAIL",
"THIRDPARTY",
"FIRSTPARTY",
"LOCALFOLDER"
]

[build-system]
requires = ["setuptools", "wheel"]
requires = [
"setuptools>=42",
"wheel"
]
build-backend = "setuptools.build_meta"
76 changes: 76 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
[metadata]
name = wagtail-flags
version = 5.2.0
author = CFPB
author_email = [email protected]
description = Feature flags for Wagtail sites
long_description = file: README.md
long_description_content_type = text/markdown
license = CC0
url = https://github.com/cfpb/wagtail-flags
classifiers =
Operating System :: OS Independent
Framework :: Django
Framework :: Django :: 3.2
Framework :: Django :: 4.0
Framework :: Wagtail
Framework :: Wagtail :: 2
Framework :: Wagtail :: 3
License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
License :: Public Domain
Programming Language :: Python
Programming Language :: Python :: 3

[options]
include_package_data = True
packages = find:
python_requires = >=3.8
zip_safe = False
install_requires =
wagtail>=2.15,<4
django-flags>=4.2,<5.1

[options.extras_require]
testing =
coverage

[flake8]
ignore = E731,W503,W504
exclude =
.git,
.tox,
__pycache__,
*/migrations/*.py,
.eggs/*,

[isort]
profile = black
combine_as_imports = 1
lines_after_imports = 2
include_trailing_comma = 1
multi_line_output = 3
skip = .tox,migrations
known_django = django
known_wagtail = wagtail
default_section = THIRDPARTY
sections = FUTURE,STDLIB,DJANGO,WAGTAIL,THIRDPARTY,FIRSTPARTY,LOCALFOLDER

[mypy]
allow_redefinition = false
check_untyped_defs = true
disallow_untyped_decorators = true
disallow_any_explicit = true
disallow_any_generics = true
disallow_untyped_calls = true
ignore_errors = false
ignore_missing_imports = true
implicit_reexport = false
local_partial_types = true
strict_optional = true
strict_equality = true
no_implicit_optional = true
warn_unused_ignores = true
warn_redundant_casts = true
warn_unused_configs = true
warn_unreachable = true
warn_no_return = true
38 changes: 3 additions & 35 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,4 @@
from setuptools import find_packages, setup
from setuptools import setup

install_requires = [
"wagtail>=2.11,<3",
"django-flags>=4.2,<5.1",
]

testing_extras = ["coverage>=3.7.0"]

setup(
name="wagtail-flags",
url="https://github.com/cfpb/wagtail-flags",
author="CFPB",
author_email="[email protected]",
description="Feature flags for Wagtail sites",
long_description=open("README.md", "r", encoding="utf-8").read(),
long_description_content_type="text/markdown",
license="CC0",
version="5.1.0",
include_package_data=True,
packages=find_packages(),
python_requires=">=3.6",
install_requires=install_requires,
extras_require={"testing": testing_extras},
classifiers=[
"Framework :: Django",
"Framework :: Django :: 2.2",
"Framework :: Django :: 3.1",
"Framework :: Wagtail",
"Framework :: Wagtail :: 2",
"License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication",
"License :: Public Domain",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
],
)
if __name__ == '__main__':
setup()
56 changes: 22 additions & 34 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,45 @@
skipsdist=True
envlist=
lint,
py{36}-dj{22}-wag{211,latest},
py{39}-dj{22}-wag{211},
py{39}-dj{22,32}-wag{latest}
py{39,310}-dj{32}-wag{215},
py{39,310}-dj{32,40}-wag{30,latest},
coverage

[testenv]
install_command=pip install -e ".[testing]" -U {opts} {packages}
commands=
coverage erase
coverage run --source='wagtailflags' {envbindir}/django-admin.py test {posargs}
coverage report -m
python -b -m coverage run --parallel-mode --source='wagtailflags' {envbindir}/django-admin test {posargs}
setenv=
DJANGO_SETTINGS_MODULE=wagtailflags.tests.settings

basepython=
py36: python3.6
py39: python3.9
py39: python3.9
py310: python3.10

deps=
dj22: Django>=2.2,<2.3
dj32: Django>=3.2,<3.3
wag211: wagtail>=2.11,<2.12
waglatest: wagtail<3
dj40: Django>=4.0,<4.1
wag215: wagtail>=2.15,<2.16
wag30: wagtail>=3.0,<3.1
waglatest: wagtail<4

[testenv:lint]
basepython=python3.9
basepython=python3.10
deps=
black
flake8
isort
commands=
black --check wagtailflags setup.py
flake8 wagtailflags setup.py
black --check wagtailflags
flake8 wagtailflags
isort --check-only --diff wagtailflags

[flake8]
ignore=E731,W503,W504
exclude=
.git,
.tox,
__pycache__,
*/migrations/*.py,
.eggs/*,

[isort]
combine_as_imports=1
lines_after_imports=2
include_trailing_comma=1
multi_line_output=3
skip=.tox,migrations
use_parentheses=1
known_django=django
known_wagtail=wagtail
default_section=THIRDPARTY
sections=FUTURE,STDLIB,DJANGO,WAGTAIL,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
[testenv:coverage]
basepython=python3.10
deps=
coverage
diff_cover
commands=
coverage combine
coverage xml
diff-cover coverage.xml --compare-branch=origin/main --fail-under=100
1 change: 0 additions & 1 deletion wagtailflags/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = "wagtailflags.apps.WagtailFlagsAppConfig"
4 changes: 2 additions & 2 deletions wagtailflags/signals.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.dispatch import Signal


flag_disabled = Signal(providing_args=["instance", "flag_name"])
flag_enabled = Signal(providing_args=["instance", "flag_name"])
flag_disabled = Signal()
flag_enabled = Signal()
4 changes: 2 additions & 2 deletions wagtailflags/templates/wagtailflags/flags/create_flag.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "wagtailadmin/base.html" %}
{% load i18n %}
{% load i18n wagtailadmin_tags %}
{% block titletag %}Create a flag{% endblock %}

{% block content %}
Expand Down Expand Up @@ -31,7 +31,7 @@ <h2 class="nice-padding">
</li>
<li class="actions">
<input class="button action-save button-longrunning" type="submit" value="Save flag" />
<a class="button bicolor icon icon-cog" href="{% url 'wagtailflags:list' %}">Back to flags</a>
<a class="button bicolor button--icon" href="{% url 'wagtailflags:list' %}">{% icon name="cog" wrapped=1 %} Back to flags</a>
</li>
</ul>
</form>
Expand Down
Loading

0 comments on commit 0e274ee

Please sign in to comment.