-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
98 lines (77 loc) · 3.07 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
VAR_DIR ?= /var/lib/repoapi
RESULTS ?= ./reports
CACHE_DIR ?= $(RESULTS)/.pytest_cache
# do nothing by default
all:
# virtual environments #############
.ONESHELL:
SHELL = /bin/bash
venv_prod: requirements/prod.txt
python3 -m venv $(VAR_DIR)/venv_prod
source $(VAR_DIR)/venv_prod/bin/activate && \
pip3 install -r ./requirements/prod.txt | tee -a install.log
venv_dev: requirements/dev.txt
python3 -m venv $(VAR_DIR)/venv_dev
source $(VAR_DIR)/venv_dev/bin/activate && \
pip3 install -r ./requirements/dev.txt | tee -a install.log
###################################
test: test_templates
RESULTS=$(RESULTS) pytest-3 -ra --junitxml=$(RESULTS)/junit.xml \
-o cache_dir=$(CACHE_DIR) \
--cov=. --cov-report=xml:$(RESULTS)/coverage.xml --cov-config=pyproject.toml \
--pep8
test_pylint:
RESULTS=$(RESULTS) pytest-3 --junitxml=$(RESULTS)/junit.xml \
-o cache_dir=$(CACHE_DIR) \
--pylint --pylint-rcfile=pylint.cfg --pylint-jobs=4
test_templates:
./manage.py validate_templates --settings="repoapi.settings.test"
###################################
deploy: venv_prod
source $(VAR_DIR)/venv_prod/bin/activate && \
./manage.py collectstatic --noinput --settings="repoapi.settings.prod"
chown www-data:www-data -R ./static_media/
migrate: venv_prod
source $(VAR_DIR)/venv_prod/bin/activate && \
./manage.py migrate --settings="repoapi.settings.prod"
load_apikeys: venv_prod
source $(VAR_DIR)/venv_prod/bin/activate && \
./manage.py loaddata $(VAR_DIR)/apikey.json --settings="repoapi.settings.prod"
shell: venv_prod
source $(VAR_DIR)/venv_prod/bin/activate && \
./manage.py shell_plus --settings="repoapi.settings.prod"
###################################
run_dev: venv_dev
IP=$(shell ip a show dev eth0 scope global | grep inet | awk '{print $$2}' | cut -d/ -f1); \
source $(VAR_DIR)/venv_dev/bin/activate && \
DJANGO_LOG_LEVEL=DEBUG \
./manage.py runserver_plus $$IP:8000 --settings="repoapi.settings.dev" --keep-meta-shutdown
worker_dev: venv_dev
source $(VAR_DIR)/venv_dev/bin/activate && \
DJANGO_LOG_LEVEL=DEBUG DJANGO_SETTINGS_MODULE=repoapi.settings.dev \
$(VAR_DIR)/venv_dev/bin/celery -A repoapi worker \
--loglevel=info
monitor_dev: venv_dev
IP=$(shell ip a show dev eth0 scope global | grep inet | awk '{print $$2}' | cut -d/ -f1); \
source $(VAR_DIR)/venv_dev/bin/activate && \
DJANGO_SETTINGS_MODULE=repoapi.settings.dev \
$(VAR_DIR)/venv_dev/bin/celery -A repoapi flower \
--address=$$IP --port=5555 --settings="repoapi.settings.dev"
makemigrations_dev: venv_dev
source $(VAR_DIR)/venv_dev/bin/activate && \
./manage.py makemigrations --settings="repoapi.settings.dev"
migrate_dev: venv_dev
source $(VAR_DIR)/venv_dev/bin/activate && \
./manage.py migrate --settings="repoapi.settings.dev"
shell_dev: venv_dev
source $(VAR_DIR)/venv_dev/bin/activate && \
./manage.py shell_plus --settings="repoapi.settings.dev"
###################################
# get rid of test files
clean:
find . -type f -name '*.pyc' -exec rm {} \;
rm -rf reports install.log
# also get rid of virtual environments
distclean dist-clean: clean
rm -rf venv*
.PHONY: all test clean dist-clean