Skip to content

Commit

Permalink
feat: add instructions for database to makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
raf-nr authored and toadharvard committed Nov 20, 2023
1 parent 7cab5b4 commit 3254376
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
.PHONY: env install-deps up worker app init lint test
.PHONY: env install-deps up open-db revision migrate worker app init lint test

ifeq ($(shell test -e '.env' && echo -n yes),yes)
include .env
endif

args := $(wordlist 2, 100, $(MAKECMDGOALS))

## Create .env file from .env.example
env:
Expand All @@ -16,6 +22,18 @@ up:
(trap 'docker compose -f dev-docker-compose.yaml down' INT; \
docker compose -f dev-docker-compose.yaml up --build --force-recreate --remove-orphans)

## Open database with docker-compose
open-db:
docker exec -it desbordante-postgres psql -d $(POSTGRES_DB) -U $(POSTGRES_USER)

## Create new revision file automatically
revision:
poetry run alembic -c app/settings/alembic.ini revision --autogenerate

## Make migrations in database
migrate:
poetry run alembic -c app/settings/alembic.ini upgrade $(args)

## Run celery worker in watch mode
worker:
. .venv/bin/activate && watchmedo auto-restart --directory=./ --pattern='*.py' --recursive -- celery -A app.worker worker --loglevel=info --concurrency=1
Expand All @@ -34,6 +52,7 @@ lint:
poetry run ruff format --check ./tests/*.py ./app/*.py
poetry run black --check ./tests/*.py ./app/*.py
poetry run mypy --ignore-missing-imports ./app/*.py

## Run all tests in project
test:
poetry run pytest --verbosity=2 --showlocals -log-level=DEBUG --cov=app --cov-report term
Expand Down

0 comments on commit 3254376

Please sign in to comment.