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

Maintenance update: switch to pyproject.toml, format with black, add back coverage report, Wagtail 6.3 #97

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
jobs:
nightly-wagtail-test:
docker:
- image: circleci/python:3.8
- image: circleci/python:3.9
steps:
- checkout
- run: git clone [email protected]:wagtail/wagtail.git
Expand Down
17 changes: 12 additions & 5 deletions .circleci/report_nightly_build_failure.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,23 @@
This reports an error to the #nightly-build-failures Slack channel.
"""

import os

import requests

if 'SLACK_WEBHOOK_URL' in os.environ:
if "SLACK_WEBHOOK_URL" in os.environ:
print("Reporting to #nightly-build-failures slack channel")
response = requests.post(os.environ['SLACK_WEBHOOK_URL'], json={
"text": "A Nightly build failed. See " + os.environ['CIRCLE_BUILD_URL'],
})
response = requests.post(
os.environ["SLACK_WEBHOOK_URL"],
json={
"text": "A Nightly build failed. See " + os.environ["CIRCLE_BUILD_URL"],
},
)

print("Slack responded with:", response)

else:
print("Unable to report to #nightly-build-failures slack channel because SLACK_WEBHOOK_URL is not set")
print(
"Unable to report to #nightly-build-failures slack channel because SLACK_WEBHOOK_URL is not set"
)
5 changes: 5 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[flake8]
max-line-length = 88
exclude = .tox,.git,*/migrations/*,venv,dist,build,*.pyc,*.egg-info
ignore = E203,E231,E266,E501,W503,B950,F405
max-complexity = 11
8 changes: 8 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# git-blame ignored revisions
# To configure, run
# git config blame.ignoreRevsFile .git-blame-ignore-revs
# Requires Git > 2.23
# See https://git-scm.com/docs/git-blame#Documentation/git-blame.txt---ignore-revs-fileltfilegt

# Reformat with Black
b1212e3346b3a193aa1a10417eb2b68170a4e339
14 changes: 7 additions & 7 deletions .github/workflows/publish-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ jobs:
needs: ['test']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-python@v3
- uses: actions/setup-python@v5
with:
python-version: 3.11
python-version: 3.13

- run: |
pip install setuptools
python setup.py sdist
pip install build
python -m build .

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
path: ./dist

Expand All @@ -38,7 +38,7 @@ jobs:
# Mandatory for trusted publishing
id-token: write
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4

- name: Publish package distributions to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ jobs:
needs: ['test']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-python@v3
- uses: actions/setup-python@v5
with:
python-version: 3.11
python-version: 3.13

- run: |
pip install setuptools
python setup.py sdist
pip install build
python -m build .

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
path: ./dist

Expand All @@ -39,7 +39,7 @@ jobs:
# Mandatory for trusted publishing
id-token: write
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
53 changes: 39 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,73 @@ on:
workflow_call: # Allow for the publish workflows to run the tests by calling this workflow

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: 3.9
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install .[test]
- name: Run linting
run: |
make format
test:
name: Python ${{ matrix.python}} ${{ matrix.toxenv }}
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
python: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python: ["3.9", "3.10", "3.11", "3.12", "3.13"]
experimental: [false]
toxenv: ["py"]
include:
# Linting
- python: "3.8"
toxenv: flake8
experimental: false
- python: "3.8"
toxenv: isort
experimental: false
# Future Wagtail release from main branch (allowed to fail)
- python: "3.12"
- python: "3.13"
toxenv: wagtailmain
experimental: true
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install setuptools tox tox-py
python -m pip install tox tox-py coverage

# This step runs only for jobs NOT in the include matrix
- name: Run tox targets for Python ${{ matrix.python }}
if: ${{ matrix.toxenv == 'py' }}
run: |
tox --py current

# This step runs only for jobs in the include matrix and covers linting
# This step runs only for jobs in the include matrix
- name: Run tox targets for Python ${{ matrix.python }} (${{ matrix.toxenv }})
if: ${{ matrix.toxenv != 'py' }}
run: |
tox -e ${{ matrix.toxenv }}
env:
TOXENV: ${{ matrix.toxenv }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Generate coverage report
run: |
coverage combine
coverage xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: coverage.xml
flags: unittests
fail_ci_if_error: true
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ __pycache__/
.cache/
.tox/
.coverage
.coverage.*
.DS_Store
.python-version
*.egg-info/
*.py[cod]
coverage.xml
htmlcov/
build/
dist/
venv/
src/wagtailbakery/build/
src/wagtailbakery/tests/public/
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Added

- Compatibility with Wagtail 6.0 and 6.1. [#95](https://github.com/wagtail-nest/wagtail-bakery/pull/95)
- Compatibility with Django 5.0. [#95](https://github.com/wagtail-nest/wagtail-bakery/pull/95)
- Compatibility with Python 3.12 and 3.13
- Compatibility with Wagtail 6.1, 6.2 and 6.3.
- Compatibility with Django 5.0 and 5.1.
- Switch `setup.py` to `pyproject.toml`.
- Linting with `black`, `isort` and `flake8`.
- Added back coverage reporting.

### Fixed

Expand All @@ -21,6 +25,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- Drop support for Wagtail before 5.2. [#95](https://github.com/wagtail-nest/wagtail-bakery/pull/95)
- Drop support for Django before 4.2. [#95](https://github.com/wagtail-nest/wagtail-bakery/pull/95)
- Drop Python 3.8 support as it is end of life.

## [0.8.0](https://github.com/wagtail-nest/wagtail-bakery/compare/0.7.0...0.8.0)

Expand Down
3 changes: 1 addition & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ include CHANGELOG.md
include LICENSE
include MANIFEST.in
include README.md
include setup.cfg
include setup.py
include pyproject.toml

recursive-include src/wagtailbakery *.html *.py
26 changes: 14 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
.PHONY: help all clean install flake8 isort lint test
.PHONY: help all clean install format test
.DEFAULT_GOAL := help

help: ## See what commands are available.
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36mmake %-15s\033[0m # %s\n", $$1, $$2}'


all: install clean test lint ## Install, test and lint the project.
all: clean install format test ## Install, format and test the project.

clean: ## Remove Python file artifacts.
find . -type f -name "*.py[co]" -delete
find . -type d -name "__pycache__" -delete
find . -name '*.pyc' -exec rm -rf {} +
find . -name '__pycache__' -exec rm -rf {} +
find . -name '*.egg-info' -exec rm -rf {} +
rm -rf build dist

install: ## Install dependencies.
pip install -e .[test]

flake8: ## Run flake8 on the project.
flake8 src/

isort: ## Run isort on the project.
isort --check-only --diff --recursive src/

lint: flake8 isort ## Lint the project.
format: ## Format the code.
black .
isort .
flake8 .

test: ## Test the project.
py.test
pytest --cov

cov: ## Generate coverage report (manually open htmlcov/index.html in browser)
pytest --cov --cov-report html
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ A set of helpers for baking your Django Wagtail site out as flat files.

[![License: MIT](https://img.shields.io/pypi/l/wagtail-bakery)](https://github.com/wagtail-nest/wagtail-bakery/blob/main/LICENSE)
[![Build Status](https://github.com/wagtail-nest/wagtail-bakery/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/wagtail-nest/wagtail-bakery/actions/workflows/test.yml)
[![codecov](https://codecov.io/gh/wagtail-nest/wagtail-bakery/graph/badge.svg?token=5SbMtmHcal)](https://codecov.io/gh/wagtail-nest/wagtail-bakery)
[![Version](https://img.shields.io/pypi/v/wagtail-bakery.svg)](https://pypi.python.org/pypi/wagtail-bakery/)
[![Monthly downloads](https://img.shields.io/pypi/dm/wagtail-bakery.svg?logo=Downloads)](https://pypi.python.org/pypi/wagtail-bakery/)

Expand Down Expand Up @@ -31,8 +32,8 @@ If you want to send an encrypted email (optional), the public key ID for securit

## Supported Versions

- Python 3.8 - 3.12
- Django 4.2 - 5.0
- Python 3.9 - 3.13
- Django 4.2 - 5.1
- Wagtail >= 5.2

We aim to support the Wagtail versions as [supported](http://docs.wagtail.org/en/latest/releases/upgrading.html) by Wagtail (current LTS, current stable).
Expand Down Expand Up @@ -163,7 +164,7 @@ Test as follow:
### Releases

1. Create a new branch (e.g. `release/1.1.3`) for the release of the new version.
1. Update the version number in `setup.py` following [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
1. Update the version number in `pyproject.toml` following [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
1. Update `CHANGELOG.md`.
1. On GitHub, create a pull request and squash merge it.
1. On GitHub, if this is a minor release bump (for example `1.1.0` or `1.2.0` but not `1.1.1`, `1.2.3`), create a `stable/1.1.x` branch from `main`.
Expand All @@ -179,6 +180,8 @@ Test as follow:

## Credits

`wagtail-bakery` was originally developed by [Rob Moorman](https://github.com/robmoorman) and is now maintained by the Wagtail Nest team.

Thanks to [@mhnbcu](https://github.com/mhnbcu/wagtailbakery) for bringing this
idea up initially, and [Django Bakery](https://github.com/datadesk/django-bakery)
for providing the initial bakery package.
Expand Down
4 changes: 4 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
coverage:
precision: 1
round: nearest
range: "70...100"
Loading