|
@@ -21,27 +21,27 @@ You will also need to install the **libjpeg** and **zlib** libraries, if you hav
|
|
|
|
|
|
Clone a copy of [the Wagtail codebase](https://github.com/wagtail/wagtail):
|
|
|
|
|
|
-```console
|
|
|
-$ git clone https://github.com/wagtail/wagtail.git
|
|
|
-$ cd wagtail
|
|
|
+```sh
|
|
|
+git clone https://github.com/wagtail/wagtail.git
|
|
|
+cd wagtail
|
|
|
```
|
|
|
|
|
|
**With your preferred virtualenv activated,** install the Wagtail package in development mode with the included testing and documentation dependencies:
|
|
|
|
|
|
-```console
|
|
|
-$ pip install -e '.[testing,docs]' -U
|
|
|
+```sh
|
|
|
+pip install -e '.[testing,docs]' -U
|
|
|
```
|
|
|
|
|
|
Install the tool chain for building static assets:
|
|
|
|
|
|
-```console
|
|
|
-$ npm ci
|
|
|
+```sh
|
|
|
+npm ci
|
|
|
```
|
|
|
|
|
|
Compile the assets:
|
|
|
|
|
|
-```console
|
|
|
-$ npm run build
|
|
|
+```sh
|
|
|
+npm run build
|
|
|
```
|
|
|
|
|
|
Any Wagtail sites you start up in this virtualenv will now run against this development instance of Wagtail. We recommend using the [Wagtail Bakery demo site](https://github.com/wagtail/bakerydemo/) as a basis for developing Wagtail. Keep in mind that the setup steps for a Wagtail site may include installing a release version of Wagtail, which will override the development version you've just set up. In this case, you should install the site before running the `pip install -e` step, or re-run that step after the site is installed.
|
|
@@ -52,8 +52,8 @@ Any Wagtail sites you start up in this virtualenv will now run against this deve
|
|
|
|
|
|
From the root of the Wagtail codebase, run the following command to run all the Python tests:
|
|
|
|
|
|
-```console
|
|
|
-$ python runtests.py
|
|
|
+```sh
|
|
|
+python runtests.py
|
|
|
```
|
|
|
|
|
|
### Running only some of the tests
|
|
@@ -62,34 +62,34 @@ At the time of writing, Wagtail has well over 2500 tests, which takes a while to
|
|
|
run. You can run tests for only one part of Wagtail by passing in the path as
|
|
|
an argument to `runtests.py` or `tox`:
|
|
|
|
|
|
-```console
|
|
|
+```sh
|
|
|
# Running in the current environment
|
|
|
-$ python runtests.py wagtail
|
|
|
+python runtests.py wagtail
|
|
|
|
|
|
# Running in a specified Tox environment
|
|
|
-$ tox -e py39-dj32-sqlite-noelasticsearch wagtail
|
|
|
+tox -e py39-dj32-sqlite-noelasticsearch wagtail
|
|
|
|
|
|
# See a list of available Tox environments
|
|
|
-$ tox -l
|
|
|
+tox -l
|
|
|
```
|
|
|
|
|
|
You can also run tests for individual TestCases by passing in the path as
|
|
|
an argument to `runtests.py`
|
|
|
|
|
|
-```console
|
|
|
+```sh
|
|
|
# Running in the current environment
|
|
|
-$ python runtests.py wagtail.tests.test_blocks.TestIntegerBlock
|
|
|
+python runtests.py wagtail.tests.test_blocks.TestIntegerBlock
|
|
|
|
|
|
# Running in a specified Tox environment
|
|
|
-$ tox -e py39-dj32-sqlite-noelasticsearch wagtail.tests.test_blocks.TestIntegerBlock
|
|
|
+tox -e py39-dj32-sqlite-noelasticsearch wagtail.tests.test_blocks.TestIntegerBlock
|
|
|
```
|
|
|
|
|
|
### Running migrations for the test app models
|
|
|
|
|
|
You can create migrations for the test app by running the following from the Wagtail root.
|
|
|
|
|
|
-```console
|
|
|
-$ django-admin makemigrations --settings=wagtail.test.settings
|
|
|
+```sh
|
|
|
+django-admin makemigrations --settings=wagtail.test.settings
|
|
|
```
|
|
|
|
|
|
### Testing against PostgreSQL
|
|
@@ -101,8 +101,8 @@ In order to run these tests, you must install the required modules for PostgreSQ
|
|
|
By default, Wagtail tests against SQLite. You can switch to using PostgreSQL by
|
|
|
using the `--postgres` argument:
|
|
|
|
|
|
-```console
|
|
|
-$ python runtests.py --postgres
|
|
|
+```sh
|
|
|
+python runtests.py --postgres
|
|
|
```
|
|
|
|
|
|
If you need to use a different user, password, host or port, use the `PGUSER`, `PGPASSWORD`, `PGHOST` and `PGPORT` environment variables respectively.
|
|
@@ -116,8 +116,8 @@ In order to run these tests, you must install the required client libraries and
|
|
|
If you need to test against a different database, set the `DATABASE_ENGINE`
|
|
|
environment variable to the name of the Django database backend to test against:
|
|
|
|
|
|
-```console
|
|
|
-$ DATABASE_ENGINE=django.db.backends.mysql python runtests.py
|
|
|
+```sh
|
|
|
+DATABASE_ENGINE=django.db.backends.mysql python runtests.py
|
|
|
```
|
|
|
|
|
|
This will create a new database called `test_wagtail` in MySQL and run
|
|
@@ -139,8 +139,8 @@ It is also possible to set `DATABASE_DRIVER`, which corresponds to the `driver`
|
|
|
You can test Wagtail against Elasticsearch by passing the `--elasticsearch`
|
|
|
argument to `runtests.py`:
|
|
|
|
|
|
-```console
|
|
|
-$ python runtests.py --elasticsearch
|
|
|
+```sh
|
|
|
+python runtests.py --elasticsearch
|
|
|
```
|
|
|
|
|
|
Wagtail will attempt to connect to a local instance of Elasticsearch
|
|
@@ -149,32 +149,32 @@ Wagtail will attempt to connect to a local instance of Elasticsearch
|
|
|
If your Elasticsearch instance is located somewhere else, you can set the
|
|
|
`ELASTICSEARCH_URL` environment variable to point to its location:
|
|
|
|
|
|
-```console
|
|
|
-$ ELASTICSEARCH_URL=http://my-elasticsearch-instance:9200 python runtests.py --elasticsearch
|
|
|
+```sh
|
|
|
+ELASTICSEARCH_URL=http://my-elasticsearch-instance:9200 python runtests.py --elasticsearch
|
|
|
```
|
|
|
|
|
|
### Unit tests for JavaScript
|
|
|
|
|
|
We use [Jest](https://jestjs.io/) for unit tests of client-side business logic or UI components. From the root of the Wagtail codebase, run the following command to run all the front-end unit tests:
|
|
|
|
|
|
-```console
|
|
|
-$ npm run test:unit
|
|
|
+```sh
|
|
|
+npm run test:unit
|
|
|
```
|
|
|
|
|
|
### Integration tests
|
|
|
|
|
|
Our end-to-end browser testing suite also uses [Jest](https://jestjs.io/), combined with [Puppeteer](https://pptr.dev/). We set this up to be installed separately so as not to increase the installation size of the existing Node tooling. To run the tests, you will need to install the dependencies and, in a separate terminal, run the test suite’s Django development server:
|
|
|
|
|
|
-```console
|
|
|
-$ export DJANGO_SETTINGS_MODULE=wagtail.test.settings_ui
|
|
|
+```sh
|
|
|
+export DJANGO_SETTINGS_MODULE=wagtail.test.settings_ui
|
|
|
# Assumes the current environment contains a valid installation of Wagtail for local development.
|
|
|
-$ ./wagtail/test/manage.py migrate
|
|
|
-$ ./wagtail/test/manage.py createcachetable
|
|
|
-$ DJANGO_SUPERUSER_EMAIL=admin@example.com DJANGO_SUPERUSER_USERNAME=admin DJANGO_SUPERUSER_PASSWORD=changeme ./wagtail/test/manage.py createsuperuser --noinput
|
|
|
-$ ./wagtail/test/manage.py runserver 0:8000
|
|
|
+./wagtail/test/manage.py migrate
|
|
|
+./wagtail/test/manage.py createcachetable
|
|
|
+DJANGO_SUPERUSER_EMAIL=admin@example.com DJANGO_SUPERUSER_USERNAME=admin DJANGO_SUPERUSER_PASSWORD=changeme ./wagtail/test/manage.py createsuperuser --noinput
|
|
|
+./wagtail/test/manage.py runserver 0:8000
|
|
|
# In a separate terminal:
|
|
|
-$ npm --prefix client/tests/integration install
|
|
|
-$ npm run test:integration
|
|
|
+npm --prefix client/tests/integration install
|
|
|
+npm run test:integration
|
|
|
```
|
|
|
|
|
|
Integration tests target `http://localhost:8000` by default. Use the `TEST_ORIGIN` environment variable to use a different port, or test a remote Wagtail instance: `TEST_ORIGIN=http://localhost:9000 npm run test:integration`.
|
|
@@ -244,28 +244,28 @@ All static assets such as JavaScript, CSS, images, and fonts for the Wagtail adm
|
|
|
|
|
|
To compile the assets, run:
|
|
|
|
|
|
-```console
|
|
|
-$ npm run build
|
|
|
+```sh
|
|
|
+npm run build
|
|
|
```
|
|
|
|
|
|
This must be done after every change to the source files. To watch the source files for changes and then automatically recompile the assets, run:
|
|
|
|
|
|
-```console
|
|
|
-$ npm start
|
|
|
+```sh
|
|
|
+npm start
|
|
|
```
|
|
|
|
|
|
## Using the pattern library
|
|
|
|
|
|
Wagtail’s UI component library is built with [Storybook](https://storybook.js.org/) and [django-pattern-library](https://github.com/torchbox/django-pattern-library). To run it locally,
|
|
|
|
|
|
-```console
|
|
|
-$ export DJANGO_SETTINGS_MODULE=wagtail.test.settings_ui
|
|
|
+```sh
|
|
|
+export DJANGO_SETTINGS_MODULE=wagtail.test.settings_ui
|
|
|
# Assumes the current environment contains a valid installation of Wagtail for local development.
|
|
|
-$ ./wagtail/test/manage.py migrate
|
|
|
-$ ./wagtail/test/manage.py createcachetable
|
|
|
-$ ./wagtail/test/manage.py runserver 0:8000
|
|
|
+./wagtail/test/manage.py migrate
|
|
|
+./wagtail/test/manage.py createcachetable
|
|
|
+./wagtail/test/manage.py runserver 0:8000
|
|
|
# In a separate terminal:
|
|
|
-$ npm run storybook
|
|
|
+npm run storybook
|
|
|
```
|
|
|
|
|
|
The last command will start Storybook at `http://localhost:6006/`. It will proxy specific requests to Django at `http://localhost:8000` by default. Use the `TEST_ORIGIN` environment variable to use a different port for Django: `TEST_ORIGIN=http://localhost:9000 npm run storybook`.
|
|
@@ -274,15 +274,15 @@ The last command will start Storybook at `http://localhost:6006/`. It will proxy
|
|
|
|
|
|
The Wagtail documentation is built by Sphinx. To install Sphinx and compile the documentation, run:
|
|
|
|
|
|
-```console
|
|
|
-$ cd /path/to/wagtail
|
|
|
+```sh
|
|
|
+cd /path/to/wagtail
|
|
|
# Install the documentation dependencies
|
|
|
-$ pip install -e .[docs]
|
|
|
+pip install -e .[docs]
|
|
|
# or if using zsh as your shell:
|
|
|
# pip install -e '.[docs]' -U
|
|
|
# Compile the docs
|
|
|
-$ cd docs/
|
|
|
-$ make html
|
|
|
+cd docs/
|
|
|
+make html
|
|
|
```
|
|
|
|
|
|
The compiled documentation will now be in `docs/_build/html`.
|
|
@@ -290,9 +290,9 @@ Open this directory in a web browser to see it.
|
|
|
Python comes with a module that makes it very easy to preview static files in a web browser.
|
|
|
To start this simple server, run the following commands:
|
|
|
|
|
|
-```console
|
|
|
-$ cd docs/_build/html/
|
|
|
-$ python -m http.server 8080
|
|
|
+```sh
|
|
|
+cd docs/_build/html/
|
|
|
+python -m http.server 8080
|
|
|
```
|
|
|
|
|
|
Now you can open <http://localhost:8080/> in your web browser to see the compiled documentation.
|
|
@@ -301,26 +301,26 @@ Sphinx caches the built documentation to speed up subsequent compilations.
|
|
|
Unfortunately, this cache also hides any warnings thrown by unmodified documentation source files.
|
|
|
To clear the built HTML and start fresh, so you can see all warnings thrown when building the documentation, run:
|
|
|
|
|
|
-```console
|
|
|
-$ cd docs/
|
|
|
-$ make clean
|
|
|
-$ make html
|
|
|
+```sh
|
|
|
+cd docs/
|
|
|
+make clean
|
|
|
+make html
|
|
|
```
|
|
|
|
|
|
Wagtail also provides a way for documentation to be compiled automatically on each change.
|
|
|
To do this, you can run the following command to see the changes automatically at `localhost:4000`:
|
|
|
|
|
|
-```console
|
|
|
-$ cd docs/
|
|
|
-$ make livehtml
|
|
|
+```sh
|
|
|
+cd docs/
|
|
|
+make livehtml
|
|
|
```
|
|
|
|
|
|
## Automatically lint and code format on commits
|
|
|
|
|
|
[pre-commit](https://pre-commit.com/) is configured to automatically run code linting and formatting checks with every commit. To install pre-commit into your git hooks run:
|
|
|
|
|
|
-```console
|
|
|
-$ pre-commit install
|
|
|
+```sh
|
|
|
+pre-commit install
|
|
|
```
|
|
|
|
|
|
pre-commit should now run on every commit you make.
|