github.com/wreckingballstudiolabs/migrate@v3.5.4+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 && CGO_ENABLED=0 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 && CGO_ENABLED=0 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 && CGO_ENABLED=0 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) ./database 42 @go test $(TEST_FLAGS) ./testing/... 43 44 @echo -n '$(SOURCE)' | tr -s ' ' '\n' | xargs -I{} go test $(TEST_FLAGS) ./source/{} 45 @go test $(TEST_FLAGS) ./source/testing/... 46 @go test $(TEST_FLAGS) ./source/stub/... 47 48 @echo -n '$(DATABASE)' | tr -s ' ' '\n' | xargs -I{} go test $(TEST_FLAGS) ./database/{} 49 @go test $(TEST_FLAGS) ./database/testing/... 50 @go test $(TEST_FLAGS) ./database/stub/... 51 52 53 kill-orphaned-docker-containers: 54 docker rm -f $(shell docker ps -aq --filter label=migrate_test) 55 56 57 html-coverage: 58 go tool cover -html=$(COVERAGE_DIR)/combined.txt 59 60 61 list-external-deps: 62 $(call external_deps,'.') 63 $(call external_deps,'./cli/...') 64 $(call external_deps,'./testing/...') 65 66 $(foreach v, $(SOURCE), $(call external_deps,'./source/$(v)/...')) 67 $(call external_deps,'./source/testing/...') 68 $(call external_deps,'./source/stub/...') 69 70 $(foreach v, $(DATABASE), $(call external_deps,'./database/$(v)/...')) 71 $(call external_deps,'./database/testing/...') 72 $(call external_deps,'./database/stub/...') 73 74 75 restore-import-paths: 76 find . -name '*.go' -type f -execdir sed -i '' s%\"github.com/$(REPO_OWNER)/migrate%\"github.com/mattes/migrate%g '{}' \; 77 78 79 rewrite-import-paths: 80 find . -name '*.go' -type f -execdir sed -i '' s%\"github.com/mattes/migrate%\"github.com/$(REPO_OWNER)/migrate%g '{}' \; 81 82 83 # example: fswatch -0 --exclude .godoc.pid --event Updated . | xargs -0 -n1 -I{} make docs 84 docs: 85 -make kill-docs 86 nohup godoc -play -http=127.0.0.1:6064 </dev/null >/dev/null 2>&1 & echo $$! > .godoc.pid 87 cat .godoc.pid 88 89 90 kill-docs: 91 @cat .godoc.pid 92 kill -9 $$(cat .godoc.pid) 93 rm .godoc.pid 94 95 96 open-docs: 97 open http://localhost:6064/pkg/github.com/$(REPO_OWNER)/migrate 98 99 100 # example: make release V=0.0.0 101 release: 102 git tag v$(V) 103 @read -p "Press enter to confirm and push to origin ..." && git push origin v$(V) 104 105 106 define external_deps 107 @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}}' 108 109 endef 110 111 112 .PHONY: build-cli clean test-short test test-with-flags html-coverage \ 113 restore-import-paths rewrite-import-paths list-external-deps release \ 114 docs kill-docs open-docs kill-orphaned-docker-containers 115 116 SHELL = /bin/bash 117 RAND = $(shell echo $$RANDOM) 118