diff --git a/.travis.yml b/.travis.yml index fe413d33..ad0844b4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,25 +6,7 @@ go: # Derived from https://github.com/lib/pq/blob/master/.travis.yml before_install: - - sudo apt-get remove -y --purge postgresql libpq-dev libpq5 postgresql-client-common postgresql-common - - sudo rm -rf /var/lib/postgresql - - wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - - - sudo sh -c "echo deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main $PGVERSION >> /etc/apt/sources.list.d/postgresql.list" - - sudo apt-get update -qq - - sudo apt-get -y -o Dpkg::Options::=--force-confdef -o Dpkg::Options::="--force-confnew" install postgresql-$PGVERSION postgresql-server-dev-$PGVERSION postgresql-contrib-$PGVERSION - - sudo chmod 777 /etc/postgresql/$PGVERSION/main/pg_hba.conf - - echo "local all postgres trust" > /etc/postgresql/$PGVERSION/main/pg_hba.conf - - echo "local all all trust" >> /etc/postgresql/$PGVERSION/main/pg_hba.conf - - echo "host all pgx_md5 127.0.0.1/32 md5" >> /etc/postgresql/$PGVERSION/main/pg_hba.conf - - echo "host all pgx_pw 127.0.0.1/32 password" >> /etc/postgresql/$PGVERSION/main/pg_hba.conf - - echo "hostssl all pgx_ssl 127.0.0.1/32 md5" >> /etc/postgresql/$PGVERSION/main/pg_hba.conf - - echo "host replication pgx_replication 127.0.0.1/32 md5" >> /etc/postgresql/$PGVERSION/main/pg_hba.conf - - echo "host pgx_test pgx_replication 127.0.0.1/32 md5" >> /etc/postgresql/$PGVERSION/main/pg_hba.conf - - sudo chmod 777 /etc/postgresql/$PGVERSION/main/postgresql.conf - - "[[ $PGVERSION < 9.6 ]] || echo \"wal_level='logical'\" >> /etc/postgresql/$PGVERSION/main/postgresql.conf" - - "[[ $PGVERSION < 9.6 ]] || echo \"max_wal_senders=5\" >> /etc/postgresql/$PGVERSION/main/postgresql.conf" - - "[[ $PGVERSION < 9.6 ]] || echo \"max_replication_slots=5\" >> /etc/postgresql/$PGVERSION/main/postgresql.conf" - - sudo /etc/init.d/postgresql restart + - ./travis/before_install.bash env: global: @@ -39,26 +21,10 @@ env: # The tricky test user, below, has to actually exist so that it can be used in a test # of aclitem formatting. It turns out aclitems cannot contain non-existing users/roles. before_script: - - mv conn_config_test.go.travis conn_config_test.go - - psql -U postgres -c 'create database pgx_test' - - psql -U postgres pgx_test -c 'create extension hstore' - - psql -U postgres -c "create user pgx_ssl SUPERUSER PASSWORD 'secret'" - - psql -U postgres -c "create user pgx_md5 SUPERUSER PASSWORD 'secret'" - - psql -U postgres -c "create user pgx_pw SUPERUSER PASSWORD 'secret'" - - psql -U postgres -c "create user pgx_replication with replication password 'secret'" - - psql -U postgres -c "create user \" tricky, ' } \"\" \\ test user \" superuser password 'secret'" + - ./travis/before_script.bash install: - - go get -u github.com/cockroachdb/apd - - go get -u github.com/shopspring/decimal - - go get -u gopkg.in/inconshreveable/log15.v2 - - go get -u github.com/jackc/fake - - go get -u github.com/lib/pq - - go get -u github.com/hashicorp/go-version - - go get -u github.com/satori/go.uuid - - go get -u github.com/sirupsen/logrus - - go get -u github.com/pkg/errors - - go get -u go.uber.org/zap + - ./travis/install.bash script: - go test -v -race ./... diff --git a/travis/before_install.bash b/travis/before_install.bash new file mode 100755 index 00000000..c52af7f9 --- /dev/null +++ b/travis/before_install.bash @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -eux + +sudo apt-get remove -y --purge postgresql libpq-dev libpq5 postgresql-client-common postgresql-common +sudo rm -rf /var/lib/postgresql +wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - +sudo sh -c "echo deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main $PGVERSION >> /etc/apt/sources.list.d/postgresql.list" +sudo apt-get update -qq +sudo apt-get -y -o Dpkg::Options::=--force-confdef -o Dpkg::Options::="--force-confnew" install postgresql-$PGVERSION postgresql-server-dev-$PGVERSION postgresql-contrib-$PGVERSION +sudo chmod 777 /etc/postgresql/$PGVERSION/main/pg_hba.conf +echo "local all postgres trust" > /etc/postgresql/$PGVERSION/main/pg_hba.conf +echo "local all all trust" >> /etc/postgresql/$PGVERSION/main/pg_hba.conf +echo "host all pgx_md5 127.0.0.1/32 md5" >> /etc/postgresql/$PGVERSION/main/pg_hba.conf +echo "host all pgx_pw 127.0.0.1/32 password" >> /etc/postgresql/$PGVERSION/main/pg_hba.conf +echo "hostssl all pgx_ssl 127.0.0.1/32 md5" >> /etc/postgresql/$PGVERSION/main/pg_hba.conf +echo "host replication pgx_replication 127.0.0.1/32 md5" >> /etc/postgresql/$PGVERSION/main/pg_hba.conf +echo "host pgx_test pgx_replication 127.0.0.1/32 md5" >> /etc/postgresql/$PGVERSION/main/pg_hba.conf +sudo chmod 777 /etc/postgresql/$PGVERSION/main/postgresql.conf +"[[ $PGVERSION < 9.6 ]] || echo \"wal_level='logical'\" >> /etc/postgresql/$PGVERSION/main/postgresql.conf" +"[[ $PGVERSION < 9.6 ]] || echo \"max_wal_senders=5\" >> /etc/postgresql/$PGVERSION/main/postgresql.conf" +"[[ $PGVERSION < 9.6 ]] || echo \"max_replication_slots=5\" >> /etc/postgresql/$PGVERSION/main/postgresql.conf" +sudo /etc/init.d/postgresql restart diff --git a/travis/before_script.bash b/travis/before_script.bash new file mode 100755 index 00000000..5bc53f55 --- /dev/null +++ b/travis/before_script.bash @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +set -eux + +mv conn_config_test.go.travis conn_config_test.go +psql -U postgres -c 'create database pgx_test' +psql -U postgres pgx_test -c 'create extension hstore' +psql -U postgres -c "create user pgx_ssl SUPERUSER PASSWORD 'secret'" +psql -U postgres -c "create user pgx_md5 SUPERUSER PASSWORD 'secret'" +psql -U postgres -c "create user pgx_pw SUPERUSER PASSWORD 'secret'" +psql -U postgres -c "create user pgx_replication with replication password 'secret'" +psql -U postgres -c "create user \" tricky, ' } \"\" \\ test user \" superuser password 'secret'" diff --git a/travis/install.bash b/travis/install.bash new file mode 100755 index 00000000..61b683ec --- /dev/null +++ b/travis/install.bash @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +set -eux + +go get -u github.com/cockroachdb/apd +go get -u github.com/shopspring/decimal +go get -u gopkg.in/inconshreveable/log15.v2 +go get -u github.com/jackc/fake +go get -u github.com/lib/pq +go get -u github.com/hashicorp/go-version +go get -u github.com/satori/go.uuid +go get -u github.com/sirupsen/logrus +go get -u github.com/pkg/errors +go get -u go.uber.org/zap