add go coverage

This commit is contained in:
Matthias Kadenbach 2017-02-08 16:17:04 -08:00
parent 297a4227ef
commit fe1b5c06eb
8 changed files with 39 additions and 20 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
cli/build cli/build
cli/cli cli/cli
cli/migrate cli/migrate
.coverage

View File

@ -16,10 +16,14 @@ install:
- make deps - make deps
- (cd $GOPATH/src/github.com/docker/docker && git fetch --all --tags --prune && git checkout v1.13.0) - (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* - sudo apt-get update && sudo apt-get install docker-engine=1.13.0*
- go get github.com/mattn/goveralls
script: script:
- make test - make test
after_success:
- goveralls -service=travis-ci -coverprofile .coverage/combined.txt
before_deploy: before_deploy:
- make build-cli - make build-cli

View File

@ -1,28 +1,34 @@
SOURCE?=file go-bindata github SOURCE ?= file go-bindata github
DATABASE?=postgres DATABASE ?= postgres
VERSION?=$(shell git describe --tags 2>/dev/null) VERSION ?= $(shell git describe --tags 2>/dev/null)
TEST_FLAGS?= TEST_FLAGS ?=
build-cli: clean build-cli: clean
-mkdir ./cli/build -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=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=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=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 && find . -name 'migrate*' | xargs -I{} tar czf {}.tar.gz {}
cd ./cli/build && shasum -a 256 * > sha256sum.txt cd ./cli/build && shasum -a 256 * > sha256sum.txt
cat ./cli/build/sha256sum.txt cat ./cli/build/sha256sum.txt
clean: clean:
-rm -r ./cli/build -rm -r ./cli/build
test-short: test-short:
make test-with-flags --ignore-errors TEST_FLAGS='-short' make test-with-flags --ignore-errors TEST_FLAGS='-short'
test:
make test-with-flags TEST_FLAGS='-race -v -cover -bench=. -benchmem'
coverage: test:
make test-with-flags TEST_FLAGS='-cover -short' @-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: test-with-flags:
@echo SOURCE: $(SOURCE) @echo SOURCE: $(SOURCE)
@ -30,27 +36,30 @@ test-with-flags:
@go test $(TEST_FLAGS) . @go test $(TEST_FLAGS) .
@go test $(TEST_FLAGS) ./cli/... @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/testing
@go test $(TEST_FLAGS) ./source/stub @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/testing
@go test $(TEST_FLAGS) ./database/stub @go test $(TEST_FLAGS) ./database/stub
# deprecated v1compat: # deprecated v1compat:
@go test $(TEST_FLAGS) ./migrate/... @go test ./migrate/...
html-coverage:
go tool cover -html=.coverage/combined.txt
deps: deps:
-go get -v -u ./... -go get -v -u ./...
-go test -v -i ./... -go test -v -i ./...
.PHONY: build-cli clean test-short test coverage test-with-flags deps
SHELL=/bin/bash
# define comma and space .PHONY: build-cli clean test-short test test-with-flags deps html-coverage
, := , SHELL = /bin/bash
space := RAND = $(shell echo $$RANDOM)
space +=

View File

@ -2,6 +2,7 @@
[![Build Status](https://travis-ci.org/mattes/migrate.svg?branch=v3.0-prev)](https://travis-ci.org/mattes/migrate) [![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) [![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. Database migrations written in Go. Use as CLI or import as library.

View File

@ -0,0 +1 @@
package awss3

View File

@ -0,0 +1 @@
package awss3

View File

@ -0,0 +1 @@
package googlecloudstorage

View File

@ -0,0 +1 @@
package googlecloudstorage