diff --git a/.travis.yml b/.travis.yml index c47d33628c..7727843028 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,12 +4,6 @@ dist: xenial services: - redis - docker -addons: - postgresql: '11' - apt: - packages: - - postgresql-11-postgis-2.5 - - postgresql-11-postgis-2.5-scripts branches: only: - master @@ -27,22 +21,14 @@ env: jobs: - MONGODB_VERSION=4.0.4 MONGODB_TOPOLOGY=replicaset MONGODB_STORAGE_ENGINE=wiredTiger - MONGODB_VERSION=3.6.9 - - PARSE_SERVER_TEST_DB=postgres - PARSE_SERVER_TEST_CACHE=redis - NODE_VERSION=12.12.0 before_install: - nvm install $NODE_VERSION - nvm use $NODE_VERSION - npm install -g greenkeeper-lockfile@1 -- sudo sed -i 's/port = 5433/port = 5432/' /etc/postgresql/11/main/postgresql.conf -- sudo cp /etc/postgresql/{10,11}/main/pg_hba.conf -- sudo service postgresql stop -- sudo service postgresql start 11 before_script: - node -e 'require("./lib/index.js")' -- psql -c 'create database parse_server_postgres_adapter_test_database;' -U postgres -- psql -c 'CREATE EXTENSION postgis;' -U postgres -d parse_server_postgres_adapter_test_database -- psql -c 'CREATE EXTENSION postgis_topology;' -U postgres -d parse_server_postgres_adapter_test_database - greenkeeper-lockfile-update script: - npm run lint @@ -54,6 +40,16 @@ jobs: allow_failures: - env: NODE_VERSION=12.12.0 include: + - stage: + addons: + postgresql: '11' + apt: + packages: + - postgresql-11-postgis-2.5 + - postgresql-11-postgis-2.5-scripts + env: POSTGRES_MAJOR_VERSION=11 PARSE_SERVER_TEST_DB=postgres + before_install: bash scripts/before_install_postgres.sh + before_script: bash scripts/before_script_postgres.sh - stage: release node_js: '10' env: diff --git a/scripts/before_install_postgres.sh b/scripts/before_install_postgres.sh new file mode 100755 index 0000000000..f2269e1301 --- /dev/null +++ b/scripts/before_install_postgres.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +set -e + +source ~/.nvm/nvm.sh + +echo "[SCRIPT] Before Install Script :: Setup Postgres ${POSTGRES_MAJOR_VERSION}" + +nvm install $NODE_VERSION +nvm use $NODE_VERSION +npm install -g greenkeeper-lockfile@1 + +sudo sed -i 's/port = 5433/port = 5432/' /etc/postgresql/${POSTGRES_MAJOR_VERSION}/main/postgresql.conf + +if [[ $POSTGRES_MAJOR_VERSION -lt 11 ]]; then + # Setup postgres 9 or 10 + sudo service postgresql stop + + # Remove correct version of postgres + if [[ $POSTGRES_MAJOR_VERSION -lt 10 ]]; then + sudo apt-get remove -q 'postgresql-10.*' + else + sudo apt-get remove -q 'postgresql-9.*' + fi + + sudo service postgresql start ${POSTGRES_MAJOR_VERSION} + +else + + # Setup postgres 11 or higher + sudo cp /etc/postgresql/{10,${POSTGRES_MAJOR_VERSION}}/main/pg_hba.conf + sudo service postgresql stop + # Remove previous versions of postgres + sudo apt-get remove -q 'postgresql-9.*' 'postgresql-10.*' + sudo service postgresql start ${POSTGRES_MAJOR_VERSION} +fi diff --git a/scripts/before_script_postgres.sh b/scripts/before_script_postgres.sh new file mode 100755 index 0000000000..c63d30de23 --- /dev/null +++ b/scripts/before_script_postgres.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -e + +echo "[SCRIPT] Before Script :: Setup Parse DB for Postgres ${POSTGRES_MAJOR_VERSION}" + +node -e 'require("./lib/index.js")' + +psql -v ON_ERROR_STOP=1 --username "postgres" --dbname "${POSTGRES_DB}" <<-EOSQL + CREATE DATABASE parse_server_postgres_adapter_test_database; + \c parse_server_postgres_adapter_test_database; + CREATE EXTENSION postgis; + CREATE EXTENSION postgis_topology; +EOSQL +