diff options
Diffstat (limited to 'ci-build')
-rwxr-xr-x | ci-build | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/ci-build b/ci-build new file mode 100755 index 0000000..714c5da --- /dev/null +++ b/ci-build @@ -0,0 +1,58 @@ +#!/bin/sh + +VENV_DIR=".ci-build-venv" +# Directory where coverage HTML report will be written. +COVERAGE_REPORT_DIR="lava_tool_coverage" + +set -e + +if test -z "$VIRTUAL_ENV"; then + set -x + virtualenv $VENV_DIR + . $VENV_DIR/bin/activate + python setup.py develop +fi + +# requirement for integration tests +if ! pip show Flask | grep -q Flask; then + pip install 'Flask==0.9' +fi +if ! pip show PyYAML | grep -q PyYAML; then + pip install PyYAML +fi +# requirement for unit tests +if ! pip show mocker | grep -q mocker; then + pip install mocker +fi + +if ! pip show mock | grep -q mock; then + pip install mock +fi +# Requirement to run code coverage tests. +if ! pip show coverage | grep -q coverage; then + pip install coverage +fi + +if test -z "$DISPLAY"; then + # actual CI + + # will install tests dependencies automatically. The output is also more + # verbose + python setup.py test < /dev/null + + # integration-tests will pick this up and provide detailed output + export VERBOSE=1 +else + # in a development workstation, this will produce shorter/nicer output, but + # requires the test dependencies to be installed manually (or by running + # `python setup.py test` before). + python -m unittest lava_tool.tests.test_suite < /dev/null +fi + +if test -d $COVERAGE_REPORT_DIR; then + rm -rf $COVERAGE_REPORT_DIR +fi +# Runs python-coverage. +python-coverage run -m unittest lava_tool.tests.test_suite 2>/dev/null && python-coverage html + +./integration-tests |