|
| 1 | +# List available recipes |
| 2 | +default: |
| 3 | + @just --list |
| 4 | + |
| 5 | +# Roots passed to Ruff (Python only) |
| 6 | +py_roots := "src tests/backend tests/e2e testproject" |
| 7 | +# Roots passed to djlint (HTML templates) |
| 8 | +template_roots := "src/wagtail_inspect/templates testproject" |
| 9 | + |
| 10 | +# --------------------------------------------------------------------------- |
| 11 | +# Setup |
| 12 | +# --------------------------------------------------------------------------- |
| 13 | + |
| 14 | +# Install all dependencies (Python + JavaScript) |
| 15 | +install: |
| 16 | + uv sync --extra testing |
| 17 | + bun install |
| 18 | + |
| 19 | +# Register pre-commit hooks (run once per clone) |
| 20 | +pre-commit-install: |
| 21 | + uv run pre-commit install |
| 22 | + |
| 23 | +# Run pre-commit on staged files (default) or pass e.g. `--all-files` |
| 24 | +pre-commit *args: |
| 25 | + uv run pre-commit run {{args}} |
| 26 | + |
| 27 | +# Install Playwright browsers (run once after install) |
| 28 | +install-browsers: |
| 29 | + uv run playwright install chromium |
| 30 | + |
| 31 | +# --------------------------------------------------------------------------- |
| 32 | +# Testing |
| 33 | +# --------------------------------------------------------------------------- |
| 34 | + |
| 35 | +# Run backend and frontend tests |
| 36 | +test *args: |
| 37 | + #!/usr/bin/env bash |
| 38 | + pytest_extra="" |
| 39 | + bun_extra="" |
| 40 | + if echo " {{ args }} " | grep -qw -- "-x"; then |
| 41 | + pytest_extra="-x" |
| 42 | + bun_extra="--bail" |
| 43 | + fi |
| 44 | + just test-backend $pytest_extra & just test-frontend $bun_extra |
| 45 | + wait |
| 46 | +
|
| 47 | +# Run all tests (including E2E) |
| 48 | +test-all *args: |
| 49 | + #!/usr/bin/env bash |
| 50 | + pytest_extra="" |
| 51 | + bun_extra="" |
| 52 | + if echo " {{ args }} " | grep -qw -- "-x"; then |
| 53 | + pytest_extra="-x" |
| 54 | + bun_extra="--bail" |
| 55 | + fi |
| 56 | + just test-backend $pytest_extra & just test-frontend $bun_extra & just test-e2e $pytest_extra |
| 57 | + wait |
| 58 | +
|
| 59 | +# Run Python/Django tests |
| 60 | +test-backend *args: |
| 61 | + uv run pytest tests/backend {{ args }} |
| 62 | + |
| 63 | +# Run JavaScript tests with Bun |
| 64 | +test-frontend *args: |
| 65 | + bun test tests/frontend {{ args }} |
| 66 | + |
| 67 | +# Run JavaScript tests in watch mode |
| 68 | +test-frontend-watch: |
| 69 | + bun test --watch tests/frontend |
| 70 | + |
| 71 | +# Run E2E tests with Playwright (headless, artifacts captured on failure) |
| 72 | +test-e2e *args: |
| 73 | + uv run pytest tests/e2e --ds=tests.e2e.settings \ |
| 74 | + --screenshot=only-on-failure --video=retain-on-failure {{ args }} |
| 75 | + |
| 76 | +# Run E2E tests in headed mode for interactive debugging |
| 77 | +test-e2e-headed *args: |
| 78 | + uv run pytest tests/e2e --ds=tests.e2e.settings --headed {{ args }} |
| 79 | + |
| 80 | +# Run backend tests against all supported Django/Wagtail version combinations |
| 81 | +tox *args: |
| 82 | + uvx --with tox-uv tox {{ args }} |
| 83 | + |
| 84 | +# Run backend tests against a single tox environment (e.g. just tox-env py312-django51-wagtail7) |
| 85 | +tox-env env *args: |
| 86 | + uvx --with tox-uv tox -e {{ env }} {{ args }} |
| 87 | + |
| 88 | +# Run Python tests with coverage report |
| 89 | +coverage: |
| 90 | + uv run coverage run -m pytest tests/backend -n auto |
| 91 | + uv run coverage report |
| 92 | + |
| 93 | +# Ruff, djlint, oxlint (scoped paths). Pass Ruff flags after the recipe name, e.g. `just lint --no-fix` (CI) or `just lint --fix`. |
| 94 | +lint *args: |
| 95 | + uv run ruff check {{ py_roots }} {{ args }} |
| 96 | + uv run djlint {{ template_roots }} --lint |
| 97 | + bun run lint:check |
| 98 | + |
| 99 | +# Apply Ruff and oxlint autofixes (same paths as `lint`). |
| 100 | +lint-fix *args: |
| 101 | + uv run ruff check {{ py_roots }} --fix {{ args }} |
| 102 | + uv run djlint {{ template_roots }} --lint |
| 103 | + bun run lint |
| 104 | + |
| 105 | +format *args: # Ruff format, djlint reformat, oxfmt (scoped paths) |
| 106 | + uv run ruff format {{ py_roots }} {{ args }} |
| 107 | + uv run djlint {{ template_roots }} --reformat |
| 108 | + bun run format |
| 109 | + |
| 110 | +# --------------------------------------------------------------------------- |
| 111 | +# Development |
| 112 | +# --------------------------------------------------------------------------- |
| 113 | + |
| 114 | +# Migrate and run the dev server; set LOAD_E2E_FIXTURE=1 to load tests/e2e/fixtures/test_data.json first (skipped if missing or empty) |
| 115 | +run: |
| 116 | + #!/usr/bin/env bash |
| 117 | + set -euo pipefail |
| 118 | + uv run python testproject/manage.py migrate |
| 119 | + fixture="tests/e2e/fixtures/test_data.json" |
| 120 | + if [[ "${LOAD_E2E_FIXTURE:-}" == "1" ]] && [[ -f "$fixture" ]]; then |
| 121 | + if uv run python -c "import json, pathlib, sys; d=json.loads(pathlib.Path('$fixture').read_text()); sys.exit(0 if d else 1)"; then |
| 122 | + # Wagtail migrate leaves default pages (e.g. path 00010001); fixture pages |
| 123 | + # use the same tree paths → UNIQUE on wagtailcore_page.path without a flush. |
| 124 | + uv run python testproject/manage.py flush --no-input |
| 125 | + uv run python testproject/manage.py loaddata "$fixture" |
| 126 | + fi |
| 127 | + fi |
| 128 | + uv run python testproject/manage.py runserver |
| 129 | +
|
| 130 | +# Same as `just run` with LOAD_E2E_FIXTURE=1 (loads test_data.json when non-empty) |
| 131 | +run-with-fixture: |
| 132 | + #!/usr/bin/env bash |
| 133 | + set -euo pipefail |
| 134 | + export LOAD_E2E_FIXTURE=1 |
| 135 | + just run |
| 136 | +
|
| 137 | +# Export local Wagtail DB to tests/e2e/fixtures/test_data.json (for E2E tests) |
| 138 | +dump-fixture: |
| 139 | + uv run python testproject/manage.py dump_test_fixture |
| 140 | + |
| 141 | +# Load E2E fixture into the local dev database (testproject/testapp/db.sqlite3) |
| 142 | +load-fixture: |
| 143 | + uv run python testproject/manage.py flush --no-input |
| 144 | + uv run python testproject/manage.py loaddata tests/e2e/fixtures/test_data.json |
| 145 | + |
| 146 | +# --------------------------------------------------------------------------- |
| 147 | +# Build |
| 148 | +# --------------------------------------------------------------------------- |
| 149 | + |
| 150 | +# Build the distributable wheel and sdist |
| 151 | +build: |
| 152 | + uv build |
| 153 | + |
| 154 | +# Remove build artefacts |
| 155 | +clean: |
| 156 | + rm -rf dist/ build/ *.egg-info src/*.egg-info |
0 commit comments