pep8
[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 functional_tests_ci ensure_virtualenv_installed clean
6 .PHONY: clean_all clean_py clean_js clean_cache remove_virtualenv remove_javascript_packages run
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 --production;\
26         npm install;\
27         node_modules/.bin/bower install
28
29 install_js:
30         @cd web-ui;\
31         npm rebuild node-sass;\
32         npm run build
33
34 create_virtualenv: ensure_virtualenv_installed
35         @if [ ! -e $(VIRTUALENV)/bin/activate ]; then\
36                 echo "Pixelated virtualenv doesn't exist, creating now";\
37                 virtualenv --python=python2 $(VIRTUALENV);\
38         fi
39
40 test: clean install test_py test_js coverage
41 test_py: linters_py unit_tests_py integration_tests_py
42 test_js: linters_js unit_tests_js
43 test_all: test functional_tests
44 linters: clean install linters_py linters_js
45
46 linters_py:
47         @. $(VIRTUALENV)/bin/activate;\
48         cd service;\
49         pep8 --ignore=E501 pixelated test
50
51 linters_js:
52         @cd web-ui;\
53         npm run lint
54
55 coverage:
56         @. $(VIRTUALENV)/bin/activate;\
57         cd service;\
58         export PYTHONPATH=$(PYTHONPATH):`pwd`;\
59         coverage run -p --source=pixelated `which trial` test.unit;\
60         coverage run -p --source=pixelated `which trial` test.integration;\
61         coverage combine;\
62         coverage html
63
64 unit_tests_py:
65         @. $(VIRTUALENV)/bin/activate;\
66         cd service;\
67         export PYTHONPATH=$(PYTHONPATH):`pwd`;\
68         trial --reporter=text test.unit
69
70 unit_tests_js:
71         @cd web-ui;\
72         npm run test
73
74 integration_tests_py:
75         @. $(VIRTUALENV)/bin/activate;\
76         cd service;\
77         export PYTHONPATH=$(PYTHONPATH):`pwd`;\
78         trial --reporter=text test.integration
79
80 functional_tests: clean requirements install
81         @. $(VIRTUALENV)/bin/activate;\
82         cd service;\
83         xvfb-run --server-args="-screen 0 1280x1024x24" behave --tags ~@wip --tags ~@smoke test/functional/features
84
85 smoke_tests: clean install
86         @. $(VIRTUALENV)/bin/activate;\
87         cd service;\
88         xvfb-run --server-args="-screen 0 1280x1024x24" behave --tags ~@wip --tags @smoke test/functional/features -k -D host=$(provider)
89
90 functional_tests_ci: clean requirements install
91         @. $(VIRTUALENV)/bin/activate;\
92         cd service;\
93         behave --tags ~@wip --tags ~@smoke test/functional/features
94
95 functional_tests_wip:
96         @. $(VIRTUALENV)/bin/activate;\
97         cd service;\
98         xvfb-run --server-args="-screen 0 1280x1024x24" behave --tags @wip test/functional/features
99
100 ensure_virtualenv_installed:
101         @if [ ! `which virtualenv` ]; then\
102                 echo "Virtualenv must be installed";\
103                 exit 1;\
104         fi
105
106 clean: clean_py clean_js clean_cache
107 clean_all: clean remove_javascript_packages remove_virtualenv
108
109 clean_py:
110         rm -rf service/_trial_temp
111         find . -name "*.pyc" -delete
112         rm -rf service/.coverage
113         rm -rf service/htmlcov
114
115 clean_js:
116         rm -rf web-ui/dist
117         rm -rf web-ui/.sass-cache
118
119 clean_cache:
120         rm -rf ~/.config/leap
121         rm -rf ~/.leap
122         rm -rf service/ghostdriver.log
123
124 remove_virtualenv:
125         rm -rf $(VIRTUALENV)
126
127 remove_javascript_packages:
128         rm -rf web-ui/node_modules
129         rm -rf web-ui/app/bower_components
130
131 diagrams:
132         @. $(VIRTUALENV)/bin/activate;\
133         pip install plantuml;\
134         cd service/diagrams/png;\
135         python -m plantuml *.txt
136
137 run:
138         @. $(VIRTUALENV)/bin/activate;\
139         pixelated-user-agent --host 0.0.0.0 --multi-user --provider=$(provider)