From 0ab4dc5582d57790f3646200a318ca8cd050eba4 Mon Sep 17 00:00:00 2001 From: Yong Date: Thu, 10 Jul 2025 23:59:33 -0500 Subject: [PATCH 1/6] Use Makefile to simplify setup and commands --- Makefile | 151 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 00000000000..09a22de7ad5 --- /dev/null +++ b/Makefile @@ -0,0 +1,151 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Configures the shell for recipes to use bash, enabling bash commands and ensuring +# that recipes exit on any command failure (including within pipes). +SHELL = /usr/bin/env bash -o pipefail +.SHELLFLAGS = -ec + +## Variables +BUILD_IMAGE ?= true +IMAGE_TAG ?= postgres-latest +BINARIES := git docker helm-docs jq java21 ct helm + +##@ General + +.PHONY: help +help: ## Display this help. + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-30s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) + +.PHONY: check-brew +check-brew: + @echo "--- Checking Homebrew installation ---" + @if command -v brew >/dev/null 2>&1; then \ + echo "--- Homebrew is installed ---"; \ + else \ + echo "--- Homebrew is not installed. Aborting ---"; \ + exit 1; \ + fi + +##@ Polaris Build + +.PHONY: build +build: build-server build-admin ## Build Polaris server, admin, and container images + +.PHONY: build-server +build-server: setup-binaries ## Build Polaris server and container image + @echo "--- Building Polaris server ---" + @./gradlew \ + :polaris-server:assemble \ + :polaris-server:quarkusAppPartsBuild --rerun \ + -Dquarkus.container-image.tag=$(IMAGE_TAG) \ + -Dquarkus.container-image.build=$(BUILD_IMAGE) + @echo "--- Polaris server build complete ---" + +.PHONY: build-admin +build-admin: setup-binaries ## Build Polaris admin and container image + @echo "--- Building Polaris admin ---" + @./gradlew \ + :polaris-admin:assemble \ + :polaris-admin:quarkusAppPartsBuild --rerun \ + -Dquarkus.container-image.tag=$(IMAGE_TAG) \ + -Dquarkus.container-image.build=$(BUILD_IMAGE) + @echo "--- Polaris admin build complete ---" + +.PHONY: build-cleanup +build-cleanup: setup-binaries ## Clean build artifacts + @echo "--- Cleaning up build artifacts ---" + @./gradlew clean + @echo "--- Build artifacts cleaned ---" + +.PHONY: spotless-apply +spotless-apply: setup-binaries ## Apply code formatting using Spotless Gradle plugin. + @echo "--- Applying Spotless formatting ---" + @./gradlew spotlessApply + @echo "--- Spotless formatting applied ---" + +##@ Helm + +.PHONY: helm-doc-generate +helm-doc-generate: setup-binaries ## Generate Helm chart documentation + @echo "--- Generating Helm documentation ---" + @helm-docs --chart-search-root=helm + @cp helm/polaris/README.md site/content/in-dev/unreleased/helm.md + @echo "--- Helm documentation generated and copied ---" + +.PHONY: helm-unittest +helm-unittest: setup-binaries ## Run Helm chart unittest + @echo "--- Running Helm chart unittest ---" + @helm unittest helm/polaris + @echo "--- Helm chart unittest complete ---" + +.PHONY: helm-lint +helm-lint: setup-binaries ## Run Helm chart lint check + @echo "--- Running Helm chart linting ---" + @ct lint --charts helm/polaris + @echo "--- Helm chart linting complete ---" + +##@ Pre-commit + +.PHONY: pre-commit +pre-commit: spotless-apply helm-doc-generate ## Run tasks for pre-commit + +##@ Dependencies + +.PHONY: setup-binaries +setup-binaries: check-brew ## Install required binaries if not present + @echo "--- Checking and installing required binaries ---" + @for bin in $(BINARIES); do \ + case $$bin in \ + java21) \ + if java -version 2>&1 | grep -q '21'; then \ + :; \ + else \ + echo "Java 21 is not installed. Installing openjdk@21 and jenv..."; \ + brew install openjdk@21 jenv; \ + $(shell brew --prefix jenv)/bin/jenv add $(shell brew --prefix openjdk@21); \ + jenv local 21; \ + echo "Java 21 installed."; \ + fi ;; \ + docker) \ + if command -v docker >/dev/null 2>&1; then \ + :; \ + else \ + echo "docker is not installed. Installing with Homebrew..."; \ + brew install --cask docker; \ + echo "docker installed."; \ + fi ;; \ + ct) \ + if command -v ct >/dev/null 2>&1; then \ + :; \ + else \ + echo "ct is not installed. Installing with Homebrew..."; \ + brew install --cask chart-testing; \ + echo "ct installed."; \ + fi ;; \ + *) \ + if command -v $$bin >/dev/null 2>&1; then \ + :; \ + else \ + echo "$$bin is not installed. Installing with Homebrew..."; \ + brew install $$bin; \ + echo "$$bin installed."; \ + fi ;; \ + esac; \ + done + @echo "--- All required binaries checked/installed ---" + From 3d3ebd795bf601a852f0628bc938a5c5393afa61 Mon Sep 17 00:00:00 2001 From: Yong Date: Fri, 11 Jul 2025 15:30:13 -0500 Subject: [PATCH 2/6] Add targets for minikube state management --- Makefile | 89 ++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 70 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index 09a22de7ad5..a36ab41cbb1 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ SHELL = /usr/bin/env bash -o pipefail ## Variables BUILD_IMAGE ?= true IMAGE_TAG ?= postgres-latest -BINARIES := git docker helm-docs jq java21 ct helm +DEPENDENCIES := git docker helm-docs jq java21 ct helm helm-docs kubectl minikube ##@ General @@ -46,8 +46,9 @@ check-brew: .PHONY: build build: build-server build-admin ## Build Polaris server, admin, and container images +build-server: DEPENDENCIES := java21 docker .PHONY: build-server -build-server: setup-binaries ## Build Polaris server and container image +build-server: setup-dependencies ## Build Polaris server and container image @echo "--- Building Polaris server ---" @./gradlew \ :polaris-server:assemble \ @@ -56,8 +57,9 @@ build-server: setup-binaries ## Build Polaris server and container image -Dquarkus.container-image.build=$(BUILD_IMAGE) @echo "--- Polaris server build complete ---" +build-admin: DEPENDENCIES := java21 docker .PHONY: build-admin -build-admin: setup-binaries ## Build Polaris admin and container image +build-admin: setup-dependencies ## Build Polaris admin and container image @echo "--- Building Polaris admin ---" @./gradlew \ :polaris-admin:assemble \ @@ -66,39 +68,89 @@ build-admin: setup-binaries ## Build Polaris admin and container image -Dquarkus.container-image.build=$(BUILD_IMAGE) @echo "--- Polaris admin build complete ---" +build-cleanup: DEPENDENCIES := java21 .PHONY: build-cleanup -build-cleanup: setup-binaries ## Clean build artifacts +build-cleanup: setup-dependencies ## Clean build artifacts @echo "--- Cleaning up build artifacts ---" @./gradlew clean @echo "--- Build artifacts cleaned ---" +spotless-apply: DEPENDENCIES := java21 .PHONY: spotless-apply -spotless-apply: setup-binaries ## Apply code formatting using Spotless Gradle plugin. +spotless-apply: setup-dependencies ## Apply code formatting using Spotless Gradle plugin. @echo "--- Applying Spotless formatting ---" @./gradlew spotlessApply @echo "--- Spotless formatting applied ---" ##@ Helm +helm-doc-generate: DEPENDENCIES := helm-docs .PHONY: helm-doc-generate -helm-doc-generate: setup-binaries ## Generate Helm chart documentation +helm-doc-generate: setup-dependencies ## Generate Helm chart documentation @echo "--- Generating Helm documentation ---" @helm-docs --chart-search-root=helm @cp helm/polaris/README.md site/content/in-dev/unreleased/helm.md @echo "--- Helm documentation generated and copied ---" +helm-unittest: DEPENDENCIES := helm .PHONY: helm-unittest -helm-unittest: setup-binaries ## Run Helm chart unittest +helm-unittest: setup-dependencies ## Run Helm chart unittest @echo "--- Running Helm chart unittest ---" @helm unittest helm/polaris @echo "--- Helm chart unittest complete ---" +helm-lint: DEPENDENCIES := ct .PHONY: helm-lint -helm-lint: setup-binaries ## Run Helm chart lint check +helm-lint: setup-dependencies ## Run Helm chart lint check @echo "--- Running Helm chart linting ---" @ct lint --charts helm/polaris @echo "--- Helm chart linting complete ---" +##@ Minikube + +minikube-start-cluster: DEPENDENCIES := minikube +.PHONY: minikube-start-cluster +minikube-start-cluster: setup-dependencies ## Start the Minikube cluster. + @echo "--- Checking Minikube cluster status ---" + @if minikube status -p minikube --format "{{.Host}}" | grep -q "Running"; then \ + echo "--- Minikube cluster is already running. Skipping start ---"; \ + else \ + echo "--- Starting Minikube cluster ---"; \ + minikube start; \ + echo "--- Minikube cluster started ---"; \ + fi + +minikube-stop-cluster: DEPENDENCIES := minikube +.PHONY: minikube-stop-cluster +minikube-stop-cluster: setup-dependencies ## Stop the Minikube cluster. + @echo "--- Checking Minikube cluster status ---" + @if minikube status -p minikube --format "{{.Host}}" | grep -q "Running"; then \ + echo "--- Stopping Minikube cluster ---"; \ + minikube stop; \ + echo "--- Minikube cluster stopped ---"; \ + else \ + echo "--- Minikube cluster is already stopped or does not exist. Skipping stop ---"; \ + fi + +minikube-load-images: DEPENDENCIES := minikube +.PHONY: minikube-load-images +minikube-load-images: minikube-start-cluster setup-dependencies ## Load local Docker images into the Minikube cluster. + @echo "--- Loading images into Minikube cluster ---" + @eval "$$(minikube docker-env)" && $(MAKE) build + @echo "--- Images loaded into Minikube cluster ---" + +minikube-cleanup: DEPENDENCIES := minikube +.PHONY: minikube-cleanup +minikube-cleanup: setup-dependencies ## Clean up and delete the Minikube cluster. + @echo "--- Checking Minikube cluster existence ---" + @if minikube profile list | grep -q "minikube"; then \ + echo "--- Deleting Minikube cluster ---"; \ + minikube delete; \ + echo "--- Minikube cluster removed ---"; \ + else \ + echo "--- Minikube cluster does not exist. Skipping cleanup ---"; \ + fi + ##@ Pre-commit .PHONY: pre-commit @@ -106,11 +158,11 @@ pre-commit: spotless-apply helm-doc-generate ## Run tasks for pre-commit ##@ Dependencies -.PHONY: setup-binaries -setup-binaries: check-brew ## Install required binaries if not present - @echo "--- Checking and installing required binaries ---" - @for bin in $(BINARIES); do \ - case $$bin in \ +.PHONY: setup-dependencies +setup-dependencies: check-brew ## Install required binaries if not present + @echo "--- Checking and installing required dependencies for this target ---" + @for dependency in $(DEPENDENCIES); do \ + case $$dependency in \ java21) \ if java -version 2>&1 | grep -q '21'; then \ :; \ @@ -138,14 +190,13 @@ setup-binaries: check-brew ## Install required binaries if not present echo "ct installed."; \ fi ;; \ *) \ - if command -v $$bin >/dev/null 2>&1; then \ + if command -v $$dependency >/dev/null 2>&1; then \ :; \ else \ - echo "$$bin is not installed. Installing with Homebrew..."; \ - brew install $$bin; \ - echo "$$bin installed."; \ + echo "$$dependency is not installed. Installing with Homebrew..."; \ + brew install $$dependency; \ + echo "$$dependency installed."; \ fi ;; \ esac; \ done - @echo "--- All required binaries checked/installed ---" - + @echo "--- All required dependencies checked/installed ---" From b1da878110710fff5c515ba18c4f14e15f91a5ac Mon Sep 17 00:00:00 2001 From: Yong Date: Sat, 12 Jul 2025 21:02:21 -0500 Subject: [PATCH 3/6] Add podman support and spark plugin build --- Makefile | 157 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 104 insertions(+), 53 deletions(-) diff --git a/Makefile b/Makefile index a36ab41cbb1..4893d797a64 100644 --- a/Makefile +++ b/Makefile @@ -22,62 +22,71 @@ SHELL = /usr/bin/env bash -o pipefail ## Variables BUILD_IMAGE ?= true -IMAGE_TAG ?= postgres-latest -DEPENDENCIES := git docker helm-docs jq java21 ct helm helm-docs kubectl minikube +CONTAINER_TOOL ?= docker +MINIKUBE_PROFILE ?= minikube +DEPENDENCIES ?= ct helm helm-docs java21 +OPTIONAL_DEPENDENCIES := jq kubectl minikube +BUILD_VERSION := $(shell ./gradlew properties | grep version: | cut -d' ' -f2) ##@ General .PHONY: help help: ## Display this help. - @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-30s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) - -.PHONY: check-brew -check-brew: - @echo "--- Checking Homebrew installation ---" - @if command -v brew >/dev/null 2>&1; then \ - echo "--- Homebrew is installed ---"; \ - else \ - echo "--- Homebrew is not installed. Aborting ---"; \ - exit 1; \ - fi + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\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) ##@ Polaris Build .PHONY: build build: build-server build-admin ## Build Polaris server, admin, and container images -build-server: DEPENDENCIES := java21 docker +build-server: DEPENDENCIES := java21 $(CONTAINER_TOOL) .PHONY: build-server -build-server: setup-dependencies ## Build Polaris server and container image +build-server: check-dependencies ## Build Polaris server and container image @echo "--- Building Polaris server ---" @./gradlew \ :polaris-server:assemble \ :polaris-server:quarkusAppPartsBuild --rerun \ - -Dquarkus.container-image.tag=$(IMAGE_TAG) \ - -Dquarkus.container-image.build=$(BUILD_IMAGE) + -Dquarkus.container-image.build=$(BUILD_IMAGE) \ + -Dquarkus.docker.executable-name=$(CONTAINER_TOOL) @echo "--- Polaris server build complete ---" -build-admin: DEPENDENCIES := java21 docker +build-admin: DEPENDENCIES := java21 $(CONTAINER_TOOL) .PHONY: build-admin -build-admin: setup-dependencies ## Build Polaris admin and container image +build-admin: check-dependencies ## Build Polaris admin and container image @echo "--- Building Polaris admin ---" @./gradlew \ :polaris-admin:assemble \ :polaris-admin:quarkusAppPartsBuild --rerun \ - -Dquarkus.container-image.tag=$(IMAGE_TAG) \ - -Dquarkus.container-image.build=$(BUILD_IMAGE) + -Dquarkus.container-image.build=$(BUILD_IMAGE) \ + -Dquarkus.docker.executable-name=$(CONTAINER_TOOL) @echo "--- Polaris admin build complete ---" +build-spark-plugin-3.5-2.12: DEPENDENCIES := java21 +.PHONY: build-spark-plugin-3.5-2.12 +build-spark-plugin-3.5-2.12: check-dependencies ## Build Spark plugin v3.5 with Scala v2.12 + @echo "--- Building Spark plugin v3.5 with Scala v2.12 ---" + @./gradlew \ + :polaris-spark-3.5_2.12:assemble + @echo "--- Spark plugin v3.5 with Scala v2.12 build complete ---" + +build-spark-plugin-3.5-2.13: DEPENDENCIES := java21 +.PHONY: build-spark-plugin-3.5-2.13 +build-spark-plugin-3.5-2.13: check-dependencies ## Build Spark plugin v3.5 with Scala v2.13 + @echo "--- Building Spark plugin v3.5 with Scala v2.13 ---" + @./gradlew \ + :polaris-spark-3.5_2.13:assemble + @echo "--- Spark plugin v3.5 with Scala v2.13 build complete ---" + build-cleanup: DEPENDENCIES := java21 .PHONY: build-cleanup -build-cleanup: setup-dependencies ## Clean build artifacts +build-cleanup: check-dependencies ## Clean build artifacts @echo "--- Cleaning up build artifacts ---" @./gradlew clean @echo "--- Build artifacts cleaned ---" spotless-apply: DEPENDENCIES := java21 .PHONY: spotless-apply -spotless-apply: setup-dependencies ## Apply code formatting using Spotless Gradle plugin. +spotless-apply: check-dependencies ## Apply code formatting using Spotless Gradle plugin. @echo "--- Applying Spotless formatting ---" @./gradlew spotlessApply @echo "--- Spotless formatting applied ---" @@ -86,7 +95,7 @@ spotless-apply: setup-dependencies ## Apply code formatting using Spotless Gradl helm-doc-generate: DEPENDENCIES := helm-docs .PHONY: helm-doc-generate -helm-doc-generate: setup-dependencies ## Generate Helm chart documentation +helm-doc-generate: check-dependencies ## Generate Helm chart documentation @echo "--- Generating Helm documentation ---" @helm-docs --chart-search-root=helm @cp helm/polaris/README.md site/content/in-dev/unreleased/helm.md @@ -94,58 +103,65 @@ helm-doc-generate: setup-dependencies ## Generate Helm chart documentation helm-unittest: DEPENDENCIES := helm .PHONY: helm-unittest -helm-unittest: setup-dependencies ## Run Helm chart unittest +helm-unittest: check-dependencies ## Run Helm chart unittest @echo "--- Running Helm chart unittest ---" @helm unittest helm/polaris @echo "--- Helm chart unittest complete ---" helm-lint: DEPENDENCIES := ct .PHONY: helm-lint -helm-lint: setup-dependencies ## Run Helm chart lint check +helm-lint: check-dependencies ## Run Helm chart lint check @echo "--- Running Helm chart linting ---" @ct lint --charts helm/polaris @echo "--- Helm chart linting complete ---" ##@ Minikube -minikube-start-cluster: DEPENDENCIES := minikube +minikube-start-cluster: DEPENDENCIES := minikube $(CONTAINER_TOOL) .PHONY: minikube-start-cluster -minikube-start-cluster: setup-dependencies ## Start the Minikube cluster. +minikube-start-cluster: check-dependencies ## Start the Minikube cluster @echo "--- Checking Minikube cluster status ---" - @if minikube status -p minikube --format "{{.Host}}" | grep -q "Running"; then \ + @if minikube status -p $(MINIKUBE_PROFILE) --format "{{.Host}}" | grep -q "Running"; then \ echo "--- Minikube cluster is already running. Skipping start ---"; \ else \ echo "--- Starting Minikube cluster ---"; \ - minikube start; \ + if [ "$(CONTAINER_TOOL)" = "podman" ]; then \ + minikube start -p $(MINIKUBE_PROFILE) --driver=$(CONTAINER_TOOL) --container-runtime=cri-o; \ + else \ + minikube start -p $(MINIKUBE_PROFILE) --driver=$(CONTAINER_TOOL); \ + fi; \ echo "--- Minikube cluster started ---"; \ fi -minikube-stop-cluster: DEPENDENCIES := minikube +minikube-stop-cluster: DEPENDENCIES := minikube $(CONTAINER_TOOL) .PHONY: minikube-stop-cluster -minikube-stop-cluster: setup-dependencies ## Stop the Minikube cluster. +minikube-stop-cluster: check-dependencies ## Stop the Minikube cluster @echo "--- Checking Minikube cluster status ---" - @if minikube status -p minikube --format "{{.Host}}" | grep -q "Running"; then \ + @if minikube status -p $(MINIKUBE_PROFILE) --format "{{.Host}}" | grep -q "Running"; then \ echo "--- Stopping Minikube cluster ---"; \ - minikube stop; \ + minikube stop -p $(MINIKUBE_PROFILE); \ echo "--- Minikube cluster stopped ---"; \ else \ echo "--- Minikube cluster is already stopped or does not exist. Skipping stop ---"; \ fi -minikube-load-images: DEPENDENCIES := minikube +minikube-load-images: DEPENDENCIES := minikube $(CONTAINER_TOOL) .PHONY: minikube-load-images -minikube-load-images: minikube-start-cluster setup-dependencies ## Load local Docker images into the Minikube cluster. +minikube-load-images: minikube-start-cluster check-dependencies ## Load local Docker images into the Minikube cluster @echo "--- Loading images into Minikube cluster ---" - @eval "$$(minikube docker-env)" && $(MAKE) build + @minikube image load -p $(MINIKUBE_PROFILE) docker.io/apache/polaris:latest + @minikube image tag -p $(MINIKUBE_PROFILE) docker.io/apache/polaris:latest docker.io/apache/polaris:$(BUILD_VERSION) + @minikube image load -p $(MINIKUBE_PROFILE) docker.io/apache/polaris-admin-tool:latest + @minikube image tag -p $(MINIKUBE_PROFILE) docker.io/apache/polaris-admin-tool:latest docker.io/apache/polaris-admin-tool:$(BUILD_VERSION) @echo "--- Images loaded into Minikube cluster ---" -minikube-cleanup: DEPENDENCIES := minikube +minikube-cleanup: DEPENDENCIES := minikube $(CONTAINER_TOOL) .PHONY: minikube-cleanup -minikube-cleanup: setup-dependencies ## Clean up and delete the Minikube cluster. - @echo "--- Checking Minikube cluster existence ---" - @if minikube profile list | grep -q "minikube"; then \ - echo "--- Deleting Minikube cluster ---"; \ - minikube delete; \ +minikube-cleanup: check-dependencies ## Cleanup the Minikube cluster + @echo "--- Checking Minikube cluster status ---" + @if minikube status -p $(MINIKUBE_PROFILE) >/dev/null 2>&1; then \ + echo "--- Cleanup Minikube cluster ---"; \ + minikube delete -p $(MINIKUBE_PROFILE); \ echo "--- Minikube cluster removed ---"; \ else \ echo "--- Minikube cluster does not exist. Skipping cleanup ---"; \ @@ -158,9 +174,42 @@ pre-commit: spotless-apply helm-doc-generate ## Run tasks for pre-commit ##@ Dependencies -.PHONY: setup-dependencies -setup-dependencies: check-brew ## Install required binaries if not present - @echo "--- Checking and installing required dependencies for this target ---" +.PHONY: check-dependencies +check-dependencies: ## Check if all requested dependencies are present + @echo "--- Checking for requested dependencies ---" + @for dependency in $(DEPENDENCIES); do \ + echo "Checking for $$dependency..."; \ + if [ "$$dependency" = "java21" ]; then \ + if java -version 2>&1 | grep -q 'openjdk version "21\.' >/dev/null 2>&1; then \ + echo "Java 21 is installed."; \ + else \ + echo "Java 21 is NOT installed."; \ + echo "--- ERROR: Dependency 'Java 21' is missing. Please install it to proceed. Exiting. ---"; \ + exit 1; \ + fi ; \ + elif command -v $$dependency >/dev/null 2>&1; then \ + echo "$$dependency is installed."; \ + else \ + echo "$$dependency is NOT installed."; \ + echo "--- ERROR: Dependency '$$dependency' is missing. Please install it to proceed. Exiting. ---"; \ + exit 1; \ + fi; \ + done + @echo "--- All checks complete. ---" + +.PHONY: check-brew +check-brew: + @echo "--- Checking Homebrew installation ---" + @if command -v brew >/dev/null 2>&1; then \ + echo "--- Homebrew is installed ---"; \ + else \ + echo "--- Homebrew is not installed. Aborting ---"; \ + exit 1; \ + fi + +.PHONY: install-dependencies-brew +install-dependencies-brew: check-brew ## Install dependencies if not present via Brew + @echo "--- Checking and installing dependencies for this target ---" @for dependency in $(DEPENDENCIES); do \ case $$dependency in \ java21) \ @@ -173,20 +222,18 @@ setup-dependencies: check-brew ## Install required binaries if not present jenv local 21; \ echo "Java 21 installed."; \ fi ;; \ - docker) \ - if command -v docker >/dev/null 2>&1; then \ + docker|podman) \ + if command -v $$dependency >/dev/null 2>&1; then \ :; \ else \ - echo "docker is not installed. Installing with Homebrew..."; \ - brew install --cask docker; \ - echo "docker installed."; \ + echo "$$dependency is not installed. Manual installation required"; \ fi ;; \ ct) \ if command -v ct >/dev/null 2>&1; then \ :; \ else \ echo "ct is not installed. Installing with Homebrew..."; \ - brew install --cask chart-testing; \ + brew install chart-testing; \ echo "ct installed."; \ fi ;; \ *) \ @@ -199,4 +246,8 @@ setup-dependencies: check-brew ## Install required binaries if not present fi ;; \ esac; \ done - @echo "--- All required dependencies checked/installed ---" + @echo "--- All requested dependencies checked/installed ---" + +install-optional-dependencies-brew: DEPENDENCIES := $(OPTIONAL_DEPENDENCIES) +.PHONY: install-optional-dependencies-brew +install-optional-dependencies-brew: install-dependencies-brew ## Install optional dependencies if not present via Brew From 3c9ad915548dcf46bf04ceb20ee0c64961ef8441 Mon Sep 17 00:00:00 2001 From: Yong Date: Sat, 12 Jul 2025 22:11:35 -0500 Subject: [PATCH 4/6] Add version target --- Makefile | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 4893d797a64..3a0589e2f03 100644 --- a/Makefile +++ b/Makefile @@ -24,16 +24,24 @@ SHELL = /usr/bin/env bash -o pipefail BUILD_IMAGE ?= true CONTAINER_TOOL ?= docker MINIKUBE_PROFILE ?= minikube -DEPENDENCIES ?= ct helm helm-docs java21 +DEPENDENCIES ?= ct helm helm-docs java21 git OPTIONAL_DEPENDENCIES := jq kubectl minikube -BUILD_VERSION := $(shell ./gradlew properties | grep version: | cut -d' ' -f2) + +## Version information +BUILD_VERSION := $(shell cat version.txt) +GIT_COMMIT := $(shell git rev-parse HEAD) ##@ General .PHONY: help -help: ## Display this help. +help: ## Display this help @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\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) +.PHONY: version +version: ## Display version information + @echo "Build version: ${BUILD_VERSION}" + @echo "Git commit: ${GIT_COMMIT}" + ##@ Polaris Build .PHONY: build @@ -180,8 +188,8 @@ check-dependencies: ## Check if all requested dependencies are present @for dependency in $(DEPENDENCIES); do \ echo "Checking for $$dependency..."; \ if [ "$$dependency" = "java21" ]; then \ - if java -version 2>&1 | grep -q 'openjdk version "21\.' >/dev/null 2>&1; then \ - echo "Java 21 is installed."; \ + if java --version | head -n1 | cut -d' ' -f2 | grep -q '^21\.'; then \ + echo "Java 21 is installed."; \ else \ echo "Java 21 is NOT installed."; \ echo "--- ERROR: Dependency 'Java 21' is missing. Please install it to proceed. Exiting. ---"; \ From 964c722447a252efb6795409f5e2130424801b5e Mon Sep 17 00:00:00 2001 From: Yong Date: Fri, 18 Jul 2025 17:01:11 -0500 Subject: [PATCH 5/6] Update README.md for Makefile usage and relation to the project --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 20b66047427..b00dbe646bc 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,25 @@ insert into db1.table1 values (1, 'a'); select * from db1.table1; ``` - `env POLARIS_HOST=localhost ./regtests/run.sh` - To run regression tests locally, see more options [here](./regtests/README.md). + +## Makefile Convenience Commands + +To streamline the developer experience, especially for common setup and build tasks, a root-level Makefile is now available. This Makefile acts as a convenient wrapper around various Gradle commands and other tooling, simplifying interactions. While Gradle remains the primary build system, the Makefile provides concise shortcuts for frequent operations like: + - Building Polaris components: e.g., `make build-server, make build-admin` + - Managing development clusters: e.g., `make minikube-start-cluster, make minikube-cleanup` + - Automating Helm tasks: e.g., `make helm-doc-generate, make helm-unittest` + - Handling dependencies: e.g., `make install-dependencies-brew` + +To see available commands: +```bash +make help +``` + +For example, to build the Polaris server and its container image, you can simply run: +```bash +make build-server +``` + ### More build and run options #### Running in Docker From e4e5edae3f32dcfa603e014254170f255b78028e Mon Sep 17 00:00:00 2001 From: Yong Date: Fri, 18 Jul 2025 17:06:07 -0500 Subject: [PATCH 6/6] Fix nit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b00dbe646bc..1296e00cb42 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ select * from db1.table1; ## Makefile Convenience Commands -To streamline the developer experience, especially for common setup and build tasks, a root-level Makefile is now available. This Makefile acts as a convenient wrapper around various Gradle commands and other tooling, simplifying interactions. While Gradle remains the primary build system, the Makefile provides concise shortcuts for frequent operations like: +To streamline the developer experience, especially for common setup and build tasks, a root-level Makefile is available. This Makefile acts as a convenient wrapper around various Gradle commands and other tooling, simplifying interactions. While Gradle remains the primary build system, the Makefile provides concise shortcuts for frequent operations like: - Building Polaris components: e.g., `make build-server, make build-admin` - Managing development clusters: e.g., `make minikube-start-cluster, make minikube-cleanup` - Automating Helm tasks: e.g., `make helm-doc-generate, make helm-unittest`