Skip to content

Commit 2f7d3e1

Browse files
committed
cah
1 parent 91f2182 commit 2f7d3e1

File tree

3 files changed

+141
-40
lines changed

3 files changed

+141
-40
lines changed

.github/workflows/cli_core_e2e_windows_test_msys2.yaml

Lines changed: 49 additions & 15 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,35 @@ 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
64105
shell: powershell
65106

66-
- name: Setup dependencies
107+
- name: E2E Tests
67108
run: |
68-
topLevel=$(git rev-parse --show-toplevel)
69-
echo "Top level: $topLevel"
70-
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"
109+
C:\tools\msys64\usr\bin\bash -lc "wget --version"
110+
C:\tools\msys64\usr\bin\bash -lc "bzip2 --version"
111+
make e2e-cli-core
75112
shell: powershell
76-
env:
77-
MSYS2_PATH_TYPE: inherit # This might help inheriting the PATH correctly
78-

Makefile

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,34 @@ GOOS ?= $(shell go env GOOS)
1818
GOARCH ?= $(shell go env GOARCH)
1919
GOHOSTOS ?= $(shell go env GOHOSTOS)
2020
GOHOSTARCH ?= $(shell go env GOHOSTARCH)
21+
HOST_OS=$(shell go env GOOS)
22+
23+
WGET := $(shell which wget)
24+
BZIP2 := $(shell which bzip2)
25+
TAR := $(shell which tar)
26+
27+
# Load environment variables from GitHub workflow
28+
ifeq ($(GITHUB_ACTIONS),true)
29+
ifeq ($(GOOS),windows)
30+
# Use the values from GitHub Actions
31+
MSYS_BIN ?= $(shell echo $MSYS_BIN)
32+
WGET = $(MSYS_BIN)/wget
33+
BZIP2 = $(MSYS_BIN)/bzip2
34+
TAR = $(MSYS_BIN)/tar
35+
GITHUB_INFO := Running in GitHub Actions on Windows
36+
endif
37+
endif
38+
39+
# Ensure $(GOPATH) uses forward slashes
40+
WGET := $(subst \,/,$(WGET))
41+
BZIP2 := $(subst \,/,$(BZIP2))
42+
TAR := $(subst \,/,$(TAR))
43+
44+
$(info WGET after update: $(WGET))
45+
$(info BZIP2 after update: $(BZIP2))
46+
$(info TAR after update: $(TAR))
47+
$(info $(GITHUB_INFO))
48+
2149

2250
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
2351
ifeq (,$(shell go env GOBIN))
@@ -49,7 +77,10 @@ COSIGN := $(TOOLS_BIN_DIR)/cosign
4977
GOJUNITREPORT := $(TOOLS_BIN_DIR)/go-junit-report
5078

5179
#TOOLING_BINARIES := $(GOIMPORTS) $(GOLANGCI_LINT) $(VALE) $(MISSPELL) $(CONTROLLER_GEN) $(IMGPKG) $(KUBECTL) $(KIND) $(GINKGO) $(COSIGN) $(GOJUNITREPORT)
52-
TOOLING_BINARIES := $(GOLANGCI_LINT)
80+
TOOLING_BINARIES := $(GOIMPORTS) $(GOLANGCI_LINT) $(VALE) $(MISSPELL) $(CONTROLLER_GEN) $(IMGPKG) $(KUBECTL) $(KIND) $(GINKGO) $(COSIGN) $(GOJUNITREPORT)
81+
#TOOLING_BINARIES := $(GOIMPORTS)
82+
83+
#TOOLING_BINARIES := $(GOLANGCI_LINT)
5384

5485
# Build and version information
5586

@@ -244,9 +275,13 @@ e2e-cli-core: tools start-test-central-repo start-airgapped-local-registry e2e-c
244275

245276
.PHONY: setup-custom-cert-for-test-central-repo
246277
setup-custom-cert-for-test-central-repo: ## Setup up the custom ca cert for test-central-repo in the config file
278+
@echo "ROOT_DIR inside setup-custom-cert-for-test-central-repo: $(ROOT_DIR)"
279+
@echo "WGET inside setup-custom-cert-for-test-central-repo: $(WGET)"
280+
@echo "BZIP2 inside setup-custom-cert-for-test-central-repo: $(BZIP2)"
247281
@if [ ! -d $(ROOT_DIR)/hack/central-repo/certs ]; then \
248-
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;\
249-
tar xjf $(ROOT_DIR)/hack/central-repo/local-central-repo-testcontent.bz2 -C $(ROOT_DIR)/hack/central-repo/;\
282+
$(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;\
283+
TAR_BZ2_FILE:=$(shell cygpath -w $(ROOT_DIR)/hack/central-repo/local-central-repo-testcontent.bz2)
284+
$(TAR) xjf ${TAR_BZ2_FILE} -C $(ROOT_DIR)/hack/central-repo/;\
250285
fi
251286
echo "Adding docker test central repo cert to the config file"
252287
TANZU_CLI_CEIP_OPT_IN_PROMPT_ANSWER="No" TANZU_CLI_EULA_PROMPT_ANSWER="Yes" $(ROOT_DIR)/bin/tanzu config cert delete localhost:9876 || true
@@ -255,7 +290,7 @@ setup-custom-cert-for-test-central-repo: ## Setup up the custom ca cert for test
255290
.PHONY: start-test-central-repo
256291
start-test-central-repo: stop-test-central-repo setup-custom-cert-for-test-central-repo ## Starts up a test central repository locally with docker
257292
@if [ ! -d $(ROOT_DIR)/hack/central-repo/registry-content ]; then \
258-
(cd $(ROOT_DIR)/hack/central-repo && tar xjf registry-content.bz2 || true;) \
293+
(cd $(ROOT_DIR)/hack/central-repo && $(TAR) xjf registry-content.bz2 || true;) \
259294
fi
260295
@docker run --rm -d -p 9876:443 --name central \
261296
-v $(ROOT_DIR)/hack/central-repo/certs:/certs \

hack/tools/Makefile

Lines changed: 53 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,51 @@ VAL_URL := https://github.com/errata-ai/vale/releases/download/v$(VALE_VERSION)/
5151
sed 's,darwin,macOS,g'| sed 's,linux,Linux,g'| sed 's,windows,Windows,g')_$(shell echo $(HOST_ARCH) | sed 's,amd64,64-bit,g')$(shell echo $(HOST_OS) | \
5252
sed 's,darwin,.tar.gz,g'| sed 's,linux,.tar.gz,g'| sed 's,windows,.zip,g')
5353

54-
ifeq ($(CI),true)
55-
GOBIN := $(subst /,\,$(ROOT_DIR)/hack/tools/$(BIN_DIR))
54+
55+
ifeq ($(GITHUB_ACTIONS),true)
56+
# Use the values from GitHub Actions
57+
GOPATH := $(shell echo $$GOPATH)
58+
GOBIN := $(shell echo $$GOBIN)
59+
GITHUB_INFO := Running in GitHub Actions
5660
else
57-
GOBIN := $(ROOT_DIR)/hack/tools/$(BIN_DIR)
61+
# Use the system's GOPATH and GOBIN; if they're not set, use defaults
62+
GOPATH ?= $(HOME)/go
63+
GOBIN ?= $(GOPATH)/bin
64+
GITHUB_INFO := Not running in GitHub Actions
5865
endif
5966

67+
$(info GOPATH before update: $(GOPATH))
68+
$(info GOBIN before update: $(GOBIN))
69+
$(info $(GITHUB_INFO))
70+
71+
# Normalize $(ROOT_DIR) and ensure no double slashes before appending
72+
GOBIN := $(patsubst %/,%,$(subst \,/,${ROOT_DIR}))/hack/tools/$(BIN_DIR)
73+
74+
# Ensure $(GOPATH) uses forward slashes
75+
GOPATH := $(subst \,/,$(GOPATH))
76+
77+
78+
# It's best to use these echo commands in an actual recipe, not directly in the conditional logic
79+
# For demonstration purposes, they are kept here but consider moving them into a rule's command
80+
$(info GOBIN after update: $(GOBIN))
81+
$(info GOPATH after update: $(GOPATH))
82+
83+
84+
golangci-lint: $(GOLANGCI_LINT) ## Install golangci-lint
85+
$(GOLANGCI_LINT):
86+
@echo "GOPATH current: $(GOPATH)"
87+
@echo "GOBIN current: $(GOBIN)"
88+
mkdir -p $(BIN_DIR)
89+
@ls $(GOPATH)
90+
@ls $(GOPATH)/bin
91+
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v$(GOLANGCI_LINT_VERSION)
92+
@ls $(GOPATH)
93+
@ls $(GOPATH)/bin
94+
@echo "GOBIN files: $(GOBIN)"
95+
@ls $(GOBIN)
96+
#mv $(GOPATH)/$(GOLANGCI_LINT) $(GOBIN) && chmod a+x $(GOBIN)/$(notdir $(GOLANGCI_LINT))
97+
98+
6099
## --------------------------------------
61100
## Help
62101
## --------------------------------------
@@ -70,11 +109,11 @@ help: ## Display this help
70109

71110
goimports: $(GOIMPORTS) ## Install goimports
72111
$(GOIMPORTS):
73-
@echo "BIN_DIR: $(BIN_DIR)"
74-
@echo "ROOT_DIR: $(ROOT_DIR)"
75-
@echo "GOBIN path: $(ROOT_DIR)/hack/tools/$(BIN_DIR)"
76-
@mkdir -p $(BIN_DIR)
77-
@GOBIN=$(subst \,/,$(ROOT_DIR)/hack/tools/$(BIN_DIR)) go install golang.org/x/tools/cmd/goimports@v$(GOIMPORTS_VERSION)
112+
@echo "gobin in goimports: $(GOBIN)"
113+
mkdir -p $(BIN_DIR)
114+
go install golang.org/x/tools/cmd/goimports@v$(GOIMPORTS_VERSION)
115+
@echo "GOBIN files: $(GOBIN)"
116+
@ls $(GOBIN)
78117

79118
#mkdir -p $(BIN_DIR)
80119
#GOBIN=$(ROOT_DIR)/hack/tools/$(BIN_DIR) go install golang.org/x/tools/cmd/goimports@v$(GOIMPORTS_VERSION)
@@ -84,13 +123,6 @@ $(GOIMPORTS):
84123
#mv $(GOPATH)/bin/goimports $(GOIMPORTS)
85124
#GOBIN=$(ROOT_DIR)/hack/tools/$(BIN_DIR) go install golang.org/x/tools/cmd/goimports@v$(GOIMPORTS_VERSION)
86125

87-
golangci-lint: $(GOLANGCI_LINT) ## Install golangci-lint
88-
$(GOLANGCI_LINT):
89-
@echo "Installing golangci-lint to $(GOLANGCI_LINT)"
90-
@echo "GOBIN path: $(ROOT_DIR)/hack/tools/$(BIN_DIR)"
91-
@echo "GOBIN will be set to $(GOBIN)"
92-
mkdir -p $(BIN_DIR)
93-
GOBIN=$(ROOT_DIR)/hack/tools/$(BIN_DIR) go install github.com/golangci/golangci-lint/cmd/golangci-lint@v$(GOLANGCI_LINT_VERSION)
94126

95127
vale: $(VALE)
96128
$(VALE):
@@ -112,18 +144,17 @@ $(VALE):
112144
controller-gen: $(CONTROLLER_GEN) ## Build controller-gen
113145
$(CONTROLLER_GEN):
114146
mkdir -p $(BIN_DIR)
115-
#go build -tags=tools -o $@ sigs.k8s.io/controller-tools/cmd/controller-gen
116-
GOBIN=$(ROOT_DIR)/hack/tools/$(BIN_DIR) go install sigs.k8s.io/controller-tools/cmd/controller-gen@v$(CONTROLLER_TOOLS_VERSION)
147+
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v$(CONTROLLER_TOOLS_VERSION)
117148

118149
cosign: $(COSIGN) ## Install cosign
119150
$(COSIGN):
120151
mkdir -p $(BIN_DIR)
121-
GOBIN=$(ROOT_DIR)/hack/tools/$(BIN_DIR) go install github.com/sigstore/cosign/v2/cmd/cosign@v$(COSIGN_VERSION)
152+
go install github.com/sigstore/cosign/v2/cmd/cosign@v$(COSIGN_VERSION)
122153

123154
misspell: $(MISSPELL) ## Install misspell
124155
$(MISSPELL):
125156
mkdir -p $(BIN_DIR)
126-
GOBIN=$(ROOT_DIR)/hack/tools/$(BIN_DIR) go install github.com/client9/misspell/cmd/misspell@v$(MISSPELL_VERSION)
157+
go install github.com/client9/misspell/cmd/misspell@v$(MISSPELL_VERSION)
127158

128159
imgpkg: $(IMGPKG) ## Install imgpkg
129160
$(IMGPKG):
@@ -152,12 +183,13 @@ $(KIND):
152183
ginkgo: $(GINKGO) ## Install ginkgo
153184
$(GINKGO):
154185
mkdir -p $(BIN_DIR)
155-
GOBIN=$(ROOT_DIR)/hack/tools/$(BIN_DIR) go install github.com/onsi/ginkgo/v2/ginkgo@$(GINKGO_VERSION)
186+
go install github.com/onsi/ginkgo/v2/ginkgo@$(GINKGO_VERSION)
156187

157188
go-junit-report: $(GOJUNITREPORT) ## Install go-junit-report
158189
$(GOJUNITREPORT):
159190
mkdir -p $(BIN_DIR)
160-
GOBIN=$(ROOT_DIR)/hack/tools/$(BIN_DIR) go install github.com/jstemmer/go-junit-report@latest
191+
go install github.com/jstemmer/go-junit-report@latest
192+
@ls $(GOBIN)
161193

162194
## --------------------------------------
163195
## Cleanup

0 commit comments

Comments
 (0)