diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 27ea2d4d..3e3c1ed8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,19 +12,6 @@ jobs: name: Test runs-on: ubuntu-latest - services: - postgres: - image: postgres - env: - POSTGRES_PASSWORD: secret - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - 5432:5432 - steps: - name: Set up Go 1.x @@ -35,18 +22,17 @@ jobs: - name: Check out code into the Go module directory uses: actions/checkout@v2 - - name: Create hstore extension - run: psql -c 'create extension hstore' + - name: Setup database server for testing + run: ci/setup_test.bash env: - PGHOST: localhost - PGUSER: postgres - PGPASSWORD: secret - PGSSLMODE: disable + PGVERSION: 12 - name: Test run: go test -v ./... env: - PGHOST: localhost - PGUSER: postgres - PGPASSWORD: secret - PGSSLMODE: disable + PGX_TEST_CONN_STRING: postgres://pgx_md5:secret@127.0.0.1/pgx_test + PGX_TEST_UNIX_SOCKET_CONN_STRING: "host=/var/run/postgresql dbname=pgx_test" + PGX_TEST_TCP_CONN_STRING: postgres://pgx_md5:secret@127.0.0.1/pgx_test + PGX_TEST_TLS_CONN_STRING: postgres://pgx_md5:secret@127.0.0.1/pgx_test?sslmode=require + PGX_TEST_MD5_PASSWORD_CONN_STRING: postgres://pgx_md5:secret@127.0.0.1/pgx_test + PGX_TEST_PLAIN_PASSWORD_CONN_STRING: postgres://pgx_pw:secret@127.0.0.1/pgx_test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 95dce226..00000000 --- a/.travis.yml +++ /dev/null @@ -1,49 +0,0 @@ -language: go - -go: - - 1.15.x - - 1.14.x - - tip - -git: - depth: 1 - -# Derived from https://github.com/lib/pq/blob/master/.travis.yml -before_install: - - ./travis/before_install.bash - -env: - global: - - GO111MODULE=on - - GOPROXY=https://proxy.golang.org - - GOFLAGS=-mod=readonly - - PGX_TEST_CONN_STRING=postgres://pgx_md5:secret@127.0.0.1/pgx_test - - PGX_TEST_UNIX_SOCKET_CONN_STRING="host=/var/run/postgresql dbname=pgx_test" - - PGX_TEST_TCP_CONN_STRING=postgres://pgx_md5:secret@127.0.0.1/pgx_test - - PGX_TEST_TLS_CONN_STRING=postgres://pgx_md5:secret@127.0.0.1/pgx_test?sslmode=require - - PGX_TEST_MD5_PASSWORD_CONN_STRING=postgres://pgx_md5:secret@127.0.0.1/pgx_test - - PGX_TEST_PLAIN_PASSWORD_CONN_STRING=postgres://pgx_pw:secret@127.0.0.1/pgx_test - matrix: - - CRATEVERSION=2.1 PGX_TEST_CRATEDB_CONN_STRING="host=127.0.0.1 port=6543 user=pgx dbname=pgx_test" - - PGVERSION=12 - - PGVERSION=11 - - PGVERSION=10 - - PGVERSION=9.6 - - PGVERSION=9.5 - -cache: - directories: - - $HOME/.cache/go-build - - $HOME/gopath/pkg/mod - -before_script: - - ./travis/before_script.bash - -install: go mod download - -script: - - ./travis/script.bash - -matrix: - allow_failures: - - go: tip diff --git a/travis/script.bash b/ci/script.bash similarity index 100% rename from travis/script.bash rename to ci/script.bash diff --git a/travis/before_install.bash b/ci/setup_test.bash similarity index 73% rename from travis/before_install.bash rename to ci/setup_test.bash index 23c7d9cf..78e30383 100755 --- a/travis/before_install.bash +++ b/ci/setup_test.bash @@ -24,6 +24,18 @@ then echo "max_replication_slots=5" >> /etc/postgresql/$PGVERSION/main/postgresql.conf fi sudo /etc/init.d/postgresql restart + + # 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. + psql -U postgres -c 'create database pgx_test' + psql -U postgres pgx_test -c 'create extension hstore' + psql -U postgres pgx_test -c 'create domain uint64 as numeric(20,0)' + 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 travis" + psql -U postgres -c "create user pgx_replication with replication password 'secret'" + psql -U postgres -c "create user \" tricky, ' } \"\" \\ test user \" superuser password 'secret'" fi if [ "${CRATEVERSION-}" != "" ] diff --git a/travis/before_script.bash b/travis/before_script.bash deleted file mode 100755 index 923b7d06..00000000 --- a/travis/before_script.bash +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash -set -eux - -if [ "${PGVERSION-}" != "" ] -then - # 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. - psql -U postgres -c 'create database pgx_test' - psql -U postgres pgx_test -c 'create extension hstore' - psql -U postgres pgx_test -c 'create domain uint64 as numeric(20,0)' - 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 travis" - psql -U postgres -c "create user pgx_replication with replication password 'secret'" - psql -U postgres -c "create user \" tricky, ' } \"\" \\ test user \" superuser password 'secret'" -fi