|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +# or more contributor license agreements. See the NOTICE file |
| 3 | +# distributed with this work for additional information |
| 4 | +# regarding copyright ownership. The ASF licenses this file |
| 5 | +# to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance |
| 7 | +# with the License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | + |
| 18 | +# Configures the shell for recipes to use bash, enabling bash commands and ensuring |
| 19 | +# that recipes exit on any command failure (including within pipes). |
| 20 | +SHELL = /usr/bin/env bash -o pipefail |
| 21 | +.SHELLFLAGS = -ec |
| 22 | + |
| 23 | +## Variables |
| 24 | +BUILD_IMAGE ?= true |
| 25 | +CONTAINER_TOOL ?= docker |
| 26 | +MINIKUBE_PROFILE ?= minikube |
| 27 | +DEPENDENCIES ?= ct helm helm-docs java21 git |
| 28 | +OPTIONAL_DEPENDENCIES := jq kubectl minikube |
| 29 | + |
| 30 | +## Version information |
| 31 | +BUILD_VERSION := $(shell cat version.txt) |
| 32 | +GIT_COMMIT := $(shell git rev-parse HEAD) |
| 33 | + |
| 34 | +##@ General |
| 35 | + |
| 36 | +.PHONY: help |
| 37 | +help: ## Display this help |
| 38 | + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9\.-]+:.*?##/ { printf " \033[36m%-40s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) |
| 39 | + |
| 40 | +.PHONY: version |
| 41 | +version: ## Display version information |
| 42 | + @echo "Build version: ${BUILD_VERSION}" |
| 43 | + @echo "Git commit: ${GIT_COMMIT}" |
| 44 | + |
| 45 | +##@ Polaris Build |
| 46 | + |
| 47 | +.PHONY: build |
| 48 | +build: build-server build-admin ## Build Polaris server, admin, and container images |
| 49 | + |
| 50 | +build-server: DEPENDENCIES := java21 $(CONTAINER_TOOL) |
| 51 | +.PHONY: build-server |
| 52 | +build-server: check-dependencies ## Build Polaris server and container image |
| 53 | + @echo "--- Building Polaris server ---" |
| 54 | + @./gradlew \ |
| 55 | + :polaris-server:assemble \ |
| 56 | + :polaris-server:quarkusAppPartsBuild --rerun \ |
| 57 | + -Dquarkus.container-image.build=$(BUILD_IMAGE) \ |
| 58 | + -Dquarkus.docker.executable-name=$(CONTAINER_TOOL) |
| 59 | + @echo "--- Polaris server build complete ---" |
| 60 | + |
| 61 | +build-admin: DEPENDENCIES := java21 $(CONTAINER_TOOL) |
| 62 | +.PHONY: build-admin |
| 63 | +build-admin: check-dependencies ## Build Polaris admin and container image |
| 64 | + @echo "--- Building Polaris admin ---" |
| 65 | + @./gradlew \ |
| 66 | + :polaris-admin:assemble \ |
| 67 | + :polaris-admin:quarkusAppPartsBuild --rerun \ |
| 68 | + -Dquarkus.container-image.build=$(BUILD_IMAGE) \ |
| 69 | + -Dquarkus.docker.executable-name=$(CONTAINER_TOOL) |
| 70 | + @echo "--- Polaris admin build complete ---" |
| 71 | + |
| 72 | +build-spark-plugin-3.5-2.12: DEPENDENCIES := java21 |
| 73 | +.PHONY: build-spark-plugin-3.5-2.12 |
| 74 | +build-spark-plugin-3.5-2.12: check-dependencies ## Build Spark plugin v3.5 with Scala v2.12 |
| 75 | + @echo "--- Building Spark plugin v3.5 with Scala v2.12 ---" |
| 76 | + @./gradlew \ |
| 77 | + :polaris-spark-3.5_2.12:assemble |
| 78 | + @echo "--- Spark plugin v3.5 with Scala v2.12 build complete ---" |
| 79 | + |
| 80 | +build-spark-plugin-3.5-2.13: DEPENDENCIES := java21 |
| 81 | +.PHONY: build-spark-plugin-3.5-2.13 |
| 82 | +build-spark-plugin-3.5-2.13: check-dependencies ## Build Spark plugin v3.5 with Scala v2.13 |
| 83 | + @echo "--- Building Spark plugin v3.5 with Scala v2.13 ---" |
| 84 | + @./gradlew \ |
| 85 | + :polaris-spark-3.5_2.13:assemble |
| 86 | + @echo "--- Spark plugin v3.5 with Scala v2.13 build complete ---" |
| 87 | + |
| 88 | +build-cleanup: DEPENDENCIES := java21 |
| 89 | +.PHONY: build-cleanup |
| 90 | +build-cleanup: check-dependencies ## Clean build artifacts |
| 91 | + @echo "--- Cleaning up build artifacts ---" |
| 92 | + @./gradlew clean |
| 93 | + @echo "--- Build artifacts cleaned ---" |
| 94 | + |
| 95 | +spotless-apply: DEPENDENCIES := java21 |
| 96 | +.PHONY: spotless-apply |
| 97 | +spotless-apply: check-dependencies ## Apply code formatting using Spotless Gradle plugin. |
| 98 | + @echo "--- Applying Spotless formatting ---" |
| 99 | + @./gradlew spotlessApply |
| 100 | + @echo "--- Spotless formatting applied ---" |
| 101 | + |
| 102 | +##@ Helm |
| 103 | + |
| 104 | +helm-doc-generate: DEPENDENCIES := helm-docs |
| 105 | +.PHONY: helm-doc-generate |
| 106 | +helm-doc-generate: check-dependencies ## Generate Helm chart documentation |
| 107 | + @echo "--- Generating Helm documentation ---" |
| 108 | + @helm-docs --chart-search-root=helm |
| 109 | + @cp helm/polaris/README.md site/content/in-dev/unreleased/helm.md |
| 110 | + @echo "--- Helm documentation generated and copied ---" |
| 111 | + |
| 112 | +helm-unittest: DEPENDENCIES := helm |
| 113 | +.PHONY: helm-unittest |
| 114 | +helm-unittest: check-dependencies ## Run Helm chart unittest |
| 115 | + @echo "--- Running Helm chart unittest ---" |
| 116 | + @helm unittest helm/polaris |
| 117 | + @echo "--- Helm chart unittest complete ---" |
| 118 | + |
| 119 | +helm-lint: DEPENDENCIES := ct |
| 120 | +.PHONY: helm-lint |
| 121 | +helm-lint: check-dependencies ## Run Helm chart lint check |
| 122 | + @echo "--- Running Helm chart linting ---" |
| 123 | + @ct lint --charts helm/polaris |
| 124 | + @echo "--- Helm chart linting complete ---" |
| 125 | + |
| 126 | +##@ Minikube |
| 127 | + |
| 128 | +minikube-start-cluster: DEPENDENCIES := minikube $(CONTAINER_TOOL) |
| 129 | +.PHONY: minikube-start-cluster |
| 130 | +minikube-start-cluster: check-dependencies ## Start the Minikube cluster |
| 131 | + @echo "--- Checking Minikube cluster status ---" |
| 132 | + @if minikube status -p $(MINIKUBE_PROFILE) --format "{{.Host}}" | grep -q "Running"; then \ |
| 133 | + echo "--- Minikube cluster is already running. Skipping start ---"; \ |
| 134 | + else \ |
| 135 | + echo "--- Starting Minikube cluster ---"; \ |
| 136 | + if [ "$(CONTAINER_TOOL)" = "podman" ]; then \ |
| 137 | + minikube start -p $(MINIKUBE_PROFILE) --driver=$(CONTAINER_TOOL) --container-runtime=cri-o; \ |
| 138 | + else \ |
| 139 | + minikube start -p $(MINIKUBE_PROFILE) --driver=$(CONTAINER_TOOL); \ |
| 140 | + fi; \ |
| 141 | + echo "--- Minikube cluster started ---"; \ |
| 142 | + fi |
| 143 | + |
| 144 | +minikube-stop-cluster: DEPENDENCIES := minikube $(CONTAINER_TOOL) |
| 145 | +.PHONY: minikube-stop-cluster |
| 146 | +minikube-stop-cluster: check-dependencies ## Stop the Minikube cluster |
| 147 | + @echo "--- Checking Minikube cluster status ---" |
| 148 | + @if minikube status -p $(MINIKUBE_PROFILE) --format "{{.Host}}" | grep -q "Running"; then \ |
| 149 | + echo "--- Stopping Minikube cluster ---"; \ |
| 150 | + minikube stop -p $(MINIKUBE_PROFILE); \ |
| 151 | + echo "--- Minikube cluster stopped ---"; \ |
| 152 | + else \ |
| 153 | + echo "--- Minikube cluster is already stopped or does not exist. Skipping stop ---"; \ |
| 154 | + fi |
| 155 | + |
| 156 | +minikube-load-images: DEPENDENCIES := minikube $(CONTAINER_TOOL) |
| 157 | +.PHONY: minikube-load-images |
| 158 | +minikube-load-images: minikube-start-cluster check-dependencies ## Load local Docker images into the Minikube cluster |
| 159 | + @echo "--- Loading images into Minikube cluster ---" |
| 160 | + @minikube image load -p $(MINIKUBE_PROFILE) docker.io/apache/polaris:latest |
| 161 | + @minikube image tag -p $(MINIKUBE_PROFILE) docker.io/apache/polaris:latest docker.io/apache/polaris:$(BUILD_VERSION) |
| 162 | + @minikube image load -p $(MINIKUBE_PROFILE) docker.io/apache/polaris-admin-tool:latest |
| 163 | + @minikube image tag -p $(MINIKUBE_PROFILE) docker.io/apache/polaris-admin-tool:latest docker.io/apache/polaris-admin-tool:$(BUILD_VERSION) |
| 164 | + @echo "--- Images loaded into Minikube cluster ---" |
| 165 | + |
| 166 | +minikube-cleanup: DEPENDENCIES := minikube $(CONTAINER_TOOL) |
| 167 | +.PHONY: minikube-cleanup |
| 168 | +minikube-cleanup: check-dependencies ## Cleanup the Minikube cluster |
| 169 | + @echo "--- Checking Minikube cluster status ---" |
| 170 | + @if minikube status -p $(MINIKUBE_PROFILE) >/dev/null 2>&1; then \ |
| 171 | + echo "--- Cleanup Minikube cluster ---"; \ |
| 172 | + minikube delete -p $(MINIKUBE_PROFILE); \ |
| 173 | + echo "--- Minikube cluster removed ---"; \ |
| 174 | + else \ |
| 175 | + echo "--- Minikube cluster does not exist. Skipping cleanup ---"; \ |
| 176 | + fi |
| 177 | + |
| 178 | +##@ Pre-commit |
| 179 | + |
| 180 | +.PHONY: pre-commit |
| 181 | +pre-commit: spotless-apply helm-doc-generate ## Run tasks for pre-commit |
| 182 | + |
| 183 | +##@ Dependencies |
| 184 | + |
| 185 | +.PHONY: check-dependencies |
| 186 | +check-dependencies: ## Check if all requested dependencies are present |
| 187 | + @echo "--- Checking for requested dependencies ---" |
| 188 | + @for dependency in $(DEPENDENCIES); do \ |
| 189 | + echo "Checking for $$dependency..."; \ |
| 190 | + if [ "$$dependency" = "java21" ]; then \ |
| 191 | + if java --version | head -n1 | cut -d' ' -f2 | grep -q '^21\.'; then \ |
| 192 | + echo "Java 21 is installed."; \ |
| 193 | + else \ |
| 194 | + echo "Java 21 is NOT installed."; \ |
| 195 | + echo "--- ERROR: Dependency 'Java 21' is missing. Please install it to proceed. Exiting. ---"; \ |
| 196 | + exit 1; \ |
| 197 | + fi ; \ |
| 198 | + elif command -v $$dependency >/dev/null 2>&1; then \ |
| 199 | + echo "$$dependency is installed."; \ |
| 200 | + else \ |
| 201 | + echo "$$dependency is NOT installed."; \ |
| 202 | + echo "--- ERROR: Dependency '$$dependency' is missing. Please install it to proceed. Exiting. ---"; \ |
| 203 | + exit 1; \ |
| 204 | + fi; \ |
| 205 | + done |
| 206 | + @echo "--- All checks complete. ---" |
| 207 | + |
| 208 | +.PHONY: check-brew |
| 209 | +check-brew: |
| 210 | + @echo "--- Checking Homebrew installation ---" |
| 211 | + @if command -v brew >/dev/null 2>&1; then \ |
| 212 | + echo "--- Homebrew is installed ---"; \ |
| 213 | + else \ |
| 214 | + echo "--- Homebrew is not installed. Aborting ---"; \ |
| 215 | + exit 1; \ |
| 216 | + fi |
| 217 | + |
| 218 | +.PHONY: install-dependencies-brew |
| 219 | +install-dependencies-brew: check-brew ## Install dependencies if not present via Brew |
| 220 | + @echo "--- Checking and installing dependencies for this target ---" |
| 221 | + @for dependency in $(DEPENDENCIES); do \ |
| 222 | + case $$dependency in \ |
| 223 | + java21) \ |
| 224 | + if java -version 2>&1 | grep -q '21'; then \ |
| 225 | + :; \ |
| 226 | + else \ |
| 227 | + echo "Java 21 is not installed. Installing openjdk@21 and jenv..."; \ |
| 228 | + brew install openjdk@21 jenv; \ |
| 229 | + $(shell brew --prefix jenv)/bin/jenv add $(shell brew --prefix openjdk@21); \ |
| 230 | + jenv local 21; \ |
| 231 | + echo "Java 21 installed."; \ |
| 232 | + fi ;; \ |
| 233 | + docker|podman) \ |
| 234 | + if command -v $$dependency >/dev/null 2>&1; then \ |
| 235 | + :; \ |
| 236 | + else \ |
| 237 | + echo "$$dependency is not installed. Manual installation required"; \ |
| 238 | + fi ;; \ |
| 239 | + ct) \ |
| 240 | + if command -v ct >/dev/null 2>&1; then \ |
| 241 | + :; \ |
| 242 | + else \ |
| 243 | + echo "ct is not installed. Installing with Homebrew..."; \ |
| 244 | + brew install chart-testing; \ |
| 245 | + echo "ct installed."; \ |
| 246 | + fi ;; \ |
| 247 | + *) \ |
| 248 | + if command -v $$dependency >/dev/null 2>&1; then \ |
| 249 | + :; \ |
| 250 | + else \ |
| 251 | + echo "$$dependency is not installed. Installing with Homebrew..."; \ |
| 252 | + brew install $$dependency; \ |
| 253 | + echo "$$dependency installed."; \ |
| 254 | + fi ;; \ |
| 255 | + esac; \ |
| 256 | + done |
| 257 | + @echo "--- All requested dependencies checked/installed ---" |
| 258 | + |
| 259 | +install-optional-dependencies-brew: DEPENDENCIES := $(OPTIONAL_DEPENDENCIES) |
| 260 | +.PHONY: install-optional-dependencies-brew |
| 261 | +install-optional-dependencies-brew: install-dependencies-brew ## Install optional dependencies if not present via Brew |
0 commit comments