2019-06-16 20:48:01 +01:00
SOURCE ?= file go_bindata github github_ee aws_s3 google_cloud_storage godoc_vfs gitlab
2019-05-24 15:16:12 +02:00
DATABASE ?= postgres mysql redshift cassandra spanner cockroachdb clickhouse mongodb sqlserver
2017-02-23 10:36:33 -08:00
VERSION ?= $( shell git describe --tags 2>/dev/null | cut -c 2-)
2017-02-08 16:17:04 -08:00
TEST_FLAGS ?=
2017-02-08 19:34:53 -08:00
REPO_OWNER ?= $( shell cd .. && basename " $$ (pwd) " )
2018-01-19 19:57:05 -08:00
COVERAGE_DIR ?= .coverage
2017-02-08 16:17:04 -08:00
2017-02-07 22:01:29 -08:00
build-cli : clean
-mkdir ./cli/build
2018-11-19 14:17:38 +01:00
cd ./cmd/migrate && CGO_ENABLED = 0 GOOS = linux GOARCH = amd64 go build -a -o ../../cli/build/migrate.linux-amd64 -ldflags= '-X main.Version=$(VERSION) -extldflags "-static"' -tags '$(DATABASE) $(SOURCE)' .
cd ./cmd/migrate && CGO_ENABLED = 0 GOOS = darwin GOARCH = amd64 go build -a -o ../../cli/build/migrate.darwin-amd64 -ldflags= '-X main.Version=$(VERSION) -extldflags "-static"' -tags '$(DATABASE) $(SOURCE)' .
cd ./cmd/migrate && CGO_ENABLED = 0 GOOS = windows GOARCH = amd64 go build -a -o ../../cli/build/migrate.windows-amd64.exe -ldflags= '-X main.Version=$(VERSION) -extldflags "-static"' -tags '$(DATABASE) $(SOURCE)' .
2017-02-07 22:01:29 -08: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 12:49:43 -04:00
2017-02-08 16:17:04 -08:00
2015-10-15 12:49:43 -04:00
clean :
2017-02-07 22:01:29 -08:00
-rm -r ./cli/build
2017-02-08 16:17:04 -08:00
2017-02-07 22:01:29 -08:00
test-short :
make test-with-flags --ignore-errors TEST_FLAGS = '-short'
2017-02-08 16:17:04 -08:00
2017-02-07 22:01:29 -08:00
test :
2018-01-19 19:57:05 -08:00
@-rm -r $( COVERAGE_DIR)
@mkdir $( COVERAGE_DIR)
2019-06-20 23:07:47 -07:00
make test-with-flags TEST_FLAGS = '-v -race -covermode atomic -coverprofile $$(COVERAGE_DIR)/combined.txt -bench=. -benchmem -timeout 20m'
2017-02-07 22:01:29 -08:00
2015-10-15 12:49:43 -04:00
2017-02-07 22:01:29 -08:00
test-with-flags :
2019-06-16 20:48:01 +01:00
@echo SOURCE: $( SOURCE)
2017-02-07 22:01:29 -08:00
@echo DATABASE: $( DATABASE)
2016-10-23 14:56:37 -07:00
2019-06-20 23:07:47 -07:00
@go test $( TEST_FLAGS) ./...
2017-02-08 16:17:04 -08:00
2017-02-11 19:15:54 -08:00
kill-orphaned-docker-containers :
docker rm -f $( shell docker ps -aq --filter label = migrate_test)
2017-02-08 16:17:04 -08:00
html-coverage :
2018-01-19 19:57:05 -08:00
go tool cover -html= $( COVERAGE_DIR) /combined.txt
2017-02-08 16:17:04 -08:00
2015-10-15 12:49:43 -04:00
2017-02-08 19:34:53 -08:00
list-external-deps :
$( call external_deps,'.' )
$( call external_deps,'./cli/...' )
$( call external_deps,'./testing/...' )
$( foreach v, $( SOURCE) , $( call external_deps,'./source/$(v)/...' ) )
$( call external_deps,'./source/testing/...' )
$( call external_deps,'./source/stub/...' )
$( foreach v, $( DATABASE) , $( call external_deps,'./database/$(v)/...' ) )
$( call external_deps,'./database/testing/...' )
$( call external_deps,'./database/stub/...' )
2017-02-08 18:01:01 -08:00
restore-import-paths :
2017-02-08 19:34:53 -08:00
find . -name '*.go' -type f -execdir sed -i '' s%\" github.com/$( REPO_OWNER) /migrate%\" github.com/mattes/migrate%g '{}' \;
2017-02-08 18:01:01 -08:00
rewrite-import-paths :
2017-02-08 19:34:53 -08:00
find . -name '*.go' -type f -execdir sed -i '' s%\" github.com/mattes/migrate%\" github.com/$( REPO_OWNER) /migrate%g '{}' \;
2017-02-09 11:59:49 -08:00
# example: fswatch -0 --exclude .godoc.pid --event Updated . | xargs -0 -n1 -I{} make docs
docs :
-make kill-docs
nohup godoc -play -http= 127.0.0.1:6064 </dev/null >/dev/null 2>& 1 & echo $$ ! > .godoc.pid
2019-06-16 20:48:01 +01:00
cat .godoc.pid
2017-02-09 11:59:49 -08:00
kill-docs :
@cat .godoc.pid
kill -9 $$ ( cat .godoc.pid)
rm .godoc.pid
open-docs :
open http://localhost:6064/pkg/github.com/$( REPO_OWNER) /migrate
# example: make release V=0.0.0
2017-02-08 19:54:50 -08:00
release :
git tag v$( V)
@read -p "Press enter to confirm and push to origin ..." && git push origin v$( V)
2017-02-08 19:34:53 -08:00
d e f i n e e x t e r n a l _ d e p s
2017-02-11 11:13:27 -08:00
@echo '-- $(1)' ; go list -f '{{join .Deps "\n"}}' $( 1) | grep -v github.com/$( REPO_OWNER) /migrate | xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}'
2017-02-08 19:34:53 -08:00
e n d e f
2017-02-08 18:01:01 -08:00
2018-05-13 00:23:32 -07:00
.PHONY : build -cli clean test -short test test -with -flags html -coverage \
2017-02-09 12:03:03 -08:00
restore-import-paths rewrite-import-paths list-external-deps release \
2017-02-11 19:15:54 -08:00
docs kill-docs open-docs kill-orphaned-docker-containers
2017-02-08 18:01:01 -08:00
2017-02-08 16:17:04 -08:00
SHELL = /bin/bash
RAND = $( shell echo $$ RANDOM)
2015-10-15 12:49:43 -04:00