github.com/fabregas/migrate@v3.0.2-0.20180727084154-c99964ae499e+incompatible/Makefile (about)

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