Skip to content

Commit

Permalink
Rearrange the makefile, remove the lint target & add fmt, vet targets
Browse files Browse the repository at this point in the history
Signed-off-by: Malay Kumar Parida <[email protected]>
  • Loading branch information
malayparida2000 committed Sep 27, 2023
1 parent 6767764 commit b340b75
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 65 deletions.
132 changes: 71 additions & 61 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,88 +13,106 @@ OPM_VERSION=v1.28.0
OPM=$(LOCALBIN)/opm-$(OPM_VERSION)

.PHONY: \
fmt \
vet \
build \
gen-protobuf \
clean \
ocs-operator \
ocs-metrics-exporter \
gen-latest-csv \
verify-latest-csv \
gen-release-csv \
operator-bundle \
verify-operator-bundle \
gen-latest-csv \
gen-latest-deploy-yaml \
operator-catalog \
deps-update \
verify-deps \
gen-protobuf \
gen-latest-prometheus-rules-yamls \
gen-latest-deploy-yaml \
verify-latest-deploy-yaml \
verify-latest-csv \
cluster-deploy \
cluster-clean \
unit-test \
functest \
shellcheck-test \
golangci-lint \
update-generated \
ocs-operator-ci \
unit-test \
deps-update

deps-update:
@echo "Running deps-update"
go mod tidy && go mod vendor
generate \
manifests \
verify-generated \
run \
clean \
controller-gen \
kustomize \
operator-sdk \
opm \
install-noobaa \
install-ocs

fmt:
go fmt ./...

operator-sdk:
@echo "Ensuring operator-sdk"
hack/ensure-operator-sdk.sh
vet:
go vet ./...

build: deps-update generate gen-protobuf
build: fmt vet deps-update generate

ocs-operator: build
ocs-operator: build gen-protobuf
@echo "Building the ocs-operator image"
hack/build-operator.sh

ocs-metrics-exporter: build
@echo "Building the ocs-metrics-exporter image"
hack/build-metrics-exporter.sh

gen-protobuf:
@echo "Generating protobuf files for gRPC services"
hack/gen-protobuf.sh

gen-latest-csv: operator-sdk manifests kustomize
@echo "Generating latest development CSV version using predefined ENV VARs."
hack/generate-latest-csv.sh

gen-release-csv: operator-sdk manifests kustomize
@echo "Generating unified CSV from sourced component-level operators"
hack/generate-unified-csv.sh

gen-latest-deploy-yaml:
@echo "Generating latest deployment yaml file"
hack/gen-deployment-yaml.sh

gen-latest-prometheus-rules-yamls:
@echo "Generating latest Prometheus rules yamls"
hack/gen-promethues-rules.sh

verify-latest-deploy-yaml: gen-latest-deploy-yaml
@echo "Verifying deployment yaml changes"
hack/verify-latest-deploy-yaml.sh

verify-latest-csv: gen-latest-csv
@echo "Verifying latest CSV"
hack/verify-latest-csv.sh

verify-operator-bundle: operator-sdk
@echo "Verifying operator bundle"
hack/verify-operator-bundle.sh
# This target is used in DownStream build scripts
gen-release-csv: operator-sdk manifests kustomize
@echo "Generating unified CSV from sourced component-level operators"
hack/generate-unified-csv.sh

operator-bundle: gen-latest-csv
@echo "Building ocs operator bundle"
hack/build-operator-bundle.sh

operator-catalog:
verify-operator-bundle: operator-sdk
@echo "Verifying operator bundle"
hack/verify-operator-bundle.sh

operator-catalog: opm
@echo "Building ocs catalog image in file based catalog format"
hack/build-operator-catalog.sh

clean:
@echo "cleaning previous outputs"
hack/clean.sh
deps-update:
@echo "Running deps-update"
go mod tidy && go mod vendor

verify-deps: deps-update
@echo "Verifying dependency files"
hack/verify-dependencies.sh

gen-protobuf:
@echo "Generating protobuf files for gRPC services"
hack/gen-protobuf.sh

gen-latest-prometheus-rules-yamls:
@echo "Generating latest Prometheus rules yamls"
hack/gen-promethues-rules.sh

gen-latest-deploy-yaml:
@echo "Generating latest deployment yaml file"
hack/gen-deployment-yaml.sh

verify-latest-deploy-yaml: gen-latest-deploy-yaml
@echo "Verifying deployment yaml changes"
hack/verify-latest-deploy-yaml.sh

cluster-deploy: cluster-clean
@echo "Deploying ocs to cluster"
Expand All @@ -104,6 +122,9 @@ cluster-clean:
@echo "Removing ocs install from cluster"
hack/cluster-clean.sh

unit-test:
@echo "Executing unit tests"
hack/unit-test.sh

functest:
@echo "Running ocs developer functional test suite"
Expand All @@ -117,16 +138,6 @@ golangci-lint:
@echo "Running golangci-lint run"
hack/golangci_lint.sh

lint: ## Run golangci-lint inside a container
source hack/common.sh; source hack/docker-common.sh; \
$${IMAGE_BUILD_CMD} run --rm -v $${PROJECT_DIR}:/app:Z -w /app $${GO_LINT_IMG} golangci-lint run ./...

# ignoring the functest dir since it requires an active cluster
# use 'make functest' to run just the functional tests
unit-test:
@echo "Executing unit tests"
hack/unit-test.sh

ocs-operator-ci: shellcheck-test golangci-lint unit-test verify-deps verify-generated verify-latest-csv verify-operator-bundle verify-latest-deploy-yaml

# Generate code
Expand All @@ -139,13 +150,7 @@ manifests: controller-gen
@echo Updating generated manifests
$(CONTROLLER_GEN) rbac:roleName=manager-role crd:generateEmbeddedObjectMeta=true paths=./api/... webhook paths="./..." output:crd:artifacts:config=config/crd/bases

verify-deps: deps-update
@echo "Verifying dependency files"
hack/verify-dependencies.sh

update-generated: generate manifests

verify-generated: update-generated
verify-generated: generate manifests
@echo "Verifying generated code and manifests"
hack/verify-generated.sh

Expand All @@ -157,6 +162,10 @@ run: manifests generate
go vet ./...
go run ./main.go $(ARGS)

clean:
@echo "cleaning previously fetched & built tools/binaries"
hack/clean.sh

# find or download controller-gen if necessary
controller-gen:
ifeq ($(wildcard ${CONTROLLER_GEN}),)
Expand All @@ -173,6 +182,7 @@ endif
kustomize:
ifeq ($(wildcard ${KUSTOMIZE}),)
@echo "Installing kustomize@${KUSTOMIZE_VERSION} at ${KUSTOMIZE}"
@mkdir -p $(LOCALBIN)
@curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN)
else ifneq ($(shell ${KUSTOMIZE} version | awk -F'[ /]' '/Version/{print $$2}'), $(KUSTOMIZE_VERSION))
@echo "Installing newer kustomize@${KUSTOMIZE_VERSION} at ${KUSTOMIZE}"
Expand Down
4 changes: 0 additions & 4 deletions hack/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ GOARCH="${GOARCH:-amd64}"
GOHOSTOS="$(go env GOHOSTOS)"
GOHOSTARCH="$(go env GOHOSTARCH)"

GO_LINT_IMG_LOCATION="${GO_LINT_IMG_LOCATION:-golangci/golangci-lint}"
GO_LINT_IMG_TAG="${GO_LINT_IMG_TAG:-v1.49.0}"
GO_LINT_IMG="${GO_LINT_IMG:-${GO_LINT_IMG_LOCATION}:${GO_LINT_IMG_TAG}}"

# Current DEV version of the CSV
DEFAULT_CSV_VERSION="4.14.0"
CSV_VERSION="${CSV_VERSION:-${DEFAULT_CSV_VERSION}}"
Expand Down

0 comments on commit b340b75

Please sign in to comment.