github.com/qdentity/migrate@v3.3.0+incompatible/Makefile (about) 1 SOURCE ?= file go_bindata github aws_s3 google_cloud_storage godoc_vfs 2 DATABASE ?= postgres mysql redshift cassandra spanner cockroachdb clickhouse 3 VERSION ?= $(shell git describe --tags 2>/dev/null | cut -c 2-) 4 TEST_FLAGS ?= 5 REPO_OWNER ?= $(shell cd .. && basename "$$(pwd)") 6 COVERAGE_DIR ?= .coverage 7 8 9 build-cli: clean 10 -mkdir ./cli/build 11 cd ./cli && GOOS=linux GOARCH=amd64 go build -a -o build/migrate.linux-amd64 -ldflags='-X main.Version=$(VERSION) -extldflags "-static"' -tags '$(DATABASE) $(SOURCE)' . 12 cd ./cli && GOOS=darwin GOARCH=amd64 go build -a -o build/migrate.darwin-amd64 -ldflags='-X main.Version=$(VERSION) -extldflags "-static"' -tags '$(DATABASE) $(SOURCE)' . 13 cd ./cli && GOOS=windows GOARCH=amd64 go build -a -o build/migrate.windows-amd64.exe -ldflags='-X main.Version=$(VERSION) -extldflags "-static"' -tags '$(DATABASE) $(SOURCE)' . 14 cd ./cli/build && find . -name 'migrate*' | xargs -I{} tar czf {}.tar.gz {} 15 cd ./cli/build && shasum -a 256 * > sha256sum.txt 16 cat ./cli/build/sha256sum.txt 17 18 19 clean: 20 -rm -r ./cli/build 21 22 23 test-short: 24 make test-with-flags --ignore-errors TEST_FLAGS='-short' 25 26 27 test: 28 @-rm -r $(COVERAGE_DIR) 29 @mkdir $(COVERAGE_DIR) 30 make test-with-flags TEST_FLAGS='-v -race -covermode atomic -coverprofile $$(COVERAGE_DIR)/_$$(RAND).txt -bench=. -benchmem -timeout 20m' 31 @echo 'mode: atomic' > $(COVERAGE_DIR)/combined.txt 32 @cat $(COVERAGE_DIR)/_*.txt | grep -v 'mode: atomic' >> $(COVERAGE_DIR)/combined.txt 33 34 35 test-with-flags: 36 @echo SOURCE: $(SOURCE) 37 @echo DATABASE: $(DATABASE) 38 39 @go test $(TEST_FLAGS) . 40 @go test $(TEST_FLAGS) ./cli/... 41 @go test $(TEST_FLAGS) ./testing/... 42 43 @echo -n '$(SOURCE)' | tr -s ' ' '\n' | xargs -I{} go test $(TEST_FLAGS) ./source/{} 44 @go test $(TEST_FLAGS) ./source/testing/... 45 @go test $(TEST_FLAGS) ./source/stub/... 46 47 @echo -n '$(DATABASE)' | tr -s ' ' '\n' | xargs -I{} go test $(TEST_FLAGS) ./database/{} 48 @go test $(TEST_FLAGS) ./database/testing/... 49 @go test $(TEST_FLAGS) ./database/stub/... 50 51 52 kill-orphaned-docker-containers: 53 docker rm -f $(shell docker ps -aq --filter label=migrate_test) 54 55 56 html-coverage: 57 go tool cover -html=$(COVERAGE_DIR)/combined.txt 58 59 60 list-external-deps: 61 $(call external_deps,'.') 62 $(call external_deps,'./cli/...') 63 $(call external_deps,'./testing/...') 64 65 $(foreach v, $(SOURCE), $(call external_deps,'./source/$(v)/...')) 66 $(call external_deps,'./source/testing/...') 67 $(call external_deps,'./source/stub/...') 68 69 $(foreach v, $(DATABASE), $(call external_deps,'./database/$(v)/...')) 70 $(call external_deps,'./database/testing/...') 71 $(call external_deps,'./database/stub/...') 72 73 74 restore-import-paths: 75 find . -name '*.go' -type f -execdir sed -i '' s%\"github.com/$(REPO_OWNER)/migrate%\"github.com/mattes/migrate%g '{}' \; 76 77 78 rewrite-import-paths: 79 find . -name '*.go' -type f -execdir sed -i '' s%\"github.com/mattes/migrate%\"github.com/$(REPO_OWNER)/migrate%g '{}' \; 80 81 82 # example: fswatch -0 --exclude .godoc.pid --event Updated . | xargs -0 -n1 -I{} make docs 83 docs: 84 -make kill-docs 85 nohup godoc -play -http=127.0.0.1:6064 </dev/null >/dev/null 2>&1 & echo $$! > .godoc.pid 86 cat .godoc.pid 87 88 89 kill-docs: 90 @cat .godoc.pid 91 kill -9 $$(cat .godoc.pid) 92 rm .godoc.pid 93 94 95 open-docs: 96 open http://localhost:6064/pkg/github.com/$(REPO_OWNER)/migrate 97 98 99 # example: make release V=0.0.0 100 release: 101 git tag v$(V) 102 @read -p "Press enter to confirm and push to origin ..." && git push origin v$(V) 103 104 105 define external_deps 106 @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}}' 107 108 endef 109 110 111 .PHONY: build-cli clean test-short test test-with-flags html-coverage \ 112 restore-import-paths rewrite-import-paths list-external-deps release \ 113 docs kill-docs open-docs kill-orphaned-docker-containers 114 115 SHELL = /bin/bash 116 RAND = $(shell echo $$RANDOM) 117