Skip to content

Commit aebebd4

Browse files
matrixiseclaude
andcommitted
docs: add prek installation and hook setup to every setup guide
List uv and prek as prerequisites (pinned in mise.toml) and add the `uv sync --all-groups && prek install` step to the Docker and local setup guides in README.md, CONTRIBUTING.md and DEVELOPMENT.md: the hooks run on the host even when developing with Docker. README.md gets a Git Hooks section. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 695a364 commit aebebd4

3 files changed

Lines changed: 58 additions & 17 deletions

File tree

‎CONTRIBUTING.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ This project follows the [Python Community Code of Conduct](https://www.python.o
2929
- **Docker** and **docker-compose** (recommended)
3030
- **Git**
3131
- **Task** (optional, for running predefined commands)
32+
- **uv** and **prek** (git hooks), pinned in `mise.toml` (`mise install`), see [Git Hooks (prek)](#git-hooks-prek)
3233

3334
### Repository Structure
3435

@@ -57,6 +58,11 @@ website/
5758
git clone <repository-url>
5859
cd website
5960

61+
# Install the git hooks (requires uv and prek, see "Git Hooks (prek)" below;
62+
# the ruff and Django hooks run on the host through `uv run`)
63+
uv sync --all-groups
64+
prek install
65+
6066
# Build Docker image
6167
task docker:build
6268
# or: make docker-build
@@ -195,6 +201,8 @@ uv tool install prek # uv
195201
The ruff and Django hooks run through `uv run`, so they also need the project
196202
environment (`uv sync --all-groups`).
197203

204+
Then enable the hooks, once per clone (whether you develop with Docker or not):
205+
198206
```bash
199207
# Install the git hook once per clone
200208
prek install

‎DEVELOPMENT.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ pythonie/
101101
- Docker + docker-compose
102102
- Task (or Make)
103103
- Git
104+
- uv and prek (git hooks), pinned in `mise.toml` (`mise install`); see CONTRIBUTING.md for other ways to install prek
104105

105106
### Initial Setup (Docker - Recommended)
106107

@@ -109,6 +110,11 @@ pythonie/
109110
git clone <repo-url>
110111
cd website
111112

113+
# Install the prek git hooks (they run on the host: the ruff and Django hooks
114+
# use `uv run`, so the host environment is needed too)
115+
uv sync --all-groups
116+
prek install
117+
112118
# 2. Build Docker image
113119
task docker:build
114120

‎README.md‎

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,55 @@ Website for Python Ireland (python.ie / pycon.ie) community, built with Django 6
44

55
## Prerequisites
66

7-
- Python 3.13 (see `mise.toml`)
7+
- Python 3.13, [uv](https://docs.astral.sh/uv/) and [prek](https://github.com/j178/prek) (git hooks), all pinned in `mise.toml`: run `mise install`, or see [Git Hooks](#git-hooks-prek) for other ways to install prek
88
- Docker & Docker Compose (for containerized development - recommended)
99
- [Task](https://taskfile.dev/) (optional but recommended)
1010
- Redis (only for local non-Docker development)
1111
- Environment variables file as per [the instructions here](#environment-variables)
1212

1313
## Quick Start (Docker - Recommended)
1414

15-
1. Build the Docker image:
15+
1. Install the git hooks (the ruff and Django hooks run on the host through `uv run`):
16+
```bash
17+
uv sync --all-groups
18+
prek install
19+
```
20+
21+
2. Build the Docker image:
1622
```bash
1723
task docker:build
1824
# or: make docker-build
1925
```
2026

21-
2. Start supporting services:
27+
3. Start supporting services:
2228
```bash
2329
docker compose up -d postgres redis minio
2430
```
2531

26-
3. Run database migrations:
32+
4. Run database migrations:
2733
```bash
2834
task django:migrate
2935
```
3036

31-
4. Generate sample data (creates pages, navigation, meetups):
37+
5. Generate sample data (creates pages, navigation, meetups):
3238
```bash
3339
task django:generate-sample-data
3440
# or: docker compose run --rm web python pythonie/manage.py generate_sample_data --settings=pythonie.settings.dev
3541
```
3642

37-
5. Create a superuser:
43+
6. Create a superuser:
3844
```bash
3945
docker compose run --rm web python pythonie/manage.py createsuperuser --settings=pythonie.settings.dev
4046
```
4147

42-
6. Start the development server:
48+
7. Start the development server:
4349
```bash
4450
task run
4551
# or: docker compose run --rm --service-ports web python pythonie/manage.py runserver 0.0.0.0:8000
4652
```
4753

48-
7. Visit http://127.0.0.1:8000/ to see the site with sample content
49-
8. Access Wagtail admin at http://127.0.0.1:8000/admin/
54+
8. Visit http://127.0.0.1:8000/ to see the site with sample content
55+
9. Access Wagtail admin at http://127.0.0.1:8000/admin/
5056

5157
## Local Setup (Without Docker)
5258

@@ -56,14 +62,15 @@ If you prefer to develop without Docker:
5662
2. Clone your fork: `git clone git@github.com:YourGitHubName/website.git`
5763
3. Ensure you are running Python 3.13: `python -V` should output `Python 3.13.x`
5864
4. Install dependencies: `uv sync --all-groups` (creates and populates a `.venv` automatically)
59-
5. Set up the database: `uv run python pythonie/manage.py migrate --settings=pythonie.settings.dev`
60-
6. Generate sample data: `task django:generate-sample-data` (or `uv run python pythonie/manage.py generate_sample_data --settings=pythonie.settings.dev`)
61-
7. Create a superuser: `uv run python pythonie/manage.py createsuperuser --settings=pythonie.settings.dev`
62-
8. Install and run Redis server locally: `redis-server`
63-
9. Set Redis environment variable: `export REDISCLOUD_URL=127.0.0.1:6379`
64-
10. Run the server: `uv run python pythonie/manage.py runserver --settings=pythonie.settings.dev`
65-
11. Visit http://127.0.0.1:8000/ to see the site with sample content
66-
12. Visit http://127.0.0.1:8000/admin/ to log in to Wagtail admin
65+
5. Install the git hooks: `prek install` (see [Git Hooks](#git-hooks-prek))
66+
6. Set up the database: `uv run python pythonie/manage.py migrate --settings=pythonie.settings.dev`
67+
7. Generate sample data: `task django:generate-sample-data` (or `uv run python pythonie/manage.py generate_sample_data --settings=pythonie.settings.dev`)
68+
8. Create a superuser: `uv run python pythonie/manage.py createsuperuser --settings=pythonie.settings.dev`
69+
9. Install and run Redis server locally: `redis-server`
70+
10. Set Redis environment variable: `export REDISCLOUD_URL=127.0.0.1:6379`
71+
11. Run the server: `uv run python pythonie/manage.py runserver --settings=pythonie.settings.dev`
72+
12. Visit http://127.0.0.1:8000/ to see the site with sample content
73+
13. Visit http://127.0.0.1:8000/admin/ to log in to Wagtail admin
6774

6875
## Project Structure
6976

@@ -185,6 +192,26 @@ task code:lint
185192
task code:check
186193
```
187194

195+
### Git Hooks (prek)
196+
197+
The repository uses [prek](https://github.com/j178/prek), a fast drop-in replacement for pre-commit, to run ruff, django-upgrade, the Django system checks, the missing migrations check and generic file checks on every commit. Like uv, prek is not a project dependency: install it on your machine, then enable the hooks in your clone.
198+
199+
```bash
200+
# 1. Install prek (once per machine), with one of:
201+
mise install # installs the versions pinned in mise.toml
202+
brew install prek
203+
uv tool install prek
204+
205+
# 2. Enable the git hooks (once per clone)
206+
uv sync --all-groups # the ruff and Django hooks run through `uv run`
207+
prek install
208+
209+
# Run every hook on the whole repository (same as CI)
210+
prek run --all-files
211+
```
212+
213+
See [CONTRIBUTING.md](CONTRIBUTING.md#git-hooks-prek) for the list of hooks and how to skip one in an emergency.
214+
188215
## Environment Variables
189216

190217
For Docker development, create/edit `development.env`:

0 commit comments

Comments
 (0)