-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
139 lines (119 loc) · 4.62 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
VIRTUAL_ENV ?= venv
SOURCE_DIRS = euth euth_wagtail home tests
ARGUMENTS=$(filter-out $(firstword $(MAKECMDGOALS)), $(MAKECMDGOALS))
SED = sed
ifneq (, $(shell command -v gsed))
SED = gsed
endif
.PHONY: all
all: help
.PHONY: help
help:
@echo OPIN development tools
@echo
@echo It will either use a exisiting virtualenv if it was entered
@echo before or create a new one in the same directory.
@echo
@echo usage:
@echo
@echo " make install -- install dev setup"
@echo " make clean -- delete node modules and venv"
@echo " make fixtures -- load example data"
@echo " make server -- start a dev server"
@echo " make watch -- start a dev server and rebuild js and css files on changes"
@echo " make background -- start background processes"
@echo " make test -- tests on exiting database"
@echo " make test-lastfailed -- run test that failed last"
@echo " make test-clean -- test on new database"
@echo " make coverage -- write coverage report to dir htmlcov"
@echo " make lint -- lint javascript and python, check for missing migrations"
@echo " make lint-quick -- lint all files staged in git"
@echo " make lint-python-files -- lint all python files files staged in git"
@echo " make lint-fix -- fix linting for all js files staged in git"
@echo " make po -- create new po files from the source"
@echo " make mo -- create new mo files from the translated po files"
@echo " make tx-mo -- pull from transifex and create new mo files from the translated po files"
@echo " make release -- build everything required for a release"
@echo
.PHONY: install
install:
npm install --no-save
npm run build
if [ ! -f $(VIRTUAL_ENV)/bin/python3 ]; then python3 -m venv $(VIRTUAL_ENV); fi
$(VIRTUAL_ENV)/bin/python3 -m pip install --upgrade -r requirements/dev.txt
$(VIRTUAL_ENV)/bin/python3 manage.py migrate
.PHONY: clean
clean:
if [ -f package-lock.json ]; then rm package-lock.json; fi
if [ -d node_modules ]; then rm -rf node_modules; fi
if [ -d venv ]; then rm -rf venv; fi
.PHONY: fixtures
fixtures:
$(VIRTUAL_ENV)/bin/python3 manage.py loaddata site-dev
.PHONY: server
server:
$(VIRTUAL_ENV)/bin/python3 manage.py runserver 8001
.PHONY: watch
watch:
trap 'kill %1' KILL; \
npm run watch & \
$(VIRTUAL_ENV)/bin/python3 manage.py runserver 8001
.PHONY: background
background:
$(VIRTUAL_ENV)/bin/python3 manage.py process_tasks
.PHONY: test
test:
$(VIRTUAL_ENV)/bin/py.test --reuse-db
.PHONY: test-lastfailed
test-lastfailed:
$(VIRTUAL_ENV)/bin/py.test --reuse-db --last-failed
.PHONY: test-clean
test-clean:
if [ -f test_db.sqlite3 ]; then rm test_db.sqlite3; fi
$(VIRTUAL_ENV)/bin/py.test
.PHONY: coverage
coverage:
$(VIRTUAL_ENV)/bin/py.test --reuse-db --cov --cov-report=html
.PHONY: lint
lint:
EXIT_STATUS=0; \
$(VIRTUAL_ENV)/bin/isort -c $(SOURCE_DIRS) --diff || EXIT_STATUS=$$?; \
$(VIRTUAL_ENV)/bin/flake8 $(SOURCE_DIRS) --exclude migrations,settings || EXIT_STATUS=$$?; \
npm run lint --silent || EXIT_STATUS=$$?; \
$(VIRTUAL_ENV)/bin/python manage.py makemigrations --dry-run --check --noinput || EXIT_STATUS=$$?; \
exit $${EXIT_STATUS}
.PHONY: lint-quick
lint-quick:
EXIT_STATUS=0; \
npm run lint-staged || EXIT_STATUS=$$?; \
$(VIRTUAL_ENV)/bin/python manage.py makemigrations --dry-run --check --noinput || EXIT_STATUS=$$?; \
exit $${EXIT_STATUS}
.PHONY: lint-python-files
lint-python-files:
EXIT_STATUS=0; \
$(VIRTUAL_ENV)/bin/isort --df -c $(ARGUMENTS) --filter-files || EXIT_STATUS=$$?; \
$(VIRTUAL_ENV)/bin/flake8 $(ARGUMENTS) || EXIT_STATUS=$$?; \
exit $${EXIT_STATUS}
.PHONY: lint-fix
lint-fix:
EXIT_STATUS=0; \
npm run lint-fix --exclude node_modules || EXIT_STATUS=$$?; \
exit $${EXIT_STATUS}
.PHONY: po
po:
$(VIRTUAL_ENV)/bin/python manage.py makemessages --all -d djangojs --ignore '$(VIRTUAL_ENV)/*'
$(VIRTUAL_ENV)/bin/python manage.py makemessages --all -d django --ignore '$(CURDIR)/node_modules/adhocracy4/adhocracy4/*'
$(SED) -i 's%#: .*/adhocracy4%#: adhocracy4%' locale/*/LC_MESSAGES/django*.po
msgen locale/en_GB/LC_MESSAGES/django.po -o locale/en_GB/LC_MESSAGES/django.po
msgen locale/en_GB/LC_MESSAGES/djangojs.po -o locale/en_GB/LC_MESSAGES/djangojs.po
.PHONY: mo
mo:
$(VIRTUAL_ENV)/bin/python manage.py compilemessages
.PHONY: release
release: export DJANGO_SETTINGS_MODULE ?= euth_wagtail.settings.build
release:
npm install --silent --legacy-peer-deps
npm run build:prod
$(VIRTUAL_ENV)/bin/python3 -m pip install -r requirements.txt -q
$(VIRTUAL_ENV)/bin/python3 manage.py compilemessages -v0
$(VIRTUAL_ENV)/bin/python3 manage.py collectstatic --noinput -v0