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 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 ++++++++++++++++++++++++++++++--------- web-ui/_trial_temp/_trial_marker | 0 2 files changed, 83 insertions(+), 24 deletions(-) delete mode 100755 web-ui/_trial_temp/_trial_marker 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 diff --git a/web-ui/_trial_temp/_trial_marker b/web-ui/_trial_temp/_trial_marker deleted file mode 100755 index e69de29b..00000000 -- 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 +- service/go | 173 +++++++------------------------------------------------------ 2 files changed, 19 insertions(+), 156 deletions(-) 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: diff --git a/service/go b/service/go index eae21a2e..4c388d91 100755 --- a/service/go +++ b/service/go @@ -1,167 +1,30 @@ #!/bin/bash -NUM_OF_CORES='' -NUM_OF_JOBS='' -TRIAL_PATH='' -TRIAL_REPORTER='verbose' - -function getTrialAbsolutePath { - TRIAL_PATH="$(which trial)" -} - -function resolveNumOfCores { - if [ "$(uname)" == "Darwin" ]; then - NUM_OF_CORES="$(sysctl -n hw.ncpu)" - else - NUM_OF_CORES="$(nproc)" - fi -} - -function resolveNumOfJobs { - resolveNumOfCores - if [ "$(uname)" == "Darwin" ]; then - # Somehow, the tests fail on MacOS X for NUM_OF_JOBS="$NUM_OF_CORES" - NUM_OF_JOBS="$(($NUM_OF_CORES > 1 ? $NUM_OF_CORES / 2 : 1))" - else - NUM_OF_JOBS="$NUM_OF_CORES" - fi -} - -function removeZmqCertificates { - if [ -d ~/.config/leap/events/zmq_certificates ] ; then - echo "Removing zmq folder before running tests." - rm -Rf ~/.config/leap/events/zmq_certificates - fi -} - -function setuppy { - echo "Installing Pixelated User Agent." - pip install --upgrade pip setuptools - if [ `uname -s` = "Darwin" ]; then - CFLAGS="-DCRYPTOPP_DISABLE_ASM=1" pip install --exists-action s -r requirements.txt - else - pip install --exists-action s -r requirements.txt - fi - pip install --exists-action s -r test_requirements.txt - echo "Done." -} - -function setupjs { - echo "Installing node and bower libraries." - cd ../web-ui - npm install - node_modules/bower/bin/bower install --config.interactive=false --allow-root - LC_ALL=en_US.UTF-8 ./go build - cd - - echo "Done." -} - -function runIntegrationTests { - echo "Executing Integration Tests." - resolveNumOfJobs - trial -j $NUM_OF_JOBS --reporter=$TRIAL_REPORTER $* test.integration - echo "Done." -} - -function runUnitTests { - echo "Executing Unit Tests." - removeZmqCertificates - trial --reporter=$TRIAL_REPORTER $* test.unit - echo "Done." -} - -function runPep8 { - echo "Verifying conformation to pep8." - pep8 pixelated test --ignore=E501 - echo "Done." -} - -function runJSHint { - echo "Executing JSHint." - cd ../web-ui - LC_ALL=en_US.UTF-8 ./go jshint - cd - - echo "Done." -} - -function runCoverageUnit { - echo "Generating Unit Test Converage Information." - coverage erase - getTrialAbsolutePath - coverage run -p --source=pixelated $TRIAL_PATH --reporter=$TRIAL_REPORTER $* test.unit - coverage combine - coverage html - echo "Done." -} - -function runCoverageIntegration { - echo "Generating Integration Test Converage Information." - coverage erase - getTrialAbsolutePath - coverage run -p --source=pixelated $TRIAL_PATH --reporter=$TRIAL_REPORTER $* test.integration - coverage combine - coverage html - echo "Done." -} - -function runCoverageUnitAndIntegration { - echo "Generating Unit and Integration Test Converage Information." - coverage erase - getTrialAbsolutePath - coverage run -p --source=pixelated $TRIAL_PATH --reporter=$TRIAL_REPORTER test.unit - coverage run -p --source=pixelated $TRIAL_PATH --reporter=$TRIAL_REPORTER test.integration - coverage combine - coverage html - echo "Done." -} - -function runFunctionalTests { - echo "Executing Functional Tests on headless PhantomJS." - removeZmqCertificates - echo "You should execute it on Debian box for more similar results with CI environment." - behave --tags ~@wip --tags ~@smoke test/functional/features - echo "Done." -} - -function cleanPyc { - find . -name '*.pyc' -delete -} - if [ "$1" == 'test' ]; then set -e - runPep8 - runUnitTests "${@:2}" - runIntegrationTests "${@:2}" -elif [ "$1" == 'unit' ]; then - set -e - cleanPyc - runUnitTests -elif [ "$1" == 'integration' ]; then - set -e - cleanPyc - runIntegrationTests + pushd .. + make test_py + popd elif [ "$1" == 'pep8' ]; then set -e - runPep8 -elif [ "$1" == 'setuppy' ]; then - setuppy -elif [ "$1" == 'setupjs' ]; then - setupjs + pushd .. + make linters_js + popd elif [ "$1" == 'setup' ]; then - setupjs - setuppy "${@:2}" -elif [ "$1" == 'coverage_unit' ]; then - runCoverageUnit "${@:2}" -elif [ "$1" == 'coverage_integration' ]; then - runCoverageIntegration "${@:2}" + set -e + pushd .. + make setup + popd elif [ "$1" == 'coverage_all' ]; then set -e - runPep8 - runCoverageUnitAndIntegration "${@:2}" -elif [ "$1" == 'start' ]; then - /usr/bin/env pixelated-user-agent "${@:2}" + pushd .. + make coverage + popd elif [ "$1" == "functional" ]; then - runFunctionalTests "${@:2}" + set -e + pushd .. + make test_functional + popd else - python setup.py $* + echo "Command doesn't exist" fi -- 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(-) 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 +++++------ service/go | 1 + web-ui/package.json | 3 ++- 3 files changed, 8 insertions(+), 7 deletions(-) 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: diff --git a/service/go b/service/go index 4c388d91..0183c7b2 100755 --- a/service/go +++ b/service/go @@ -27,4 +27,5 @@ elif [ "$1" == "functional" ]; then popd else echo "Command doesn't exist" + exit 1 fi diff --git a/web-ui/package.json b/web-ui/package.json index 3d1720e1..d67114cc 100644 --- a/web-ui/package.json +++ b/web-ui/package.json @@ -62,6 +62,7 @@ "clean": "rm -rf dist/ app/js/generated/hbs/* app/css/*", "package": "PIXELATED_BUILD='package' npm run build-prod && npm run imagemin", "imagemin": "node config/imagemin.js", - "add_git_version": "/bin/bash config/add_git_version.sh" + "add_git_version": "/bin/bash config/add_git_version.sh", + "postinstall" : "bower install" } } -- cgit v1.2.3 From 602da0c9358c3d1b01fee3870202abcbae548602 Mon Sep 17 00:00:00 2001 From: Bruno Wagner Date: Wed, 4 Jan 2017 10:53:43 -0200 Subject: Simplified service ./go to call make directly Also added the deactivation of the virtualenv before running anything, to avoid conflicting virtualenvs --- service/go | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/service/go b/service/go index 0183c7b2..25661508 100755 --- a/service/go +++ b/service/go @@ -1,31 +1,7 @@ #!/bin/bash -if [ "$1" == 'test' ]; then - set -e - pushd .. - make test_py - popd -elif [ "$1" == 'pep8' ]; then - set -e - pushd .. - make linters_js - popd -elif [ "$1" == 'setup' ]; then - set -e - pushd .. - make setup - popd -elif [ "$1" == 'coverage_all' ]; then - set -e - pushd .. - make coverage - popd -elif [ "$1" == "functional" ]; then - set -e - pushd .. - make test_functional - popd -else - echo "Command doesn't exist" - exit 1 -fi +type -t deactivate && deactivate +set -e +pushd .. +make $* +popd -- 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(-) 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 ++++- README.md | 39 ++++++++++++--------------------------- 2 files changed, 16 insertions(+), 28 deletions(-) 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;\ diff --git a/README.md b/README.md index 6eef10d8..f27aeef8 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ You are most welcome to contribute to the pixelated user agent code base. Please You like the idea and you want to run it locally, then before you have to install the following packages: * [Vagrant](https://www.vagrantup.com/downloads.html), Vagrant is a tool that automates the setup of a virtual machine with the development environment -* A vagrant [compatible provider](https://www.vagrantup.com/docs/providers/), e.g. [Virtual Box](https://www.virtualbox.org/wiki/Downloads). +* A vagrant [compatible provider](https://www.vagrantup.com/docs/providers/), e.g. [Virtual Box](https://www.virtualbox.org/wiki/Downloads). ### Option 1: Pixelated User Agent without LEAP provider @@ -79,31 +79,19 @@ Then you can connect to `try.pixelated-project.org` ... 6) If you like console output, you can also run the tests to see if everything went according to plan. ```bash -(user-agent-venv)vagrant@jessie:~$ cd /vagrant + vagrant@jessie:~ $ cd /vagrant ``` -To run the backend tests: +To run the tests: ```bash - (user-agent-venv)vagrant@jessie:/vagrant$ cd service - (user-agent-venv)vagrant@jessie:/vagrant/service$ ./go test - (user-agent-venv)vagrant@jessie:/vagrant/service$ cd .. -``` - -To run the frontend tests: - -```bash - (user-agent-venv)vagrant@jessie:/vagrant$ cd web-ui - (user-agent-venv)vagrant@jessie:/vagrant/web-ui$ ./go test - (user-agent-venv)vagrant@jessie:/vagrant/web-ui$ cd .. + vagrant@jessie:/vagrant $ make test ``` To run the functional tests: ```bash - (user-agent-venv)vagrant@jessie:/vagrant$ cd service - (user-agent-venv)vagrant@jessie:/vagrant/service$ ./go functional - (user-agent-venv)vagrant@jessie:/vagrant/service$ cd .. + vagrant@jessie:/vagrant $ make functional_tests ``` 7) You're all set! We've prepared [a couple of issues labeled "Volunteer Task"](https://github.com/pixelated/pixelated-user-agent/labels/Volunteer%20task) that are a good place to dive into the project. Happy Hacking! @@ -128,16 +116,14 @@ You can install the Pixelated User Agent and the Leap Platform at once, just by NOTE: Be aware that you will not be able to send mails outside, but you can test sending mails internally from one user to another. -## Running tests inside your local IDE +## Running tests on your local machine -If you want to run the tests in your IDE on your host machine outside of vagrant, set up your python virtualenv +If you want to run the tests in your host machine outside of vagrant: ``` -$ pip install virtualenv setuptools -$ cd ~ -$ virtualenv pixelated -$ virtualenv -p [PATH/TO/YOUR/PYTHON/EXECUTABLE] pixelated -$ source ~/.virtualenv/pixelated/bin/activate +$ pip install virtualenv +$ cd +$ make test ``` If you want to run the tests in your IDE on your host machine outside of vagrant, there's a bug in a LEAP library that can't handle symlinks to your local GPG installation. @@ -155,7 +141,7 @@ Do it the easy way first, and submit a pull request as a “work in progress” To run the pixelated user agent multi user mode, please run the following: ```bash - (user-agent-venv)vagrant@jessie:/vagrant$ pixelated-user-agent --host 0.0.0.0 --multi-user --provider=dev.pixelated-project.org + vagrant@jessie:/vagrant$ pixelated-user-agent --host 0.0.0.0 --multi-user --provider=dev.pixelated-project.org ``` You will need to change `dev.pixelated-project.org` to the hostname of the leap provider that you will be using. @@ -197,8 +183,7 @@ All commits to the pixelated user agent code trigger all tests to be run in [sna * For all backend changes, you will need to stop and restart the server again (Step 5 above). * For most frontend changes, you will just need to reload the browser. Some changes (in particular, those involving css or handlebars) you will need to run: ```bash - (user-agent-venv)vagrant@jessie:/vagrant$ cd web-ui - (user-agent-venv)vagrant@jessie:/vagrant/web-ui$ ./go build + vagrant@jessie:/vagrant$ make install_js ``` ## Developer Setup On Native OS -- 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(+) 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(+) 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(-) 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