Fancier makefile.

This commit is contained in:
Chris Giacofei 2024-06-05 11:16:52 -04:00
parent 26a58ff6c8
commit f76f5cec75

View File

@ -9,16 +9,22 @@ IGNORE = .git .env
PYFILES := $(filter-out $(IGNORE),$(call rwildcard,.,*.py)) PYFILES := $(filter-out $(IGNORE),$(call rwildcard,.,*.py))
HTMLFILES := $(filter-out $(IGNORE),$(call rwildcard,.,*.html)) HTMLFILES := $(filter-out $(IGNORE),$(call rwildcard,.,*.html))
$(VENV)/touchfile: requirements.txt $(VENV)/.install: requirements.txt
test -d $(VENV) || python3 -m venv $(VENV) test -d $(VENV) || python3 -m venv $(VENV)
$(BIN)/pip install --upgrade -r requirements.txt $(BIN)/pip install --upgrade -r requirements.txt
touch $(VENV)/touchfile touch $(VENV)/.install
.PHONY: migrate $(VENV)/.migrate: $(PYFILES) $(VENV)/.install
migrate: $(PYFILES) ## Make and run migrations
$(PYTHON) manage.py makemigrations $(PYTHON) manage.py makemigrations
$(PYTHON) manage.py migrate $(PYTHON) manage.py migrate
$(PYTHON) manage.py collectstatic --noinput $(PYTHON) manage.py collectstatic --noinput
touch $(VENV)/.migrate
$(VENV)/.start: $(HTMLFILES) $(VENV)/.migrate
sudo systemctl restart gunicorn.service gunicorn.socket
touch $(VENV)/.start
.PHONY: migrate
migrate: $(VENV)/.migrate ## Make and run migrations
.PHONY: test .PHONY: test
test: ## Run tests test: ## Run tests
@ -29,11 +35,10 @@ pull:
git pull origin master git pull origin master
.PHONY: start .PHONY: start
start: $(HTMLFILES) $(PYFILES) ## Restart gunicorn start: $(VENV)/.start ## Restart gunicorn
sudo systemctl restart gunicorn.service gunicorn.socket
.PHONY: update .PHONY: update
update: pull $(VENV)/touchfile migrate start ## Pull latest from remote and restart update: pull $(VENV)/.install $(VENV)/.migrate $(VENV)/.start ## Pull latest from remote and restart
.PHONY: backup .PHONY: backup
backup: ## Backup database to json file. backup: ## Backup database to json file.
@ -49,3 +54,4 @@ clean:
help: ## Self-documented Makefile help: ## Self-documented Makefile
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'