spatial-d4science/bin/travis-build.bash

109 lines
2.9 KiB
Bash
Raw Normal View History

#!/bin/bash
set -e
echo "This is travis-build.bash..."
echo "Installing the packages that CKAN requires..."
sudo apt-get update -qq
2017-09-14 16:56:57 +02:00
sudo apt-get install solr-jetty
2020-04-15 01:20:30 +02:00
if python -c 'import sys;exit(sys.version_info < (3,))'
then
PYTHONVERSION=3
else
PYTHONVERSION=2
fi
echo "Installing CKAN and its Python dependencies..."
git clone https://github.com/ckan/ckan
cd ckan
2020-04-15 01:20:30 +02:00
if [ $CKANVERSION == 'master' ]
then
2020-04-15 01:20:30 +02:00
echo "CKAN version: master"
else
CKAN_TAG=$(git tag | grep ^ckan-$CKANVERSION | sort --version-sort | tail -n 1)
git checkout $CKAN_TAG
echo "CKAN version: ${CKAN_TAG#ckan-}"
fi
2020-05-06 00:20:21 +02:00
if [ -f requirement-setuptools.txt ]
then
pip install -r requirement-setuptools.txt
fi
2020-05-06 00:42:30 +02:00
python setup.py develop
2020-04-15 01:20:30 +02:00
if [ -f requirements-py2.txt ] && [ $PYTHONVERSION = 2 ]
then
2020-04-15 01:20:30 +02:00
grep -v psycopg2 < requirements-py2.txt > reqs.txt
else
2020-04-15 01:20:30 +02:00
grep -v psycopg2 < requirements.txt > reqs.txt
fi
2020-04-15 01:20:30 +02:00
pip install psycopg2==2.7.7 # workaround travis 10 psycopg2 incompatibility
pip install -r reqs.txt
pip install -r dev-requirements.txt
cd -
echo "Setting up Solr..."
2016-04-28 11:02:24 +02:00
# solr is multicore for tests on ckan master now, but it's easier to run tests
# on Travis single-core still.
# see https://github.com/ckan/ckan/issues/2972
sed -i -e 's/solr_url.*/solr_url = http:\/\/127.0.0.1:8983\/solr/' ckan/test-core.ini
printf "NO_START=0\nJETTY_HOST=127.0.0.1\nJETTY_PORT=8983\nJAVA_HOME=$JAVA_HOME" | sudo tee /etc/default/jetty
sudo cp ckan/ckan/config/solr/schema.xml /etc/solr/conf/schema.xml
sudo service jetty restart
echo "Creating the PostgreSQL user and database..."
sudo -u postgres psql -c "CREATE USER ckan_default WITH PASSWORD 'pass';"
sudo -u postgres psql -c 'CREATE DATABASE ckan_test WITH OWNER ckan_default;'
echo "Setting up PostGIS on the database..."
sudo -u postgres psql -d ckan_test -c 'CREATE EXTENSION postgis;'
sudo -u postgres psql -d ckan_test -c 'ALTER VIEW geometry_columns OWNER TO ckan_default;'
sudo -u postgres psql -d ckan_test -c 'ALTER TABLE spatial_ref_sys OWNER TO ckan_default;'
echo "Install other libraries required..."
sudo apt-get install python-dev libxml2-dev libxslt1-dev libgeos-c1
echo "Initialising the database..."
cd ckan
2020-04-15 01:20:30 +02:00
if [ $CKANVERSION \< '2.9' ]
then
paster db init -c test-core.ini
else
ckan -c test-core.ini db init
fi
cd -
echo "Installing ckanext-harvest and its requirements..."
git clone https://github.com/ckan/ckanext-harvest
cd ckanext-harvest
python setup.py develop
pip install -r pip-requirements.txt
2020-05-06 16:19:09 +02:00
if [ $CKANVERSION \< '2.9' ]
then
paster harvester initdb -c ../ckan/test-core.ini
fi
cd -
echo "Installing ckanext-spatial and its requirements..."
pip install -r pip-requirements.txt
python setup.py develop
2020-05-06 16:13:06 +02:00
pip install pycsw
echo "Moving test.ini into a subdir..."
mkdir subdir
mv test.ini subdir
2020-05-06 14:29:16 +02:00
if [ $CKANVERSION \< '2.9' ]
then
paster spatial initdb -c subdir/test.ini
else
2020-05-06 14:59:31 +02:00
ckan -c subdir/test.ini harvester initdb
ckan -c subdir/test.ini spatial initdb
2020-05-06 14:29:16 +02:00
fi
echo "travis-build.bash is done."