It is recommended to use Docker to run the app and database.
./run_local.sh
This command:
- Builds the containers for the app and database
- Migrates the database to the latest version
- Reloads the app whenever changes are made within the
/app
directory
The API docs can then be found at: localhost:8027
If you run into any isues please see TROUBLESHOOT.md.
An authorised user is created as part of the run_local script. The created user will have the username cla_admin and password of cla_admin.
If you wish to run the app in a virtual environment you can do so with:
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements/generated/requirements-development.txt
To migrate the database to the latest revision run:
alembic upgrade head
To run the web server run:
uvicorn app:case_api --reload
To install testing dependencies run:
pip install -r requirements/generated/requirements-testing.txt
Tests are managed using Pytest and can be run by using:
pytest
All tests use a mocked user that circumvents the authorisation.
For information on writing tests please see here.
The following will:
- Generate requirement.txt files from files inside requirements/source/.in and put them into requirements/generated/.txt
- Run linting checks with ruff
- Run secret detection via trufflehog3
pre-commit install
The Ruff linter looks for code quality issues. Ensure there are no ruff issues before committing.
To lint all files in the directory, run:
ruff check
To format all files in the directory, run:
ruff format
The trufflehog3 package looks for any exposed secrets in your project.
To use trufflehog on your current project, run:
trufflehog3 filesystem .
For information on how to contribute please see the following:
-
Models - app/models/README.md
-
Migrations - app/db/migrations/README.md
-
Routers - app/routers/README.md
-
Testing - tests/README.md