Skip to content

Commit df3492a

Browse files
committed
OCPCLOUD-1811: Modernize test tooling
Currently our approach to manage and update auxiliary tooling (such as envtest, controller-gen, etc) is inconsistent. Fine pattern was introduced in CPMS repo, which relies on golang toolchain for update, vendor and run this auxiliary tooling. This commit aligns envtest, controller-gen and other tooling management with pattern introduced within CPMS repo.
1 parent 6c619f4 commit df3492a

File tree

261 files changed

+30091
-420
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

261 files changed

+30091
-420
lines changed

Makefile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ REPO_PATH ?= github.com/openshift/machine-api-provider-azure
2626
LD_FLAGS ?= -X $(REPO_PATH)/pkg/version.Raw=$(VERSION) -extldflags -static
2727
BUILD_IMAGE ?= registry.ci.openshift.org/openshift/release:golang-1.18
2828

29+
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
30+
ENVTEST_K8S_VERSION = 1.25
31+
32+
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
33+
CONTROLLER_GEN = go run ${PROJECT_DIR}/vendor/sigs.k8s.io/controller-tools/cmd/controller-gen
34+
ENVTEST = go run ${PROJECT_DIR}/vendor/sigs.k8s.io/controller-runtime/tools/setup-envtest
35+
GINKGO = go run ${PROJECT_DIR}/vendor/github.com/onsi/ginkgo/v2/ginkgo
36+
GOLANGCI_LINT = go run ${PROJECT_DIR}/vendor/github.com/golangci/golangci-lint/cmd/golangci-lint
37+
2938
GO111MODULE = on
3039
export GO111MODULE
3140
GOFLAGS ?= -mod=vendor
@@ -53,7 +62,7 @@ endif
5362

5463
# race tests need CGO_ENABLED, everything else should have it disabled
5564
CGO_ENABLED = 0
56-
unit : CGO_ENABLED = 1
65+
unit test : CGO_ENABLED = 1
5766

5867
ifeq ($(NO_DOCKER), 1)
5968
DOCKER_CMD = CGO_ENABLED=$(CGO_ENABLED) GOARCH=$(GOARCH) GOOS=$(GOOS)
@@ -106,7 +115,7 @@ build: ## build binaries
106115
.PHONY: test
107116
test: ## Run tests
108117
@echo -e "\033[32mTesting...\033[0m"
109-
$(DOCKER_CMD) hack/ci-test.sh
118+
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path --bin-dir $(PROJECT_DIR)/bin)" ./hack/ci-test.sh
110119

111120
.PHONY: unit
112121
unit: # Run unit test

go.mod

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ require (
1313
github.com/google/go-cmp v0.5.9
1414
github.com/hashicorp/golang-lru v0.5.1
1515
github.com/mitchellh/mapstructure v1.4.2
16-
github.com/onsi/ginkgo/v2 v2.6.0
17-
github.com/onsi/gomega v1.24.0
16+
github.com/onsi/ginkgo/v2 v2.7.0
17+
github.com/onsi/gomega v1.24.1
1818
github.com/openshift/api v0.0.0-20220921125526-1866ef90edbf
1919
github.com/openshift/machine-api-operator v0.2.1-0.20220922080915-f7f326323f37
2020
github.com/pkg/errors v0.9.1
@@ -28,6 +28,7 @@ require (
2828
k8s.io/klog/v2 v2.80.1
2929
k8s.io/utils v0.0.0-20220823124924-e9cbc92d1a73
3030
sigs.k8s.io/controller-runtime v0.13.0
31+
sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20221219225944-92234b3c49a3
3132
sigs.k8s.io/controller-tools v0.10.0
3233
sigs.k8s.io/yaml v1.3.0
3334
)
@@ -53,9 +54,11 @@ require (
5354
github.com/fatih/color v1.13.0 // indirect
5455
github.com/fsnotify/fsnotify v1.5.4 // indirect
5556
github.com/go-errors/errors v1.0.1 // indirect
57+
github.com/go-logr/zapr v1.2.3 // indirect
5658
github.com/go-openapi/jsonpointer v0.19.5 // indirect
5759
github.com/go-openapi/jsonreference v0.19.5 // indirect
5860
github.com/go-openapi/swag v0.19.14 // indirect
61+
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
5962
github.com/gobuffalo/flect v0.2.5 // indirect
6063
github.com/gogo/protobuf v1.3.2 // indirect
6164
github.com/golang-jwt/jwt/v4 v4.2.0 // indirect
@@ -64,6 +67,7 @@ require (
6467
github.com/google/btree v1.0.1 // indirect
6568
github.com/google/gnostic v0.5.7-v3refs // indirect
6669
github.com/google/gofuzz v1.2.0 // indirect
70+
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect
6771
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
6872
github.com/google/uuid v1.3.0 // indirect
6973
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect
@@ -91,17 +95,21 @@ require (
9195
github.com/prometheus/common v0.32.1 // indirect
9296
github.com/prometheus/procfs v0.7.3 // indirect
9397
github.com/russross/blackfriday v1.5.2 // indirect
98+
github.com/spf13/afero v1.6.0 // indirect
9499
github.com/spf13/pflag v1.0.5 // indirect
95100
github.com/xlab/treeprint v1.1.0 // indirect
96101
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
97-
golang.org/x/mod v0.6.0 // indirect
98-
golang.org/x/net v0.1.0 // indirect
102+
go.uber.org/atomic v1.7.0 // indirect
103+
go.uber.org/multierr v1.6.0 // indirect
104+
go.uber.org/zap v1.21.0 // indirect
105+
golang.org/x/mod v0.7.0 // indirect
106+
golang.org/x/net v0.3.0 // indirect
99107
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect
100-
golang.org/x/sys v0.2.0 // indirect
101-
golang.org/x/term v0.1.0 // indirect
102-
golang.org/x/text v0.4.0 // indirect
108+
golang.org/x/sys v0.3.0 // indirect
109+
golang.org/x/term v0.3.0 // indirect
110+
golang.org/x/text v0.5.0 // indirect
103111
golang.org/x/time v0.0.0-20220609170525-579cf78fd858 // indirect
104-
golang.org/x/tools v0.2.0 // indirect
112+
golang.org/x/tools v0.4.0 // indirect
105113
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
106114
google.golang.org/appengine v1.6.7 // indirect
107115
google.golang.org/protobuf v1.28.0 // indirect

0 commit comments

Comments
 (0)