2017-02-08 06:01:29 +00:00
SOURCE ?= file go-bindata github
DATABASE ?= postgres
VERSION ?= $( shell git describe --tags 2>/dev/null)
TEST_FLAGS ?=
build-cli : clean
-mkdir ./cli/build
2017-02-08 09:49:57 +00:00
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)' .
2017-02-08 06:01:29 +00:00
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
2015-10-15 16:49:43 +00:00
clean :
2017-02-08 06:01:29 +00:00
-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'
2015-10-15 16:49:43 +00:00
2017-02-08 06:01:29 +00:00
test-with-flags :
@echo SOURCE: $( SOURCE)
@echo DATABASE: $( DATABASE)
2016-10-23 21:56:37 +00:00
2017-02-08 06:01:29 +00:00
@go test $( TEST_FLAGS) .
@go test $( TEST_FLAGS) ./cli/...
2016-10-23 21:56:37 +00:00
2017-02-08 06:01:29 +00:00
@go test $( TEST_FLAGS) ./source/{ $( subst $( space) ,$( ,) ,$( SOURCE) ) ,}
@go test $( TEST_FLAGS) ./source/testing
@go test $( TEST_FLAGS) ./source/stub
2015-10-15 16:49:43 +00:00
2017-02-08 06:01:29 +00:00
@go test $( TEST_FLAGS) ./database/{ $( subst $( space) ,$( ,) ,$( DATABASE) ) ,}
@go test $( TEST_FLAGS) ./database/testing
@go test $( TEST_FLAGS) ./database/stub
# deprecated v1compat:
@go test $( TEST_FLAGS) ./migrate/...
2015-10-15 16:49:43 +00:00
2017-02-08 09:49:57 +00:00
deps :
-go get -v -u ./...
-go test -v -i ./...
2015-10-15 16:49:43 +00:00
2017-02-08 09:49:57 +00:00
.PHONY : build -cli clean test -short test coverage test -with -flags deps
SHELL = /bin/bash
# define comma and space
, : = ,
space :=
space +=
2015-10-15 16:49:43 +00:00