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

Commit 297a422

Browse files
committed
fixing travis
1 parent 9f774d3 commit 297a422

File tree

5 files changed

+63
-19
lines changed

5 files changed

+63
-19
lines changed

.travis.yml

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,38 @@ language: go
22
sudo: required
33

44
go:
5-
- 1.5
6-
- 1.6
75
- 1.7
86

7+
env:
8+
- MIGRATE_TEST_CONTAINER_BOOT_DELAY=15
9+
10+
# TODO: https://docs.docker.com/engine/installation/linux/ubuntu/
11+
# pre-provision with travis docker setup and pin down docker version in install step
912
services:
10-
- docker
13+
- docker
14+
15+
install:
16+
- make deps
17+
- (cd $GOPATH/src/github.com/docker/docker && git fetch --all --tags --prune && git checkout v1.13.0)
18+
- sudo apt-get update && sudo apt-get install docker-engine=1.13.0*
19+
20+
script:
21+
- make test
22+
23+
before_deploy:
24+
- make build-cli
1125

12-
script: make test
26+
deploy:
27+
provider: releases
28+
skip_cleanup: true
29+
api_key:
30+
secure: EFow50BI448HVb/uQ1Kk2Kq0xzmwIYq3V67YyymXIuqSCodvXEsMiBPUoLrxEknpPEIc67LEQTNdfHBgvyHk6oRINWAfie+7pr5tKrpOTF9ghyxoN1PlO8WKQCqwCvGMBCnc5ur5rvzp0bqfpV2rs5q9/nngy3kBuEvs12V7iho=
31+
on:
32+
repo: mattes/migrate
33+
tags: true
34+
file:
35+
- cli/build/migrate.linux-amd64.tar.gz
36+
- cli/build/migrate.darwin-amd64.tar.gz
37+
- cli/build/migrate.windows-amd64.exe.tar.gz
38+
- cli/build/sha256sum.txt
1339

Makefile

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,11 @@ DATABASE?=postgres
33
VERSION?=$(shell git describe --tags 2>/dev/null)
44
TEST_FLAGS?=
55

6-
# define comma and space
7-
, := ,
8-
space :=
9-
space +=
10-
116
build-cli: clean
127
-mkdir ./cli/build
13-
cd ./cli && GOOS=linux GOARCH=amd64 go build -a -o build/migrate.$(VERSION).linux-amd64 -ldflags="-X main.Version=$(VERSION)" -tags '$(DATABASE) $(SOURCE)' .
14-
cd ./cli && GOOS=darwin GOARCH=amd64 go build -a -o build/migrate.$(VERSION).darwin-amd64 -ldflags="-X main.Version=$(VERSION)" -tags '$(DATABASE) $(SOURCE)' .
15-
cd ./cli && GOOS=windows GOARCH=amd64 go build -a -o build/migrate.$(VERSION).windows-amd64.exe -ldflags="-X main.Version=$(VERSION)" -tags '$(DATABASE) $(SOURCE)' .
8+
cd ./cli && GOOS=linux GOARCH=amd64 go build -a -o build/migrate.linux-amd64 -ldflags="-X main.Version=$(VERSION)" -tags '$(DATABASE) $(SOURCE)' .
9+
cd ./cli && GOOS=darwin GOARCH=amd64 go build -a -o build/migrate.darwin-amd64 -ldflags="-X main.Version=$(VERSION)" -tags '$(DATABASE) $(SOURCE)' .
10+
cd ./cli && GOOS=windows GOARCH=amd64 go build -a -o build/migrate.windows-amd64.exe -ldflags="-X main.Version=$(VERSION)" -tags '$(DATABASE) $(SOURCE)' .
1611
cd ./cli/build && find . -name 'migrate*' | xargs -I{} tar czf {}.tar.gz {}
1712
cd ./cli/build && shasum -a 256 * > sha256sum.txt
1813
cat ./cli/build/sha256sum.txt
@@ -47,6 +42,15 @@ test-with-flags:
4742
# deprecated v1compat:
4843
@go test $(TEST_FLAGS) ./migrate/...
4944

45+
deps:
46+
-go get -v -u ./...
47+
-go test -v -i ./...
5048

51-
.PHONY: build-cli clean test-short test coverage test-with-flags
49+
.PHONY: build-cli clean test-short test coverage test-with-flags deps
50+
SHELL=/bin/bash
51+
52+
# define comma and space
53+
, := ,
54+
space :=
55+
space +=
5256

database/postgres/postgres_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ func Test(t *testing.T) {
4646
mt.ParallelTest(t, versions, isReady,
4747
func(t *testing.T, i mt.Instance) {
4848
p := &Postgres{}
49-
d, err := p.Open(fmt.Sprintf("postgres://postgres@%v:%v/postgres?sslmode=disable", i.Host(), i.Port()))
49+
addr := fmt.Sprintf("postgres://postgres@%v:%v/postgres?sslmode=disable", i.Host(), i.Port())
50+
d, err := p.Open(addr)
5051
if err != nil {
51-
t.Fatalf("%#v", err)
52+
t.Fatalf("%v", err)
5253
}
5354
dt.Test(t, d, []byte("SELECT 1"))
5455
})
@@ -58,9 +59,10 @@ func TestWithSchema(t *testing.T) {
5859
mt.ParallelTest(t, versions, isReady,
5960
func(t *testing.T, i mt.Instance) {
6061
p := &Postgres{}
61-
d, err := p.Open(fmt.Sprintf("postgres://postgres@%v:%v/postgres?sslmode=disable", i.Host(), i.Port()))
62+
addr := fmt.Sprintf("postgres://postgres@%v:%v/postgres?sslmode=disable", i.Host(), i.Port())
63+
d, err := p.Open(addr)
6264
if err != nil {
63-
t.Fatalf("%#v", err)
65+
t.Fatalf("%v", err)
6466
}
6567

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

7779
version, err := d2.Version()

source/github/github_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ func init() {
1818
}
1919

2020
func Test(t *testing.T) {
21+
if len(GithubTestSecret) == 0 {
22+
t.Skip("test requires .github_test_secrets")
23+
}
24+
2125
g := &Github{}
2226
d, err := g.Open("github://" + GithubTestSecret + "@mattes/migrate_test_tmp/test")
2327
if err != nil {

testing/testing.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package testing
22

33
import (
4+
"os"
5+
"strconv"
46
"testing"
57
"time"
68
)
@@ -46,8 +48,14 @@ func ParallelTest(t *testing.T, versions []string, readyFn IsReadyFunc, testFn T
4648
}
4749
}
4850

51+
delay, err := strconv.Atoi(os.Getenv("MIGRATE_TEST_CONTAINER_BOOT_DELAY"))
52+
if err == nil {
53+
time.Sleep(time.Duration(int64(delay)) * time.Second)
54+
} else {
55+
time.Sleep(2 * time.Second)
56+
}
57+
4958
// we can now run the tests
50-
time.Sleep(2 * time.Second) // addded grace period
5159
testFn(t, container)
5260
})
5361
}

0 commit comments

Comments
 (0)