Skip to content

Commit

Permalink
fix makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
brassy-endomorph committed Jan 21, 2025
1 parent 6be2cf6 commit 2e8bfb3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
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
docker compose run app poetry run ./scripts/dev_migrations.py
$(CMD) poetry run ./scripts/dev_migrations.py

.PHONY: migrate-prod
migrate-prod: ## Run prod env (alembic) migrations
docker compose run app 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
docker compose run app 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

0 comments on commit 2e8bfb3

Please sign in to comment.