@@ -5,11 +5,12 @@ include ./plugin-tooling.mk
55include ./test/e2e/Makefile
66
77# Ensure Make is run with bash shell as some syntax below is bash-specific
8- SHELL := /usr/bin/env bash
98
109ROOT_DIR := $(shell git rev-parse --show-toplevel)
10+ ROOT_DIR := $(subst \,/,$(ROOT_DIR ) )
1111ARTIFACTS_DIR ?= $(ROOT_DIR ) /artifacts
1212
13+ HOME := $(subst \,/,$(HOME ) )
1314XDG_CONFIG_HOME := ${HOME}/.config
1415export XDG_CONFIG_HOME
1516
@@ -18,6 +19,34 @@ GOOS ?= $(shell go env GOOS)
1819GOARCH ?= $(shell go env GOARCH)
1920GOHOSTOS ?= $(shell go env GOHOSTOS)
2021GOHOSTARCH ?= $(shell go env GOHOSTARCH)
22+ HOST_OS =$(shell go env GOOS)
23+
24+ WGET := $(shell which wget)
25+ BZIP2 := $(shell which bzip2)
26+ TAR := $(shell which tar)
27+
28+ # Load environment variables from GitHub workflow
29+ ifeq ($(GITHUB_ACTIONS ) ,true)
30+ ifeq ($(GOOS),windows)
31+ # Use the values from GitHub Actions
32+ MSYS_BIN ?= $(shell echo $MSYS_BIN)
33+ WGET = $(MSYS_BIN)/wget
34+ BZIP2 = $(MSYS_BIN)/bzip2
35+ TAR = $(MSYS_BIN)/tar
36+ GITHUB_INFO := Running in GitHub Actions on Windows
37+ endif
38+ endif
39+
40+ # Ensure $(GOPATH) uses forward slashes
41+ WGET := $(subst \,/,$(WGET ) )
42+ BZIP2 := $(subst \,/,$(BZIP2 ) )
43+ TAR := $(subst \,/,$(TAR ) )
44+
45+ $(info WGET after update : $(WGET ) )
46+ $(info BZIP2 after update : $(BZIP2 ) )
47+ $(info TAR after update : $(TAR ) )
48+ $(info $(GITHUB_INFO))
49+
2150
2251# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
2352ifeq (,$(shell go env GOBIN) )
@@ -54,7 +83,10 @@ VENDIR := $(TOOLS_BIN_DIR)/vendir
5483YQ := $(TOOLS_BIN_DIR ) /yq
5584
5685# TOOLING_BINARIES := $(GOIMPORTS) $(GOLANGCI_LINT) $(VALE) $(MISSPELL) $(CONTROLLER_GEN) $(IMGPKG) $(KUBECTL) $(KIND) $(GINKGO) $(COSIGN) $(GOJUNITREPORT)
57- TOOLING_BINARIES := $(GOLANGCI_LINT )
86+ TOOLING_BINARIES := $(GOIMPORTS ) $(GOLANGCI_LINT ) $(VALE ) $(MISSPELL ) $(CONTROLLER_GEN ) $(IMGPKG ) $(KUBECTL ) $(KIND ) $(GINKGO ) $(COSIGN ) $(GOJUNITREPORT )
87+ # TOOLING_BINARIES := $(GOIMPORTS)
88+
89+ # TOOLING_BINARIES := $(GOLANGCI_LINT)
5890
5991# Build and version information
6092
@@ -145,17 +177,19 @@ build-cli-%: ##Build the Tanzu Core CLI for a platform
145177
146178 @echo build $(OS)-$(ARCH) CLI with version: $(BUILD_VERSION)
147179
148- @if [ "$(filter $(OS)-$(ARCH),$(ENVS))" = "" ]; then\
149- printf "\n\n======================================\n";\
150- printf "! $(OS)-$(ARCH) is not an officially supported platform!\n";\
151- printf "======================================\n\n";\
152- fi
180+ @mkdir -p artifacts/$(OS)/$(ARCH)/cli/core/$(BUILD_VERSION)
153181
154- @if [ "$(OS)" = "windows" ]; then \
155- GOOS=$(OS) GOARCH=$(ARCH) $(GO) build -gcflags=all="-l" --ldflags "$(LD_FLAGS)" -o "$(ARTIFACTS_DIR)/$(OS)/$(ARCH)/cli/core/$(BUILD_VERSION)/tanzu-cli-$(OS)_$(ARCH).exe" ./cmd/tanzu/main.go;\
156- else \
157- GOOS=$(OS) GOARCH=$(ARCH) $(GO) build -gcflags=all="-l" --ldflags "$(LD_FLAGS)" -o "$(ARTIFACTS_DIR)/$(OS)/$(ARCH)/cli/core/$(BUILD_VERSION)/tanzu-cli-$(OS)_$(ARCH)" ./cmd/tanzu/main.go;\
158- fi
182+ @echo "Listing artifacts directory:"
183+ @ls artifacts
184+
185+ @echo "BEfore build"
186+ @echo "Windows build"
187+ @pwd
188+ @cd cmd/tanzu
189+ @pwd
190+ @go build -o $(ARTIFACTS_DIR)/$(OS)/$(ARCH)/cli/core/$(BUILD_VERSION)/tanzu-cli-$(OS)_$(ARCH).exe cmd/tanzu/main.go
191+ @ls cmd/tanzu
192+ @ls $(ARTIFACTS_DIR)/$(OS)/$(ARCH)/cli/core/$(BUILD_VERSION)
159193
160194# # --------------------------------------
161195# # Plugins-specific
@@ -255,28 +289,54 @@ test-with-summary-report: tools
255289.PHONY : e2e-cli-core # # Execute all CLI Core E2E Tests
256290e2e-cli-core : tools crd-package-for-test start-test-central-repo start-airgapped-local-registry e2e-cli-core-all # # Execute all CLI Core E2E Tests
257291
292+
258293.PHONY : setup-custom-cert-for-test-central-repo
259294setup-custom-cert-for-test-central-repo : # # Setup up the custom ca cert for test-central-repo in the config file
260- @if [ ! -d $( ROOT_DIR) /hack/central-repo/certs ]; then \
261- wget https ://storage.googleapis.com/tanzu-cli/data/testcerts/local-central-repo-testcontent.bz2 -O $(ROOT_DIR ) /hack/central-repo/local-central-repo-testcontent.bz2;\
262- tar xjf $(ROOT_DIR)/hack/central-repo/local-central-repo-testcontent.bz2 -C $(ROOT_DIR)/hack/central-repo/;\
263- fi
295+ @echo " ROOT_DIR inside setup-custom-cert-for-test-central-repo: $( ROOT_DIR) "
296+ @echo " WGET inside setup-custom-cert-for-test-central-repo: $( WGET) "
297+ @echo " BZIP2 inside setup-custom-cert-for-test-central-repo: $( BZIP2) "
298+ $(WGET ) https://storage.googleapis.com/tanzu-cli/data/testcerts/local-central-repo-testcontent.bz2 -O hack/central-repo/local-central-repo-testcontent.bz2
299+ $(TAR ) xjf hack/central-repo/local-central-repo-testcontent.bz2 -C hack/central-repo/
300+ @echo " Listing the contents of the hack/central-repo"
301+ @ls -l hack/central-repo
302+ @echo " current directory: $( PWD) files: $( ls) "
303+ @ls
264304 echo " Adding docker test central repo cert to the config file"
265305 TANZU_CLI_CEIP_OPT_IN_PROMPT_ANSWER=" No" TANZU_CLI_EULA_PROMPT_ANSWER=" Yes" $(ROOT_DIR ) /bin/tanzu config cert delete localhost:9876 || true
266306 $(ROOT_DIR ) /bin/tanzu config cert add --host localhost:9876 --ca-cert $(ROOT_DIR ) /hack/central-repo/certs/localhost.crt
267307
268308.PHONY : start-test-central-repo
309+ start-test-central-repo : stop-test-central-repo setup-custom-cert-for-test-central-repo # # Starts up a test central repository locally with docker
310+ @if [ ! -d $( ROOT_DIR) /hack/central-repo/registry-content ]; then \
311+ (cd $( ROOT_DIR) /hack/central-repo && $( TAR) xjf registry-content.bz2 || true ; ) \
312+ fi
313+ @echo " Starting docker test central repo"
314+
315+ @docker run --rm -d -p 9876:443 --name central \
316+ -e REGISTRY_HTTP_ADDR=0.0.0.0:443 \
317+ -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/localhost.crt \
318+ -e REGISTRY_HTTP_TLS_KEY=/certs/localhost.key \
319+ -v "D:\a\tanzu-cli\tanzu-cli\hack\central-repo\registry-content:C:\registry" \
320+ -v "D:\a\tanzu-cli\tanzu-cli\hack\central-repo\certs:C:\certs" \
321+ stefanscherer/registry-windows:latest > /dev/null && \
322+ echo "Started docker test central repo with images:" && \
323+ $(ROOT_DIR)/hack/central-repo/upload-plugins.sh info
324+
325+ @echo "Docker test central repo started at localhost:9876"
326+
327+ .PHONY : start-test-central-repo-11
269328start-test-central-repo : stop-test-central-repo setup-custom-cert-for-test-central-repo # # Starts up a test central repository locally with docker
270329 @if [ ! -d $( ROOT_DIR) /hack/central-repo/registry-content ]; then \
271330 (cd $( ROOT_DIR) /hack/central-repo && tar xjf registry-content.bz2 || true ; ) \
272331 fi
332+ @echo " Starting docker test central repo"
273333 @docker run --rm -d -p 9876:443 --name central \
274334 -v $(ROOT_DIR ) /hack/central-repo/certs:/certs \
275335 -e REGISTRY_HTTP_ADDR=0.0.0.0:443 \
276336 -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/localhost.crt \
277337 -e REGISTRY_HTTP_TLS_KEY=/certs/localhost.key \
278338 -v $(ROOT_DIR ) /hack/central-repo/registry-content:/var/lib/registry \
279- $( REGISTRY_IMAGE ) > /dev/null && \
339+ stefanscherer/registry-windows:latest > /dev/null && \
280340 echo " Started docker test central repo with images:" && \
281341 $(ROOT_DIR ) /hack/central-repo/upload-plugins.sh info
282342
@@ -285,7 +345,24 @@ stop-test-central-repo: ## Stops and removes the local test central repository
285345 @docker container stop central > /dev/null 2>&1 && echo " Stopped docker test central repo" || true
286346
287347.PHONY : start-airgapped-local-registry
288- start-airgapped-local-registry : stop-airgapped-local-registry
348+ start-airgapped-local-registry-11 : stop-airgapped-local-registry
349+ @docker run --rm -d -p 6001:5000 --name temp-airgapped-local-registry \
350+ $(REGISTRY_IMAGE ) > /dev/null && \
351+ echo " Started docker test airgapped repo at 'localhost:6001'."
352+
353+ @mkdir -p $(ROOT_DIR)/hack/central-repo/auth && docker run --entrypoint htpasswd httpd:2 -Bbn ${TANZU_CLI_E2E_AIRGAPPED_REPO_WITH_AUTH_USERNAME} ${TANZU_CLI_E2E_AIRGAPPED_REPO_WITH_AUTH_PASSWORD} > $(ROOT_DIR)/hack/central-repo/auth/htpasswd
354+ @docker run --rm -d -p 6002:5000 --name temp-airgapped-local-registry-with-auth \
355+ -v "D:\a\tanzu-cli\tanzu-cli\hack\central-repo\auth:C:\auth" \
356+ -e "REGISTRY_AUTH=htpasswd" \
357+ -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \
358+ -e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \
359+ stefanscherer/registry-windows:latest > /dev/null && \
360+ echo "Started docker test airgapped repo with authentication at 'localhost:6002'."
361+
362+ @docker logout localhost:6002 || true
363+
364+ .PHONY : start-airgapped-local-registry-11
365+ start-airgapped-local-registry-11 : stop-airgapped-local-registry
289366 @docker run --rm -d -p 6001:5000 --name temp-airgapped-local-registry \
290367 $(REGISTRY_IMAGE ) > /dev/null && \
291368 echo " Started docker test airgapped repo at 'localhost:6001'."
@@ -301,6 +378,7 @@ start-airgapped-local-registry: stop-airgapped-local-registry
301378
302379 @docker logout localhost:6002 || true
303380
381+
304382.PHONY : stop-airgapped-local-registry
305383stop-airgapped-local-registry :
306384 @docker stop temp-airgapped-local-registry temp-airgapped-local-registry-with-auth > /dev/null 2>&1 && \
0 commit comments