github.com/cloudfoundry-community/cloudfoundry-cli@v6.44.1-0.20240130060226-cda5ed8e89a5+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  golangci-lint: ## Run golangci-lint to validate code quality
    70  	golangci-lint run
    71  
    72  integration-cleanup:
    73  	$(PWD)/bin/cleanup-integration
    74  
    75  ie: integration-experimental
    76  integration-experimental: build integration-cleanup integration-shared-experimental integration-experimental-versioned ## Run all experimental integration tests, both versioned and shared across versions
    77  
    78  ise: integration-shared-experimental
    79  integration-experimental-shared: integration-shared-experimental
    80  integration-shared-experimental: build integration-cleanup ## Run experimental integration tests that are shared between v6 and v7
    81  	$(ginkgo_int) -nodes $(NODES) integration/shared/experimental
    82  
    83  ive: integration-versioned-experimental
    84  integration-experimental-versioned: integration-versioned-experimental
    85  integration-versioned-experimental: build integration-cleanup ## Run experimental integration tests that are specific to your CLI version
    86  	$(ginkgo_int) -nodes $(NODES) integration/$(TARGET)/experimental
    87  
    88  ig: integration-global
    89  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
    90  
    91  isg: integration-shared-global
    92  integration-global-shared: integration-shared-global
    93  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
    94  	$(ginkgo_int) integration/shared/global
    95  
    96  ivg: integration-versioned-global
    97  integration-global-versioned: integration-versioned-global
    98  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
    99  	$(ginkgo_int) integration/$(TARGET)/global
   100  
   101  ii: integration-isolated
   102  integration-isolated: build integration-cleanup integration-shared-isolated integration-isolated-versioned ## Run all parallel-enabled integration tests, both versioned and shared across versions
   103  
   104  isi: integration-shared-isolated
   105  integration-isolated-shared: integration-shared-isolated
   106  integration-shared-isolated: build integration-cleanup ## Run all parallel-enabled integration tests that are shared between v6 and v7
   107  	$(ginkgo_int) -nodes $(NODES) integration/shared/isolated
   108  
   109  integration-performance: build integration-cleanup integration-shared-performance
   110  
   111  isp: integration-shared-performance
   112  integration-performance-shared: integration-shared-performance
   113  integration-shared-performance: build integration-cleanup
   114  	$(ginkgo_int) integration/shared/performance
   115  
   116  ivi: integration-versioned-isolated
   117  integration-isolated-versioned: integration-versioned-isolated
   118  integration-versioned-isolated: build integration-cleanup ## Run all parallel-enabled integration tests, both versioned and shared across versions
   119  	$(ginkgo_int) -nodes $(NODES) integration/$(TARGET)/isolated
   120  
   121  integration-plugin: build integration-cleanup ## Run all plugin-related integration tests
   122  	$(ginkgo_int) -nodes $(NODES) integration/shared/plugin
   123  
   124  ip: integration-push
   125  integration-push: build integration-cleanup  ## Run all push-related integration tests
   126  	$(ginkgo_int) -nodes $(NODES) integration/$(TARGET)/push
   127  
   128  integration-tests: build integration-cleanup integration-isolated integration-push integration-global ## Run all isolated, push, and global integration tests
   129  
   130  i: integration-tests-full
   131  integration-full-tests: integration-tests-full
   132  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
   133  
   134  lint: ## Run our custom linters
   135  	@echo "style linting files:" # this list will grow as we cleanup all the code
   136  	@bash -c "go run bin/style/main.go api util"
   137  	@echo "No lint errors!"
   138  	@echo
   139  
   140  ifeq ($(TARGET),v6)
   141  out/cf: out/cf6
   142  	cp out/cf6 out/cf
   143  else
   144  out/cf: out/cf7
   145  	cp out/cf7 out/cf
   146  endif
   147  
   148  # Build dynamic binary for Darwin
   149  ifeq ($(UNAME_S),Darwin)
   150  out/cf6: $(GOSRC)
   151  	go build -ldflags "$(LD_FLAGS)" -o out/cf6 .
   152  else
   153  out/cf6: $(GOSRC)
   154  	CGO_ENABLED=0 go build \
   155  		$(REQUIRED_FOR_STATIC_BINARY) \
   156  		-ldflags "$(LD_FLAGS_LINUX)" -o out/cf6 .
   157  endif
   158  
   159  # Build dynamic binary for Darwin
   160  ifeq ($(UNAME_S),Darwin)
   161  out/cf7: $(GOSRC)
   162  	go build -tags="V7" -ldflags "$(LD_FLAGS_V7)" -o out/cf7 .
   163  else
   164  out/cf7: $(GOSRC)
   165  	CGO_ENABLED=0 go build \
   166  		$(REQUIRED_FOR_STATIC_BINARY_V7) \
   167  		-ldflags "$(LD_FLAGS_LINUX_V7)" -o out/cf7 .
   168  endif
   169  
   170  out/cf-cli_linux_i686: $(GOSRC)
   171  	CGO_ENABLED=0 GOARCH=386 GOOS=linux go build \
   172  							$(REQUIRED_FOR_STATIC_BINARY) \
   173  							-ldflags "$(LD_FLAGS_LINUX)" -o out/cf-cli_linux_i686 .
   174  
   175  out/cf-cli_linux_x86-64: $(GOSRC)
   176  	CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build \
   177  							$(REQUIRED_FOR_STATIC_BINARY) \
   178  							-ldflags "$(LD_FLAGS_LINUX)" -o out/cf-cli_linux_x86-64 .
   179  
   180  out/cf-cli_osx: $(GOSRC)
   181  	GOARCH=amd64 GOOS=darwin go build \
   182  				 -a -ldflags "$(LD_FLAGS)" -o out/cf-cli_osx .
   183  
   184  out/cf-cli_win32.exe: $(GOSRC) rsrc.syso
   185  	GOARCH=386 GOOS=windows go build -tags="forceposix" -o out/cf-cli_win32.exe -ldflags "$(LD_FLAGS)" .
   186  	rm rsrc.syso
   187  
   188  out/cf-cli_winx64.exe: $(GOSRC) rsrc.syso
   189  	GOARCH=amd64 GOOS=windows go build -tags="forceposix" -o out/cf-cli_winx64.exe -ldflags "$(LD_FLAGS)" .
   190  	rm rsrc.syso
   191  
   192  out/cf7-cli_linux_i686: $(GOSRC)
   193  	CGO_ENABLED=0 GOARCH=386 GOOS=linux go build \
   194  							$(REQUIRED_FOR_STATIC_BINARY_V7) \
   195  							-ldflags "$(LD_FLAGS_LINUX_V7)" -o out/cf7-cli_linux_i686 .
   196  
   197  out/cf7-cli_linux_x86-64: $(GOSRC)
   198  	CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build \
   199  							$(REQUIRED_FOR_STATIC_BINARY_V7) \
   200  							-ldflags "$(LD_FLAGS_LINUX_V7)" -o out/cf7-cli_linux_x86-64 .
   201  
   202  out/cf7-cli_osx: $(GOSRC)
   203  	GOARCH=amd64 GOOS=darwin go build -tags="V7" \
   204  				 -a -ldflags "$(LD_FLAGS_V7)" -o out/cf7-cli_osx .
   205  
   206  out/cf7-cli_win32.exe: $(GOSRC) rsrc.syso
   207  	GOARCH=386 GOOS=windows go build -tags="forceposix V7" -o out/cf7-cli_win32.exe -ldflags "$(LD_FLAGS_V7)" .
   208  	rm rsrc.syso
   209  
   210  out/cf7-cli_winx64.exe: $(GOSRC) rsrc.syso
   211  	GOARCH=amd64 GOOS=windows go build -tags="forceposix V7" -o out/cf7-cli_winx64.exe -ldflags "$(LD_FLAGS_V7)" .
   212  	rm rsrc.syso
   213  
   214  rsrc.syso:
   215  	@# Software for windows icon
   216  	go get github.com/akavel/rsrc
   217  	@# Generates icon file
   218  	rsrc -ico ci/installers/windows/cf.ico
   219  
   220  test: units ## (synonym for units)
   221  
   222  units: format vet lint build golangci-lint ## Ensure the code looks good, compiles, and passes unit tests
   223  	ginkgo -r -p -randomizeAllSpecs -randomizeSuites \
   224  		$(PACKAGES)
   225  	@echo "\nSWEET SUITE SUCCESS"
   226  
   227  units-plugin:
   228  	CF_HOME=$(PWD)/fixtures ginkgo -r -nodes 1 -randomizeAllSpecs -randomizeSuites -flakeAttempts 2 -skipPackage integration ./**/plugin* ./plugin
   229  
   230  units-non-plugin:
   231  	@rm -f $(wildcard fixtures/plugins/*.exe)
   232  	@ginkgo version
   233  	CF_HOME=$(PWD)/fixtures ginkgo -r -p -randomizeAllSpecs -randomizeSuites \
   234  		-skipPackage integration,cf/ssh,plugin,cf/actors/plugin,cf/commands/plugin,cf/actors/plugin
   235  	CF_HOME=$(PWD)/fixtures ginkgo -r -p -randomizeAllSpecs -randomizeSuites -flakeAttempts 3 cf/ssh
   236  
   237  units-full: format vet lint build units-plugin units-non-plugin
   238  	@echo "\nSWEET SUITE SUCCESS"
   239  
   240  version: ## Print the version number of what would be built
   241  	@echo $(CF_BUILD_VERSION)+$(CF_BUILD_SHA).$(CF_BUILD_DATE)
   242  
   243  GO_VERSION=$$(go version)
   244  vet: ## Run go vet
   245  	@echo  "Vetting packages for potential issues..."
   246  	go vet -all  ./api/... ./actor/... ./command ./integration/... ./types ./util ./version
   247  	@echo
   248  
   249  .PHONY: all build clean format version vet lint
   250  .PHONY: test units units-full integration integration-tests-full integration-cleanup integration-experimental integration-plugin integration-isolated integration-push
   251  .PHONY: check-target-env fly-windows-experimental fly-windows-isolated fly-windows-plugin fly-windows-push
   252  .PHONY: help
   253  
   254  help:
   255  	@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-34s\033[0m %s\n", $$1, $$2}'
   256  
   257  vet-api:
   258  	go vet -all  ./api/...