This repository has been archived by the owner on Jul 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
143 lines (119 loc) · 5.05 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
APPLICATIONS := activitystream administration api core promotion publishers social submissions tags usermgmt
APPLICATIONS_COMMA := $(shell echo $(APPLICATIONS) | tr ' ' ',')
TESTTAGS_ARGS := $(shell echo $(TAGS) | xargs python -c 'import sys;print("--tag "+" --tag ".join(" ".join(sys.argv[1:]).split(",")))')
.PHONY: help
help: ## This help.
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
.PHONY: run
run: ## Run the development environment from tox.
tox -e 3.5-run
.PHONY: shell
shell: ## Run the django shell using some additional tools.
venv/bin/python manage.py shell_plus
.PHONY: migrate
migrate: makemigrations ## Run migrate on the DB, updating schema per migration files.
venv/bin/python manage.py migrate
.PHONY: makemigrations
makemigrations: venv/bin/django-admin ## Generate migration files based on models.
venv/bin/python manage.py makemigrations
.PHONY: fixtures
fixtures: venv/bin/django-admin ## Load data fixtures.
venv/bin/python manage.py loaddata core/fixtures/*
.PHONY: generatefixtures
generatefixtures: venv/bin/django-admin ## Generate data fixtures.
venv/bin/python manage.py dumpdata --natural-foreign --natural-primary -o core/fixtures/flatpages.json flatpages.FlatPage
venv/bin/python manage.py dumpdata --natural-foreign --natural-primary -o core/fixtures/groups.json auth.Group auth.Permission
.PHONY: update-flatpages
update-flatpages: venv/bin/django-admin ## Update the flatpages from the markdown files.
venv/bin/python manage.py update_flatpages
venv/bin/python manage.py dumpdata --natural-foreign --natural-primary -o core/fixtures/flatpages.json flatpages.FlatPage
.PHONY: collectstatic
collectstatic: ## Collect static files into the STATIC_ROOT directory.
venv/bin/python manage.py collectstatic
.PHONY: check
check: ## Run various checks against the project
venv/bin/python manage.py check --deploy
venv/bin/python manage.py validate_templates
.PHONY: reestdb
resetdb: ## Remove the development database and regenerate it, loading fixtures.
- rm db.sqlite3
$(MAKE) migrate fixtures
.PHONY: cleanmigrations
cleanmigrations: venv/bin/django-admin ## DO NOT USE: clean superfluous migrations.
@echo "XXX HOLD UP - PRE-ALPHA STUFF ONLY XXX"
@echo
@echo "In case @makyo does not delete this before first alpha, do not"
@echo "run this target. Migrations are hecka important for dev after"
@echo "that point!"
exit 1 # We really shouldn't do this, but may need to in the future
@echo
@echo "Psst, @makyo, don't forget to delete this target!"
@sleep 5
for i in $(APPLICATIONS); do \
rm $$i/migrations/*.py; \
touch $$i/migrations/__init__.py; \
done
.PHONY: update-revno
update-revno: venv/bin/django-admin ## Update the git revno for non-DEBUG templates.
venv/bin/python manage.py git_revno $(TAG)
.PHONY: test
test: ## Rapid test (parallel test running, no coverage)
tox -e 3.5-rapidtest
.PHONY: testall
testall: ## Run tests in all available environments.
tox -e test
.PHONY: testone
testone: ## Run tests in py3.5 only.
tox -e 3.5-test
.PHONY: testtags
testtags: ## Run only tests tagged with a certain tag or tags (comma separated) passed through the TAGS environment variable.
venv/bin/python manage.py test --parallel --verbosity=2 $(TESTTAGS_ARGS)
.PHONY: rapidcoverage
rapidcoverage: ## Run tests in four parallel threads and generate coverage from that (may be unstable)
tox --notest -e 3.5
venv/bin/coverage erase
detox -e rapidcov-1,rapidcov-2,rapidcov-3,rapidcov-4
tox -e rapidcoverage
.PHONY: test-travis
test-travis: ## Test target for travis-ci use.
flake8
coverage run \
--source='$(APPLICATIONS_COMMA)' \
--omit='*migrations*,*urls.py,*apps.py,*admin.py,*__init__.py,*test.py' \
manage.py test --verbosity=2 $(TEST_SUITE)
coverage report -m --skip-covered
.PHONY: metadata
metadata: ## Get metadata about the project (sloc, models, urls)
git ls-files \
| grep -v static \
| grep -v manage.py \
| grep -v migrations \
| grep -E '(.py|.html|.md|Makefile|sh)' \
| xargs python sloc.py > sloc.tsv
# This will eventually move to makemigrations, probably, after things aren't in as much flux
#venv/bin/python manage.py graph_models -g -a -o models.png
venv/bin/python manage.py show_urls > urls.tsv
.PHONY: clean
clean: ## Remove virtualenv and tox environments, along with compiled/optimized python files.
rm -rf venv .tox
find . -name *.py[co] -exec rm {} \;
.PHONY: deps
deps: check-sysdeps venv ## Install dependencies in the virtualenv.
venv/bin/pip install -r requirements.txt
.PHONY: check-sysdeps
check-sysdeps: ## Check that system dependencies are met.
@printf "\e[31mChecking for tox...\e[0m"
@tox --version
@printf "\e[32m- tox found\e[0m\n\n"
@printf "\e[31mChecking for detox...\e[0m"
@detox --version
@printf "\e[32m- detox found\e[0m\n\n"
@printf "\e[31mChecking for virtualenv...\e[0m"
@virtualenv --version
@printf "\e[32m- virtualenv found\e[0m\n\n"
@printf "\e[31mChecking for pandoc...\e[0m"
@pandoc --version
@printf "\e[32m- pandoc found\e[0m\n"
@printf "\e[32mSysdeps met\e[0m\n"
venv: ## Setup the virtualenv.
virtualenv venv