Skip to content

Latest commit

 

History

History
184 lines (115 loc) · 3.57 KB

howto.md

File metadata and controls

184 lines (115 loc) · 3.57 KB

arad / documentation / development

How To?

This document describes how to perform common tasks while developing ARAD.

Convenience

There are a few scripts in the scripts directory that provide convenience methods for developers.

Sync Script

This script synchronizes common code across the back-end services.

arad $ scripts/sync

Local Script

This script provides the ability to interact with the local stack.

build

This will build your docker images. It is required before up.

arad $ scripts/local build

up

This starts a development stack. Healthchecks at each layer block the next from starting. Read docker-compose.yml for more information.

arad $ scripts/local up

down

This stops a development stack from another terminal, and removes the stack's containers if run a second time.

arad $ scripts/local down

relock

This will update all the poetry.lock files in the backend. Warning: test well if you use this. Updating individual solitary dependencies as required is much safer.

arad $ scripts/local relock

exec

This will execute a command in all backend services.

arad $ scripts/local exec poetry env info

prune

This will clean up some intermediate Docker images.

arad $ scripts/local prune

rm

This will remove containers spawned by docker run without the --rm parameter.

arad $ scripts/local rm

types

This will fetch type information from the OpenAPI definitions generated by the back-end and create types in the front-end.

arad $ scripts/local types

nuke

This command will reset a local Arad stack, recreating the database.

arad $ scripts/local nuke

repl

This command starts an interactive shell in the back-end of your choice.

arad $ scripts/local repl identity

Database script

The database script provides access to common tasks involving the database.

create

This command will create a PostgreSQL database suitable for development and install the pgcrypto extension.

arad $ scripts/database create

drop

This command will destroy the existing database.

arad $ scripts/database drop

migrate

This command will run any pending migrations.

arad $ scripts/database migrate

generate-migrations

This command will attept to generate new migrations from changes in database/models.py.

arad $ scripts/database generate-migrations

empty-migration

This command will generate an empty migration for whatever purposes you may need.

arad $ scripts/database empty-migration

Common Tasks

Adding a new dependency to all back-end stacks

First we'll add the package without installing it, since the changes won't persist.

arad $ scripts/local exec poetry add <package> -vv --lock

To make these changes stick, we'll need to rebuild our images. Layer caching won't help us much, since thd slow step is poetry install.

arad $ scripts/local build

That's it! You're ready to develop using your new package.

Adding a new test or dev dependency to a single service

Here we add black to identity, as a test dependency, without installing.

docker compose run --rm identity poetry add black -vv --group test --lock

Next, we'll want to rebuild:

arad $ scripts/sync && scripts/local build

It's convenient to sync before building in case you've made changes to common files. Sometimes I forget. If others find this annoying, someone should open a PR to sync from the build command itself.