From fb17d05714ea560967b72c3f36799dc68b32bff4 Mon Sep 17 00:00:00 2001 From: Mario de Frutos Date: Fri, 16 Feb 2018 09:47:39 +0100 Subject: [PATCH] Improve Travis testing - Added multiple versions of PostgreSQL to test (9.5, 9.6 and 10) - Added multiple versions of Postgis to test - Cleand travis yaml in favor of a script done in other project thanks to Paul Ramsey --- .travis.yml | 34 +++++++----------------------- scripts/ci/install_postgres.sh | 38 ++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 27 deletions(-) create mode 100644 scripts/ci/install_postgres.sh diff --git a/.travis.yml b/.travis.yml index 7330ccf..a7a3cbf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,34 +6,14 @@ env: global: - PAGER=cat +matrix: + include: + - env: PGSQL_VERSION=9.5 POSTGIS_VERSION=2.2 + - env: PGSQL_VERSION=9.6 POSTGIS_VERSION=2.3 + - env: PGSQL_VERSION=10 POSTGIS_VERSION=2.4 + before_install: - - sudo add-apt-repository -y ppa:cartodb/postgresql-9.5 - - sudo add-apt-repository -y ppa:cartodb/gis - - sudo add-apt-repository -y ppa:cartodb/gis-testing - - sudo apt-get update - - # Install postgres db and build deps - - sudo /etc/init.d/postgresql stop # stop travis default instance - - sudo apt-get -y remove --purge postgresql-9.1 - - sudo apt-get -y remove --purge postgresql-9.2 - - sudo apt-get -y remove --purge postgresql-9.3 - - sudo apt-get -y remove --purge postgresql-9.4 - - sudo apt-get -y remove --purge postgresql-9.5 - - sudo rm -rf /var/lib/postgresql/ - - sudo rm -rf /var/log/postgresql/ - - sudo rm -rf /etc/postgresql/ - - sudo apt-get -y remove --purge postgis-2.2 - - sudo apt-get -y autoremove - - - sudo apt-get -y install postgresql-9.5=9.5.2-3cdb3 - - sudo apt-get -y install postgresql-server-dev-9.5=9.5.2-3cdb3 - - sudo apt-get -y install postgresql-plpython-9.5=9.5.2-3cdb3 - - sudo apt-get -y install postgresql-9.5-postgis-scripts=2.2.2.0-cdb2 - - sudo apt-get -y install postgresql-9.5-postgis-2.2=2.2.2.0-cdb2 - - # configure it to accept local connections from postgres - - echo -e "# TYPE DATABASE USER ADDRESS METHOD \nlocal all postgres trust\nlocal all all trust\nhost all all 127.0.0.1/32 trust" \ | sudo tee /etc/postgresql/9.5/main/pg_hba.conf - - sudo /etc/init.d/postgresql restart 9.5 + - sudo bash $TRAVIS_BUILD_DIR/scripts/ci/install_postgres.sh install: - sudo make install diff --git a/scripts/ci/install_postgres.sh b/scripts/ci/install_postgres.sh new file mode 100644 index 0000000..9ea6676 --- /dev/null +++ b/scripts/ci/install_postgres.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# echo commands +set -x + +# exit on error +set -e + +dpkg -l | grep postgresql + +# Add the PDGD repository +apt-key adv --keyserver keys.gnupg.net --recv-keys 7FCC7D46ACCC4CF8 +add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" +apt-get update + +# Remove those all PgSQL versions except the one we're testing +PGSQL_VERSIONS=(9.2 9.3 9.4 9.5 9.6 10) +/etc/init.d/postgresql stop # stop travis default instance +for V in "${PGSQL_VERSIONS[@]}"; do + if [ "$V" != "$PGSQL_VERSION" ]; then + apt-get -y remove --purge postgresql-${V} postgresql-client-${V} postgresql-contrib-${V} postgresql-${V}-postgis-2.3-scripts + else + apt-get -y remove --purge postgresql-${V}-postgis-2.3-scripts + fi +done + +apt-get -y autoremove + +# Install PostgreSQL +apt-get -y install postgresql-${PGSQL_VERSION} postgresql-${PGSQL_VERSION}-postgis-${POSTGIS_VERSION} postgresql-server-dev-${PGSQL_VERSION} + +# Configure it to accept local connections from postgres +echo -e "# TYPE DATABASE USER ADDRESS METHOD \nlocal all postgres trust\nlocal all all trust\nhost all all 127.0.0.1/32 trust" > /etc/postgresql/${PGSQL_VERSION}/main/pg_hba.conf + +# Restart PostgreSQL +/etc/init.d/postgresql restart ${PGSQL_VERSION} + +dpkg -l | grep postgresql