forked from redhat-developer/odo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
191 lines (147 loc) · 6.14 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
PROJECT := github.com/redhat-developer/odo
ifdef GITCOMMIT
GITCOMMIT := $(GITCOMMIT)
else
GITCOMMIT := $(shell git rev-parse --short HEAD 2>/dev/null)
endif
COMMON_GOFLAGS := -mod=vendor
COMMON_LDFLAGS := -X $(PROJECT)/pkg/version.GITCOMMIT=$(GITCOMMIT)
BUILD_FLAGS := $(COMMON_GOFLAGS) -ldflags="$(COMMON_LDFLAGS)"
CROSS_BUILD_FLAGS := $(COMMON_GOFLAGS) -ldflags="-s -w -X $(PROJECT)/pkg/segment.writeKey=R1Z79HadJIrphLoeONZy5uqOjusljSwN $(COMMON_LDFLAGS)"
PKGS := $(shell go list $(COMMON_GOFLAGS) ./... | grep -v $(PROJECT)/vendor | grep -v $(PROJECT)/tests)
FILES := odo dist
TIMEOUT ?= 14400s
# We should NOT output any color when running interactive tests
# or else we may have issues with regards to comparing coloured output strings
NO_COLOR = true
# Env variable TEST_EXEC_NODES is used to pass spec execution type
# (parallel or sequential) for ginkgo tests. To run the specs sequentially use
# TEST_EXEC_NODES=1, otherwise by default the specs are run in parallel on 4 ginkgo test node if running on PSI cluster or 24 nodes if running on IBM Cloud cluster.
# NOTE: Any TEST_EXEC_NODES value greater than one runs the spec in parallel
# on the same number of ginkgo test nodes.
ifdef TEST_EXEC_NODES
TEST_EXEC_NODES := $(TEST_EXEC_NODES)
else
TEST_EXEC_NODES := 4
endif
# Slow spec threshold for ginkgo tests. After this time (in second), ginkgo marks test as slow
SLOW_SPEC_THRESHOLD := 120s
# Env variable GINKGO_TEST_ARGS is used to get control over enabling ginkgo test flags against each test target run.
# For example:
# To enable verbosity export or set env GINKGO_TEST_ARGS like "GINKGO_TEST_ARGS=-v"
GINKGO_TEST_ARGS ?=
# ODO_LOG_LEVEL sets the verbose log level for the make tests
export ODO_LOG_LEVEL ?= 4
# Env variable UNIT_TEST_ARGS is used to get control over enabling test flags along with go test.
# For example:
# To enable verbosity export or set env GINKGO_TEST_ARGS like "GINKGO_TEST_ARGS=-v"
UNIT_TEST_ARGS ?=
GINKGO_FLAGS_ALL = $(GINKGO_TEST_ARGS) --randomize-all --slow-spec-threshold=$(SLOW_SPEC_THRESHOLD) -timeout $(TIMEOUT) --no-color
# Flags for tests that must not be run in parallel.
GINKGO_FLAGS_SERIAL = $(GINKGO_FLAGS_ALL) -nodes=1
# Flags for tests that may be run in parallel
GINKGO_FLAGS=$(GINKGO_FLAGS_ALL) -nodes=$(TEST_EXEC_NODES)
# GolangCi version for unit-validate test
GOLANGCI_LINT_VERSION=1.37.0
RUN_GINKGO = go run -mod=vendor github.com/onsi/ginkgo/v2/ginkgo
default: bin
.PHONY: help
help: ## Show this help.
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
.PHONY: bin
bin: ## build the odo binary
go build ${BUILD_FLAGS} cmd/odo/odo.go
.PHONY: install
install:
go install ${BUILD_FLAGS} ./cmd/odo/
.PHONY: validate
validate: gofmt check-fit check-vendor vet validate-vendor-licenses sec golint ## run all validation tests
.PHONY: gofmt
gofmt:
./scripts/check-gofmt.sh
.PHONY: check-vendor
check-vendor:
go mod verify
.PHONY: check-fit
check-fit:
./scripts/check-fit.sh
.PHONY: validate-vendor-licenses
validate-vendor-licenses:
go run $(COMMON_GOFLAGS) github.com/frapposelli/wwhrd check -q
.PHONY: golint
golint:
golangci-lint run ./... --timeout 15m
.PHONY: lint
lint: ## golint errors are only recommendations
golint $(PKGS)
.PHONY: vet
vet:
go vet $(PKGS)
.PHONY: sec
sec:
go run $(COMMON_GOFLAGS) github.com/securego/gosec/v2/cmd/gosec -severity medium -confidence medium -exclude G304,G204,G107 -quiet ./tests/...
go run $(COMMON_GOFLAGS) github.com/securego/gosec/v2/cmd/gosec -severity medium -confidence medium -exclude G304,G204 -quiet ./cmd/... ./pkg/...
.PHONY: clean
clean:
@rm -rf $(FILES)
.PHONY: goget-tools
goget-tools:
(curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/v$(GOLANGCI_LINT_VERSION)/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v$(GOLANGCI_LINT_VERSION)) || go install -mod=readonly github.com/golangci/golangci-lint/cmd/golangci-lint@v$(GOLANGCI_LINT_VERSION)
.PHONY: goget-ginkgo
goget-ginkgo:
@echo "This is no longer used."
@echo "Ginkgo can be executed directly from this repository using command '$(RUN_GINKGO)'"
.PHONY: test-coverage
test-coverage: ## Run unit tests and collect coverage
./scripts/generate-coverage.sh
.PHONY: cross
cross: ## compile for multiple platforms
./scripts/cross-compile.sh $(CROSS_BUILD_FLAGS)
.PHONY: generate-cli-structure
generate-cli-structure:
go run cmd/cli-doc/cli-doc.go structure
.PHONY: generate-cli-reference
generate-cli-reference:
go run cmd/cli-doc/cli-doc.go reference > docs/cli-reference.adoc
# run make cross before this!
.PHONY: prepare-release
prepare-release: cross ## create gzipped binaries in ./dist/release/ for uploading to GitHub release page
./scripts/prepare-release.sh
.PHONY: configure-installer-tests-cluster
configure-installer-tests-cluster:
. ./scripts/configure-installer-tests-cluster.sh
.PHONY: configure-installer-tests-cluster-s390x
configure-installer-tests-cluster-s390x: ## configure cluster to run tests on s390x arch
. ./scripts/configure-installer-tests-cluster-s390x.sh
.PHONY: configure-installer-tests-cluster-ppc64le
configure-installer-tests-cluster-ppc64le: ## configure cluster to run tests on ppc64le arch
. ./scripts/configure-installer-tests-cluster-ppc64le.sh
.PHONY: configure-supported-311-is
configure-supported-311-is:
. ./scripts/supported-311-is.sh
.PHONY: test
test:
go test $(UNIT_TEST_ARGS) -race $(PKGS)
.PHONY: test-windows
test-windows:
go test $(UNIT_TEST_ARGS) $(PKGS)
# run make cross before this!
.PHONY: packages
packages: ## create deb and rpm packages using fpm in ./dist/pkgs/
./scripts/create-packages.sh
# run 'make cross' and 'make packages' before this!
.PHONY: upload-packages
upload-packages: ## upload packages created by 'make packages' to bintray repositories
./scripts/upload-packages.sh
.PHONY: vendor-update
vendor-update: ## Update vendoring
go mod vendor
.PHONY: openshiftci-presubmit-unittests
openshiftci-presubmit-unittests:
./scripts/openshiftci-presubmit-unittests.sh
.PHONY: test-integration
test-integration:
$(RUN_GINKGO) $(GINKGO_FLAGS) tests/integration
.PHONY: test-e2e
test-e2e:
$(RUN_GINKGO) $(GINKGO_FLAGS) tests/e2escenarios