summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnike Arni <anikarni@gmail.com>2017-01-10 11:34:01 -0200
committerGitHub <noreply@github.com>2017-01-10 11:34:01 -0200
commit67f06daab61be9ec763fd228cf51a4d3f9c091a3 (patch)
treec7bbf6ec32d9b9eb5ab5ab3eac04fc60a6fcf253
parentbc84433a06a742c3b29e115fb9e88c86df0f2b1c (diff)
parent96e377d4957b32db440f8179d4c1b16de724fa71 (diff)
Merge pull request #899 from bwagnerr/make
Creates a unified makefile for pixelated client and web-ui
-rw-r--r--Makefile162
-rw-r--r--README.md39
-rwxr-xr-xservice/go170
-rwxr-xr-xweb-ui/_trial_temp/_trial_marker0
-rw-r--r--web-ui/package.json3
5 files changed, 181 insertions, 193 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 00000000..ec865cf5
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,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"
+ @. $(VIRTUALENV)/bin/activate;\
+ pip install --upgrade pip setuptools
+
+.PHONY: install_py
+install_py: service/requirements.txt service/test_requirements.txt
+ @echo "Installing python packages"
+ @. $(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"
+ @. $(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:
+ @. $(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"
+ @. $(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"
+ @. $(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"
+ @. $(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
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 <root/of/pixelated-user-agent>
+$ 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
diff --git a/service/go b/service/go
index eae21a2e..25661508 100755
--- a/service/go
+++ b/service/go
@@ -1,167 +1,7 @@
#!/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
-elif [ "$1" == 'pep8' ]; then
- set -e
- runPep8
-elif [ "$1" == 'setuppy' ]; then
- setuppy
-elif [ "$1" == 'setupjs' ]; then
- setupjs
-elif [ "$1" == 'setup' ]; then
- setupjs
- setuppy "${@:2}"
-elif [ "$1" == 'coverage_unit' ]; then
- runCoverageUnit "${@:2}"
-elif [ "$1" == 'coverage_integration' ]; then
- runCoverageIntegration "${@:2}"
-elif [ "$1" == 'coverage_all' ]; then
- set -e
- runPep8
- runCoverageUnitAndIntegration "${@:2}"
-elif [ "$1" == 'start' ]; then
- /usr/bin/env pixelated-user-agent "${@:2}"
-elif [ "$1" == "functional" ]; then
- runFunctionalTests "${@:2}"
-else
- python setup.py $*
-fi
+type -t deactivate && deactivate
+set -e
+pushd ..
+make $*
+popd
diff --git a/web-ui/_trial_temp/_trial_marker b/web-ui/_trial_temp/_trial_marker
deleted file mode 100755
index e69de29b..00000000
--- a/web-ui/_trial_temp/_trial_marker
+++ /dev/null
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"
}
}