From 6ee9c34003ceb2678a944764563359ad8d29a51b Mon Sep 17 00:00:00 2001 From: Bruno Wagner Date: Tue, 3 Jan 2017 11:45:51 -0200 Subject: Creates a unified makefile for pixelated client and web-ui The python setup (including automatic creation of virtualenv) and test runners are already working. Pending javascript build and tests --- Makefile | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 Makefile (limited to 'Makefile') diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..e9b4472f --- /dev/null +++ b/Makefile @@ -0,0 +1,90 @@ +VIRTUALENV=~/.venvs/pixua + +.PHONY=setup requirements install requirements_py requirements_js\ +install_py install_js create_virtualenv \ +test test_all linters coverage unit_tests integration_tests functional_tests\ +clean ensure_virtualenv_installed ensure_phantomjs_installed + +setup: requirements install + +requirements: requirements_py requirements_js + +install: install_py install_js + @echo "Installing dependencies" + +requirements_py: create_virtualenv + @echo "Upgrading pip and setuptools" + @source ~/.venvs/pixua/bin/activate;\ + pip install --upgrade pip setuptools + +requirements_js: + @echo "Installing js requirements" + +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 + +install_js: + @echo "Installing javascript packages" + +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 + +test: clean requirements_py install_py linters coverage unit_tests integration_tests + +test_all: test functional_tests + +linters: + @echo "Running pep8 and jshint" + @source ~/.venvs/pixua/bin/activate;\ + cd service;\ + pep8 --ignore=E501 pixelated test + @echo jshint pending + +coverage: + +unit_tests: + @echo "Running python and javascript unit tests" + -@source ~/.venvs/pixua/bin/activate;\ + cd service;\ + trial --reporter=text test.unit + @echo js unit tests pending + +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 + +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 + +ensure_phantomjs_installed: + @if [ ! `which phantomjs` ]; then\ + echo "You need phantomJS to run these tests";\ + exit 1;\ + fi + +ensure_virtualenv_installed: + @if [ ! `which virtualenv` ]; then\ + exit 1;\ + else\ + echo "Virtualenv located at "`which virtualenv`;\ + fi + +clean: + @echo "Cleaning cache and temporary files" + rm -rf ~/.config/leap + rm -rf ~/.leap + rm -rf service/_trial_temp + find . -name "*.pyc" -delete -- cgit v1.2.3 From 7870742af6738a595a58facf006829d0f35f28e0 Mon Sep 17 00:00:00 2001 From: Bruno Wagner Date: Tue, 3 Jan 2017 15:21:41 -0200 Subject: Adds javascript build and tests to makefile Now you can setup both javascript and python from scratch and run the test suites on both sides directly from the root of the project --- Makefile | 107 +++++++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 83 insertions(+), 24 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index e9b4472f..b0f1ee78 100644 --- a/Makefile +++ b/Makefile @@ -1,34 +1,43 @@ VIRTUALENV=~/.venvs/pixua -.PHONY=setup requirements install requirements_py requirements_js\ -install_py install_js create_virtualenv \ -test test_all linters coverage unit_tests integration_tests functional_tests\ -clean ensure_virtualenv_installed ensure_phantomjs_installed - +.PHONY: setup setup: requirements install +.PHONY: requirements requirements: requirements_py requirements_js + @echo "Installed requirements" -install: install_py install_js - @echo "Installing dependencies" +.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 -requirements_js: - @echo "Installing js requirements" - +.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 "Installing javascript packages" + @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";\ @@ -37,44 +46,70 @@ create_virtualenv: ensure_virtualenv_installed echo "Pixelated virtualenv already exists, moving on";\ fi -test: clean requirements_py install_py linters coverage unit_tests integration_tests +.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 -linters: - @echo "Running pep8 and jshint" +.PHONY: linters_py +linters_py: + @echo "Running pep8" @source ~/.venvs/pixua/bin/activate;\ cd service;\ pep8 --ignore=E501 pixelated test - @echo jshint pending +.PHONY: linters_js +linters_js: + @echo "Running jshint" + @cd web-ui;\ + npm run jshint + +.PHONY: coverage coverage: -unit_tests: - @echo "Running python and javascript unit tests" +.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;\ + @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;\ @@ -82,9 +117,33 @@ ensure_virtualenv_installed: echo "Virtualenv located at "`which virtualenv`;\ fi -clean: - @echo "Cleaning cache and temporary files" - rm -rf ~/.config/leap - rm -rf ~/.leap - rm -rf service/_trial_temp - find . -name "*.pyc" -delete +.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 -- cgit v1.2.3 From 9da37a371bd4f7b14b28036ddb528c33bad1ad18 Mon Sep 17 00:00:00 2001 From: Bruno Wagner Date: Tue, 3 Jan 2017 15:58:36 -0200 Subject: Go script is now using make to ease the transition --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index b0f1ee78..1f3eddc1 100644 --- a/Makefile +++ b/Makefile @@ -80,7 +80,6 @@ unit_tests_py: -@source ~/.venvs/pixua/bin/activate;\ cd service;\ trial --reporter=text test.unit - @echo js unit tests pending .PHONY: unit_tests_js unit_tests_js: @@ -138,6 +137,7 @@ clean_js: clean_cache: rm -rf ~/.config/leap rm -rf ~/.leap + rm -rf service/ghostdriver.log .PHONY: remove_virtualenv remove_virtualenv: -- cgit v1.2.3 From cb21017d3affd6ff51c47de36913311206c865df Mon Sep 17 00:00:00 2001 From: Bruno Wagner Date: Tue, 3 Jan 2017 16:31:00 -0200 Subject: Added coverage to the Makefile --- Makefile | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 1f3eddc1..cdd5e85c 100644 --- a/Makefile +++ b/Makefile @@ -14,13 +14,13 @@ install: requirements install_py install_js .PHONY: requirements_py requirements_py: create_virtualenv @echo "Upgrading pip and setuptools" - @source ~/.venvs/pixua/bin/activate;\ + @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 ~/.venvs/pixua/bin/activate;\ + @source $(VIRTUALENV)/bin/activate;\ cd service;\ pip install --exists-action s -r requirements.txt -r test_requirements.txt @@ -61,7 +61,7 @@ test_all: test functional_tests .PHONY: linters_py linters_py: @echo "Running pep8" - @source ~/.venvs/pixua/bin/activate;\ + @source $(VIRTUALENV)/bin/activate;\ cd service;\ pep8 --ignore=E501 pixelated test @@ -73,11 +73,17 @@ linters_js: .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 ~/.venvs/pixua/bin/activate;\ + @source $(VIRTUALENV)/bin/activate;\ cd service;\ trial --reporter=text test.unit @@ -90,14 +96,14 @@ unit_tests_js: .PHONY: integration_tests_py integration_tests: @echo "Running integration tests" - @source ~/.venvs/pixua/bin/activate;\ + @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: ensure_phantomjs_installed @echo "Running behave functional tests" - @source ~/.venvs/pixua/bin/activate;\ + @source $(VIRTUALENV)/bin/activate;\ cd service;\ behave --tags ~@wip --tags ~@smoke test/functional/features @@ -128,10 +134,13 @@ clean_all: clean remove_javascript_packages remove_virtualenv clean_py: rm -rf service/_trial_temp find . -name "*.pyc" -delete + @source $(VIRTUALENV)/bin/activate;\ + rm -rf service/.coverage .PHONY: clean_js clean_js: rm -rf web-ui/dist + rm -rf web-ui/.sass-cache .PHONY: clean_cache clean_cache: -- cgit v1.2.3 From 8e2f0852f173aca560f71e871ceab1d471a8b206 Mon Sep 17 00:00:00 2001 From: Bruno Wagner Date: Tue, 3 Jan 2017 18:58:52 -0200 Subject: Moved bower install to npm post_install Also fixed some indentation errors on the Makefile --- Makefile | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index cdd5e85c..61203118 100644 --- a/Makefile +++ b/Makefile @@ -28,8 +28,7 @@ install_py: service/requirements.txt service/test_requirements.txt requirements_js: @echo "Installing javascript npm and bower dependencies" @cd web-ui;\ - npm install;\ - node_modules/.bin/bower install + npm install .PHONY: install_js install_js: @@ -43,7 +42,7 @@ create_virtualenv: ensure_virtualenv_installed echo "Pixelated virtualenv doesn't exist, creating now";\ virtualenv --python=python2 $(VIRTUALENV);\ else\ - echo "Pixelated virtualenv already exists, moving on";\ + echo "Pixelated virtualenv already exists, moving on";\ fi .PHONY: test @@ -91,7 +90,7 @@ unit_tests_py: unit_tests_js: @echo "Running javascript unit tests" @cd web-ui;\ - npm run test + npm run test .PHONY: integration_tests_py integration_tests: @@ -119,7 +118,7 @@ ensure_virtualenv_installed: @if [ ! `which virtualenv` ]; then\ exit 1;\ else\ - echo "Virtualenv located at "`which virtualenv`;\ + echo "Virtualenv located at "`which virtualenv`;\ fi .PHONY: clean @@ -134,8 +133,8 @@ clean_all: clean remove_javascript_packages remove_virtualenv clean_py: rm -rf service/_trial_temp find . -name "*.pyc" -delete - @source $(VIRTUALENV)/bin/activate;\ rm -rf service/.coverage + rm -rf service/htmlcov .PHONY: clean_js clean_js: -- cgit v1.2.3 From 8967edec473d9d98feeab8ff65cee20d1db6b159 Mon Sep 17 00:00:00 2001 From: Bruno Wagner Date: Wed, 4 Jan 2017 12:19:52 -0200 Subject: Make target setup now only calls install --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 61203118..962138c8 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ VIRTUALENV=~/.venvs/pixua .PHONY: setup -setup: requirements install +setup: install .PHONY: requirements requirements: requirements_py requirements_js -- cgit v1.2.3 From 62975b2391180b065f4a0f1537f8fbf191223b89 Mon Sep 17 00:00:00 2001 From: Bruno Wagner Date: Mon, 9 Jan 2017 17:55:14 -0200 Subject: Functional tests and linters can now be ran standalone Also adapted the README to use the makefile for instructions --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 962138c8..c00dd461 100644 --- a/Makefile +++ b/Makefile @@ -57,6 +57,9 @@ 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" @@ -100,7 +103,7 @@ integration_tests: trial -j`grep -c "^processor" /proc/cpuinfo || sysctl -n hw.logicalcpu` --reporter=text test.integration .PHONY: functional_tests -functional_tests: ensure_phantomjs_installed +functional_tests: clean requirements install ensure_phantomjs_installed @echo "Running behave functional tests" @source $(VIRTUALENV)/bin/activate;\ cd service;\ -- cgit v1.2.3 From be1f95f20083e64955bb041f94d96bb46b8112b1 Mon Sep 17 00:00:00 2001 From: Bruno Wagner Date: Mon, 9 Jan 2017 18:00:43 -0200 Subject: Added error message in case virtualenv doesn't exist --- Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index c00dd461..e903ab34 100644 --- a/Makefile +++ b/Makefile @@ -119,6 +119,7 @@ ensure_phantomjs_installed: .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`;\ -- cgit v1.2.3 From fa3660a5a10935be343f0fcb8b09515375f79736 Mon Sep 17 00:00:00 2001 From: Bruno Wagner Date: Mon, 9 Jan 2017 18:29:31 -0200 Subject: Added special bundled requirements for pysqlcipher The build breaks without it, with it most machines can run the tests --- Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index e903ab34..2d66a79f 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,7 @@ 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 -- cgit v1.2.3 From 96e377d4957b32db440f8179d4c1b16de724fa71 Mon Sep 17 00:00:00 2001 From: Bruno Wagner Date: Mon, 9 Jan 2017 18:55:59 -0200 Subject: Moved source to . so we are compatible with sh Snap uses sh directly to run the build, so we cannot expect bash. I changed everything to . so that the make runs more broadly --- Makefile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 2d66a79f..ec865cf5 100644 --- a/Makefile +++ b/Makefile @@ -14,13 +14,13 @@ install: requirements install_py install_js .PHONY: requirements_py requirements_py: create_virtualenv @echo "Upgrading pip and setuptools" - @source $(VIRTUALENV)/bin/activate;\ + @. $(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;\ + @. $(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 @@ -64,7 +64,7 @@ linters: clean requirements install linters_py linters_js .PHONY: linters_py linters_py: @echo "Running pep8" - @source $(VIRTUALENV)/bin/activate;\ + @. $(VIRTUALENV)/bin/activate;\ cd service;\ pep8 --ignore=E501 pixelated test @@ -76,7 +76,7 @@ linters_js: .PHONY: coverage coverage: - @source $(VIRTUALENV)/bin/activate;\ + @. $(VIRTUALENV)/bin/activate;\ cd service;\ coverage run -p --source=pixelated `which trial` test.unit;\ coverage run -p --source=pixelated `which trial` test.integration;\ @@ -86,7 +86,7 @@ coverage: .PHONY: unit_tests_py unit_tests_py: @echo "Running python unit tests" - @source $(VIRTUALENV)/bin/activate;\ + @. $(VIRTUALENV)/bin/activate;\ cd service;\ trial --reporter=text test.unit @@ -99,14 +99,14 @@ unit_tests_js: .PHONY: integration_tests_py integration_tests: @echo "Running integration tests" - @source $(VIRTUALENV)/bin/activate;\ + @. $(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;\ + @. $(VIRTUALENV)/bin/activate;\ cd service;\ behave --tags ~@wip --tags ~@smoke test/functional/features -- cgit v1.2.3