Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

Latest commit

 

History

History
108 lines (68 loc) · 3.24 KB

DEVELOPERS.md

File metadata and controls

108 lines (68 loc) · 3.24 KB

Notes for developers

System requirements

just

# macOS
brew install just

# Linux
# Install from https://github.com/casey/just/releases

# Add completion for your shell. E.g. for bash:
source <(just --completions bash)

# Show all available commands
just #  shortcut for just --list

Local development environment

Prerequisites

  • Python v3.10.x
  • virtualenv
  • pip
  • Docker (for running postgres)
  • Node.js v16.x (fnm is recommended for Node.js and npm)
  • npm v7.x

Setup

Set up a local development environment with:

just devenv

Build the assets

See the Compiling assets section.

Tests

Run the tests with:

just test <args>

Run the application

just run

Development DB

By default, the justfile will use the configuration in docker/docker-compose.yaml to run a local dev postgres instance.

You can use the normal ./manage dbshell will provide psql console if needed.

Frontend development (CSS/JS)

This project uses Vite, a modern build tool and development server, to build the frontend assets. Vite integrates into the Django project using the django-vite package.

Vite works by compiling JavaScript files, and outputs a manifest file, the JavaScript files, and any included assets such as stylesheets or images.

Vite adds all JavaScript files to the page using ES6 Module syntax. For legacy browsers, this project is utilising the Vite Legacy Plugin to provide a fallback using the module/nomodule pattern.

For styling this project uses Scss to compile the stylesheets, and then PostCSS for post-processing.

Running the local asset server

Vite has a built-in development server which will serve the assets and reload them on save.

To run the development server:

  1. Update the .env file to DJANGO_VITE_DEV_MODE=True
  2. Open a new terminal and run npm run dev

This will start the Vite dev server at localhost:3000 and inject the relevant scripts into the Django templates.

Compiling assets

To view the compiled assets:

  1. Update the .env file to DJANGO_VITE_DEV_MODE=False
  2. Run just assets-rebuild

Vite builds the assets and outputs them to the assets/dist folder.

Django Staticfiles app then collects the files and places them in the staticfiles/bundle folder, with the manifest file located at staticfiles/bundle/manifest.json.

Rotating the GitHub token

  1. Log into the opensafely-interactive-bot GitHub account (credentials are in Bitwarden).
  2. Got to the Personal access tokens (classic) page.
  3. Click on opensafely-interactive-token.
  4. Click "Regenerate token".
  5. Set the expiry to 90 days.
  6. Copy the new token.
  7. ssh into dokku3.ebmdatalab.net
  8. Run: dokku config:set interactive GITHUB_TOKEN=<the new token>