-
Notifications
You must be signed in to change notification settings - Fork 2k
/
travis-build
executable file
·93 lines (76 loc) · 2.92 KB
/
travis-build
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/sh
# get the commit message of the last commit on the branch
COMMIT=`git log -n1 --oneline`
echo ==========================================================
echo
echo Python: $TRAVIS_PYTHON_VERSION
echo Postgres: $PGVERSION
echo Branch: $TRAVIS_BRANCH
echo Commit: $COMMIT
echo
echo ==========================================================
# Are we on a branch that we need to do full testing
MAJOR_BRANCH=`echo $TRAVIS_BRANCH | egrep release\|master`
if [ "$MAJOR_BRANCH" = '' ]
then
# If commit message ends in ++ we will run all the tests
IS_PLUS=`echo $COMMIT | grep \+\+$`
if [ "$IS_PLUS" = '' ]
then
# Don't test under python 2.6
if [ $TRAVIS_PYTHON_VERSION = '2.6' ]
then
echo No need to test this branch under python 2.6
exit 0
fi
# Don't test on Postgres 8.4
if [ $PGVERSION = '8.4' ]
then
echo No need to test this branch under postgres 8.4
exit 0
fi
fi
fi
# Drop Travis' postgres cluster if we're building using a different pg version
TRAVIS_PGVERSION='9.1'
if [ $PGVERSION != $TRAVIS_PGVERSION ]
then
sudo -u postgres pg_dropcluster --stop $TRAVIS_PGVERSION main
# Make psql use $PGVERSION
export PGCLUSTER=$PGVERSION/main
fi
# Install postgres and solr
# We need this ppa so we can install postgres-8.4
sudo add-apt-repository -yy ppa:pitti/postgresql
sudo apt-get -qq update
sudo apt-get -qq install solr-jetty postgresql-$PGVERSION
# Don't require a password to access DB
#sudo sed -i -e 's/ident/trust/g' /etc/postgresql/$PGVERSION/main/pg_hba.conf
sudo service postgresql reload
# make users
sudo -u postgres psql -c "CREATE USER ckanuser WITH PASSWORD 'pass';"
sudo -u postgres psql -c "CREATE USER readonlyuser WITH PASSWORD 'pass';"
# make databases psql
sudo -u postgres psql -c 'CREATE DATABASE ckan_test WITH OWNER ckanuser;'
sudo -u postgres psql -c 'CREATE DATABASE ckan_test_datastore WITH OWNER ckanuser;'
pip install -r pip-requirements.txt --use-mirrors
pip install -r pip-requirements-test.txt --use-mirrors
python setup.py develop
# Configure Solr
echo "NO_START=0\nJETTY_HOST=127.0.0.1\nJETTY_PORT=8983\nJAVA_HOME=$JAVA_HOME" | sudo tee /etc/default/jetty
# FIXME the solr schema cannot be hardcoded as it is dependent on the ckan version
sudo cp ckan/config/solr/schema-2.0.xml /etc/solr/conf/schema.xml
sudo service jetty restart
paster db init -c test-core.ini
# If Postgres >= 9.0, we don't need to use datastore's legacy mode.
if [ $PGVERSION != '8.4' ]
then
psql -c 'CREATE USER readonlyuser;' -U postgres
sed -i -e 's/.*datastore.read_url.*/ckan.datastore.read_url = postgresql:\/\/readonlyuser@\/ckan_test_datastore/' test-core.ini
paster datastore set-permissions postgres -c test-core.ini
else
sed -i -e 's/.*datastore.read_url.*//' test-core.ini
fi
cat test-core.ini
# And finally, run the tests
nosetests --ckan --with-pylons=test-core.ini --nologcapture ckan ckanext