Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix makefile migrations #874

Merged
merged 2 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
.DEFAULT_GOAL := help

ifndef IS_DOCKER
CMD := docker compose run --rm app
else
CMD :=
endif

.PHONY: help
help: ## Print the help message
@awk 'BEGIN {FS = ":.*?## "} /^[0-9a-zA-Z_-]+:.*?## / {printf "\033[36m%s\033[0m : %s\n", $$1, $$2}' $(MAKEFILE_LIST) | \
Expand All @@ -20,38 +26,37 @@ run-full: ## Run the app with all features enabled

.PHONY: migrate-dev
migrate-dev: ## Run dev env migrations
poetry run ./scripts/dev_migrations.py
$(CMD) poetry run ./scripts/dev_migrations.py

.PHONY: migrate-prod
migrate-prod: ## Run prod env (alembic) migrations
poetry run flask db upgrade
$(CMD) poetry run flask db upgrade

.PHONY: dev-data
dev-data: migrate-dev ## Run dev env migrations, and add dev data
poetry run ./scripts/dev_data.py
$(CMD) poetry run ./scripts/dev_data.py

.PHONY: lint
lint: ## Lint the code
poetry run ruff format --check && \
poetry run ruff check --output-format full && \
poetry run mypy . && \
docker compose run --rm app npx prettier --check ./*.md ./docs ./.github/workflows/* ./hushline
$(CMD) poetry run ruff format --check && \
$(CMD) poetry run ruff check --output-format full && \
$(CMD) poetry run mypy . && \
$(CMD) npx prettier --check ./*.md ./docs ./.github/workflows/* ./hushline

.PHONY: fix
fix: ## Format the code
poetry run ruff format && \
poetry run ruff check --fix && \
docker compose run --rm app npx prettier --write ./*.md ./docs ./.github/workflows/* ./hushline
$(CMD) poetry run ruff format && \
$(CMD) poetry run ruff check --fix && \
$(CMD) npx prettier --write ./*.md ./docs ./.github/workflows/* ./hushline

.PHONY: revision
revision: migrate-prod ## Create a new migration
ifndef message
$(error 'message' must be set when invoking the revision target, eg `make revision message="short message"`)
endif
poetry run flask db revision -m "$(message)" --autogenerate
$(CMD) poetry run flask db revision -m "$(message)" --autogenerate

TESTS ?= ./tests/
.PHONY: test
test: ## Run the test suite
docker compose run --rm app \
poetry run pytest --cov hushline --cov-report term --cov-report html -vv $(PYTEST_ADDOPTS) $(TESTS)
$(CMD) poetry run pytest --cov hushline --cov-report term --cov-report html -vv $(PYTEST_ADDOPTS) $(TESTS)
1 change: 1 addition & 0 deletions docker-compose.staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ services:
ports:
- 127.0.0.1:8080:8080
environment:
IS_DOCKER: '1'
FLASK_APP: hushline
FLASK_ENV: production
ENCRYPTION_KEY: bi5FDwhZGKfc4urLJ_ChGtIAaOPgxd3RDOhnvct10mw=
Expand Down
1 change: 1 addition & 0 deletions docker-compose.stripe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ services:
ports:
- 127.0.0.1:8080:8080
environment:
IS_DOCKER: '1'
FLASK_APP: hushline
FLASK_ENV: development
ENCRYPTION_KEY: bi5FDwhZGKfc4urLJ_ChGtIAaOPgxd3RDOhnvct10mw=
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ services:
ports:
- 127.0.0.1:8080:8080
environment:
IS_DOCKER: '1'
FLASK_APP: hushline
FLASK_ENV: development
ENCRYPTION_KEY: bi5FDwhZGKfc4urLJ_ChGtIAaOPgxd3RDOhnvct10mw=
Expand Down
8 changes: 4 additions & 4 deletions scripts/dev_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

def main() -> None:
print("Adding dev data")
create_app().app_context().push()
create_users()
create_tiers()
create_localstack_buckets()
with create_app().app_context():
create_users()
create_tiers()
create_localstack_buckets()


def create_users() -> None:
Expand Down
Loading