Refactor Makefile (#5)
* Improves target handling, script safety, adds self-documenting help * Remove 'all' target
This commit is contained in:
committed by
Vasily Zubarev
parent
0ca6c79836
commit
95a151d2c2
69
Makefile
69
Makefile
@@ -1,41 +1,52 @@
|
||||
# Set the default goal if no targets were specified on the command line
|
||||
.DEFAULT_GOAL = run
|
||||
# Makes shell non-interactive and exit on any error
|
||||
.SHELLFLAGS = -ec
|
||||
|
||||
PROJECT_NAME=infomate
|
||||
|
||||
all: run
|
||||
|
||||
# Install dev requirements
|
||||
dev-requirements:
|
||||
dev-requirements: ## Install dev requirements
|
||||
@pip3 install -r requirements.txt
|
||||
|
||||
# Migrate database to the latest version
|
||||
migrate:
|
||||
@python3 manage.py migrate
|
||||
|
||||
# Check types with mypy
|
||||
mypy:
|
||||
mypy $(PROJECT_NAME)
|
||||
|
||||
# Lint code with flake8
|
||||
lint:
|
||||
flake8 $(PROJECT_NAME)
|
||||
|
||||
# Runs dev server
|
||||
run:
|
||||
@python3 manage.py runserver
|
||||
|
||||
# Run dev server in docker
|
||||
docker_run:
|
||||
docker_run: ## Run dev server in docker
|
||||
@python3 ./utils/wait_for_postgres.py
|
||||
@python3 manage.py migrate
|
||||
@python3 manage.py runserver
|
||||
|
||||
# Initialize feeds from boards.yml
|
||||
feed_init:
|
||||
feed_cleanup: ## Cleanup RSS feeds
|
||||
@python3 ./scripts/cleanup.py
|
||||
|
||||
feed_init: ## Initialize feeds from boards.yml
|
||||
@python3 ./scripts/initialize.py
|
||||
|
||||
# Refresh RSS feeds
|
||||
feed_refresh:
|
||||
feed_refresh: ## Refresh RSS feeds
|
||||
@python3 ./scripts/update.py
|
||||
|
||||
# Cleanup RSS feeds
|
||||
feed_cleanup:
|
||||
@python3 ./scripts/cleanup.py
|
||||
help: ## Display this help
|
||||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
|
||||
| sort \
|
||||
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[0;32m%-30s\033[0m %s\n", $$1, $$2}'
|
||||
|
||||
lint: ## Lint code with flake8
|
||||
flake8 $(PROJECT_NAME)
|
||||
|
||||
migrate: ## Migrate database to the latest version
|
||||
@python3 manage.py migrate
|
||||
|
||||
mypy: ## Check types with mypy
|
||||
mypy $(PROJECT_NAME)
|
||||
|
||||
run: ## Runs dev server
|
||||
@python3 manage.py runserver
|
||||
|
||||
.PHONY: \
|
||||
dev-requirements \
|
||||
docker_run \
|
||||
feed_cleanup \
|
||||
feed_init \
|
||||
feed_refresh \
|
||||
help \
|
||||
lint \
|
||||
migrate \
|
||||
mypy \
|
||||
run
|
||||
|
||||
Reference in New Issue
Block a user