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