test.sh 1.58 KB
Newer Older
1 2
#! /bin/bash

3 4 5
set -e
set -x

6
function github_status {
7
    gcli status create edx mitx $GIT_COMMIT \
8 9 10 11 12 13 14 15 16
         --params=$1 \
                  target_url:$BUILD_URL \
                  description:"Build #$BUILD_NUMBER $2" \
         -f csv
}

function github_mark_failed_on_exit {
    trap '[ $? == "0" ] || github_status state:failure "failed"' EXIT
}
17

18 19
git remote prune origin

20
github_mark_failed_on_exit
21
github_status state:pending "is running"
22

23 24 25 26 27 28 29
# Reset the submodule, in case it changed
git submodule foreach 'git reset --hard HEAD'

# Set the IO encoding to UTF-8 so that askbot will start
export PYTHONIOENCODING=UTF-8

GIT_BRANCH=${GIT_BRANCH/HEAD/master}
30 31 32 33
if [ ! -d /mnt/virtualenvs/"$JOB_NAME" ]; then
    mkdir -p /mnt/virtualenvs/"$JOB_NAME"
    virtualenv /mnt/virtualenvs/"$JOB_NAME"
fi
34

35 36
export PIP_DOWNLOAD_CACHE=/mnt/pip-cache

37
source /mnt/virtualenvs/"$JOB_NAME"/bin/activate
38
pip install -q -r pre-requirements.txt
39
yes w | pip install -q -r requirements.txt
40

41 42
bundle install

43 44
npm install

45
rake clobber
46 47
rake pep8 > pep8.log || cat pep8.log
rake pylint > pylint.log || cat pylint.log
48

49
TESTS_FAILED=0
50 51

# Run the python unit tests
52
rake test_cms[false] || TESTS_FAILED=1
53 54 55
rake test_lms[false] || TESTS_FAILED=1
rake test_common/lib/capa || TESTS_FAILED=1
rake test_common/lib/xmodule || TESTS_FAILED=1
56 57

# Run the jaavascript unit tests
58
rake phantomjs_jasmine_lms || TESTS_FAILED=1
59
rake phantomjs_jasmine_cms || TESTS_FAILED=1
60
rake phantomjs_jasmine_common/lib/xmodule || TESTS_FAILED=1
61

62
rake coverage:xml coverage:html
63 64

[ $TESTS_FAILED == '0' ]
65 66
rake autodeploy_properties

67
github_status state:success "passed"