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