github.com/verrazzano/verrazzano@v1.7.0/Makefile (about) 1 # Copyright (c) 2020, 2023, Oracle and/or its affiliates. 2 # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 4 .DEFAULT_GOAL := help 5 .PHONY: help 6 help: ## Display this help. 7 @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-25s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) 8 9 include make/quality.mk 10 11 SCRIPT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))/build 12 ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) 13 TOOLS_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))/tools 14 15 ifneq "$(MAKECMDGOALS)" "" 16 ifeq ($(MAKECMDGOALS),$(filter $(MAKECMDGOALS),docker-push create-test-deploy)) 17 ifndef DOCKER_REPO 18 $(error DOCKER_REPO must be defined as the name of the docker repository where image will be pushed) 19 endif 20 ifndef DOCKER_NAMESPACE 21 $(error DOCKER_NAMESPACE must be defined as the name of the docker namespace where image will be pushed) 22 endif 23 endif 24 endif 25 26 TIMESTAMP := $(shell date -u +%Y%m%d%H%M%S) 27 DOCKER_IMAGE_TAG ?= local-${TIMESTAMP}-$(shell git rev-parse --short HEAD) 28 VERRAZZANO_PLATFORM_OPERATOR_IMAGE_NAME ?= verrazzano-platform-operator-dev 29 VERRAZZANO_APPLICATION_OPERATOR_IMAGE_NAME ?= verrazzano-application-operator-dev 30 VERRAZZANO_CLUSTER_OPERATOR_IMAGE_NAME ?= verrazzano-cluster-operator-dev 31 VERRAZZANO_AUTHPROXY_IMAGE_NAME ?= verrazzano-authproxy-dev 32 33 VERRAZZANO_PLATFORM_OPERATOR_IMAGE = ${DOCKER_REPO}/${DOCKER_NAMESPACE}/${VERRAZZANO_PLATFORM_OPERATOR_IMAGE_NAME}:${DOCKER_IMAGE_TAG} 34 VERRAZZANO_APPLICATION_OPERATOR_IMAGE = ${DOCKER_REPO}/${DOCKER_NAMESPACE}/${VERRAZZANO_APPLICATION_OPERATOR_IMAGE_NAME}:${DOCKER_IMAGE_TAG} 35 VERRAZZANO_CLUSTER_OPERATOR_IMAGE = ${DOCKER_REPO}/${DOCKER_NAMESPACE}/${VERRAZZANO_CLUSTER_OPERATOR_IMAGE_NAME}:${DOCKER_IMAGE_TAG} 36 VERRAZZANO_AUTHPROXY_IMAGE = ${DOCKER_REPO}/${DOCKER_NAMESPACE}/${VERRAZZANO_AUTHPROXY_IMAGE_NAME}:${DOCKER_IMAGE_TAG} 37 38 CURRENT_YEAR = $(shell date +"%Y") 39 40 PARENT_BRANCH ?= origin/master 41 42 GO ?= CGO_ENABLED=0 GO111MODULE=on GOPRIVATE=github.com/verrazzano go 43 GO_LDFLAGS ?= -extldflags -static -X main.buildVersion=${BUILDVERSION} -X main.buildDate=${BUILDDATE} 44 45 .PHONY: clean 46 clean: ## remove coverage and test results 47 find . -name coverage.cov -exec rm {} \; 48 find . -name coverage.html -exec rm {} \; 49 find . -name coverage.raw.cov -exec rm {} \; 50 find . -name \*-test-result.xml -exec rm {} \; 51 find . -name coverage.xml -exec rm {} \; 52 find . -name unit-test-coverage-number.txt -exec rm {} \; 53 54 ##@ Build 55 56 .PHONY: docker-push 57 docker-push: ## build and push all images 58 (cd authproxy; make docker-push DOCKER_IMAGE_NAME=${VERRAZZANO_AUTHPROXY_IMAGE_NAME} DOCKER_IMAGE_TAG=${DOCKER_IMAGE_TAG}) 59 (cd cluster-operator; make docker-push DOCKER_IMAGE_NAME=${VERRAZZANO_CLUSTER_OPERATOR_IMAGE_NAME} DOCKER_IMAGE_TAG=${DOCKER_IMAGE_TAG}) 60 (cd application-operator; make docker-push DOCKER_IMAGE_NAME=${VERRAZZANO_APPLICATION_OPERATOR_IMAGE_NAME} DOCKER_IMAGE_TAG=${DOCKER_IMAGE_TAG}) 61 (cd platform-operator; make docker-push DOCKER_IMAGE_NAME=${VERRAZZANO_PLATFORM_OPERATOR_IMAGE_NAME} DOCKER_IMAGE_TAG=${DOCKER_IMAGE_TAG} VERRAZZANO_APPLICATION_OPERATOR_IMAGE=${VERRAZZANO_APPLICATION_OPERATOR_IMAGE} VERRAZZANO_CLUSTER_OPERATOR_IMAGE=${VERRAZZANO_CLUSTER_OPERATOR_IMAGE} VERRAZZANO_AUTHPROXY_IMAGE=${VERRAZZANO_AUTHPROXY_IMAGE}) 62 63 .PHONY: docker-push-debug 64 docker-push-debug: ## build and push all images 65 (cd authproxy; make docker-push-debug DOCKER_IMAGE_NAME=${VERRAZZANO_AUTHPROXY_IMAGE_NAME} DOCKER_IMAGE_TAG=${DOCKER_IMAGE_TAG}) 66 (cd cluster-operator; make docker-push-debug DOCKER_IMAGE_NAME=${VERRAZZANO_CLUSTER_OPERATOR_IMAGE_NAME} DOCKER_IMAGE_TAG=${DOCKER_IMAGE_TAG}) 67 (cd application-operator; make docker-push-debug DOCKER_IMAGE_NAME=${VERRAZZANO_APPLICATION_OPERATOR_IMAGE_NAME} DOCKER_IMAGE_TAG=${DOCKER_IMAGE_TAG}) 68 (cd platform-operator; make docker-push-debug DOCKER_IMAGE_NAME=${VERRAZZANO_PLATFORM_OPERATOR_IMAGE_NAME} DOCKER_IMAGE_TAG=${DOCKER_IMAGE_TAG} VERRAZZANO_APPLICATION_OPERATOR_IMAGE=${VERRAZZANO_APPLICATION_OPERATOR_IMAGE} VERRAZZANO_CLUSTER_OPERATOR_IMAGE=${VERRAZZANO_CLUSTER_OPERATOR_IMAGE} VERRAZZANO_AUTHPROXY_IMAGE=${VERRAZZANO_AUTHPROXY_IMAGE}) 69 70 .PHONY: create-test-deploy 71 create-test-deploy: docker-push create-test-deploy-common ## build and push all images, then create operator.yaml file for Verrazzano deployment 72 73 .PHONY: create-test-deploy-debug 74 create-test-deploy-debug: docker-push-debug create-test-deploy-common ## build and push all images, then create operator.yaml file for Verrazzano deployment (debug) 75 76 .PHONY: create-test-deploy-common 77 create-test-deploy-common: ## create operator.yaml file for Verrazzano deployment 78 (cd platform-operator; make create-test-deploy VZ_DEV_IMAGE=${VERRAZZANO_PLATFORM_OPERATOR_IMAGE} VZ_APP_OP_IMAGE=${VERRAZZANO_APPLICATION_OPERATOR_IMAGE} VZ_CLUSTER_OP_IMAGE=${VERRAZZANO_CLUSTER_OPERATOR_IMAGE} VZ_AUTHPROXY_IMAGE=${VERRAZZANO_AUTHPROXY_IMAGE}) 79 80 .PHONY: test-platform-operator-install 81 test-platform-operator-install: ## install VPO from operator.yaml 82 kubectl apply -f platform-operator/build/deploy/operator.yaml 83 kubectl -n verrazzano-install rollout status deployment/verrazzano-platform-operator 84 85 .PHONY: test-platform-operator-remove 86 test-platform-operator-remove: ## delete VPO from operator.yaml 87 kubectl delete -f platform-operator/build/deploy/operator.yaml 88 89 .PHONY: test-platform-operator-install-logs 90 test-platform-operator-install-logs: ## tail VPO logs 91 kubectl logs -f -n verrazzano-install $(shell kubectl get pods -n verrazzano-install --no-headers | grep "^verrazzano-platform-operator-" | cut -d ' ' -f 1) 92 93 ##@ Testing 94 95 .PHONY: precommit 96 precommit: precommit-check precommit-build unit-test-coverage ## run all precommit checks 97 98 .PHONY: precommit-nocover 99 precommit-nocover: precommit-check precommit-build unit-test ## run precommit checks without code coverage check 100 101 .PHONY: precommit-check 102 precommit-check: check-tidy check check-tests copyright-check check-bom-tags ## run precommit checks without unit testing 103 104 .PHONY: precommit-build 105 precommit-build: ## go build the project 106 go build ./... 107 108 unit-test-coverage: export COVERAGE_EXCLUSIONS ?= tests/e2e|tools/psr|tools/charts-manager/vcm|platform-operator/experimental|platform-operator/controllers/module|platform-operator/controllers/verrazzano/controller 109 .PHONY: unit-test-coverage 110 unit-test-coverage: ## run unit tests with coverage 111 ${SCRIPT_DIR}/coverage.sh html 112 113 .PHONY: unit-test-coverage-ratcheting 114 unit-test-coverage-ratcheting: ## run unit tests with coverage ratcheting 115 ${SCRIPT_DIR}/coverage-number-comparison.sh 116 117 .PHONY: unit-test 118 unit-test: ## run all unit tests in project 119 go test $$(go list ./... | grep -Ev "/tests/e2e|/tools/psr|tools/charts-manager/vcm") 120 121 # 122 # Compliance check targets 123 # 124 125 ##@ Compliance 126 127 .PHONY: copyright-test 128 copyright-test: ## run the tests for the copyright checker 129 (cd tools/copyright; go test .) 130 131 .PHONY: copyright-check-year 132 copyright-check-year: copyright-test ## check copyright notices have correct current year 133 go run tools/copyright/copyright.go --enforce-current $(shell git log --since=01-01-${CURRENT_YEAR} --name-only --oneline --pretty="format:" | sort -u) 134 135 .PHONY: copyright-check 136 copyright-check: copyright-test copyright-check-year ## check copyright notices are correct 137 go run tools/copyright/copyright.go . 138 139 .PHONY: copyright-check-local 140 copyright-check-local: copyright-test ## check copyright notices are correct in local working copy 141 go run tools/copyright/copyright.go --verbose --enforce-current $(shell git status --short | cut -c 4-) 142 143 .PHONY: copyright-check-branch 144 copyright-check-branch: copyright-check ## check copyright notices are correct in parent branch 145 go run tools/copyright/copyright.go --verbose --enforce-current $(shell git diff --name-only ${PARENT_BRANCH}) 146 147 .PHONY: check-bom-tags 148 check-bom-tags: ## check for any image tag problems in the BOM 149 release/scripts/check_image_tags.sh platform-operator/verrazzano-bom.json 150 151 # 152 # Quality checks on acceptance tests 153 # 154 155 ##@ Quality 156 157 .PHONY: check-tests 158 check-tests: check-eventually ## check test code for known quality issues 159 160 .PHONY: check-eventually 161 check-eventually: check-eventually-test ## check for correct use of Gomega Eventually func 162 go run tools/eventually-checker/check_eventually.go tests/e2e 163 164 .PHONY: check-eventually-test 165 check-eventually-test: ## run tests for Gomega Eventually checker 166 (cd tools/eventually-checker; go test .) 167 168 .PHONY: check-tidy 169 check-tidy: ## check if go mod tidy results in no changes 170 go mod tidy 171 ci/scripts/check_if_clean_after_generate.sh