You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

makefile 3.3 kB

3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #
  2. # Licensed to the Apache Software Foundation (ASF) under one or more
  3. # contributor license agreements. See the NOTICE file distributed with
  4. # this work for additional information regarding copyright ownership.
  5. # The ASF licenses this file to You under the Apache License, Version 2.0
  6. # (the "License"); you may not use this file except in compliance with
  7. # the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. #
  17. VERSION=$(shell cat "./VERSION" 2> /dev/null)
  18. GO_FLAGS := -ldflags "-X main.Branch=$(GIT_BRANCH) -X main.Revision=$(GIT_REVISION) -X main.Version=$(VERSION) -extldflags \"-static\" -s -w" -tags netgo
  19. GO = go
  20. GO_PATH = $(shell $(GO) env GOPATH)
  21. GO_OS = $(shell $(GO) env GOOS)
  22. ifeq ($(GO_OS), darwin)
  23. GO_OS = mac
  24. endif
  25. # License environment
  26. GO_LICENSE_CHECKER_DIR = license-header-checker-$(GO_OS)
  27. GO_LICENSE_CHECKER = $(GO_PATH)/bin/license-header-checker
  28. LICENSE_DIR = /tmp/tools/license
  29. # format import code
  30. format-import:
  31. go get -d github.com/dubbogo/tools/cmd/imports-formatter
  32. imports-formatter -path . -module seata.apache.org/seata-go -bl false
  33. unit-test:
  34. go test ./pkg/... -coverprofile=coverage.txt -covermode=atomic
  35. # Generate binaries for a Cortex release
  36. dist dist/seatago-linux-amd64 dist/seatago-darwin-amd64 dist/seatago-linux-amd64-sha-256 dist/seatago-darwin-amd64-sha-256:
  37. rm -fr ./dist
  38. mkdir -p ./dist
  39. GOOS="linux" GOARCH="amd64" CGO_ENABLED=0 go build $(GO_FLAGS) -o ./dist/seatago-linux-amd64 ./cmd
  40. GOOS="darwin" GOARCH="amd64" CGO_ENABLED=0 go build $(GO_FLAGS) -o ./dist/seatago-darwin-amd64 ./cmd
  41. sha256sum ./dist/seatago-darwin-amd64 | cut -d ' ' -f 1 > ./dist/seatago-darwin-amd64-sha-256
  42. sha256sum ./dist/seatago-linux-amd64 | cut -d ' ' -f 1 > ./dist/seatago-linux-amd64-sha-256
  43. # Generate binaries for a Cortex release
  44. build dist/seatago dist/seatago-sha-256:
  45. rm -fr ./dist
  46. mkdir -p ./dist
  47. CGO_ENABLED=0 go build $(GO_FLAGS) -o ./dist/seatago ./cmd
  48. sha256sum ./dist/seatago | cut -d ' ' -f 1 > ./dist/seatago-sha-256
  49. #docker-build:
  50. # docker build -t seatago/seatago:latest .
  51. integration-test:
  52. @go clean -testcache
  53. go test -tags integration -v ./test/...
  54. clean:
  55. @rm -rf coverage.txt
  56. @rm -rf dist
  57. prepareLic:
  58. echo 'The makefile is for ci test and has dependencies. Do not run it locally. If you want to run the unit tests, run command `go test ./...` directly.'
  59. $(GO_LICENSE_CHECKER) -version || (wget https://github.com/lsm-dev/license-header-checker/releases/download/v1.2.0/$(GO_LICENSE_CHECKER_DIR).zip -O $(GO_LICENSE_CHECKER_DIR).zip && unzip -o $(GO_LICENSE_CHECKER_DIR).zip && mkdir -p $(GO_PATH)/bin/ && cp $(GO_LICENSE_CHECKER_DIR)/64bit/license-header-checker $(GO_PATH)/bin/)
  60. ls /tmp/tools/license/license.txt || wget -P $(LICENSE_DIR) https://github.com/dubbogo/resources/raw/master/tools/license/license.txt
  61. .PHONY: license
  62. license: prepareLic
  63. $(GO_LICENSE_CHECKER) -v -a -r -i vendor $(LICENSE_DIR)/license.txt . go && [[ -z `git status -s` ]]