migrate/Makefile

76 lines
2.3 KiB
Makefile
Raw Normal View History

2017-02-08 16:17:04 -08: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 16:17:04 -08: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)' .
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:
-rm -r ./cli/build
2017-02-08 16:17:04 -08:00
test-short:
make test-with-flags --ignore-errors TEST_FLAGS='-short'
2017-02-08 16:17:04 -08:00
test:
2017-02-08 16:17:04 -08:00
@-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
2015-10-15 12:49:43 -04:00
test-with-flags:
@echo SOURCE: $(SOURCE)
@echo DATABASE: $(DATABASE)
@go test $(TEST_FLAGS) .
@go test $(TEST_FLAGS) ./cli/...
2017-02-08 16:17:04 -08:00
@go test $(TEST_FLAGS) ./testing/...
2017-02-08 16:17:04 -08:00
@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
2015-10-15 12:49:43 -04:00
2017-02-08 16:17:04 -08:00
@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:
2017-02-08 16:17:04 -08:00
@go test ./migrate/...
html-coverage:
go tool cover -html=.coverage/combined.txt
2015-10-15 12:49:43 -04:00
2017-02-08 01:49:57 -08:00
deps:
-go get -v -u ./...
-go test -v -i ./...
2015-10-15 12:49:43 -04:00
2017-02-08 01:49:57 -08:00
restore-import-paths:
find . -name '*.go' -type f -execdir sed -i '' s#\"github.com/$(shell cd .. && basename "$$(pwd)")/migrate#\"github.com/mattes/migrate#g '{}' \;
rewrite-import-paths:
find . -name '*.go' -type f -execdir sed -i '' s#\"github.com/mattes/migrate#\"github.com/$(shell cd .. && basename "$$(pwd)")/migrate#g '{}' \;
.PHONY: build-cli clean test-short test test-with-flags deps html-coverage \
restore-import-paths rewrite-import-paths
2017-02-08 16:17:04 -08:00
SHELL = /bin/bash
RAND = $(shell echo $$RANDOM)
2015-10-15 12:49:43 -04:00