Skip to content

Commit 50e2a9e

Browse files
committed
Update Makefile targets for consistency
Fixes #226 * Rename the `install` target to `kind-deploy` * Remove `uninstall` target * Rename the `kind-cluster-cleanup` target to `kind-clean` * Remove the `generate` target from `kind-deploy` * 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]> Signed-off-by: Todd Short <[email protected]>
1 parent 28da6bd commit 50e2a9e

File tree

3 files changed

+68
-41
lines changed

3 files changed

+68
-41
lines changed

.github/workflows/deploy.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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 deploy/undeploy
22+
run: |
23+
make kind-cluster
24+
make deploy
25+
kubectl get crds operators.operators.operatorframework.io
26+
kubectl get ns operator-controller-system
27+
make undeploy
28+
! kubectl get ns operator-controller-system
29+
! kubectl get crds operators.operators.operatorframework.io

.github/workflows/e2e.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
# after failing tests.
3030
# With -k flag make will continue the build, but will return non-zero
3131
# exit code in case of any errors.
32-
make -k e2e
32+
make -k test-e2e
3333
3434
- uses: codecov/codecov-action@v3
3535
with:

Makefile

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,15 @@ SHELL = /usr/bin/env bash -o pipefail
5555
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
5656
# More info on the awk command:
5757
# http://linuxcommand.org/lc3_adv_awk.php
58+
# The extended-help target uses '###' as the delineator.
5859

5960
.PHONY: help
60-
help: ## Display this help.
61-
@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)
61+
help: ## Display essential help.
62+
@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)
63+
64+
.PHONY: help-extended
65+
help-extended: ## Display extended help.
66+
@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)
6267

6368
##@ Development
6469

@@ -71,32 +76,32 @@ tidy: ## Update dependencies.
7176
$(Q)go mod tidy
7277

7378
.PHONY: manifests
74-
manifests: $(CONTROLLER_GEN) ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
79+
manifests: $(CONTROLLER_GEN) ### Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
7580
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
7681

7782
.PHONY: generate
78-
generate: $(CONTROLLER_GEN) ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
83+
generate: $(CONTROLLER_GEN) ### Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
7984
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
8085

8186
.PHONY: verify
82-
verify: tidy fmt generate ## Verify the current code generation.
87+
verify: tidy fmt vet generate ## Verify all generated code is up-to-date.
8388
git diff --exit-code
8489

8590
.PHONY: fmt
86-
fmt: ## Run go fmt against code.
91+
fmt: ### Run go fmt against code.
8792
go fmt ./...
8893

8994
.PHONY: vet
90-
vet: ## Run go vet against code.
95+
vet: ### Run go vet against code.
9196
go vet ./...
9297

9398
.PHONY: test
94-
test: manifests generate fmt vet test-unit e2e ## Run all tests.
99+
test: manifests generate fmt vet test-unit test-e2e ## Run all tests.
95100

96-
.PHONY: test-e2e
101+
.PHONY: e2e
97102
FOCUS := $(if $(TEST),-v -focus "$(TEST)")
98103
E2E_FLAGS ?= ""
99-
test-e2e: $(GINKGO) ## Run the e2e tests
104+
e2e: $(GINKGO) ### Run the e2e tests
100105
$(GINKGO) --tags $(GO_BUILD_TAGS) $(E2E_FLAGS) -trace -progress $(FOCUS) test/e2e
101106

102107
.PHONY: test-unit
@@ -105,31 +110,37 @@ UNIT_TEST_DIRS=$(shell go list ./... | grep -v /test/)
105110
test-unit: $(SETUP_ENVTEST) ## Run the unit tests
106111
eval $$($(SETUP_ENVTEST) use -p env $(ENVTEST_VERSION)) && go test -tags $(GO_BUILD_TAGS) -count=1 -short $(UNIT_TEST_DIRS) -coverprofile cover.out
107112

108-
.PHONY: e2e
109-
e2e: KIND_CLUSTER_NAME=operator-controller-e2e
110-
e2e: KUSTOMIZE_BUILD_DIR=config/e2e
111-
e2e: GO_BUILD_FLAGS=-cover
112-
e2e: run kind-load-test-artifacts test-e2e e2e-coverage kind-cluster-cleanup ## Run e2e test suite on local kind cluster
113+
.PHONY: test-e2e
114+
test-e2e: KIND_CLUSTER_NAME=operator-controller-e2e
115+
test-e2e: KUSTOMIZE_BUILD_DIR=config/e2e
116+
test-e2e: GO_BUILD_FLAGS=-cover
117+
test-e2e: run kind-load-test-artifacts e2e e2e-coverage undeploy kind-clean ## Run e2e test suite on local kind cluster
113118

114119
.PHONY: e2e-coverage
115120
e2e-coverage:
116121
COVERAGE_OUTPUT=./e2e-cover.out ./hack/e2e-coverage.sh
117122

118123
.PHONY: kind-load
119-
kind-load: $(KIND) ## Loads the currently constructed image onto the cluster
124+
kind-load: $(KIND) ### Loads the currently constructed image onto the cluster
120125
$(KIND) load docker-image $(IMG) --name $(KIND_CLUSTER_NAME)
121126

127+
kind-deploy: export MANIFEST="./operator-controller.yaml"
128+
kind-deploy: manifests $(KUSTOMIZE) ### Install controller and dependencies onto the kind cluster
129+
$(KUSTOMIZE) build $(KUSTOMIZE_BUILD_DIR) > operator-controller.yaml
130+
envsubst '$$CATALOGD_VERSION,$$CERT_MGR_VERSION,$$RUKPAK_VERSION,$$MANIFEST' < scripts/install.tpl.sh | bash -s
131+
122132
.PHONY: kind-cluster
123-
kind-cluster: $(KIND) ## Standup a kind cluster
133+
kind-cluster: $(KIND) ### Standup a kind cluster
134+
$(KIND) delete cluster --name ${KIND_CLUSTER_NAME}
124135
$(KIND) create cluster --name ${KIND_CLUSTER_NAME}
125136
$(KIND) export kubeconfig --name ${KIND_CLUSTER_NAME}
126137

127-
.PHONY: kind-cluster-cleanup
128-
kind-cluster-cleanup: $(KIND) ## Delete the kind cluster
138+
.PHONY: kind-clean
139+
kind-clean: $(KIND) ### Delete the kind cluster
129140
$(KIND) delete cluster --name ${KIND_CLUSTER_NAME}
130141

131142
.PHONY: kind-load-test-artifacts
132-
kind-load-test-artifacts: $(KIND) ## Load the e2e testdata container images into a kind cluster
143+
kind-load-test-artifacts: $(KIND) ### Load the e2e testdata container images into a kind cluster
133144
$(CONTAINER_RUNTIME) build $(TESTDATA_DIR)/bundles/registry-v1/prometheus-operator.v0.37.0 -t localhost/testdata/bundles/registry-v1/prometheus-operator:v0.37.0
134145
$(CONTAINER_RUNTIME) build $(TESTDATA_DIR)/bundles/registry-v1/prometheus-operator.v0.47.0 -t localhost/testdata/bundles/registry-v1/prometheus-operator:v0.47.0
135146
$(CONTAINER_RUNTIME) build $(TESTDATA_DIR)/bundles/registry-v1/prometheus-operator.v0.65.1 -t localhost/testdata/bundles/registry-v1/prometheus-operator:v0.65.1
@@ -157,39 +168,36 @@ BUILDCMD = go build $(GO_BUILD_FLAGS) -tags '$(GO_BUILD_TAGS)' -ldflags '$(GO_BU
157168
build-deps: manifests generate fmt vet
158169

159170
.PHONY: build go-build-local
160-
build: build-deps go-build-local ## Build manager binary for current GOOS and GOARCH.
171+
build: build-deps go-build-local ## Build manager binary for current GOOS and GOARCH. Default target.
161172
go-build-local: BUILDBIN = bin
162173
go-build-local:
163174
$(BUILDCMD)
164175

165176
.PHONY: build-linux go-build-linux
166-
build-linux: build-deps go-build-linux ## Build manager binary for GOOS=linux and local GOARCH.
177+
build-linux: build-deps go-build-linux ### Build manager binary for GOOS=linux and local GOARCH.
167178
go-build-linux: BUILDBIN = bin/linux
168179
go-build-linux:
169180
GOOS=linux $(BUILDCMD)
170181

171182
.PHONY: run
172-
run: docker-build kind-cluster kind-load install ## Build the operator-controller then deploy it into a new kind cluster.
183+
run: docker-build kind-cluster kind-load kind-deploy ## Build the operator-controller then deploy it into a new kind cluster.
173184

174185
.PHONY: docker-build
175-
docker-build: build-linux ## Build docker image for operator-controller with GOOS=linux and local GOARCH.
186+
docker-build: build-linux ### Build docker image for operator-controller with GOOS=linux and local GOARCH.
176187
docker build -t ${IMG} -f Dockerfile ./bin/linux
177188

178-
###########
179-
# Release #
180-
###########
181-
182189
##@ Release:
190+
183191
export ENABLE_RELEASE_PIPELINE ?= false
184192
export GORELEASER_ARGS ?= --snapshot --clean
185193

186194
.PHONY: release
187-
release: $(GORELEASER) ## Runs goreleaser for the operator-controller. By default, this will run only as a snapshot and will not publish any artifacts unless it is run with different arguments. To override the arguments, run with "GORELEASER_ARGS=...". When run as a github action from a tag, this target will publish a full release.
195+
release: $(GORELEASER) ### Runs goreleaser for the operator-controller. By default, this will run only as a snapshot and will not publish any artifacts unless it is run with different arguments. To override the arguments, run with "GORELEASER_ARGS=...". When run as a github action from a tag, this target will publish a full release.
188196
$(GORELEASER) $(GORELEASER_ARGS)
189197

190198
.PHONY: quickstart
191199
quickstart: export MANIFEST="https://github.com/operator-framework/operator-controller/releases/download/$(VERSION)/operator-controller.yaml"
192-
quickstart: $(KUSTOMIZE) generate ## Generate the installation release manifests and scripts
200+
quickstart: $(KUSTOMIZE) manifests ### Generate the installation release manifests and scripts
193201
$(KUSTOMIZE) build $(KUSTOMIZE_BUILD_DIR) | sed "s/:devel/:$(VERSION)/g" > operator-controller.yaml
194202
envsubst '$$CATALOGD_VERSION,$$CERT_MGR_VERSION,$$RUKPAK_VERSION,$$MANIFEST' < scripts/install.tpl.sh > install.sh
195203

@@ -199,16 +207,6 @@ ifndef ignore-not-found
199207
ignore-not-found = false
200208
endif
201209

202-
.PHONY: install
203-
install: export MANIFEST="./operator-controller.yaml"
204-
install: manifests $(KUSTOMIZE) generate ## Install CRDs into the K8s cluster specified in ~/.kube/config.
205-
$(KUSTOMIZE) build $(KUSTOMIZE_BUILD_DIR) > operator-controller.yaml
206-
envsubst '$$CATALOGD_VERSION,$$CERT_MGR_VERSION,$$RUKPAK_VERSION,$$MANIFEST' < scripts/install.tpl.sh | bash -s
207-
208-
.PHONY: uninstall
209-
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.
210-
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
211-
212210
.PHONY: deploy
213211
deploy: manifests $(KUSTOMIZE) ## Deploy controller to the K8s cluster specified in ~/.kube/config.
214212
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}

0 commit comments

Comments
 (0)