summaryrefslogtreecommitdiff
path: root/Makefile
blob: b597c3f84f09e42d302fe757796be20c24b274c0 (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
VIRTUALENV=~/.venvs/pixua

.PHONY: setup requirements install requirements_py install_py requirements_js install_js create_virtualenv
.PHONY: test test_py test_js test_all linters linters_py linters_js coverage unit_tests_py unit_tests_js
.PHONY: integration_tests_py functional_tests functional_tests_ci ensure_virtualenv_installed clean
.PHONY: clean_all clean_py clean_js clean_cache remove_virtualenv remove_javascript_packages run
setup: install

requirements: requirements_py requirements_js

install: requirements install_py install_js

requirements_py: create_virtualenv
	@. $(VIRTUALENV)/bin/activate;\
	pip install --upgrade pip setuptools

install_py: service/requirements.txt service/test_requirements.txt
	@. $(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

requirements_js:
	@cd web-ui;\
	npm install;\
	node_modules/.bin/bower install

install_js:
	@cd web-ui;\
	npm rebuild node-sass;\
	npm run build

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

test: clean install test_py test_js coverage
test_py: linters_py unit_tests_py integration_tests_py
test_js: linters_js unit_tests_js
test_all: test functional_tests
linters: clean install linters_py linters_js

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

linters_js:
	@cd web-ui;\
	npm run lint

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

unit_tests_py:
	@. $(VIRTUALENV)/bin/activate;\
	cd service;\
	export PYTHONPATH=$(PYTHONPATH):`pwd`;\
	trial --reporter=text test.unit

unit_tests_js:
	@cd web-ui;\
	npm run test

integration_tests_py:
	@. $(VIRTUALENV)/bin/activate;\
	cd service;\
	export PYTHONPATH=$(PYTHONPATH):`pwd`;\
	trial --reporter=text test.integration

functional_tests: clean requirements install
	@. $(VIRTUALENV)/bin/activate;\
	export PATH=$(PATH):/usr/lib/chromium/;\
	cd service;\
	xvfb-run --server-args="-screen 0 1280x1024x24" behave --tags ~@wip --tags ~@smoke test/functional/features

smoke_tests: clean install
	@. $(VIRTUALENV)/bin/activate;\
	export PATH=$(PATH):/usr/lib/chromium/;\
	cd service;\
	xvfb-run --server-args="-screen 0 1280x1024x24" behave --tags ~@wip --tags @smoke test/functional/features -k -D host=$(provider)

functional_tests_ci: clean requirements install
	@. $(VIRTUALENV)/bin/activate;\
	cd service;\
	behave --tags ~@wip --tags ~@smoke test/functional/features

functional_tests_wip:
	@. $(VIRTUALENV)/bin/activate;\
	export PATH=$(PATH):/usr/lib/chromium/;\
	cd service;\
	xvfb-run --server-args="-screen 0 1280x1024x24" behave --tags @wip test/functional/features

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

clean: clean_py clean_js clean_cache
clean_all: clean remove_javascript_packages remove_virtualenv

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

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

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

remove_virtualenv:
	rm -rf $(VIRTUALENV)

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

diagrams:
	@. $(VIRTUALENV)/bin/activate;\
	pip install plantuml;\
	cd service/diagrams/png;\
	python -m plantuml *.txt

run:
	@. $(VIRTUALENV)/bin/activate;\
	pixelated-user-agent --host 0.0.0.0 --multi-user --provider=$(provider)