summaryrefslogtreecommitdiff
path: root/Makefile
blob: 2d66a79f7b4259e3d9e4ec7732a48b76014315f8 (plain)
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
VIRTUALENV=~/.venvs/pixua

.PHONY: setup
setup: install

.PHONY: requirements
requirements: requirements_py requirements_js
	@echo "Installed requirements"

.PHONY: install
install: requirements install_py install_js
	@echo "Installed dependencies"

.PHONY: requirements_py
requirements_py: create_virtualenv
	@echo "Upgrading pip and setuptools"
	@source $(VIRTUALENV)/bin/activate;\
	pip install --upgrade pip setuptools

.PHONY: install_py
install_py: service/requirements.txt service/test_requirements.txt
	@echo "Installing python packages"
	@source $(VIRTUALENV)/bin/activate;\
	cd service;\
	pip install pysqlcipher --upgrade --force-reinstall --install-option="--bundled";\
	pip install --exists-action s -r requirements.txt -r test_requirements.txt

.PHONY: requirements_js
requirements_js:
	@echo "Installing javascript npm and bower dependencies"
	@cd web-ui;\
	npm install

.PHONY: install_js
install_js:
	@echo "Building front-end and static files"
	@cd web-ui;\
	npm run build

.PHONY: create_virtualenv
create_virtualenv: ensure_virtualenv_installed
	@if [ ! -e $(VIRTUALENV)/bin/activate ]; then\
		echo "Pixelated virtualenv doesn't exist, creating now";\
		virtualenv --python=python2 $(VIRTUALENV);\
	else\
		echo "Pixelated virtualenv already exists, moving on";\
	fi

.PHONY: test
test: test_py test_js coverage

.PHONY: test_py
test_py: clean requirements install coverage linters_py unit_tests_py integration_tests_py

.PHONY: test_js
test_js: clean requirements_js install_js linters_js unit_tests_js

.PHONY: test_all
test_all: test functional_tests

.PHONY: linters
linters: clean requirements install linters_py linters_js

.PHONY: linters_py
linters_py:
	@echo "Running pep8"
	@source $(VIRTUALENV)/bin/activate;\
	cd service;\
	pep8 --ignore=E501 pixelated test

.PHONY: linters_js
linters_js:
	@echo "Running jshint"
	@cd web-ui;\
	npm run jshint

.PHONY: coverage
coverage:
	@source $(VIRTUALENV)/bin/activate;\
	cd service;\
	coverage run -p --source=pixelated `which trial` test.unit;\
	coverage run -p --source=pixelated `which trial` test.integration;\
	coverage combine;\
	coverage html

.PHONY: unit_tests_py
unit_tests_py:
	@echo "Running python unit tests"
	@source $(VIRTUALENV)/bin/activate;\
	cd service;\
	trial --reporter=text test.unit

.PHONY: unit_tests_js
unit_tests_js:
	@echo "Running javascript unit tests"
	@cd web-ui;\
	npm run test

.PHONY: integration_tests_py
integration_tests:
	@echo "Running integration tests"
	@source $(VIRTUALENV)/bin/activate;\
	cd service;\
	trial -j`grep -c "^processor" /proc/cpuinfo || sysctl -n hw.logicalcpu` --reporter=text test.integration

.PHONY: functional_tests
functional_tests: clean requirements install ensure_phantomjs_installed
	@echo "Running behave functional tests"
	@source $(VIRTUALENV)/bin/activate;\
	cd service;\
	behave --tags ~@wip --tags ~@smoke test/functional/features

.PHONY: ensure_phantomjs_installed
ensure_phantomjs_installed:
	@if [ ! `which phantomjs` ]; then\
		echo "You need phantomJS to run these tests";\
		exit 1;\
	fi

.PHONY: ensure_virtualenv_installed
ensure_virtualenv_installed:
	@if [ ! `which virtualenv` ]; then\
		echo "Virtualenv must be installed";\
		exit 1;\
	else\
		echo "Virtualenv located at "`which virtualenv`;\
	fi

.PHONY: clean
clean: clean_py clean_js clean_cache
	@echo "Cleaning temporary files and the caches"

.PHONY: clean_all
clean_all: clean remove_javascript_packages remove_virtualenv
	@echo "Cleaning temporary files, the caches and the virtualenv"

.PHONY: clean_py
clean_py:
	rm -rf service/_trial_temp
	find . -name "*.pyc" -delete
	rm -rf service/.coverage
	rm -rf service/htmlcov

.PHONY: clean_js
clean_js:
	rm -rf web-ui/dist
	rm -rf web-ui/.sass-cache

.PHONY: clean_cache
clean_cache:
	rm -rf ~/.config/leap
	rm -rf ~/.leap
	rm -rf service/ghostdriver.log

.PHONY: remove_virtualenv
remove_virtualenv:
	rm -rf $(VIRTUALENV)

.PHONY: remove_javascript_packages
remove_javascript_packages:
	rm -rf web-ui/node_modules
	rm -rf web-ui/app/bower_components