Clean up Makefile by unifying all phone targets, and removing a bunch of redundant...
[pixelated-user-agent.git] / Makefile
1 VIRTUALENV=~/.venvs/pixua
2
3 .PHONY: setup requirements install requirements_py install_py requirements_js install_js create_virtualenv
4 .PHONY: test test_py test_js test_all linters linters_py linters_js coverage unit_tests_py unit_tests_js
5 .PHONY: integration_tests_py functional_tests ensure_phantomjs_installed ensure_virtualenv_installed clean
6 .PHONY: clean_all clean_py clean_js clean_cache remove_virtualenv remove_javascript_packages
7 setup: install
8
9 requirements: requirements_py requirements_js
10
11 install: requirements install_py install_js
12
13 requirements_py: create_virtualenv
14         @. $(VIRTUALENV)/bin/activate;\
15         pip install --upgrade pip setuptools
16
17 install_py: service/requirements.txt service/test_requirements.txt
18         @. $(VIRTUALENV)/bin/activate;\
19         cd service;\
20         pip install pysqlcipher --upgrade --force-reinstall --install-option="--bundled";\
21         pip install --exists-action s -r requirements.txt -r test_requirements.txt
22
23 requirements_js:
24         @cd web-ui;\
25         npm install;\
26         node_modules/.bin/bower install
27
28 install_js:
29         @cd web-ui;\
30         npm run build
31
32 create_virtualenv: ensure_virtualenv_installed
33         @if [ ! -e $(VIRTUALENV)/bin/activate ]; then\
34                 echo "Pixelated virtualenv doesn't exist, creating now";\
35                 virtualenv --python=python2 $(VIRTUALENV);\
36         fi
37
38 test: test_py test_js coverage
39 test_py: clean requirements install coverage linters_py unit_tests_py integration_tests_py
40 test_js: clean requirements_js install_js linters_js unit_tests_js
41 test_all: test functional_tests
42 linters: clean requirements install linters_py linters_js
43
44 linters_py:
45         @. $(VIRTUALENV)/bin/activate;\
46         cd service;\
47         pep8 --ignore=E501 pixelated test
48
49 linters_js:
50         @cd web-ui;\
51         npm run jshint
52
53 coverage:
54         @. $(VIRTUALENV)/bin/activate;\
55         cd service;\
56         coverage run -p --source=pixelated `which trial` test.unit;\
57         coverage run -p --source=pixelated `which trial` test.integration;\
58         coverage combine;\
59         coverage html
60
61 unit_tests_py:
62         @. $(VIRTUALENV)/bin/activate;\
63         cd service;\
64         trial --reporter=text test.unit
65
66 unit_tests_js:
67         @cd web-ui;\
68         npm run test
69
70 integration_tests:
71         @. $(VIRTUALENV)/bin/activate;\
72         cd service;\
73         trial -j`grep -c "^processor" /proc/cpuinfo || sysctl -n hw.logicalcpu` --reporter=text test.integration
74
75 functional_tests: clean requirements install ensure_phantomjs_installed
76         @. $(VIRTUALENV)/bin/activate;\
77         cd service;\
78         behave --tags ~@wip --tags ~@smoke test/functional/features
79
80 ensure_phantomjs_installed:
81         @if [ ! `which phantomjs` ]; then\
82                 echo "You need phantomJS to run these tests";\
83                 exit 1;\
84         fi
85
86 ensure_virtualenv_installed:
87         @if [ ! `which virtualenv` ]; then\
88                 echo "Virtualenv must be installed";\
89                 exit 1;\
90         fi
91
92 clean: clean_py clean_js clean_cache
93 clean_all: clean remove_javascript_packages remove_virtualenv
94
95 clean_py:
96         rm -rf service/_trial_temp
97         find . -name "*.pyc" -delete
98         rm -rf service/.coverage
99         rm -rf service/htmlcov
100
101 clean_js:
102         rm -rf web-ui/dist
103         rm -rf web-ui/.sass-cache
104
105 clean_cache:
106         rm -rf ~/.config/leap
107         rm -rf ~/.leap
108         rm -rf service/ghostdriver.log
109
110 remove_virtualenv:
111         rm -rf $(VIRTUALENV)
112
113 remove_javascript_packages:
114         rm -rf web-ui/node_modules
115         rm -rf web-ui/app/bower_components