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