gopkg.in/yuukihogo/migrate.v3@v3.0.0/Makefile (about)

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