Skip to content

Commit 1c87b60

Browse files
committed
Adopt uv for contributor workflow
1 parent f68371e commit 1c87b60

9 files changed

Lines changed: 1414 additions & 45 deletions

File tree

.github/workflows/test.yml

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,20 @@ jobs:
2222
- name: Checkout repository
2323
uses: actions/checkout@v3
2424

25-
- name: Set up Python
26-
id: setup-python
27-
uses: actions/setup-python@v4
25+
- name: Set up uv
26+
id: setup-uv
27+
uses: astral-sh/setup-uv@v8.1.0
2828
with:
2929
python-version: ${{ matrix.python }}
30+
enable-cache: true
3031

31-
- name: Install dependencies
32-
id: install-dependencies
33-
run: |
34-
python -m pip install --upgrade pip
35-
python -m pip install tox tox-gh-actions
32+
- name: Sync dependencies
33+
id: sync-dependencies
34+
run: uv sync --locked
3635

3736
- name: Test with tox
3837
id: test-with-tox
39-
run: |
40-
tox
38+
run: uv run tox
4139
env:
4240
DATABASE: ${{ matrix.database }}
4341

@@ -63,22 +61,20 @@ jobs:
6361
- name: Checkout repository
6462
uses: actions/checkout@v3
6563

66-
- name: Set up Python
67-
id: setup-python
68-
uses: actions/setup-python@v4
64+
- name: Set up uv
65+
id: setup-uv
66+
uses: astral-sh/setup-uv@v8.1.0
6967
with:
7068
python-version: ${{ matrix.python }}
69+
enable-cache: true
7170

72-
- name: Install dependencies
73-
id: install-dependencies
74-
run: |
75-
python -m pip install --upgrade pip
76-
python -m pip install tox tox-gh-actions
71+
- name: Sync dependencies
72+
id: sync-dependencies
73+
run: uv sync --locked
7774

7875
- name: Test with tox
7976
id: test-with-tox
80-
run: |
81-
tox
77+
run: uv run tox
8278
env:
8379
DB_NAME: postgres
8480
DB_USER: postgres
@@ -112,22 +108,20 @@ jobs:
112108
- name: Checkout repository
113109
uses: actions/checkout@v3
114110

115-
- name: Set up Python
116-
id: setup-python
117-
uses: actions/setup-python@v4
111+
- name: Set up uv
112+
id: setup-uv
113+
uses: astral-sh/setup-uv@v8.1.0
118114
with:
119115
python-version: ${{ matrix.python }}
116+
enable-cache: true
120117

121-
- name: Install dependencies
122-
id: install-dependencies
123-
run: |
124-
python -m pip install --upgrade pip
125-
python -m pip install tox tox-gh-actions
118+
- name: Sync dependencies
119+
id: sync-dependencies
120+
run: uv sync --locked
126121

127122
- name: Test with tox
128123
id: test-with-tox
129-
run: |
130-
tox
124+
run: uv run tox
131125
env:
132126
DB_NAME: mysql
133127
DB_USER: root

.pre-commit-config.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
repos:
2+
- repo: https://github.com/astral-sh/uv-pre-commit
3+
rev: 0.11.3
4+
hooks:
5+
- id: uv-lock
26
- repo: https://github.com/pycqa/isort
37
rev: 7.0.0
48
hooks:
@@ -27,4 +31,4 @@ repos:
2731
rev: "1.29.1" # replace with latest tag on GitHub
2832
hooks:
2933
- id: django-upgrade
30-
args: [--target-version, "5.2"] # Replace with Django version
34+
args: [--target-version, "5.2"] # Replace with Django version

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

AGENTS.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
This file guides coding agents working in this repository. Keep it operational and project-specific. Use `README.md` for package usage and `docs/developer.md` for local setup details; do not duplicate those walkthroughs here.
66

7+
## Workflow Tools
8+
9+
- Use `uv` for contributor and agent workflows by default.
10+
- Use `uv sync` to create or refresh the local environment.
11+
- Use `uv run ...` for project commands instead of bare `python`, `pip`, or globally installed tooling unless the task explicitly requires it.
12+
713
## Repo Map
814

915
- `wagtail_honeypot/`: package behavior and public implementation.
@@ -37,7 +43,8 @@ This file guides coding agents working in this repository. Keep it operational a
3743
- For template tag or rendered field changes, update `tests/test_tags.py` with context and rendered HTML assertions.
3844
- Use `tests/testapp/` coverage when the change affects Wagtail page behavior or end-to-end form flow.
3945
- For translation or configuration changes, add focused assertions where practical.
40-
- Run `make test` for the default suite. Use `tox --skip-missing-interpreters` or `make tox` only when matrix coverage is relevant to the task.
46+
- Run `make test` or `uv run coverage run manage.py test` for the default suite.
47+
- Use `make tox` or `uv run tox --skip-missing-interpreters` only when matrix coverage is relevant to the task.
4148

4249
## Documentation Rules
4350

Makefile

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1+
sync:
2+
uv sync
3+
14
run:
2-
python manage.py runserver 0:8000
5+
uv run python manage.py runserver 0:8000
36

47
mail:
58
docker run -p 8025:8025 -p 1025:1025 mailhog/mailhog
69

710
test:
8-
coverage run manage.py test && coverage report
11+
uv run coverage run manage.py test
12+
uv run coverage report
913

1014
tox:
11-
tox --skip-missing-interpreters
15+
uv run tox --skip-missing-interpreters
1216

1317
migrate:
14-
python manage.py migrate
18+
uv run python manage.py migrate
1519

1620
superuser:
17-
@echo "from django.contrib.auth import get_user_model; get_user_model().objects.create_superuser('admin', 'admin@admin.com', 'changeme')" | python manage.py shell
21+
@echo "from django.contrib.auth import get_user_model; get_user_model().objects.create_superuser('admin', 'admin@admin.com', 'changeme')" | uv run python manage.py shell

docs/developer.md

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,87 @@
22

33
## Development Setup
44

5-
With a virtual environment activated, install the package in editable mode:
5+
Install [`uv`](https://docs.astral.sh/uv/) and use it as the default workflow for this project.
6+
7+
Pin or install the default contributor Python version:
8+
9+
```bash
10+
uv python install 3.12
11+
```
12+
13+
Create and sync the project environment:
614

715
```bash
8-
pip install -e ".[development]"
16+
uv sync
917
```
1018

19+
The default synced environment is intended to track the latest tested local stack for this repo: Python 3.12 with Django 5.2 and Wagtail 7.2. Use `tox` for the broader compatibility matrix.
20+
1121
There is a [testapp](../tests/testapp/) provided that is a fully configured minimal setup using Wagtail v5.1+
1222

1323
Setup the app:
1424

1525
```bash
16-
make migrate
26+
uv run python manage.py migrate
1727
```
1828

1929
Optional:
2030

31+
```bash
32+
uv run python manage.py createsuperuser
33+
```
34+
35+
Or use:
36+
2137
```bash
2238
make superuser
2339
```
2440

25-
This add an admin account with login details of Username: `admin` Password: `changeme`
41+
This adds an admin account with login details of Username: `admin` Password: `changeme`
2642

2743
Run the development server:
2844

2945
```bash
30-
make run
46+
uv run python manage.py runserver 0:8000
3147
```
3248

3349
View the site at `http://localhost:8000` or add `/admin` to login.
3450

51+
The `Makefile` targets also run through `uv`, so `make sync`, `make migrate`, `make run`, `make test`, and `make tox` remain valid shortcuts.
52+
53+
## Common commands
54+
55+
Run the default test suite:
56+
57+
```bash
58+
uv run coverage run manage.py test
59+
uv run coverage report
60+
```
61+
62+
Run the compatibility matrix:
63+
64+
```bash
65+
uv run tox --skip-missing-interpreters
66+
```
67+
68+
Run the configured formatting and lint hooks:
69+
70+
```bash
71+
uv run pre-commit run --all-files
72+
```
73+
74+
## Dependency management
75+
76+
Use `uv` to change contributor dependencies and keep the lockfile in sync:
77+
78+
```bash
79+
uv add --dev <package>
80+
uv lock
81+
uv sync
82+
```
83+
84+
If you edit `pyproject.toml` manually, regenerate `uv.lock` and resync the environment before committing.
85+
3586
### A convenient SMTP server
3687

3788
If you have docker and docker-compose installed

pyproject.toml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,25 @@ dependencies =[
3131
"Wagtail>=6.3",
3232
]
3333

34-
[project.optional-dependencies]
35-
development = [
34+
[dependency-groups]
35+
dev = [
3636
"black==25.11.0",
37+
"coverage",
38+
"Django>=5.2,<5.3",
39+
"django-upgrade",
3740
"flake8==7.3.0",
3841
"isort==7.0.0",
39-
"django-upgrade",
42+
"pre-commit",
4043
"pyupgrade",
44+
"tox",
45+
"tox-gh-actions",
46+
"Wagtail>=7.2,<7.3",
4147
]
4248

4349
[project.urls]
4450
Repository = "https://github.com/wagtail-packages/wagtail-honeypot"
4551
Issues = "https://github.com/wagtail-packages/wagtail-honeypot/issues"
4652
Changelog = "https://github.com/wagtail-packages/wagtail-honeypot/blob/release/CHANGELOG"
53+
54+
[tool.uv]
55+
default-groups = ["dev"]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Generated by Django 5.2.13 on 2026-04-20 16:05
2+
3+
import wagtail_honeypot.models
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
("tests_testapp", "0003_formfield_formpage"),
11+
]
12+
13+
operations = [
14+
migrations.AlterField(
15+
model_name="formpage",
16+
name="honeypot",
17+
field=models.BooleanField(
18+
default=wagtail_honeypot.models.get_honeypot_default,
19+
verbose_name="Honeypot enabled",
20+
),
21+
),
22+
]

0 commit comments

Comments
 (0)