diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..51a6fcf --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,56 @@ +name: CI +on: [push, pull_request] +jobs: + test: + name: Test + strategy: + matrix: + pg-version: ['10', '11'] + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v1 + + - name: Install PostgreSQL + uses: harmon758/postgresql-action@v1 + with: + postgresql version: ${{ matrix.pg-version }} + postgresql db: archiver_test + postgresql user: temba + postgresql password: temba + + - name: Install Go + uses: actions/setup-go@v1 + with: + go-version: 1.13.x + + - name: Run tests + run: go test -p=1 -coverprofile=coverage.text -covermode=atomic ./... + + - name: Upload coverage + if: success() + uses: codecov/codecov-action@v1.0.3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + + release: + name: Release + needs: [test] + if: startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v1 + + - name: Install Go + uses: actions/setup-go@v1 + with: + go-version: 1.13.x + + - name: Publish release + uses: goreleaser/goreleaser-action@v1 + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e40868a..0000000 --- a/.travis.yml +++ /dev/null @@ -1,47 +0,0 @@ -dist: xenial -sudo: required - -language: go - -go: -- "1.12" - -env: - global: - - GO111MODULE=on - matrix: - - PGDB=9.6 RELEASE=true PGIS=2.4 - - PGDB=10 PGIS=2.4 - - PGDB=11 PGIS=2.5 - -before_install: - # setup postgresql - - sudo -E service postgresql stop 9.2 - - sudo -E service postgresql stop 9.3 - - sudo -E service postgresql stop 9.4 - - sudo -E service postgresql stop 9.5 - - sudo -E service postgresql stop 9.6 - - sudo -E apt-get -yq --no-install-suggests --no-install-recommends $(travis_apt_get_options) install postgresql-$PGDB postgresql-client-$PGDB postgresql-$PGDB-postgis-$PGIS postgresql-$PGDB-postgis-$PGIS-scripts - - sudo -E sed -i -e '/local.*peer/s/postgres/all/' -e 's/peer\|md5/trust/g' /etc/postgresql/*/main/pg_hba.conf - - sudo -E sed -i 's/port = 5433/port = 5432/' /etc/postgresql/*/main/postgresql.conf - - sudo -E service postgresql restart $PGDB - -before_script: - - psql -U postgres -c "CREATE USER travis;" || true - - psql -U postgres -c "ALTER ROLE travis WITH SUPERUSER;" || true - - psql -U postgres -c "CREATE DATABASE archiver_test;" - -script: -- go test -p=1 -coverprofile=coverage.text -covermode=atomic github.com/nyaruka/rp-archiver/... - -after_success: -- bash <(curl -s https://codecov.io/bash) -- rm coverage.text - -deploy: - - provider: script - skip_cleanup: true - script: curl -sL https://git.io/goreleaser | bash - on: - tags: true - condition: $RELEASE = true diff --git a/archiver_test.go b/archiver_test.go index ed32e20..334b6b4 100644 --- a/archiver_test.go +++ b/archiver_test.go @@ -19,7 +19,7 @@ func setup(t *testing.T) *sqlx.DB { testDB, err := ioutil.ReadFile("testdb.sql") assert.NoError(t, err) - db, err := sqlx.Open("postgres", "postgres://localhost/archiver_test?sslmode=disable&TimeZone=UTC") + db, err := sqlx.Open("postgres", "postgres://temba:temba@localhost:5432/archiver_test?sslmode=disable&TimeZone=UTC") assert.NoError(t, err) _, err = db.Exec(string(testDB))