Skip to content

Commit 27bdfb2

Browse files
author
Per Goncalves da Silva
committed
update unit test gha to test against the k8s version of client-go
Signed-off-by: Per Goncalves da Silva <[email protected]>
1 parent d8ee29d commit 27bdfb2

File tree

2 files changed

+12
-25
lines changed

2 files changed

+12
-25
lines changed

.github/workflows/unit.yml

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
name: unit
2-
env:
3-
K8S_VERSION: 1.19.2
42
on:
53
push:
64
branches:
@@ -20,9 +18,5 @@ jobs:
2018
- uses: actions/setup-go@v5
2119
with:
2220
go-version-file: "go.mod"
23-
- name: Envtest setup
24-
run: |
25-
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
26-
setup-envtest use ${K8S_VERSION}
2721
- name: Run unit tests
28-
run: KUBEBUILDER_ASSETS=$(setup-envtest use -i -p path ${K8S_VERSION}) make unit
22+
run: make unit

Makefile

+11-18
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ export GO111MODULE=on
2828
YQ_INTERNAL := go run $(MOD_FLAGS) ./vendor/github.com/mikefarah/yq/v3/
2929
HELM := go run $(MOD_FLAGS) ./vendor/helm.sh/helm/v3/cmd/helm
3030
KIND := go run $(MOD_FLAGS) ./vendor/sigs.k8s.io/kind
31-
KUBEBUILDER_ASSETS := $(or $(or $(KUBEBUILDER_ASSETS),$(dir $(shell command -v kubebuilder))),/usr/local/kubebuilder/bin)
32-
export KUBEBUILDER_ASSETS
3331
GO := GO111MODULE=on GOFLAGS="$(MOD_FLAGS)" go
3432
GINKGO := $(GO) run github.com/onsi/ginkgo/v2/ginkgo
3533
BINDATA := $(GO) run github.com/go-bindata/go-bindata/v3/go-bindata
@@ -56,31 +54,26 @@ KIND_CLUSTER_IMAGE := kindest/node:v$(KIND_NODE_VERSION)
5654
.PHONY: FORCE
5755
FORCE:
5856

57+
.PHONY: setup-envtest
58+
setup-envtest:
59+
ifeq (, $(shell which setup-envtest))
60+
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
61+
endif
62+
5963
.PHONY: vet
6064
vet:
6165
go vet $(MOD_FLAGS) ./...
6266

6367
all: test build
6468

6569
test: clean cover.out
66-
67-
unit: kubebuilder
70+
.PHONY: unit
71+
KUBEBUILDER_ASSETS ?= $(shell setup-envtest use -p path $(KIND_NODE_VERSION))
72+
unit: setup-envtest
73+
@echo "Running unit tests with kubebuilder assets at $(KUBEBUILDER_ASSETS)"
74+
@echo "Running kube version: $(shell ${KUBEBUILDER_ASSETS}/kubectl version)"
6875
KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS) go test $(MOD_FLAGS) $(SPECIFIC_UNIT_TEST) -tags "json1" -race -count=1 ./pkg/... ./test/e2e/split/...
6976

70-
# Ensure kubectl installed before continuing
71-
KUBEBUILDER_ASSETS_ERR := not detected in $(KUBEBUILDER_ASSETS), to override the assets path set the KUBEBUILDER_ASSETS environment variable, for install instructions see https://pkg.go.dev/sigs.k8s.io/controller-runtime/tools/setup-envtest
72-
KUBECTL_ASSETS_ERR := kubectl not detected.
73-
kubebuilder:
74-
ifeq (, $(shell which kubectl))
75-
$(error $(KUBECTL_ASSETS_ERR))
76-
endif
77-
ifeq (, $(wildcard $(KUBEBUILDER_ASSETS)/etcd))
78-
$(error etcd $(KUBEBUILDER_ASSETS_ERR))
79-
endif
80-
ifeq (, $(wildcard $(KUBEBUILDER_ASSETS)/kube-apiserver))
81-
$(error kube-apiserver $(KUBEBUILDER_ASSETS_ERR))
82-
endif
83-
8477
cover.out:
8578
go test $(MOD_FLAGS) -tags "json1" -race -coverprofile=cover.out -covermode=atomic \
8679
-coverpkg ./pkg/controller/... ./pkg/...

0 commit comments

Comments
 (0)