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