diff --git a/.gitignore b/.gitignore index 4a06e7e..1b697ca 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ cli/build cli/cli cli/migrate +.coverage diff --git a/.travis.yml b/.travis.yml index 9b35e10..8837591 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,10 +16,14 @@ 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* + - go get github.com/mattn/goveralls script: - make test +after_success: + - goveralls -service=travis-ci -coverprofile .coverage/combined.txt + before_deploy: - make build-cli diff --git a/Makefile b/Makefile index 9ef30dc..fea48e4 100644 --- a/Makefile +++ b/Makefile @@ -1,28 +1,34 @@ -SOURCE?=file go-bindata github -DATABASE?=postgres -VERSION?=$(shell git describe --tags 2>/dev/null) -TEST_FLAGS?= +SOURCE ?= file go-bindata github +DATABASE ?= postgres +VERSION ?= $(shell git describe --tags 2>/dev/null) +TEST_FLAGS ?= + build-cli: clean -mkdir ./cli/build - 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 && 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 + clean: -rm -r ./cli/build + test-short: make test-with-flags --ignore-errors TEST_FLAGS='-short' -test: - make test-with-flags TEST_FLAGS='-race -v -cover -bench=. -benchmem' -coverage: - make test-with-flags TEST_FLAGS='-cover -short' +test: + @-rm -r .coverage + @mkdir .coverage + make test-with-flags TEST_FLAGS='-v -race -covermode atomic -coverprofile .coverage/_$$(RAND).txt -bench=. -benchmem' + @echo 'mode: atomic' > .coverage/combined.txt + @cat .coverage/*.txt | grep -v 'mode: atomic' >> .coverage/combined.txt + test-with-flags: @echo SOURCE: $(SOURCE) @@ -30,27 +36,30 @@ test-with-flags: @go test $(TEST_FLAGS) . @go test $(TEST_FLAGS) ./cli/... + @go test $(TEST_FLAGS) ./testing/... - @go test $(TEST_FLAGS) ./source/{$(subst $(space),$(,),$(SOURCE)),} + @echo -n '$(SOURCE)' | tr -s ' ' '\n' | xargs -I{} go test $(TEST_FLAGS) ./source/{} @go test $(TEST_FLAGS) ./source/testing @go test $(TEST_FLAGS) ./source/stub - @go test $(TEST_FLAGS) ./database/{$(subst $(space),$(,),$(DATABASE)),} + @echo -n '$(DATABASE)' | tr -s ' ' '\n' | xargs -I{} go test $(TEST_FLAGS) ./database/{} @go test $(TEST_FLAGS) ./database/testing @go test $(TEST_FLAGS) ./database/stub # deprecated v1compat: - @go test $(TEST_FLAGS) ./migrate/... + @go test ./migrate/... + + +html-coverage: + go tool cover -html=.coverage/combined.txt + deps: -go get -v -u ./... -go test -v -i ./... -.PHONY: build-cli clean test-short test coverage test-with-flags deps -SHELL=/bin/bash -# define comma and space -, := , -space := -space += +.PHONY: build-cli clean test-short test test-with-flags deps html-coverage +SHELL = /bin/bash +RAND = $(shell echo $$RANDOM) diff --git a/README.md b/README.md index be50791..ac46309 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![Build Status](https://travis-ci.org/mattes/migrate.svg?branch=v3.0-prev)](https://travis-ci.org/mattes/migrate) [![GoDoc](https://godoc.org/github.com/mattes/migrate?status.svg)](https://godoc.org/github.com/mattes/migrate) +[![Coverage Status](https://coveralls.io/repos/github/mattes/migrate/badge.svg?branch=v3.0-prev)](https://coveralls.io/github/mattes/migrate?branch=v3.0-prev) Database migrations written in Go. Use as CLI or import as library. diff --git a/source/aws-s3/s3.go b/source/aws-s3/s3.go index e69de29..32c097a 100644 --- a/source/aws-s3/s3.go +++ b/source/aws-s3/s3.go @@ -0,0 +1 @@ +package awss3 diff --git a/source/aws-s3/s3_test.go b/source/aws-s3/s3_test.go index e69de29..32c097a 100644 --- a/source/aws-s3/s3_test.go +++ b/source/aws-s3/s3_test.go @@ -0,0 +1 @@ +package awss3 diff --git a/source/google-cloud-storage/storage.go b/source/google-cloud-storage/storage.go index e69de29..2e3f093 100644 --- a/source/google-cloud-storage/storage.go +++ b/source/google-cloud-storage/storage.go @@ -0,0 +1 @@ +package googlecloudstorage diff --git a/source/google-cloud-storage/storage_test.go b/source/google-cloud-storage/storage_test.go index e69de29..2e3f093 100644 --- a/source/google-cloud-storage/storage_test.go +++ b/source/google-cloud-storage/storage_test.go @@ -0,0 +1 @@ +package googlecloudstorage