Before any of the following steps, copy the sample development environment file into .env. You can make a copy or if not making any changes, use a symbolic link:
cp .env.example .env
# Or ln -s .env.example .envSee .env.example for details on what each .env file is for.
Install the project dependencies in a virtual environment:
poetry install --no-root
# or
poetry updateThen you can start a shell session with the new environment with:
poetry shellAlternatively when failing to install the dependencies
poetry export --output requirements-dev.txt --with dev
pip install -r requirements-dev.txtThis will build production versions of the Docker image, and bring them up:
docker compose -f docker-compose.dev.yml up -d --buildYou can now visit localhost:7000/docs for the API. See docker-compose.yml for the ports of other services.
It likely means your .env is out of date. Perform a comparison between your .env and .env.example and add the missing fields. Alternatively, delete your .env and replace it with the contents of .env.example.
Before committing, run lint.sh:
# this will not checking the safety and include bandit checks
poetry run scripts/lint.sh
# include safety checks
poetry run scripts/lint.sh --include-safety
# exclude the bandit checks
poetry run scripts/lint.sh --skip-banditpoetry run scripts/format.shpoetry run uvicorn uselevers.main:app --reloadRunning tests locally requires running the other services in Docker:
docker compose -f docker-compose.dev.yml up -d --build
poetry run coverage run -m pytest $@ && coverage xmlAfter writing a new models, the uselevers.core.__init__.py should be updated,
adding the models to be imported so the alembic can detect the new models.
docker compose -f docker-compose.dev.yml build
docker compose -f docker-compose.dev.yml run --rm app alembic revision --autogenerate -m "Describe this migration"
# Look the generated migrations versions, check if there's new ENUM, make sure add drop type e.g op.execute("DROP TYPE enumname") in downgrade()
# alternatively to generate the alembic migration locally with poetry
poetry run alembic revision --autogenerate -m "Describe this migration"# Generate OpenAPI specs
poetry run generate-openapiVisit http://localhost:7000/docs.
docker compose -f docker-compose.dev.yml down -v