Skip to content

Commit a46e2af

Browse files
committed
Update Makefile targets for consistency
Fixes #226 * Rename the `install` target to `kind-deploy` * Create a new `install` target that installs CRD; corollary to `uninstall` * Rename the `kind-cluster-cleanup` target to `kind-clean` * Remove the `generate` target from `kind-deplpoy` * Swap `e2e`/`test-e2e` targets * Update help descriptions * Add `help-extended`, * Change e2e workflow to use test-e2e Signed-off-by: Todd Short <[email protected]>
1 parent d6aa5e9 commit a46e2af

File tree

3 files changed

+79
-31
lines changed

3 files changed

+79
-31
lines changed

.github/workflows/deploy.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: deploy-test
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
10+
jobs:
11+
deploy-basic:
12+
runs-on: ubuntu-latest
13+
steps:
14+
15+
- uses: actions/checkout@v3
16+
17+
- uses: actions/setup-go@v4
18+
with:
19+
go-version-file: go.mod
20+
21+
- name: Run basic unit tests
22+
run: |
23+
make kind-cluster
24+
make install
25+
kubectl get crds operators.operators.operatorframework.io
26+
make uninstall
27+
! kubectl get crds operators.operators.operatorframework.io
28+
make deploy
29+
kubectl get ns operator-controller-system
30+
make undeploy
31+
! kubectl get ns operator-controller-system

.github/workflows/e2e.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ jobs:
2020

2121
- name: Run e2e tests
2222
run: |
23-
make e2e
23+
make test-e2e

Makefile

Lines changed: 47 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -47,51 +47,64 @@ all: build
4747
# http://linuxcommand.org/lc3_adv_awk.php
4848

4949
.PHONY: help
50-
help: ## Display this help.
51-
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
50+
help: ## Display essential help.
51+
@awk 'BEGIN {FS = ":[^#]*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\n"} /^[a-zA-Z_0-9-]+:[^#]*## / { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } ' $(MAKEFILE_LIST)
52+
53+
.PHONY: help-extended
54+
help-extended: ## Display extended help.
55+
@awk 'BEGIN {FS = ":.*###?"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*###?/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
5256

5357
##@ Development
5458

5559
.PHONY: manifests
56-
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
60+
manifests: controller-gen ### Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
5761
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
5862

5963
.PHONY: generate
60-
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
64+
generate: controller-gen ### Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
6165
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
6266

6367
.PHONY: fmt
64-
fmt: ## Run go fmt against code.
68+
fmt: ### Run go fmt against code.
6569
go fmt ./...
6670

6771
.PHONY: vet
68-
vet: ## Run go vet against code.
72+
vet: ### Run go vet against code.
6973
go vet ./...
7074

71-
.PHONY: test test-e2e e2e kind-load kind-cluster kind-cluster-cleanup
72-
test: manifests generate fmt vet test-unit e2e ## Run all tests.
75+
.PHONY: verify
76+
verify: manifests generate fmt vet ## Verify all generated code is up-to-date
77+
git diff --quiet
78+
79+
.PHONY: test e2e test-e2e kind-load kind-cluster kind-clean kind-deploy
80+
test: manifests generate fmt vet test-unit test-e2e ## Run all tests.
7381

7482
FOCUS := $(if $(TEST),-v -focus "$(TEST)")
7583
E2E_FLAGS ?= ""
76-
test-e2e: ginkgo ## Run the e2e tests
84+
e2e: ginkgo ### Run the e2e tests
7785
$(GINKGO) --tags $(GO_BUILD_TAGS) $(E2E_FLAGS) -trace -progress $(FOCUS) test/e2e
7886

7987
ENVTEST_VERSION = $(shell go list -m k8s.io/client-go | cut -d" " -f2 | sed 's/^v0\.\([[:digit:]]\{1,\}\)\.[[:digit:]]\{1,\}$$/1.\1.x/')
8088
UNIT_TEST_DIRS=$(shell go list ./... | grep -v /test/)
8189
test-unit: envtest ## Run the unit tests
8290
eval $$($(ENVTEST) use -p env $(ENVTEST_VERSION)) && go test -tags $(GO_BUILD_TAGS) -count=1 -short $(UNIT_TEST_DIRS) -coverprofile cover.out
8391

84-
e2e: KIND_CLUSTER_NAME=operator-controller-e2e
85-
e2e: run test-e2e kind-cluster-cleanup ## Run e2e test suite on local kind cluster
92+
test-e2e: KIND_CLUSTER_NAME=operator-controller-e2e
93+
test-e2e: run e2e kind-clean ## Run e2e test suite on local kind cluster
8694

87-
kind-load: kind ## Loads the currently constructed image onto the cluster
95+
kind-load: kind ### Loads the currently constructed image onto the kind cluster
8896
$(KIND) load docker-image $(IMG) --name $(KIND_CLUSTER_NAME)
8997

90-
kind-cluster: kind kind-cluster-cleanup ## Standup a kind cluster
98+
kind-cluster: kind kind-clean ### Standup a kind cluster
9199
$(KIND) create cluster --name ${KIND_CLUSTER_NAME}
92100
$(KIND) export kubeconfig --name ${KIND_CLUSTER_NAME}
93101

94-
kind-cluster-cleanup: kind ## Delete the kind cluster
102+
kind-deploy: export MANIFEST="./operator-controller.yaml"
103+
kind-deploy: kind manifests kustomize ### Install controller and dependencies onto the kind cluster
104+
kubectl kustomize config/default > operator-controller.yaml
105+
envsubst '$$CATALOGD_VERSION,$$CERT_MGR_VERSION,$$RUKPAK_VERSION,$$MANIFEST' < scripts/install.tpl.sh | bash -s
106+
107+
kind-clean: kind ### Delete the kind cluster
95108
$(KIND) delete cluster --name ${KIND_CLUSTER_NAME}
96109

97110
##@ Build
@@ -101,23 +114,23 @@ BUILDDEPS = manifests generate fmt vet goreleaser
101114

102115
.PHONY: build
103116
build: BUILDBIN = bin
104-
build: $(BUILDDEPS) ## Build manager binary using goreleaser for current GOOS and GOARCH.
117+
build: $(BUILDDEPS) ## Build manager binary using goreleaser for current GOOS and GOARCH. Default target.
105118
$(BUILDCMD)
106119

107120
.PHONY: build-linux
108121
build-linux: BUILDBIN = bin/linux
109-
build-linux: $(BUILDDEPS) ## Build manager binary using goreleaser for GOOS=linux and local GOARCH.
122+
build-linux: $(BUILDDEPS) ### Build manager binary using goreleaser for GOOS=linux and local GOARCH.
110123
GOOS=linux $(BUILDCMD)
111124

112125
.PHONY: run
113-
run: docker-build kind-cluster kind-load install ## Build the operator-controller then deploy it into a new kind cluster.
126+
run: docker-build kind-cluster kind-load kind-deploy ## Build the operator-controller then deploy it into a new kind cluster.
114127

115128
.PHONY: wait
116129
wait:
117130
kubectl wait --for=condition=Available --namespace=$(OPERATOR_CONTROLLER_NAMESPACE) deployment/operator-controller-controller-manager --timeout=$(WAIT_TIMEOUT)
118131

119132
.PHONY: docker-build
120-
docker-build: build-linux ## Build docker image for operator-controller with GOOS=linux and local GOARCH.
133+
docker-build: build-linux ### Build docker image for operator-controller with GOOS=linux and local GOARCH.
121134
docker build -t ${IMG} -f Dockerfile ./bin/linux
122135

123136
###########
@@ -133,24 +146,26 @@ release: goreleaser ## Runs goreleaser for the operator-controller. By default,
133146
$(GORELEASER) $(GORELEASER_ARGS)
134147

135148
quickstart: export MANIFEST="https://github.com/operator-framework/operator-controller/releases/download/$(VERSION)/operator-controller.yaml"
136-
quickstart: kustomize generate ## Generate the installation release manifests and scripts
149+
quickstart: kustomize ### Generate the installation release manifests and scripts with dependencies
137150
kubectl kustomize config/default | sed "s/:devel/:$(VERSION)/g" > operator-controller.yaml
138151
envsubst '$$CATALOGD_VERSION,$$CERT_MGR_VERSION,$$RUKPAK_VERSION,$$MANIFEST' < scripts/install.tpl.sh > install.sh
139152

153+
##############
154+
# Deployment #
155+
##############
156+
140157
##@ Deployment
141158

142159
ifndef ignore-not-found
143160
ignore-not-found = false
144161
endif
145162

146163
.PHONY: install
147-
install: export MANIFEST="./operator-controller.yaml"
148-
install: manifests kustomize generate ## Install CRDs into the K8s cluster specified in ~/.kube/config.
149-
kubectl kustomize config/default > operator-controller.yaml
150-
envsubst '$$CATALOGD_VERSION,$$CERT_MGR_VERSION,$$RUKPAK_VERSION,$$MANIFEST' < scripts/install.tpl.sh | bash -s
164+
install: manifests kustomize ### Install CRDs into the K8s cluster specified in ~/.kube/config.
165+
$(KUSTOMIZE) build config/crd | kubectl apply -f -
151166

152167
.PHONY: uninstall
153-
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
168+
uninstall: manifests kustomize ### Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
154169
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
155170

156171
.PHONY: deploy
@@ -166,6 +181,8 @@ undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/confi
166181
# Hack / Tools #
167182
################
168183

184+
##@ Tools
185+
169186
## Location to install dependencies to
170187
LOCALBIN ?= $(shell pwd)/hack/tools/bin
171188
$(LOCALBIN):
@@ -184,23 +201,23 @@ KUSTOMIZE_VERSION ?= v4.5.7
184201
CONTROLLER_TOOLS_VERSION ?= v0.10.0
185202

186203
.PHONY: kind
187-
kind: $(KIND) ## Download kind locally if necessary.
204+
kind: $(KIND) ### Download kind locally if necessary.
188205
$(KIND): $(LOCALBIN)
189206
test -s $(LOCALBIN)/kind || GOBIN=$(LOCALBIN) go install sigs.k8s.io/[email protected]
190207

191208
.PHONY: ginkgo
192-
ginkgo: $(GINKGO) ## Download ginkgo locally if necessary.
209+
ginkgo: $(GINKGO) ### Download ginkgo locally if necessary.
193210
$(GINKGO): $(LOCALBIN)
194211
test -s $(LOCALBIN)/ginkgo || GOBIN=$(LOCALBIN) go install github.com/onsi/ginkgo/v2/[email protected]
195212

196213
.PHONY: goreleaser
197-
goreleaser: $(GORELEASER) ## Builds a local copy of goreleaser
214+
goreleaser: $(GORELEASER) ### Builds a local copy of goreleaser
198215
$(GORELEASER): $(LOCALBIN)
199216
test -s $(LOCALBIN)/goreleaser || GOBIN=$(LOCALBIN) go install github.com/goreleaser/goreleaser@${GORELEASER_VERSION}
200217

201218
KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
202219
.PHONY: kustomize
203-
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. If wrong version is installed, it will be removed before downloading.
220+
kustomize: $(KUSTOMIZE) ### Download kustomize locally if necessary. If wrong version is installed, it will be removed before downloading.
204221
$(KUSTOMIZE): $(LOCALBIN)
205222
@if test -x $(LOCALBIN)/kustomize && ! $(LOCALBIN)/kustomize version | grep -q $(KUSTOMIZE_VERSION); then \
206223
echo "$(LOCALBIN)/kustomize version is not expected $(KUSTOMIZE_VERSION). Removing it before installing."; \
@@ -209,12 +226,12 @@ $(KUSTOMIZE): $(LOCALBIN)
209226
test -s $(LOCALBIN)/kustomize || { curl -Ss $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN); }
210227

211228
.PHONY: controller-gen
212-
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. If wrong version is installed, it will be overwritten.
229+
controller-gen: $(CONTROLLER_GEN) ### Download controller-gen locally if necessary. If wrong version is installed, it will be overwritten.
213230
$(CONTROLLER_GEN): $(LOCALBIN)
214231
test -s $(LOCALBIN)/controller-gen && $(LOCALBIN)/controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION) || \
215232
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
216233

217234
.PHONY: envtest
218-
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
235+
envtest: $(ENVTEST) ### Download envtest-setup locally if necessary.
219236
$(ENVTEST): $(LOCALBIN)
220237
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest

0 commit comments

Comments
 (0)