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

Update package tooling and boilerplate #77

Merged
merged 1 commit into from
Jul 5, 2024
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
52 changes: 24 additions & 28 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@v3
- uses: actions/checkout@v4

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

- name: Install dependencies
run: |
Expand All @@ -31,45 +31,40 @@ jobs:

strategy:
matrix:
toxenv:
- py38-dj3-wag4
- py38-dj4-wag4
- py38-dj3-waglatest
- py38-dj4-waglatest

python: ['3.12']
django: ['4.2', '5.0']
wagtail: ['6.0', '6.1']
include:
- 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
- python: '3.8'
django: '4.2'
wagtail: '6.0'
- python: '3.8'
django: '4.2'
wagtail: '6.1'

steps:
- uses: actions/checkout@v3

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

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox coveralls

- name: Run tox
run: |
tox
run: tox
env:
TOXENV: ${{ matrix.toxenv }}
TOXENV: python${{ matrix.python }}-django${{ matrix.django }}-wagtail${{ matrix.wagtail }}


- name: Store test coverage
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: coverage
name: coverage-${{ matrix.python }}-${{ matrix.django }}-${{ matrix.wagtail }}
path: .coverage.*

coverage:
Expand All @@ -79,23 +74,24 @@ jobs:
- test

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

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

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox

- name: Retrieve test coverage
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: coverage
merge-multiple: true

- name: Check coverage
run: tox -e coverage
30 changes: 14 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
repos:
- repo: https:/psf/black
rev: 22.3.0
hooks:
- id: black
args: ["wagtailflags", "setup.py", "--line-length=79"]
exclude: migrations
- repo: https:/charliermarsh/ruff-pre-commit
rev: v0.0.188
hooks:
- id: ruff
- repo: https:/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
name: isort (python)
args: ["wagtailflags"]
- repo: https:/charliermarsh/ruff-pre-commit
rev: v0.5.0
hooks:
# Run the linter.
- id: ruff
args: ['--fix']
# Run the formatter.
- id: ruff-format
- repo: https:/PyCQA/bandit
rev: 1.7.8
hooks:
- id: bandit
args: ['-c', 'pyproject.toml', '--recursive']
additional_dependencies: ['bandit[toml]']
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ Wagtail-Flags adds a Wagtail admin UI and Wagtail Site-based condition on top of
## Dependencies

- Python 3.8+
- Django 3.2 (LTS)+
- Django-Flags 4.2
- Wagtail 4.0+
- Django 4.2 (LTS)+
- Django-Flags 5.0
- Wagtail 6.0+

It should be compatible at all intermediate versions, as well.
If you find that it is not, please [file an issue](https:/cfpb/wagtail-flags/issues/new).
Expand Down
97 changes: 48 additions & 49 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
[build-system]
requires = ["setuptools>=63", "setuptools_scm[toml]>=8"]
build-backend = "setuptools.build_meta"

[project]
name = "wagtail-flags"
version = "5.3.1"
dynamic = ["version"]
description = "Feature flags for Wagtail sites"
readme = "README.md"
requires-python = ">=3.8"
Expand All @@ -9,19 +13,15 @@ authors = [
{name = "CFPB", email = "[email protected]" }
]
dependencies = [
"wagtail>=4",
"django-flags>4.2"
"wagtail>6",
"django-flags>5"
]
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]
Expand All @@ -34,10 +34,6 @@ testing = [
"Bug Reports" = "https:/cfpb/wagtail-flags/issues"
"Source" = "https:/cfpb/wagtail-flags"

[build-system]
requires = ["setuptools>=43.0.0", "wheel"]
build-backend = "setuptools.build_meta"

[tool.setuptools.package-data]
wagtailflags = [
"templates/wagtailflags/*",
Expand All @@ -46,57 +42,60 @@ wagtailflags = [
"static/wagtailflags/css/*",
]

[tool.black]
line-length = 79
target-version = ["py38"]
include = '\.pyi?$'
exclude = '''
(
/(
\.eggs
| \.git
| \.tox
| \*.egg-info
| _build
| build
| dist
| migrations
| site
)/
)
'''

[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.setuptools_scm]

[tool.ruff]
# Use PEP8 line-length
line-length = 79
# Exclude common paths
exclude = [
".git",
".tox",
"__pycache__",
"**/migrations/*.py",
]
ignore = []

[tool.ruff.lint]
ignore = ["E731", ]
# Select specific rulesets to use
select = [
# pycodestyle
"E",
# pyflakes
"F",
"W",
# flake8-bugbear
"B",
# pyupgrade
"UP",
# flake8-simplify
"SIM",
# isort
"I",
]

[tool.ruff.lint.isort.sections]
"django" = ["django"]
"wagtail" = ["wagtail"]

[tool.ruff.lint.isort]
lines-after-imports = 2
known-third-party = ["jinja2"]
section-order = [
"future",
"standard-library",
"django",
"wagtail",
"third-party",
"first-party",
"local-folder",
]

[tool.coverage.run]
omit = [
"wagtailflags/tests/*",
]

[tool.bandit]
exclude_dirs = [
"*/tests/*",
]
32 changes: 16 additions & 16 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
skipsdist=True
envlist=
lint,
py{38,311}-dj{3,4}-wag{4,latest},
python3.8-django4.2-wagtail6.0,
python3.12-django{4.2,5.0}-wagtail{6.0,6.1}
coverage

[testenv]
Expand All @@ -13,28 +14,27 @@ setenv=
DJANGO_SETTINGS_MODULE=wagtailflags.tests.settings

basepython=
py38: python3.8
py311: python3.11
python3.8: python3.8
python3.12: python3.12

deps=
dj3: Django>=3.2,<4
dj4: Django>=4.1,<5
wag4: wagtail>=4,<5
waglatest: wagtail>4
django4.2: Django>=4.2,<5
django5.0: Django>=5.0,<5.1
wagtail6.0: wagtail>=6.0,<6.1
wagtail6.1: wagtail>=6.1,<6.2

[testenv:lint]
basepython=python3.8
basepython=python3.12
deps=
black
ruff
isort
bandit
commands=
black --check wagtailflags
ruff wagtailflags
isort --check-only --diff wagtailflags
ruff format --check
ruff check wagtailflags
bandit -c "pyproject.toml" -r wagtailflags

[testenv:coverage]
basepython=python3.8
basepython=python3.12
deps=
coverage
diff_cover
Expand All @@ -44,10 +44,10 @@ commands=
diff-cover coverage.xml --compare-branch=origin/main --fail-under=100

[testenv:interactive]
basepython=python3.8
basepython=python3.12

deps=
Django>=3.2,<3.3
Django>=5.0,<5.1

commands_pre=
{envbindir}/django-admin makemigrations
Expand Down
6 changes: 2 additions & 4 deletions wagtailflags/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ class NewFlagForm(forms.ModelForm):
def clean_name(self):
name = self.cleaned_data["name"]
if name in get_flags():
raise forms.ValidationError(
"Flag named {} already exists".format(name)
)
raise forms.ValidationError(f"Flag named {name} already exists")
return name

def save(self, commit=True):
obj = super(NewFlagForm, self).save(commit=False)
obj = super().save(commit=False)
obj.condition = "boolean"
obj.value = "False"
obj.required = False
Expand Down
1 change: 0 additions & 1 deletion wagtailflags/tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"taggit",
"wagtail",
"wagtail.contrib.forms",
"wagtail.contrib.modeladmin",
"wagtail.contrib.settings",
"wagtail.admin",
"wagtail.documents",
Expand Down
Loading
Loading