This repository has been archived by the owner on Feb 1, 2018. It is now read-only.
/
jenkins.sh
executable file
·77 lines (59 loc) · 2.24 KB
/
jenkins.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/sh
# This script makes sure that Jenkins can properly run your tests against your
# codebase.
set -e
DB_HOST="localhost"
DB_USER="hudson"
cd $WORKSPACE
VENV=$WORKSPACE/venv
echo "Starting build on executor $EXECUTOR_NUMBER..."
# Make sure there's no old pyc files around.
find . -name '*.pyc' -exec rm {} \;
# RHEL postgres 9 RPM installs pg_config here, psycopg2 needs it
export PATH=$PATH:/usr/pgsql-9.2/bin/
if [ ! -d "$VENV/bin" ]; then
echo "No virtualenv found. Making one..."
virtualenv $VENV --no-site-packages
source $VENV/bin/activate
pip install --upgrade pip
pip install coverage
fi
git submodule sync -q
git submodule update --init --recursive
if [ ! -d "$WORKSPACE/vendor" ]; then
echo "No /vendor... crap."
exit 1
fi
source $VENV/bin/activate
pip install -q -r requirements/dev.txt
pip install -I --install-option="--home=`pwd`/vendor-local" \
-r requirements/prod.txt
# because `python-ldap` is stupid and tries to re-install setuptools if you
# use the `-I` flag (aka `--ignore-installed`) we don't use it for
# `requirements/compiled.txt`
pip install --install-option="--home=`pwd`/vendor-local" \
-r requirements/compiled.txt
cp crashstats/settings/local.py-dist crashstats/settings/local.py
echo "# enabled by force by jenkins.sh" >> crashstats/settings/local.py
echo "COMPRESS_OFFLINE = True" >> crashstats/settings/local.py
echo "Linting..."
find crashstats/ | grep '\.py$' | xargs check.py | grep -v "unable to detect undefined names" | awk '{ if ($0 ~ /[A-Za-z]/) { print; exit 1 } }'
echo "Starting tests..."
./manage.py collectstatic --noinput
# even though COMPRESS_OFFLINE=True is in before the tests are run
# COMPRESS becomes (not DEBUG) which will become False so that's why we need
# to use --force here.
./manage.py compress_jingo --force
FORCE_DB=true coverage run manage.py test --noinput --with-xunit
coverage xml $(find crashstats lib -name '*.py')
echo "Tests finished."
echo "Clean up..."
if [ -a "$WORKSPACE/socorro-crashstats.tar.gz" ]; then
rm ./socorro-crashstats.tar.gz
fi
rm -rf $VENV
echo "Tar it..."
tar --mode 755 --owner 0 --group 0 --exclude-vcs -zcf ../socorro-crashstats.tar.gz ./*
mv ../socorro-crashstats.tar.gz ./
echo "GIT_SHA = \"`git rev-parse HEAD`\"" > version.py
echo "FIN"