Skip to content

Commit 752d16e

Browse files
committed
rebase
1 parent 52e4099 commit 752d16e

3 files changed

Lines changed: 204 additions & 53 deletions

File tree

.github/workflows/cli_core_e2e_windows_test_msys2.yaml

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,35 @@ jobs:
4141
restore-keys: |
4242
${{ runner.os }}-go-${{ steps.go.outputs.go-version }}-
4343
44+
- name: Set and Echo GOPATH and GOBIN
45+
run: |
46+
$GOPATH = go env GOPATH
47+
$GOBIN = "$GOPATH\bin"
48+
echo "GOPATH 1 is set to $GOPATH"
49+
echo "GOBIN 1 is set to $GOBIN"
50+
echo "GOPATH=$GOPATH" | Out-File -Append -FilePath $env:GITHUB_ENV
51+
echo "GOBIN=$GOBIN" | Out-File -Append -FilePath $env:GITHUB_ENV
52+
echo "GOPATH 2 is set to $GOPATH"
53+
echo "GOBIN 2 is set to $GOBIN"
54+
shell: pwsh
55+
56+
- name: Echo Go installation path
57+
run: |
58+
echo "Go installation path: $(go env GOROOT)"
59+
ls "$(go env GOROOT)"
60+
ls "$(go env GOROOT)\bin"
61+
shell: bash
62+
63+
- name: Echo GOPATH and GOBIN
64+
run: |
65+
echo "GOPATH=$env:GOPATH"
66+
echo "GOBIN=$env:GOBIN"
67+
echo "Contents of GOPATH:"
68+
Get-ChildItem -Path $env:GOPATH
69+
echo "Contents of GOBIN:"
70+
Get-ChildItem -Path $env:GOBIN
71+
shell: pwsh
72+
4473
- name: Install MSYS2
4574
run: choco install msys2
4675
shell: powershell
@@ -49,30 +78,42 @@ jobs:
4978
run: C:\tools\msys64\usr\bin\bash -lc "echo 'Hello from MSYS2'"
5079
shell: powershell
5180

52-
- name: Install Make in MSYS2
81+
- name: Install Make and Unzip in MSYS2
5382
run: |
54-
C:\tools\msys64\usr\bin\bash -lc "pacman -S make --noconfirm"
55-
C:\tools\msys64\usr\bin\bash -lc "pacman -S unzip --noconfirm"
83+
C:\tools\msys64\usr\bin\bash -lc "pacman -S make unzip --noconfirm"
84+
C:\tools\msys64\usr\bin\bash -lc "pacman -S make wget --noconfirm"
85+
C:\tools\msys64\usr\bin\bash -lc "pacman -S make bzip2 --noconfirm"
86+
C:\tools\msys64\usr\bin\bash -lc "wget --version"
87+
C:\tools\msys64\usr\bin\bash -lc "bzip2 --version"
5688
shell: powershell
5789

5890
- name: Run Unix Commands in MSYS2
5991
run: |
6092
C:\tools\msys64\usr\bin\bash -lc "echo 'Hello from MSYS2'"
6193
C:\tools\msys64\usr\bin\bash -lc "ls"
6294
C:\tools\msys64\usr\bin\bash -lc "pwd"
63-
C:\tools\msys64\usr\bin\bash -lc "go version"
95+
C:\tools\msys64\usr\bin\bash -lc "wget --version"
96+
C:\tools\msys64\usr\bin\bash -lc "bzip2 --version"
97+
$WGET = $(Get-Command wget).Source
98+
$BZIP2 = $(Get-Command bzip2).Source
99+
echo "WGET_PATH=$WGET" >> $env:GITHUB_ENV
100+
echo "BZIP2_PATH=$BZIP2" >> $env:GITHUB_ENV
101+
echo "WGET_PATH: $WGET"
102+
echo "BZIP2_PATH: $BZIP2"
103+
$msysBin = "C:\tools\msys64\usr\bin"
104+
echo "MSYS_BIN=$msysBin" >> $env:GITHUB_ENV
105+
echo "PATH info: $env:PATH"
106+
echo "PATH info2: $PATH"
64107
shell: powershell
65108

66-
- name: Setup dependencies
109+
- name: Build CLI Core
67110
run: |
68-
topLevel=$(git rev-parse --show-toplevel)
69-
echo "Top level: $topLevel"
111+
make build
112+
shell: powershell
70113

71-
# Set up PATH to include Go binaries
72-
export PATH=$PATH:/c/go/bin:$(go env GOPATH)/bin
73-
74-
C:/tools/msys64/usr/bin/bash -lc "cd '$topLevel' && make tools"
114+
- name: E2E Tests
115+
run: |
116+
C:\tools\msys64\usr\bin\bash -lc "wget --version"
117+
C:\tools\msys64\usr\bin\bash -lc "bzip2 --version"
118+
make e2e-cli-core
75119
shell: powershell
76-
env:
77-
MSYS2_PATH_TYPE: inherit # This might help inheriting the PATH correctly
78-

Makefile

Lines changed: 96 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ include ./plugin-tooling.mk
55
include ./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

109
ROOT_DIR := $(shell git rev-parse --show-toplevel)
10+
ROOT_DIR := $(subst \,/,$(ROOT_DIR))
1111
ARTIFACTS_DIR ?= $(ROOT_DIR)/artifacts
1212

13+
HOME := $(subst \,/,$(HOME))
1314
XDG_CONFIG_HOME := ${HOME}/.config
1415
export XDG_CONFIG_HOME
1516

@@ -18,6 +19,34 @@ GOOS ?= $(shell go env GOOS)
1819
GOARCH ?= $(shell go env GOARCH)
1920
GOHOSTOS ?= $(shell go env GOHOSTOS)
2021
GOHOSTARCH ?= $(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)
2352
ifeq (,$(shell go env GOBIN))
@@ -54,7 +83,10 @@ VENDIR := $(TOOLS_BIN_DIR)/vendir
5483
YQ := $(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
256290
e2e-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
259294
setup-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
269328
start-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
305383
stop-airgapped-local-registry:
306384
@docker stop temp-airgapped-local-registry temp-airgapped-local-registry-with-auth > /dev/null 2>&1 && \

0 commit comments

Comments
 (0)