Skip to content
This repository has been archived by the owner on Jun 28, 2018. It is now read-only.

Commit

Permalink
fixing travis
Browse files Browse the repository at this point in the history
  • Loading branch information
mattes committed Feb 8, 2017
1 parent 9f774d3 commit 297a422
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 19 deletions.
34 changes: 30 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,38 @@ language: go
sudo: required

go:
- 1.5
- 1.6
- 1.7

env:
- MIGRATE_TEST_CONTAINER_BOOT_DELAY=15

# TODO: https://docs.docker.com/engine/installation/linux/ubuntu/
# pre-provision with travis docker setup and pin down docker version in install step
services:
- docker
- docker

install:
- make deps
- (cd $GOPATH/src/github.com/docker/docker && git fetch --all --tags --prune && git checkout v1.13.0)
- sudo apt-get update && sudo apt-get install docker-engine=1.13.0*

script:
- make test

before_deploy:
- make build-cli

script: make test
deploy:
provider: releases
skip_cleanup: true
api_key:
secure: EFow50BI448HVb/uQ1Kk2Kq0xzmwIYq3V67YyymXIuqSCodvXEsMiBPUoLrxEknpPEIc67LEQTNdfHBgvyHk6oRINWAfie+7pr5tKrpOTF9ghyxoN1PlO8WKQCqwCvGMBCnc5ur5rvzp0bqfpV2rs5q9/nngy3kBuEvs12V7iho=
on:
repo: mattes/migrate
tags: true
file:
- cli/build/migrate.linux-amd64.tar.gz
- cli/build/migrate.darwin-amd64.tar.gz
- cli/build/migrate.windows-amd64.exe.tar.gz
- cli/build/sha256sum.txt

22 changes: 13 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,11 @@ DATABASE?=postgres
VERSION?=$(shell git describe --tags 2>/dev/null)
TEST_FLAGS?=

# define comma and space
, := ,
space :=
space +=

build-cli: clean
-mkdir ./cli/build
cd ./cli && GOOS=linux GOARCH=amd64 go build -a -o build/migrate.$(VERSION).linux-amd64 -ldflags="-X main.Version=$(VERSION)" -tags '$(DATABASE) $(SOURCE)' .
cd ./cli && GOOS=darwin GOARCH=amd64 go build -a -o build/migrate.$(VERSION).darwin-amd64 -ldflags="-X main.Version=$(VERSION)" -tags '$(DATABASE) $(SOURCE)' .
cd ./cli && GOOS=windows GOARCH=amd64 go build -a -o build/migrate.$(VERSION).windows-amd64.exe -ldflags="-X main.Version=$(VERSION)" -tags '$(DATABASE) $(SOURCE)' .
cd ./cli && GOOS=linux GOARCH=amd64 go build -a -o build/migrate.linux-amd64 -ldflags="-X main.Version=$(VERSION)" -tags '$(DATABASE) $(SOURCE)' .
cd ./cli && GOOS=darwin GOARCH=amd64 go build -a -o build/migrate.darwin-amd64 -ldflags="-X main.Version=$(VERSION)" -tags '$(DATABASE) $(SOURCE)' .
cd ./cli && GOOS=windows GOARCH=amd64 go build -a -o build/migrate.windows-amd64.exe -ldflags="-X main.Version=$(VERSION)" -tags '$(DATABASE) $(SOURCE)' .
cd ./cli/build && find . -name 'migrate*' | xargs -I{} tar czf {}.tar.gz {}
cd ./cli/build && shasum -a 256 * > sha256sum.txt
cat ./cli/build/sha256sum.txt
Expand Down Expand Up @@ -47,6 +42,15 @@ test-with-flags:
# deprecated v1compat:
@go test $(TEST_FLAGS) ./migrate/...

deps:
-go get -v -u ./...
-go test -v -i ./...

.PHONY: build-cli clean test-short test coverage test-with-flags
.PHONY: build-cli clean test-short test coverage test-with-flags deps
SHELL=/bin/bash

# define comma and space
, := ,
space :=
space +=

12 changes: 7 additions & 5 deletions database/postgres/postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ func Test(t *testing.T) {
mt.ParallelTest(t, versions, isReady,
func(t *testing.T, i mt.Instance) {
p := &Postgres{}
d, err := p.Open(fmt.Sprintf("postgres://postgres@%v:%v/postgres?sslmode=disable", i.Host(), i.Port()))
addr := fmt.Sprintf("postgres://postgres@%v:%v/postgres?sslmode=disable", i.Host(), i.Port())
d, err := p.Open(addr)
if err != nil {
t.Fatalf("%#v", err)
t.Fatalf("%v", err)
}
dt.Test(t, d, []byte("SELECT 1"))
})
Expand All @@ -58,9 +59,10 @@ func TestWithSchema(t *testing.T) {
mt.ParallelTest(t, versions, isReady,
func(t *testing.T, i mt.Instance) {
p := &Postgres{}
d, err := p.Open(fmt.Sprintf("postgres://postgres@%v:%v/postgres?sslmode=disable", i.Host(), i.Port()))
addr := fmt.Sprintf("postgres://postgres@%v:%v/postgres?sslmode=disable", i.Host(), i.Port())
d, err := p.Open(addr)
if err != nil {
t.Fatalf("%#v", err)
t.Fatalf("%v", err)
}

// create foobar schema
Expand All @@ -71,7 +73,7 @@ func TestWithSchema(t *testing.T) {
// re-connect using that schema
d2, err := p.Open(fmt.Sprintf("postgres://postgres@%v:%v/postgres?sslmode=disable&search_path=foobar", i.Host(), i.Port()))
if err != nil {
t.Fatalf("%#v", err)
t.Fatalf("%v", err)
}

version, err := d2.Version()
Expand Down
4 changes: 4 additions & 0 deletions source/github/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ func init() {
}

func Test(t *testing.T) {
if len(GithubTestSecret) == 0 {
t.Skip("test requires .github_test_secrets")
}

g := &Github{}
d, err := g.Open("github://" + GithubTestSecret + "@mattes/migrate_test_tmp/test")
if err != nil {
Expand Down
10 changes: 9 additions & 1 deletion testing/testing.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package testing

import (
"os"
"strconv"
"testing"
"time"
)
Expand Down Expand Up @@ -46,8 +48,14 @@ func ParallelTest(t *testing.T, versions []string, readyFn IsReadyFunc, testFn T
}
}

delay, err := strconv.Atoi(os.Getenv("MIGRATE_TEST_CONTAINER_BOOT_DELAY"))
if err == nil {
time.Sleep(time.Duration(int64(delay)) * time.Second)
} else {
time.Sleep(2 * time.Second)
}

// we can now run the tests
time.Sleep(2 * time.Second) // addded grace period
testFn(t, container)
})
}
Expand Down

0 comments on commit 297a422

Please sign in to comment.