diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..21823bfd --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,38 @@ +name: CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + + test: + name: Test + runs-on: ubuntu-latest + + strategy: + matrix: + go_version: [1.14, 1.15] + pg_version: [9.6, 10, 11, 12, 13] + + steps: + + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go_version }} + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Setup database server for testing + run: ci/setup_test.bash + env: + PGVERSION: ${{ matrix.pg_version }} + + - name: Test + run: go test -v -race ./... + env: + PGX_TEST_DATABASE: postgres://pgx_md5:secret@127.0.0.1/pgx_test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e1de3dac..00000000 --- a/.travis.yml +++ /dev/null @@ -1,33 +0,0 @@ -language: go - -go: - - 1.15.x - - 1.14.x - - tip - -# Derived from https://github.com/lib/pq/blob/master/.travis.yml -before_install: - - ./travis/before_install.bash - -env: - global: - - GO111MODULE=on - - PGX_TEST_DATABASE=postgres://pgx_md5: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 database=pgx_test" - - PGVERSION=12 - - PGVERSION=11 - - PGVERSION=10 - - PGVERSION=9.6 - - PGVERSION=9.5 - -before_script: - - ./travis/before_script.bash - -script: - - ./travis/script.bash - -matrix: - allow_failures: - - go: tip diff --git a/travis/before_install.bash b/ci/setup_test.bash similarity index 78% rename from travis/before_install.bash rename to ci/setup_test.bash index 23c7d9cf..08e7e02d 100755 --- a/travis/before_install.bash +++ b/ci/setup_test.bash @@ -13,10 +13,6 @@ then 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 if $(dpkg --compare-versions $PGVERSION ge 9.6) ; then echo "wal_level='logical'" >> /etc/postgresql/$PGVERSION/main/postgresql.conf @@ -24,6 +20,12 @@ then echo "max_replication_slots=5" >> /etc/postgresql/$PGVERSION/main/postgresql.conf fi sudo /etc/init.d/postgresql restart + + 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_md5 SUPERUSER PASSWORD 'secret'" + psql -U postgres -c "create user `whoami`" fi if [ "${CRATEVERSION-}" != "" ] diff --git a/travis/before_script.bash b/travis/before_script.bash deleted file mode 100755 index 74bbbd30..00000000 --- a/travis/before_script.bash +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -set -eux - -if [ "${PGVERSION-}" != "" ] -then - psql -U postgres -c 'create database pgx_test' - psql -U postgres pgx_test -c 'create domain uint64 as numeric(20,0)' - psql -U postgres -c "create user pgx_md5 SUPERUSER PASSWORD 'secret'" -fi diff --git a/travis/script.bash b/travis/script.bash deleted file mode 100755 index 5bf1b77e..00000000 --- a/travis/script.bash +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash -set -eux - -if [ "${PGVERSION-}" != "" ] -then - go test -v -race ./... -elif [ "${CRATEVERSION-}" != "" ] -then - go test -v -race -run 'TestCrateDBConnect' -fi