github.com/solvedata/migrate/v4@v4.8.7-0.20201127053940-c9fba4ce569f/Makefile (about) 1 SOURCE ?= file go_bindata github github_ee aws_s3 google_cloud_storage godoc_vfs gitlab 2 DATABASE ?= postgres mysql redshift cassandra spanner cockroachdb clickhouse mongodb sqlserver firebird 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 ./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)' . 12 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)' . 13 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)' . 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)/combined.txt -bench=. -benchmem -timeout 20m' 31 32 33 test-with-flags: 34 @echo SOURCE: $(SOURCE) 35 @echo DATABASE: $(DATABASE) 36 37 @go test $(TEST_FLAGS) ./... 38 39 40 kill-orphaned-docker-containers: 41 docker rm -f $(shell docker ps -aq --filter label=migrate_test) 42 43 44 html-coverage: 45 go tool cover -html=$(COVERAGE_DIR)/combined.txt 46 47 48 list-external-deps: 49 $(call external_deps,'.') 50 $(call external_deps,'./cli/...') 51 $(call external_deps,'./testing/...') 52 53 $(foreach v, $(SOURCE), $(call external_deps,'./source/$(v)/...')) 54 $(call external_deps,'./source/testing/...') 55 $(call external_deps,'./source/stub/...') 56 57 $(foreach v, $(DATABASE), $(call external_deps,'./database/$(v)/...')) 58 $(call external_deps,'./database/testing/...') 59 $(call external_deps,'./database/stub/...') 60 61 62 restore-import-paths: 63 find . -name '*.go' -type f -execdir sed -i '' s%\"github.com/$(REPO_OWNER)/migrate%\"github.com/mattes/migrate%g '{}' \; 64 65 66 rewrite-import-paths: 67 find . -name '*.go' -type f -execdir sed -i '' s%\"github.com/mattes/migrate%\"github.com/$(REPO_OWNER)/migrate%g '{}' \; 68 69 70 # example: fswatch -0 --exclude .godoc.pid --event Updated . | xargs -0 -n1 -I{} make docs 71 docs: 72 -make kill-docs 73 nohup godoc -play -http=127.0.0.1:6064 </dev/null >/dev/null 2>&1 & echo $$! > .godoc.pid 74 cat .godoc.pid 75 76 77 kill-docs: 78 @cat .godoc.pid 79 kill -9 $$(cat .godoc.pid) 80 rm .godoc.pid 81 82 83 open-docs: 84 open http://localhost:6064/pkg/github.com/$(REPO_OWNER)/migrate 85 86 87 # example: make release V=0.0.0 88 release: 89 git tag v$(V) 90 @read -p "Press enter to confirm and push to origin ..." && git push origin v$(V) 91 92 93 define external_deps 94 @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}}' 95 96 endef 97 98 99 .PHONY: build-cli clean test-short test test-with-flags html-coverage \ 100 restore-import-paths rewrite-import-paths list-external-deps release \ 101 docs kill-docs open-docs kill-orphaned-docker-containers 102 103 SHELL = /bin/bash 104 RAND = $(shell echo $$RANDOM) 105