Skip to content

ONSdigital/dis-wagtail-alpha

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ONS Alpha Wagtail site

Technical documentation

This project contains technical documentation written in Markdown in the /docs folder. This covers:

  • continuous integration
  • deployment
  • git branching
  • project conventions

You can view it using mkdocs by running:

poetry run mkdocs serve

The documentation will be available at: http://localhost:8001/

Docker Development Setup

This repository includes docker-compose configuration for running the project in local Docker containers, and a fabfile for provisioning and managing this.

There are a number of other commands to help with development using the fabric script. To see them all, run:

fab -l

Dependencies

The following are required to run the local environment. The minimum versions specified are confirmed to be working: if you have older versions already installed they may work, but are not guaranteed to do so.

Note that on Mac OS, if you have an older version of fabric installed, you may need to uninstall the old one and then install the new version with pip3:

pip uninstall fabric
pip3 install fabric

You can manage different python versions by setting up pyenv: https://realpython.com/intro-to-pyenv/

Running the local build for the first time

If you are using Docker Desktop, ensure the Resources:File Sharing settings allow the cloned directory to be mounted in the web container (avoiding mounting OCI runtime failures at the end of the build step).

Starting a local build can be done by running:

git clone https://github.com/ONSdigital/dis-wagtail-alpha
cd dis-wagtail-alpha
fab build
fab migrate
fab start

This will start the containers in the background, but not Django. To do this, connect to the web container with fab sh and run honcho start to start both Django and the scheduler in the foreground.

If you only want to run Django, run honcho start web or ./manage.py runserver 0.0.0.0:8000.

Then, connect to the running container again (fab sh) and:

dj createcachetable
dj createsuperuser

The site should be available on the host machine at: http://127.0.0.1:8000/

Upon first starting the container, the static files may not exist, or may be out of date. To resolve this, simply run make load-design-system-templates.

Frontend tooling

Here are the common commands:

# Install front-end dependencies.
npm install
# Start the Webpack build in watch mode, without live-reload.
npm run start
# Start the Webpack server build on port 3000 only with live-reload.
npm run start:reload
# Do a one-off Webpack development build.
npm run build
# Do a one-off Webpack production build.
npm run build:prod

There are two ways to run the frontend tooling:

  • In Docker. This is the default, most portable and secure, but much slower on macOS.
  • Or run npm commands from a terminal on your local machine. Create a .env file in the project root (see .env.example) with FRONTEND=local.

Installing Python packages

Python packages can be installed using poetry in the web container:

fab sh
poetry add wagtail-guide

To reset installed dependencies back to how they are in the poetry.lock file:

fab sh
poetry install --no-root

Installing system packages

If you wish to install extra packages in your local environment, to aid with debugging:

fab sh-root
apt-get update
apt-get install <package>  # eg. apt-get install vim

Then, exit the terminal and connect again using fab sh.

If you run fab build, or the container is rebuilt for some other reason, these packages will need re-installing.

If a package is always needed (eg a Python package requires a system dependency), this should be added to the Dockerfile.

Localization

Translations are stored in ons_alpha/locale/.

When updating translated strings, run make messages to update the *.po files, which can then be handled to translators. These generated files should be committed to the repository.

When new translations are added to the *.po files, run make compile-messages. These generated files should be committed to the repository.

See Django's documentation for further details.

Local Development Setup

This project uses poetry for dependency management and make for common development tasks.

Pre-requisites

Ensure you have the following installed:

  1. Python: Version specified in .python-version. We recommend using pyenv for managing Python versions.
  2. Poetry: This is used to manage package dependencies and virtual environments.

Installation

  1. Clone the repository:

    git clone https://github.com/ONSdigital/dis-wagtail-alpha.git
    cd dis-wagtail-alpha
  2. Install dependencies:

    poetry install

Linting and Formatting

This project uses Ruff, pylint, and black for linting and formatting Python code and djhtml for HTML linting.

  • To check linting issues:

    make lint
  • To format the code:

    make format