diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3677496..94954db 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,26 +1,28 @@ name: Publish to PyPI -on: +on: release: types: [published] + workflow_dispatch: + jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - name: Set up Python - uses: actions/setup-python@v1 + uses: actions/setup-python@v4 with: - python-version: 3.7 + python-version: 3.11 - name: Install dependencies run: | - python -m pip install --upgrade pip + python -m pip install --upgrade pip build pip install twine wheel - name: Build the package run: | - python setup.py sdist bdist_wheel --universal + python -m build - name: Upload to PyPI run: twine upload dist/* - env: + env: TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d4b923d..153a046 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.8" - name: Install dependencies run: | @@ -32,23 +32,20 @@ jobs: strategy: matrix: toxenv: - # Legacy versions - - py39-dj32-wag215 - - # Current and latest versions - - py310-dj32-wag30 - - py310-dj40-wag30 - - py310-dj40-waglatest + - py38-dj3-wag4 + - py38-dj4-wag4 + - py38-dj3-waglatest + - py38-dj4-waglatest include: - - 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" + - toxenv: py38-dj3-wag4 + python-version: 3.8 + - toxenv: py38-dj4-wag4 + python-version: 3.8 + - toxenv: py38-dj3-waglatest + python-version: 3.8 + - toxenv: py38-dj4-waglatest + python-version: 3.8 steps: - uses: actions/checkout@v3 @@ -89,7 +86,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.8" - name: Install dependencies run: | diff --git a/.gitignore b/.gitignore index 9f36985..429da40 100644 --- a/.gitignore +++ b/.gitignore @@ -73,3 +73,4 @@ dist/ # IDEs .idea/ +*.db diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b7efd01..d00e5b8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,11 +5,10 @@ repos: - id: black args: ["wagtailflags", "setup.py", "--line-length=79"] exclude: migrations -- repo: https://gitlab.com/pycqa/flake8 - rev: 4.0.1 +- repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.0.188 hooks: - - id: flake8 - additional_dependencies: [flake8-bugbear==22.1.11] + - id: ruff - repo: https://github.com/pycqa/isort rev: 5.10.1 hooks: diff --git a/README.md b/README.md index 202c7bb..d982b20 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # Wagtail-Flags [![Build Status](https://github.com/cfpb/wagtail-flags/workflows/test/badge.svg)](https://github.com/cfpb/wagtail-flags/actions?query=workflow%3Atest) -[![Coverage Status](https://coveralls.io/repos/github/cfpb/wagtail-flags/badge.svg?branch=main)](https://coveralls.io/github/cfpb/wagtail-flags?branch=main) [![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. @@ -22,10 +21,10 @@ Wagtail-Flags adds a Wagtail admin UI and Wagtail Site-based condition on top of ## Dependencies -- Python 3.6+ -- Django 3.2 (LTS), 4.0 (current) +- Python 3.8+ +- Django 3.2 (LTS)+ - Django-Flags 4.2 -- Wagtail 2.15 (LTS), 3.0 +- Wagtail 4.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). diff --git a/pyproject.toml b/pyproject.toml index d237113..3641b94 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,54 @@ +[project] +name = "wagtail-flags" +version = "5.3.0" +description = "Feature flags for Wagtail sites" +readme = "README.md" +requires-python = ">=3.8" +license = {text = "CC0"} +authors = [ + {name = "CFPB", email = "tech@cfpb.gov" } +] +dependencies = [ + "wagtail>=4", + "django-flags>4.2" +] +classifiers = [ + "Framework :: Django", + "Framework :: Django :: 3.2", + "Framework :: Django :: 4", + "Framework :: Wagtail", + "Framework :: Wagtail :: 4", + "License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication", + "License :: Public Domain", + "Programming Language :: Python", + "Programming Language :: Python :: 3", +] + +[project.optional-dependencies] +testing = [ + "coverage[toml]", +] + +[project.urls] +"Homepage" = "https://github.com/cfpb/wagtail-flags" +"Bug Reports" = "https://github.com/cfpb/wagtail-flags/issues" +"Source" = "https://github.com/cfpb/wagtail-flags" + +[build-system] +requires = ["setuptools>=43.0.0", "wheel"] +build-backend = "setuptools.build_meta" + +[tool.setuptools.package-data] +wagtailflags = [ + "templates/wagtailflags/*", + "templates/wagtailflags/flags/*", + "templates/wagtailflags/includes/*", + "static/wagtailflags/css/*", +] + [tool.black] line-length = 79 -target-version = ['py36', 'py38'] +target-version = ["py38"] include = '\.pyi?$' exclude = ''' ( @@ -14,15 +62,41 @@ exclude = ''' | dist | migrations | site - | \*.json - | \*.csv )/ ) ''' -[build-system] -requires = [ - "setuptools>=42", - "wheel" +[tool.isort] +profile = "black" +line_length = 79 +lines_after_imports = 2 +skip = [".tox", ".venv", "venv"] +known_django = ["django"] +known_wagtail = ["wagtail"] +default_section = "THIRDPARTY" +sections = [ + "STDLIB", + "DJANGO", + "WAGTAIL", + "THIRDPARTY", + "FIRSTPARTY", + "LOCALFOLDER" +] + +[tool.ruff] +exclude = [ + ".git", + ".tox", + "__pycache__", +] +ignore = [] +select = [ + "E", + "F", + "W", +] + +[tool.coverage.run] +omit = [ + "wagtailflags/tests/*", ] -build-backend = "setuptools.build_meta" diff --git a/screenshot_create.png b/screenshot_create.png index 440dff9..340be3f 100644 Binary files a/screenshot_create.png and b/screenshot_create.png differ diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index b2edf83..0000000 --- a/setup.cfg +++ /dev/null @@ -1,76 +0,0 @@ -[metadata] -name = wagtail-flags -version = 5.2.0 -author = CFPB -author_email = tech@cfpb.gov -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 diff --git a/setup.py b/setup.py index 6b40b52..26e08e4 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ from setuptools import setup -if __name__ == '__main__': + +if __name__ == "__main__": setup() diff --git a/tox.ini b/tox.ini index 0bc1cb8..9167ca4 100644 --- a/tox.ini +++ b/tox.ini @@ -2,8 +2,7 @@ skipsdist=True envlist= lint, - py{39,310}-dj{32}-wag{215}, - py{39,310}-dj{32,40}-wag{30,latest}, + py{38,311}-dj{3,4}-wag{4,latest}, coverage [testenv] @@ -14,29 +13,28 @@ setenv= DJANGO_SETTINGS_MODULE=wagtailflags.tests.settings basepython= - py39: python3.9 - py310: python3.10 + py38: python3.8 + py311: python3.11 deps= - dj32: Django>=3.2,<3.3 - dj40: Django>=4.0,<4.1 - wag215: wagtail>=2.15,<2.16 - wag30: wagtail>=3.0,<3.1 - waglatest: wagtail<4 + dj3: Django>=3.2,<4 + dj4: Django>=4.1,<5 + wag4: wagtail>=4,<5 + waglatest: wagtail>4 [testenv:lint] -basepython=python3.10 +basepython=python3.8 deps= black - flake8 + ruff isort commands= black --check wagtailflags - flake8 wagtailflags + ruff wagtailflags isort --check-only --diff wagtailflags [testenv:coverage] -basepython=python3.10 +basepython=python3.8 deps= coverage diff_cover @@ -44,3 +42,21 @@ commands= coverage combine coverage xml diff-cover coverage.xml --compare-branch=origin/main --fail-under=100 + +[testenv:interactive] +basepython=python3.8 + +deps= + Django>=3.2,<3.3 + +commands_pre= + {envbindir}/django-admin makemigrations + {envbindir}/django-admin migrate + {envbindir}/django-admin shell -c "from django.contrib.auth.models import User;(not User.objects.filter(username='admin').exists()) and User.objects.create_superuser('admin', 'super@example.com', 'changeme')" + +commands= + {posargs:{envbindir}/django-admin runserver 0.0.0.0:8000} + +setenv= + DJANGO_SETTINGS_MODULE=wagtailflags.tests.settings + INTERACTIVE=1 diff --git a/wagtailflags.gif b/wagtailflags.gif index eccadb2..1bbeb89 100644 Binary files a/wagtailflags.gif and b/wagtailflags.gif differ diff --git a/wagtailflags/static/wagtailflags/css/wagtailflags.css b/wagtailflags/static/wagtailflags/css/wagtailflags.css index 5ccc2fb..f51cddb 100644 --- a/wagtailflags/static/wagtailflags/css/wagtailflags.css +++ b/wagtailflags/static/wagtailflags/css/wagtailflags.css @@ -1,6 +1,3 @@ -.flags-breadcrumb { - margin-left: 0; -} section.flag { margin-top: 4em; } diff --git a/wagtailflags/templates/wagtailflags/flag.svg b/wagtailflags/templates/wagtailflags/flag.svg new file mode 100644 index 0000000..09d16bd --- /dev/null +++ b/wagtailflags/templates/wagtailflags/flag.svg @@ -0,0 +1 @@ + diff --git a/wagtailflags/templates/wagtailflags/flags/create_flag.html b/wagtailflags/templates/wagtailflags/flags/create_flag.html index 1b38d34..daf932e 100644 --- a/wagtailflags/templates/wagtailflags/flags/create_flag.html +++ b/wagtailflags/templates/wagtailflags/flags/create_flag.html @@ -3,33 +3,16 @@ {% block titletag %}Create a flag{% endblock %} {% block content %} - {% include "wagtailadmin/shared/header.html" with title=flag.name icon="tag" %} - -