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

.PHONY: setup
setup: requirements 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 ~/.venvs/pixua/bin/activate;\
	pip install --upgrade pip setuptools

.PHONY: install_py
install_py: service/requirements.txt service/test_requirements.txt
	@echo "Installing python packages"
	@source ~/.venvs/pixua/bin/activate;\
	cd service;\
	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;\
	node_modules/.bin/bower 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_py
linters_py:
	@echo "Running pep8"
	@source ~/.venvs/pixua/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:

.PHONY: unit_tests_py
unit_tests_py:
	@echo "Running python unit tests"
	-@source ~/.venvs/pixua/bin/activate;\
	cd service;\
	trial --reporter=text test.unit
	@echo js unit tests pending

.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 ~/.venvs/pixua/bin/activate;\
	cd service;\
	trial -j`grep -c "^processor" /proc/cpuinfo || sysctl -n hw.logicalcpu` --reporter=text test.integration

.PHONY: functional_tests
functional_tests: ensure_phantomjs_installed
	@echo "Running behave functional tests"
	@source ~/.venvs/pixua/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\
		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

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

.PHONY: clean_cache
clean_cache:
	rm -rf ~/.config/leap
	rm -rf ~/.leap

.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