Deliverable for D3.2

Makefile 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. SOURCE_VERSION = $(shell git rev-parse --short=6 HEAD)
  2. BUILD_FLAGS = -v -ldflags "-X gogs.dyne.org/DECODE/decode-prototype-da.SourceVersion=$(SOURCE_VERSION)"
  3. PACKAGES := $(shell go list ./... | grep -v /vendor/ )
  4. GO_TEST = go test -covermode=atomic
  5. GO_INTEGRATION = $(GO_TEST) -bench=. -v --tags=integration
  6. GO_COVER = go tool cover
  7. GO_BENCH = go test -bench=.
  8. ARTEFACT_DIR = coverage
  9. all: linux-arm linux-i386 linux-amd64 darwin-amd64 ## build executables for the various environments
  10. .PHONY: all
  11. get-build-deps: ## install build dependencies
  12. go get github.com/chespinoza/goliscan
  13. .PHONY: get-build-deps
  14. check-vendor-licenses: ## check if licenses of project dependencies meet project requirements
  15. @goliscan check --direct-only -strict
  16. @goliscan check --indirect-only -strict
  17. .PHONY: check-vendor-licenses
  18. test: ## run tests
  19. $(GO_TEST) $(PACKAGES)
  20. .PHONY: test
  21. test_integration: ## run integration tests (SLOW)
  22. mkdir -p $(ARTEFACT_DIR)
  23. echo 'mode: atomic' > $(ARTEFACT_DIR)/cover-integration.out
  24. touch $(ARTEFACT_DIR)/cover.tmp
  25. $(foreach package, $(PACKAGES), $(GO_INTEGRATION) -coverprofile=$(ARTEFACT_DIR)/cover.tmp $(package) && tail -n +2 $(ARTEFACT_DIR)/cover.tmp >> $(ARTEFACT_DIR)/cover-integration.out || exit;)
  26. .PHONY: test_integration
  27. clean: ## clean up
  28. rm -rf tmp/
  29. rm -rf $(ARTEFACT_DIR)
  30. .PHONY: clean
  31. bench: ## run benchmark tests
  32. $(GO_BENCH) $(PACKAGES)
  33. .PHONY: bench
  34. coverage: test_integration ## generate and display coverage report
  35. $(GO_COVER) -func=$(ARTEFACT_DIR)/cover-integration.out
  36. .PHONY: test_integration
  37. ui-build: ## build the ui project
  38. $(MAKE) -C ui build
  39. .PHONY: ui-build
  40. docker-build: clean ui-build linux-amd64 ## build docker images for all of the executables
  41. docker build -t prototype/metadata:latest -t prototype/metadata:$(SOURCE_VERSION) -f=./docker/Dockerfile.metadata .
  42. docker build -t prototype/node:latest -t prototype/node:$(SOURCE_VERSION) -f=./docker/Dockerfile.node .
  43. docker build -t prototype/storage:latest -t prototype/storage:$(SOURCE_VERSION) -f=./docker/Dockerfile.storage .
  44. .PHONY: docker-build
  45. docker-redis: ## run a local instance of docker for the storage service
  46. docker run -p 6379:6379 redis:3.0.7
  47. .PHONY: docker-redis
  48. client-metadata: ## build golang client for the metadata service - requires a local running metadata service
  49. java -jar ./tools/swagger-codegen-cli-2.2.1.jar generate -i http://localhost:8081/apidocs.json -l go -o ./client/metadata/ --type-mappings object=interface{}
  50. .PHONY: client-metadata
  51. client-storage: ## build golang client for the storage service - requires a local running storage service
  52. java -jar ./tools/swagger-codegen-cli-2.2.1.jar generate -i http://localhost:8083/apidocs.json -l go -o ./client/storage/ --type-mappings object=interface{}
  53. .PHONY: client-storage
  54. darwin-amd64: tmp/build/darwin-amd64/metadata tmp/build/darwin-amd64/storage tmp/build/darwin-amd64/node ## build for mac amd64
  55. linux-i386: tmp/build/linux-i386/metadata tmp/build/linux-i386/storage tmp/build/linux-i386/node ## build for linux i386
  56. linux-amd64: tmp/build/linux-amd64/metadata tmp/build/linux-amd64/storage tmp/build/linux-amd64/node ## build for linux amd64
  57. linux-arm: tmp/build/linux-arm/metadata tmp/build/linux-arm/storage tmp/build/linux-arm/node ## build for linux arm (raspberry-pi)
  58. .PHONY: darwin-amd64 linux-i386 linux-amd64 linux-arm
  59. tmp/build/linux-i386/metadata:
  60. GOOS=linux GOARCH=386 go build $(BUILD_FLAGS) -o $(@) ./cmd/metadata
  61. tmp/build/linux-i386/storage:
  62. GOOS=linux GOARCH=386 go build $(BUILD_FLAGS) -o $(@) ./cmd/storage
  63. tmp/build/linux-i386/node:
  64. GOOS=linux GOARCH=386 go build $(BUILD_FLAGS) -o $(@) ./cmd/node
  65. ## linux-amd64
  66. tmp/build/linux-amd64/metadata:
  67. GOOS=linux GOARCH=amd64 go build $(BUILD_FLAGS) -o $(@) ./cmd/metadata
  68. tmp/build/linux-amd64/storage:
  69. GOOS=linux GOARCH=amd64 go build $(BUILD_FLAGS) -o $(@) ./cmd/storage
  70. tmp/build/linux-amd64/node:
  71. GOOS=linux GOARCH=amd64 go build $(BUILD_FLAGS) -o $(@) ./cmd/node
  72. ## linux-arm
  73. tmp/build/linux-arm/metadata:
  74. GOOS=linux GOARCH=arm go build $(BUILD_FLAGS) -o $(@) ./cmd/metadata
  75. tmp/build/linux-arm/storage:
  76. GOOS=linux GOARCH=arm go build $(BUILD_FLAGS) -o $(@) ./cmd/storage
  77. tmp/build/linux-arm/node:
  78. GOOS=linux GOARCH=arm go build $(BUILD_FLAGS) -o $(@) ./cmd/node
  79. ## darwin-amd64
  80. tmp/build/darwin-amd64/metadata:
  81. GOOS=darwin GOARCH=amd64 go build $(BUILD_FLAGS) -o $(@) ./cmd/metadata
  82. tmp/build/darwin-amd64/storage:
  83. GOOS=darwin GOARCH=amd64 go build $(BUILD_FLAGS) -o $(@) ./cmd/storage
  84. tmp/build/darwin-amd64/node:
  85. GOOS=darwin GOARCH=amd64 go build $(BUILD_FLAGS) -o $(@) ./cmd/node
  86. # 'help' parses the Makefile and displays the help text
  87. help:
  88. @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
  89. .PHONY: help