github.com/LukasHeimann/cloudfoundrycli/v8@v8.4.4/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) # TODO: version specific
     7  CF_BUILD_SHA ?= $$(git rev-parse --short HEAD)
     8  CF_BUILD_DATE ?= $$(date -u +"%Y-%m-%d")
     9  LD_FLAGS_COMMON=-w -s \
    10  	-X code.cloudfoundry.org/cli/version.binarySHA=$(CF_BUILD_SHA) \
    11  	-X code.cloudfoundry.org/cli/version.binaryBuildDate=$(CF_BUILD_DATE)
    12  LD_FLAGS =$(LD_FLAGS_COMMON) \
    13  	-X code.cloudfoundry.org/cli/version.binaryVersion=$(CF_BUILD_VERSION)
    14  LD_FLAGS_LINUX = -extldflags \"-static\" $(LD_FLAGS)
    15  REQUIRED_FOR_STATIC_BINARY =-a -tags "netgo" -installsuffix netgo
    16  GOSRC = $(shell find . -name "*.go" ! -name "*test.go" ! -name "*fake*" ! -path "./integration/*")
    17  UNAME_S := $(shell uname -s)
    18  
    19  SLOW_SPEC_THRESHOLD=120
    20  
    21  GINKGO_FLAGS ?= -r -randomizeAllSpecs -requireSuite
    22  GINKGO_INT_FLAGS = $(GINKGO_FLAGS) -slowSpecThreshold $(SLOW_SPEC_THRESHOLD)
    23  ginkgo_int = ginkgo $(GINKGO_INT_FLAGS)
    24  
    25  GINKGO_UNITS_FLAGS = $(GINKGO_FLAGS) -randomizeSuites -p
    26  ginkgo_units = ginkgo $(GINKGO_UNITS_FLAGS)
    27  GOFLAGS := -mod=mod
    28  
    29  all: lint test build
    30  
    31  build: out/cf ## Compile and build a new `cf` binary
    32  
    33  check-target-env:
    34  ifndef CF_INT_API
    35  	$(error CF_INT_API is undefined)
    36  endif
    37  ifndef CF_INT_PASSWORD
    38  	$(error CF_INT_PASSWORD is undefined)
    39  endif
    40  
    41  clean: ## Just remove all cf* files from the `out` directory
    42  	rm -f $(wildcard out/cf*)
    43  
    44  clear: clean  ## Make everyone happy
    45  
    46  custom-lint: ## Run our custom linters
    47  	@echo "Running custom linters..." # this list will grow as we cleanup all the code:
    48  	bash -c "go run bin/style/main.go api util"
    49  	@echo "No custom lint errors!"
    50  	@echo
    51  
    52  # TODO: update these fly-windows* to point at the correct CI repo
    53  fly-windows-experimental: check-target-env
    54  	CF_TEST_SUITE=./integration/shared/experimental fly -t ci execute -c ci/cli/tasks/integration-windows-oneoff.yml -i cli=./ --tag "cli-windows"
    55  
    56  fly-windows-isolated: check-target-env
    57  	CF_TEST_SUITE=./integration/shared/isolated fly -t ci execute -c ci/cli/tasks/integration-windows-oneoff.yml -i cli=./ --tag "cli-windows"
    58  
    59  fly-windows-plugin: check-target-env
    60  	CF_TEST_SUITE=./integration/shared/plugin fly -t ci execute -c ci/cli/tasks/integration-windows-oneoff.yml -i cli=./ --tag "cli-windows"
    61  
    62  fly-windows-push: check-target-env
    63  	CF_TEST_SUITE=./integration/v6/push fly -t ci execute -c ci/cli/tasks/integration-windows-oneoff.yml -i cli=./ --tag "cli-windows"
    64  
    65  fly-windows-global: check-target-env
    66  	CF_TEST_SUITE=./integration/shared/global fly -t ci execute -c ci/cli/tasks/integration-windows-serial.yml -i cli=./ --tag "cli-windows"
    67  
    68  fly-windows-units:
    69  	fly -t ci execute -c ci/cli/tasks/units-windows.yml -i cli=./ -i cli-ci=./ --tag "cli-windows"
    70  
    71  format: ## Run go fmt
    72  	go fmt ./...
    73  
    74  integration-cleanup:
    75  	$(PWD)/bin/cleanup-integration
    76  
    77  ie: integration-experimental
    78  integration-experimental: build integration-cleanup integration-shared-experimental integration-experimental-versioned ## Run all experimental integration tests, both versioned and shared across versions
    79  
    80  ise: integration-shared-experimental
    81  integration-experimental-shared: integration-shared-experimental
    82  integration-shared-experimental: build integration-cleanup ## Run experimental integration tests that are shared between v6 and v7
    83  	$(ginkgo_int) -nodes $(NODES) integration/shared/experimental
    84  
    85  ive: integration-versioned-experimental
    86  integration-experimental-versioned: integration-versioned-experimental
    87  integration-versioned-experimental: build integration-cleanup ## Run experimental integration tests that are specific to your CLI version
    88  	$(ginkgo_int) -nodes $(NODES) integration/v7/experimental
    89  
    90  ig: integration-global
    91  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
    92  
    93  isg: integration-shared-global
    94  integration-global-shared: integration-shared-global
    95  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
    96  	$(ginkgo_int) integration/shared/global
    97  
    98  ivg: integration-versioned-global
    99  integration-global-versioned: integration-versioned-global
   100  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
   101  	$(ginkgo_int) integration/v7/global
   102  
   103  ii: integration-isolated
   104  integration-isolated: build integration-cleanup integration-shared-isolated integration-isolated-versioned ## Run all parallel-enabled integration tests, both versioned and shared across versions
   105  
   106  isi: integration-shared-isolated
   107  integration-isolated-shared: integration-shared-isolated
   108  integration-shared-isolated: build integration-cleanup ## Run all parallel-enabled integration tests that are shared between v6 and v7
   109  	$(ginkgo_int) -nodes $(NODES) integration/shared/isolated
   110  
   111  integration-performance: build integration-cleanup integration-shared-performance
   112  
   113  isp: integration-shared-performance
   114  integration-performance-shared: integration-shared-performance
   115  integration-shared-performance: build integration-cleanup
   116  	$(ginkgo_int) integration/shared/performance
   117  
   118  ivi: integration-versioned-isolated
   119  integration-isolated-versioned: integration-versioned-isolated
   120  integration-versioned-isolated: build integration-cleanup ## Run all parallel-enabled integration tests, both versioned and shared across versions
   121  	$(ginkgo_int) -nodes $(NODES) integration/v7/isolated
   122  
   123  integration-plugin: build integration-cleanup ## Run all plugin-related integration tests
   124  	$(ginkgo_int) -nodes $(NODES) integration/shared/plugin
   125  
   126  ip: integration-push
   127  integration-push: build integration-cleanup  ## Run all push-related integration tests
   128  	$(ginkgo_int) -nodes $(NODES) integration/v7/push
   129  
   130  integration-selfcontained: build
   131  	$(ginkgo_int) -nodes $(NODES) integration/v7/selfcontained
   132  
   133  integration-tests: build integration-cleanup integration-isolated integration-push integration-global integration-selfcontained ## Run all isolated, push, selfcontained, and global integration tests
   134  
   135  
   136  i: integration-tests-full
   137  integration-full-tests: integration-tests-full
   138  integration-tests-full: build integration-cleanup integration-isolated integration-push integration-experimental integration-plugin integration-global integration-selfcontained ## Run all isolated, push, experimental, plugin, selfcontained, and global integration tests
   139  
   140  integration-tests-full-ci: integration-cleanup
   141  	$(ginkgo_int) -nodes $(NODES)  -flakeAttempts $(FLAKE_ATTEMPTS) \
   142  		integration/shared/isolated integration/v7/isolated integration/shared/plugin integration/shared/experimental integration/v7/experimental integration/v7/push
   143  	$(ginkgo_int) -flakeAttempts $(FLAKE_ATTEMPTS) integration/shared/global integration/v7/global
   144  
   145  lint: custom-lint ## Runs all linters and formatters
   146  	@echo "Running linters..."
   147  	go list -f "{{.Dir}}" ./... \
   148  		| grep -v -e "/cf/" -e "/fixtures/" -e "/assets/" -e "/plugin/" -e "/command/plugin" -e "fakes" \
   149  		| xargs golangci-lint run
   150  	@echo "No lint errors!"
   151  
   152  # TODO: version specific tagging for all these builds
   153  # Build dynamic binary for Darwin
   154  ifeq ($(UNAME_S),Darwin)
   155  out/cf: $(GOSRC)
   156  	go build -ldflags "$(LD_FLAGS)" -o out/cf .
   157  else
   158  out/cf: $(GOSRC)
   159  	CGO_ENABLED=0 go build \
   160  		$(REQUIRED_FOR_STATIC_BINARY) \
   161  		-ldflags "$(LD_FLAGS_LINUX)" -o out/cf .
   162  endif
   163  
   164  out/cf-cli_linux_i686: $(GOSRC)
   165  	CGO_ENABLED=0 GOARCH=386 GOOS=linux go build \
   166  							$(REQUIRED_FOR_STATIC_BINARY) \
   167  							-ldflags "$(LD_FLAGS_LINUX)" -o out/cf-cli_linux_i686 .
   168  
   169  out/cf-cli_linux_x86-64: $(GOSRC)
   170  	CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build \
   171  							$(REQUIRED_FOR_STATIC_BINARY) \
   172  							-ldflags "$(LD_FLAGS_LINUX)" -o out/cf-cli_linux_x86-64 .
   173  
   174  out/cf-cli_osx: $(GOSRC)
   175  	GOARCH=amd64 GOOS=darwin go build \
   176  				 -a -ldflags "$(LD_FLAGS)" -o out/cf-cli_osx .
   177  
   178  out/cf-cli_macosarm: $(GOSRC)
   179  	GOARCH=arm64 GOOS=darwin go build \
   180  				 -a -ldflags "$(LD_FLAGS)" -o out/cf-cli_macosarm .
   181  
   182  out/cf-cli_win32.exe: $(GOSRC) rsrc.syso
   183  	GOARCH=386 GOOS=windows go build -tags="forceposix" -o out/cf-cli_win32.exe -ldflags "$(LD_FLAGS)" .
   184  	rm rsrc.syso
   185  
   186  out/cf-cli_winx64.exe: $(GOSRC) rsrc.syso
   187  	GOARCH=amd64 GOOS=windows go build -tags="forceposix" -o out/cf-cli_winx64.exe -ldflags "$(LD_FLAGS)" .
   188  	rm rsrc.syso
   189  
   190  rsrc.syso:
   191  	rsrc -ico cf.ico -o rsrc.syso
   192  
   193  test: units ## (synonym for units)
   194  
   195  units: units-full ## (synonym for units-full)
   196  
   197  units-plugin:
   198  	CF_HOME=$(PWD)/fixtures $(ginkgo_units) -nodes 1 -flakeAttempts 2 -skipPackage integration ./**/plugin* ./plugin
   199  
   200  units-non-plugin:
   201  	@rm -f $(wildcard fixtures/plugins/*.exe)
   202  	@ginkgo version
   203  	CF_HOME=$(PWD)/fixtures CF_USERNAME="" CF_PASSWORD="" $(ginkgo_units) \
   204  		-skipPackage integration,cf/ssh,plugin,cf/actors/plugin,cf/commands/plugin,cf/actors/plugin,util/randomword
   205  	CF_HOME=$(PWD)/fixtures $(ginkgo_units) -flakeAttempts 3 cf/ssh
   206  
   207  units-full: build units-plugin units-non-plugin
   208  	@echo "\nSWEET SUITE SUCCESS"
   209  
   210  version: ## Print the version number of what would be built
   211  	@echo $(CF_BUILD_VERSION)+$(CF_BUILD_SHA).$(CF_BUILD_DATE)
   212  
   213  .PHONY: all build clean format version lint custom-lint
   214  .PHONY: test units units-full integration integration-tests-full integration-cleanup integration-experimental integration-plugin integration-isolated integration-push
   215  .PHONY: check-target-env fly-windows-experimental fly-windows-isolated fly-windows-plugin fly-windows-push
   216  .PHONY: help
   217  
   218  help:
   219  	@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-34s\033[0m %s\n", $$1, $$2}'