github.com/randomtask1155/cli@v6.41.1-0.20181227003417-a98eed78cbde+incompatible/Makefile (about)

     1  CF_DIAL_TIMEOUT ?= 15
     2  NODES ?= 10
     3  PACKAGES ?= api actor command types util version integration/helpers
     4  LC_ALL = "en_US.UTF-8"
     5  
     6  CF_BUILD_VERSION ?= $$(cat BUILD_VERSION)
     7  CF_BUILD_VERSION_V7 ?= $$(cat BUILD_VERSION_V7)
     8  CF_BUILD_SHA ?= $$(git rev-parse --short HEAD)
     9  CF_BUILD_DATE ?= $$(date -u +"%Y-%m-%d")
    10  LD_FLAGS_COMMON=-w -s \
    11  	-X code.cloudfoundry.org/cli/version.binarySHA=$(CF_BUILD_SHA) \
    12  	-X code.cloudfoundry.org/cli/version.binaryBuildDate=$(CF_BUILD_DATE)
    13  LD_FLAGS =$(LD_FLAGS_COMMON) \
    14  	-X code.cloudfoundry.org/cli/version.binaryVersion=$(CF_BUILD_VERSION)
    15  LD_FLAGS_V7 =$(LD_FLAGS_COMMON) \
    16  	-X code.cloudfoundry.org/cli/version.binaryVersion=$(CF_BUILD_VERSION_V7)
    17  LD_FLAGS_LINUX = -extldflags \"-static\" $(LD_FLAGS)
    18  LD_FLAGS_LINUX_V7 = -extldflags \"-static\" $(LD_FLAGS_V7)
    19  REQUIRED_FOR_STATIC_BINARY =-a -tags netgo -installsuffix netgo
    20  REQUIRED_FOR_STATIC_BINARY_V7 =-a -tags "V7 netgo" -installsuffix netgo
    21  GOSRC = $(shell find . -name "*.go" ! -name "*test.go" ! -name "*fake*" ! -path "./integration/*")
    22  UNAME_S := $(shell uname -s)
    23  
    24  ginkgo_int = ginkgo -r -randomizeAllSpecs -slowSpecThreshold 60
    25  
    26  ifndef TARGET_V7
    27  TARGET = v6
    28  else
    29  TARGET = v7
    30  endif
    31  
    32  all: test build
    33  
    34  build: out/cf ## Compile and build a new `cf` binary
    35  
    36  check-target-env:
    37  ifndef CF_INT_API
    38  	$(error CF_INT_API is undefined)
    39  endif
    40  ifndef CF_INT_PASSWORD
    41  	$(error CF_INT_PASSWORD is undefined)
    42  endif
    43  
    44  clean: ## Remove all files from the `out` directory
    45  	rm -f $(wildcard out/cf*)
    46  
    47  format: ## Run go fmt
    48  	go fmt ./...
    49  
    50  fly-windows-experimental: check-target-env
    51  	CF_TEST_SUITE=./integration/shared/experimental fly -t ci execute -c ci/cli/tasks/integration-windows-oneoff.yml -i cli=./ --tag "cli-windows"
    52  
    53  fly-windows-isolated: check-target-env
    54  	CF_TEST_SUITE=./integration/shared/isolated fly -t ci execute -c ci/cli/tasks/integration-windows-oneoff.yml -i cli=./ --tag "cli-windows"
    55  
    56  fly-windows-plugin: check-target-env
    57  	CF_TEST_SUITE=./integration/shared/plugin fly -t ci execute -c ci/cli/tasks/integration-windows-oneoff.yml -i cli=./ --tag "cli-windows"
    58  
    59  fly-windows-push: check-target-env
    60  	CF_TEST_SUITE=./integration/v6/push fly -t ci execute -c ci/cli/tasks/integration-windows-oneoff.yml -i cli=./ --tag "cli-windows"
    61  
    62  fly-windows-global: check-target-env
    63  	CF_TEST_SUITE=./integration/shared/global fly -t ci execute -c ci/cli/tasks/integration-windows-serial.yml -i cli=./ --tag "cli-windows"
    64  
    65  fly-windows-units:
    66  	fly -t ci execute -c ci/cli/tasks/units-windows.yml -i cli=./ -i cli-ci=./ --tag "cli-windows"
    67  
    68  integration-cleanup:
    69  	$(PWD)/bin/cleanup-integration
    70  
    71  integration-experimental: build integration-cleanup integration-shared-experimental integration-experimental-versioned ## Run all experimental integration tests, both versioned and shared across versions
    72  
    73  integration-experimental-shared: integration-shared-experimental
    74  integration-shared-experimental: build integration-cleanup ## Run experimental integration tests that are shared between v6 and v7
    75  	$(ginkgo_int) -nodes $(NODES) integration/shared/experimental
    76  
    77  integration-experimental-versioned: integration-versioned-experimental
    78  integration-versioned-experimental: build integration-cleanup ## Run experimental integration tests that are specific to your CLI version
    79  	$(ginkgo_int) -nodes $(NODES) integration/$(TARGET)/experimental
    80  
    81  integration-global: build integration-cleanup integration-shared-global integration-global-versioned ## Run all unparallelizable integration tests that make cross-cutting changes to their test CF foundation
    82  
    83  integration-global-shared: integration-shared-global
    84  integration-shared-global: build integration-cleanup ## Serially run integration tests that make cross-cutting changes to their test CF foundation and are shared between v6 and v7
    85  	$(ginkgo_int) integration/shared/global
    86  
    87  integration-global-versioned: integration-versioned-global
    88  integration-versioned-global: build integration-cleanup ## Serially run integration tests that make cross-cutting changes to their test CF foundation and are specific to your CLI version
    89  	$(ginkgo_int) integration/$(TARGET)/global
    90  
    91  integration-isolated: build integration-cleanup integration-shared-isolated integration-isolated-versioned ## Run all parallel-enabled integration tests, both versioned and shared across versions
    92  
    93  integration-isolated-shared: integration-shared-isolated
    94  integration-shared-isolated: build integration-cleanup ## Run all parallel-enabled integration tests that are shared between v6 and v7
    95  	$(ginkgo_int) -nodes $(NODES) integration/shared/isolated
    96  
    97  integration-isolated-versioned: integration-versioned-isolated
    98  integration-versioned-isolated: build integration-cleanup ## Run all parallel-enabled integration tests, both versioned and shared across versions
    99  	$(ginkgo_int) -nodes $(NODES) integration/$(TARGET)/isolated
   100  
   101  integration-plugin: build integration-cleanup ## Run all plugin-related integration tests
   102  	$(ginkgo_int) -nodes $(NODES) integration/shared/plugin
   103  
   104  integration-push: build integration-cleanup  ## Run all push-related integration tests
   105  	$(ginkgo_int) -nodes $(NODES) integration/$(TARGET)/push
   106  
   107  integration-tests: build integration-cleanup integration-isolated integration-push integration-global ## Run all isolated, push, and global integration tests
   108  
   109  integration-full-tests: integration-tests-full
   110  integration-tests-full: build integration-cleanup integration-isolated integration-push integration-experimental integration-plugin integration-global  ## Run all isolated, push, experimental, plugin, and global integration tests
   111  
   112  lint: ## Run our custom linters
   113  	@echo "style linting files:" # this list will grow as we cleanup all the code
   114  	@bash -c "go run bin/style/main.go api util/{configv3,manifest,randomword,sorting,ui}"
   115  	@echo "No lint errors!"
   116  	@echo
   117  
   118  ifeq ($(TARGET),v6)
   119  out/cf: out/cf6
   120  	cp out/cf6 out/cf
   121  else
   122  out/cf: out/cf7
   123  	cp out/cf7 out/cf
   124  endif
   125  
   126  # Build dynamic binary for Darwin
   127  ifeq ($(UNAME_S),Darwin)
   128  out/cf6: $(GOSRC)
   129  	go build -ldflags "$(LD_FLAGS)" -o out/cf6 .
   130  else
   131  out/cf6: $(GOSRC)
   132  	CGO_ENABLED=0 go build \
   133  		$(REQUIRED_FOR_STATIC_BINARY) \
   134  		-ldflags "$(LD_FLAGS_LINUX)" -o out/cf6 .
   135  endif
   136  
   137  # Build dynamic binary for Darwin
   138  ifeq ($(UNAME_S),Darwin)
   139  out/cf7: $(GOSRC)
   140  	go build -tags="V7" -ldflags "$(LD_FLAGS_V7)" -o out/cf7 .
   141  else
   142  out/cf7: $(GOSRC)
   143  	CGO_ENABLED=0 go build \
   144  		$(REQUIRED_FOR_STATIC_BINARY_V7) \
   145  		-ldflags "$(LD_FLAGS_LINUX_V7)" -o out/cf7 .
   146  endif
   147  
   148  out/cf-cli_linux_i686: $(GOSRC)
   149  	CGO_ENABLED=0 GOARCH=386 GOOS=linux go build \
   150  							$(REQUIRED_FOR_STATIC_BINARY) \
   151  							-ldflags "$(LD_FLAGS_LINUX)" -o out/cf-cli_linux_i686 .
   152  
   153  out/cf-cli_linux_x86-64: $(GOSRC)
   154  	CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build \
   155  							$(REQUIRED_FOR_STATIC_BINARY) \
   156  							-ldflags "$(LD_FLAGS_LINUX)" -o out/cf-cli_linux_x86-64 .
   157  
   158  out/cf-cli_osx: $(GOSRC)
   159  	GOARCH=amd64 GOOS=darwin go build \
   160  				 -a -ldflags "$(LD_FLAGS)" -o out/cf-cli_osx .
   161  
   162  out/cf-cli_win32.exe: $(GOSRC) rsrc.syso
   163  	GOARCH=386 GOOS=windows go build -tags="forceposix" -o out/cf-cli_win32.exe -ldflags "$(LD_FLAGS)" .
   164  	rm rsrc.syso
   165  
   166  out/cf-cli_winx64.exe: $(GOSRC) rsrc.syso
   167  	GOARCH=amd64 GOOS=windows go build -tags="forceposix" -o out/cf-cli_winx64.exe -ldflags "$(LD_FLAGS)" .
   168  	rm rsrc.syso
   169  
   170  out/cf7-cli_linux_i686: $(GOSRC)
   171  	CGO_ENABLED=0 GOARCH=386 GOOS=linux go build \
   172  							$(REQUIRED_FOR_STATIC_BINARY_V7) \
   173  							-ldflags "$(LD_FLAGS_LINUX_V7)" -o out/cf7-cli_linux_i686 .
   174  
   175  out/cf7-cli_linux_x86-64: $(GOSRC)
   176  	CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build \
   177  							$(REQUIRED_FOR_STATIC_BINARY_V7) \
   178  							-ldflags "$(LD_FLAGS_LINUX_V7)" -o out/cf7-cli_linux_x86-64 .
   179  
   180  out/cf7-cli_osx: $(GOSRC)
   181  	GOARCH=amd64 GOOS=darwin go build -tags="V7" \
   182  				 -a -ldflags "$(LD_FLAGS_V7)" -o out/cf7-cli_osx .
   183  
   184  out/cf7-cli_win32.exe: $(GOSRC) rsrc.syso
   185  	GOARCH=386 GOOS=windows go build -tags="forceposix V7" -o out/cf7-cli_win32.exe -ldflags "$(LD_FLAGS_V7)" .
   186  	rm rsrc.syso
   187  
   188  out/cf7-cli_winx64.exe: $(GOSRC) rsrc.syso
   189  	GOARCH=amd64 GOOS=windows go build -tags="forceposix V7" -o out/cf7-cli_winx64.exe -ldflags "$(LD_FLAGS_V7)" .
   190  	rm rsrc.syso
   191  
   192  rsrc.syso:
   193  	@# Software for windows icon
   194  	go get github.com/akavel/rsrc
   195  	@# Generates icon file
   196  	rsrc -ico ci/installers/windows/cf.ico
   197  
   198  test: units ## Runs everything that can run locally
   199  
   200  units: format vet lint build ## Ensure the code looks good, compiles, and passes unit tests
   201  	ginkgo -r -p -randomizeAllSpecs -randomizeSuites \
   202  		$(PACKAGES)
   203  	@echo "\nSWEET SUITE SUCCESS"
   204  
   205  units-plugin:
   206  	CF_HOME=$(PWD)/fixtures ginkgo -r -nodes 1 -randomizeAllSpecs -randomizeSuites -flakeAttempts 2 -skipPackage integration ./**/plugin* ./plugin
   207  
   208  units-non-plugin:
   209  	@rm -f $(wildcard fixtures/plugins/*.exe)
   210  	@ginkgo version
   211  	CF_HOME=$(PWD)/fixtures ginkgo -r -p -randomizeAllSpecs -randomizeSuites \
   212  		-skipPackage integration,cf/ssh,plugin,cf/actors/plugin,cf/commands/plugin,cf/actors/plugin
   213  	CF_HOME=$(PWD)/fixtures ginkgo -r -p -randomizeAllSpecs -randomizeSuites -flakeAttempts 3 cf/ssh
   214  
   215  units-full: format vet lint build units-plugin units-non-plugin
   216  	@echo "\nSWEET SUITE SUCCESS"
   217  
   218  version: ## Print the version number of what would be built
   219  	@echo $(CF_BUILD_VERSION)+$(CF_BUILD_SHA).$(CF_BUILD_DATE)
   220  
   221  vet: ## Run go vet
   222  	@echo  "Vetting packages for potential issues..."
   223  	go tool vet -all -shadow=true ./api ./actor ./command ./integration ./types ./util ./version
   224  	@echo
   225  
   226  .PHONY: all build clean format version vet lint
   227  .PHONY: test units units-full integration integration-tests-full integration-cleanup integration-experimental integration-plugin integration-isolated integration-push
   228  .PHONY: check-target-env fly-windows-experimental fly-windows-isolated fly-windows-plugin fly-windows-push
   229  .PHONY: help
   230  
   231  help:
   232  	@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'