snazy commented on code in PR #2964: URL: https://github.com/apache/polaris/pull/2964#discussion_r2487309425
########## helm/polaris/build.gradle.kts: ########## @@ -0,0 +1,245 @@ +/* + * 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. + */ + +plugins { + id("base") + id("polaris-spotless") +} + +description = "Apache Polaris (incubating) Helm Chart" + +val helmTestReportsDir = layout.buildDirectory.dir("reports") + +val helmTemplateValidation by + tasks.registering(Exec::class) { + group = "verification" + description = "Run 'helm template' validation with all values files" + + workingDir = projectDir + + val outputFile = helmTestReportsDir.get().file("helm-template/validation.log") + + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + for f in values.yaml ci/*.yaml; do + echo "Validating helm template with ${'$'}f" + helm template --debug --namespace polaris-ns --values ${'$'}f . + done > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "ci/*.yaml", "templates/**/*") } + ) + + outputs.file(outputFile) + } + +val helmUnitTest by + tasks.registering(Exec::class) { + group = "verification" + description = "Run Helm unit tests" + + workingDir = projectDir + + val outputFile = helmTestReportsDir.get().file("helm-unit/test.log") + + // Install the plugin if not already installed, then run tests + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + helm plugin install https://github.com/helm-unittest/helm-unittest.git 2>/dev/null || true + helm unittest . > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "templates/**/*", "tests/**/*") } + ) + + outputs.file(outputFile) + } + +val chartTestingLint by + tasks.registering(Exec::class) { + group = "verification" + description = "Run chart-testing (lint)" + + workingDir = rootProject.projectDir + + val outputFile = helmTestReportsDir.get().file("ct/lint.log") + + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + ct lint --debug --charts ./helm/polaris > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "ci/*.yaml", "templates/**/*") } + ) + + outputs.file(outputFile) + } + +// Task to build Docker images in minikube's Docker environment +val buildMinikubeImages by + tasks.registering(Exec::class) { + group = "build" + description = "Build Polaris Docker images in minikube's Docker environment" + + workingDir = rootProject.projectDir + + // Output: file containing SHA digest of built image + val outputFile = helmTestReportsDir.get().file("minikube-images.sha256") Review Comment: Better relativize `outputFile` to `project.projectDir` (or better `this.workingDir`) here (and in other places) so the `commandLine` doesn't contain any local paths. **Within** a task configuration block, you can ```suggestion val outputFile = helmTestReportsDir.get().file("minikube-images.sha256").relativeTo(project.projectDir) ``` ########## helm/polaris/build.gradle.kts: ########## @@ -0,0 +1,245 @@ +/* + * 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. + */ + +plugins { + id("base") + id("polaris-spotless") +} + +description = "Apache Polaris (incubating) Helm Chart" + +val helmTestReportsDir = layout.buildDirectory.dir("reports") + Review Comment: ```suggestion val runtimeServerDistribution by configurations.registering { isCanBeConsumed = true isCanBeResolved = false } dependencies { runtimeServerDistribution(project(":polaris-server", "distributionElements")) } ``` ########## helm/polaris/build.gradle.kts: ########## @@ -0,0 +1,245 @@ +/* + * 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. + */ + +plugins { + id("base") + id("polaris-spotless") +} + +description = "Apache Polaris (incubating) Helm Chart" + +val helmTestReportsDir = layout.buildDirectory.dir("reports") + +val helmTemplateValidation by + tasks.registering(Exec::class) { + group = "verification" + description = "Run 'helm template' validation with all values files" + + workingDir = projectDir + + val outputFile = helmTestReportsDir.get().file("helm-template/validation.log") + + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + for f in values.yaml ci/*.yaml; do + echo "Validating helm template with ${'$'}f" + helm template --debug --namespace polaris-ns --values ${'$'}f . + done > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "ci/*.yaml", "templates/**/*") } + ) + + outputs.file(outputFile) + } + +val helmUnitTest by + tasks.registering(Exec::class) { + group = "verification" + description = "Run Helm unit tests" + + workingDir = projectDir + + val outputFile = helmTestReportsDir.get().file("helm-unit/test.log") + + // Install the plugin if not already installed, then run tests + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + helm plugin install https://github.com/helm-unittest/helm-unittest.git 2>/dev/null || true + helm unittest . > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "templates/**/*", "tests/**/*") } + ) + + outputs.file(outputFile) + } + +val chartTestingLint by + tasks.registering(Exec::class) { + group = "verification" + description = "Run chart-testing (lint)" + + workingDir = rootProject.projectDir + + val outputFile = helmTestReportsDir.get().file("ct/lint.log") + + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + ct lint --debug --charts ./helm/polaris > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "ci/*.yaml", "templates/**/*") } + ) + + outputs.file(outputFile) + } + +// Task to build Docker images in minikube's Docker environment +val buildMinikubeImages by + tasks.registering(Exec::class) { + group = "build" + description = "Build Polaris Docker images in minikube's Docker environment" + + workingDir = rootProject.projectDir + + // Output: file containing SHA digest of built image + val outputFile = helmTestReportsDir.get().file("minikube-images.sha256") + + commandLine = + listOf( + "sh", + "-c", + """ + # Check if minikube is running + if ! minikube status >/dev/null 2>&1; then + echo "Minikube is not running. Starting minikube..." + minikube start + fi + + # Set up docker environment and build images + eval $(minikube -p minikube docker-env) + + # Build server image + docker build -t apache/polaris:latest \ + -f runtime/server/src/main/docker/Dockerfile.jvm \ + runtime/server + + # Capture image digest + mkdir -p ${outputFile.asFile.parent} + { + docker inspect --format='{{.Id}}' apache/polaris:latest + } > ${outputFile.asFile} + """ + .trimIndent(), + ) + + dependsOn(":polaris-server:quarkusBuild") + + inputs.dir(rootProject.file("runtime/server/build/quarkus-app")) + inputs.file(rootProject.file("runtime/server/src/main/docker/Dockerfile.jvm")) + + outputs.file(outputFile) + } + +// Task to run chart-testing install on minikube +val chartTestingInstall by + tasks.registering(Exec::class) { + group = "verification" + description = "Run chart-testing (install) on minikube" + + workingDir = rootProject.projectDir + + val outputFile = helmTestReportsDir.get().file("ct/install.log") + + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + + # Create namespace if it doesn't exist + kubectl create namespace polaris-ns --dry-run=client -o yaml | kubectl apply -f - + + # Install fixtures + kubectl apply --namespace polaris-ns -f helm/polaris/ci/fixtures + + # Run chart-testing install + ct install \ + --namespace polaris-ns \ + --debug --charts ./helm/polaris > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( Review Comment: I guess this is needed as well: ```suggestion inputs.files(runtimeServerDistribution) inputs.files( ``` ########## helm/polaris/build.gradle.kts: ########## @@ -0,0 +1,245 @@ +/* + * 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. + */ + +plugins { + id("base") + id("polaris-spotless") +} + +description = "Apache Polaris (incubating) Helm Chart" + +val helmTestReportsDir = layout.buildDirectory.dir("reports") + +val helmTemplateValidation by + tasks.registering(Exec::class) { + group = "verification" + description = "Run 'helm template' validation with all values files" + + workingDir = projectDir + + val outputFile = helmTestReportsDir.get().file("helm-template/validation.log") + + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + for f in values.yaml ci/*.yaml; do + echo "Validating helm template with ${'$'}f" + helm template --debug --namespace polaris-ns --values ${'$'}f . + done > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "ci/*.yaml", "templates/**/*") } + ) + + outputs.file(outputFile) + } + +val helmUnitTest by + tasks.registering(Exec::class) { + group = "verification" + description = "Run Helm unit tests" + + workingDir = projectDir Review Comment: ```suggestion ``` ########## helm/polaris/build.gradle.kts: ########## @@ -0,0 +1,245 @@ +/* + * 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. + */ + +plugins { + id("base") + id("polaris-spotless") +} + +description = "Apache Polaris (incubating) Helm Chart" + +val helmTestReportsDir = layout.buildDirectory.dir("reports") + +val helmTemplateValidation by + tasks.registering(Exec::class) { + group = "verification" + description = "Run 'helm template' validation with all values files" + + workingDir = projectDir + + val outputFile = helmTestReportsDir.get().file("helm-template/validation.log") + + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + for f in values.yaml ci/*.yaml; do + echo "Validating helm template with ${'$'}f" + helm template --debug --namespace polaris-ns --values ${'$'}f . + done > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "ci/*.yaml", "templates/**/*") } + ) + + outputs.file(outputFile) + } + +val helmUnitTest by + tasks.registering(Exec::class) { + group = "verification" + description = "Run Helm unit tests" + + workingDir = projectDir + + val outputFile = helmTestReportsDir.get().file("helm-unit/test.log") + + // Install the plugin if not already installed, then run tests + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + helm plugin install https://github.com/helm-unittest/helm-unittest.git 2>/dev/null || true + helm unittest . > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "templates/**/*", "tests/**/*") } + ) + + outputs.file(outputFile) + } + +val chartTestingLint by + tasks.registering(Exec::class) { + group = "verification" + description = "Run chart-testing (lint)" + + workingDir = rootProject.projectDir + + val outputFile = helmTestReportsDir.get().file("ct/lint.log") + + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + ct lint --debug --charts ./helm/polaris > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "ci/*.yaml", "templates/**/*") } + ) + + outputs.file(outputFile) + } + +// Task to build Docker images in minikube's Docker environment +val buildMinikubeImages by + tasks.registering(Exec::class) { + group = "build" + description = "Build Polaris Docker images in minikube's Docker environment" + + workingDir = rootProject.projectDir + + // Output: file containing SHA digest of built image + val outputFile = helmTestReportsDir.get().file("minikube-images.sha256") + + commandLine = + listOf( + "sh", + "-c", + """ + # Check if minikube is running + if ! minikube status >/dev/null 2>&1; then + echo "Minikube is not running. Starting minikube..." + minikube start + fi + + # Set up docker environment and build images + eval $(minikube -p minikube docker-env) + + # Build server image + docker build -t apache/polaris:latest \ + -f runtime/server/src/main/docker/Dockerfile.jvm \ + runtime/server + + # Capture image digest + mkdir -p ${outputFile.asFile.parent} + { + docker inspect --format='{{.Id}}' apache/polaris:latest + } > ${outputFile.asFile} + """ + .trimIndent(), + ) + + dependsOn(":polaris-server:quarkusBuild") + + inputs.dir(rootProject.file("runtime/server/build/quarkus-app")) + inputs.file(rootProject.file("runtime/server/src/main/docker/Dockerfile.jvm")) + + outputs.file(outputFile) + } + +// Task to run chart-testing install on minikube +val chartTestingInstall by + tasks.registering(Exec::class) { + group = "verification" + description = "Run chart-testing (install) on minikube" + + workingDir = rootProject.projectDir + + val outputFile = helmTestReportsDir.get().file("ct/install.log") + + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + + # Create namespace if it doesn't exist + kubectl create namespace polaris-ns --dry-run=client -o yaml | kubectl apply -f - + + # Install fixtures + kubectl apply --namespace polaris-ns -f helm/polaris/ci/fixtures + + # Run chart-testing install + ct install \ + --namespace polaris-ns \ + --debug --charts ./helm/polaris > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "ci/**/*", "templates/**/*") } + ) + + outputs.file(outputFile) Review Comment: The cached outputs are (hopefully) relatively small-ish, compared to the execution time of these tasks. ########## helm/polaris/build.gradle.kts: ########## @@ -0,0 +1,245 @@ +/* + * 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. + */ + +plugins { + id("base") + id("polaris-spotless") +} + +description = "Apache Polaris (incubating) Helm Chart" + +val helmTestReportsDir = layout.buildDirectory.dir("reports") + +val helmTemplateValidation by + tasks.registering(Exec::class) { + group = "verification" + description = "Run 'helm template' validation with all values files" + + workingDir = projectDir + + val outputFile = helmTestReportsDir.get().file("helm-template/validation.log") + + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + for f in values.yaml ci/*.yaml; do + echo "Validating helm template with ${'$'}f" + helm template --debug --namespace polaris-ns --values ${'$'}f . + done > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "ci/*.yaml", "templates/**/*") } + ) + + outputs.file(outputFile) + } + +val helmUnitTest by + tasks.registering(Exec::class) { + group = "verification" + description = "Run Helm unit tests" + + workingDir = projectDir + + val outputFile = helmTestReportsDir.get().file("helm-unit/test.log") + + // Install the plugin if not already installed, then run tests + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + helm plugin install https://github.com/helm-unittest/helm-unittest.git 2>/dev/null || true + helm unittest . > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "templates/**/*", "tests/**/*") } + ) + + outputs.file(outputFile) + } + +val chartTestingLint by + tasks.registering(Exec::class) { + group = "verification" + description = "Run chart-testing (lint)" + + workingDir = rootProject.projectDir + + val outputFile = helmTestReportsDir.get().file("ct/lint.log") + + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + ct lint --debug --charts ./helm/polaris > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "ci/*.yaml", "templates/**/*") } + ) + + outputs.file(outputFile) + } + +// Task to build Docker images in minikube's Docker environment +val buildMinikubeImages by + tasks.registering(Exec::class) { + group = "build" + description = "Build Polaris Docker images in minikube's Docker environment" + + workingDir = rootProject.projectDir + + // Output: file containing SHA digest of built image + val outputFile = helmTestReportsDir.get().file("minikube-images.sha256") + + commandLine = + listOf( + "sh", + "-c", + """ + # Check if minikube is running + if ! minikube status >/dev/null 2>&1; then + echo "Minikube is not running. Starting minikube..." + minikube start + fi + + # Set up docker environment and build images + eval $(minikube -p minikube docker-env) + + # Build server image + docker build -t apache/polaris:latest \ + -f runtime/server/src/main/docker/Dockerfile.jvm \ + runtime/server + + # Capture image digest + mkdir -p ${outputFile.asFile.parent} + { + docker inspect --format='{{.Id}}' apache/polaris:latest + } > ${outputFile.asFile} + """ + .trimIndent(), + ) + + dependsOn(":polaris-server:quarkusBuild") + + inputs.dir(rootProject.file("runtime/server/build/quarkus-app")) + inputs.file(rootProject.file("runtime/server/src/main/docker/Dockerfile.jvm")) + + outputs.file(outputFile) + } + +// Task to run chart-testing install on minikube +val chartTestingInstall by + tasks.registering(Exec::class) { + group = "verification" + description = "Run chart-testing (install) on minikube" + + workingDir = rootProject.projectDir + + val outputFile = helmTestReportsDir.get().file("ct/install.log") + + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + + # Create namespace if it doesn't exist + kubectl create namespace polaris-ns --dry-run=client -o yaml | kubectl apply -f - + + # Install fixtures + kubectl apply --namespace polaris-ns -f helm/polaris/ci/fixtures + + # Run chart-testing install + ct install \ + --namespace polaris-ns \ + --debug --charts ./helm/polaris > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "ci/**/*", "templates/**/*") } + ) + + outputs.file(outputFile) + + // Depend on the images being built in minikube + dependsOn(buildMinikubeImages) + } + +// Task to generate helm documentation +val helmDocs by + tasks.registering(Exec::class) { + group = "documentation" + description = "Generate Helm chart documentation using helm-docs" + + workingDir = rootProject.projectDir + + commandLine = + listOf( + "sh", + "-c", + """ + helm-docs --chart-search-root=helm + """ + .trimIndent(), + ) + + inputs.files(fileTree(projectDir) { include("Chart.yaml", "values.yaml", "README.md.gotmpl") }) + + outputs.file(projectDir.resolve("README.md")) + } + +val test by + tasks.registering { + group = "verification" + description = "Run all Helm chart tests" + dependsOn(helmTemplateValidation, helmUnitTest, chartTestingLint) + } + +val intTest by + tasks.registering { + group = "verification" + description = "Run Helm chart integration tests on minikube" + dependsOn(chartTestingInstall) + } + +tasks.named("check") { dependsOn(test) } Review Comment: `check` is expected to exercise checks ```suggestion tasks.named("check") { dependsOn(test, intTest) } ``` ########## helm/polaris/build.gradle.kts: ########## @@ -0,0 +1,245 @@ +/* + * 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. + */ + +plugins { + id("base") + id("polaris-spotless") +} + +description = "Apache Polaris (incubating) Helm Chart" + +val helmTestReportsDir = layout.buildDirectory.dir("reports") + +val helmTemplateValidation by + tasks.registering(Exec::class) { + group = "verification" + description = "Run 'helm template' validation with all values files" + + workingDir = projectDir + + val outputFile = helmTestReportsDir.get().file("helm-template/validation.log") + + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + for f in values.yaml ci/*.yaml; do + echo "Validating helm template with ${'$'}f" + helm template --debug --namespace polaris-ns --values ${'$'}f . + done > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "ci/*.yaml", "templates/**/*") } + ) + + outputs.file(outputFile) + } + +val helmUnitTest by + tasks.registering(Exec::class) { + group = "verification" + description = "Run Helm unit tests" + + workingDir = projectDir + + val outputFile = helmTestReportsDir.get().file("helm-unit/test.log") + + // Install the plugin if not already installed, then run tests + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + helm plugin install https://github.com/helm-unittest/helm-unittest.git 2>/dev/null || true + helm unittest . > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "templates/**/*", "tests/**/*") } + ) + + outputs.file(outputFile) + } + +val chartTestingLint by + tasks.registering(Exec::class) { + group = "verification" + description = "Run chart-testing (lint)" + + workingDir = rootProject.projectDir + + val outputFile = helmTestReportsDir.get().file("ct/lint.log") + + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + ct lint --debug --charts ./helm/polaris > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "ci/*.yaml", "templates/**/*") } + ) + + outputs.file(outputFile) + } + +// Task to build Docker images in minikube's Docker environment +val buildMinikubeImages by + tasks.registering(Exec::class) { + group = "build" + description = "Build Polaris Docker images in minikube's Docker environment" + + workingDir = rootProject.projectDir + + // Output: file containing SHA digest of built image + val outputFile = helmTestReportsDir.get().file("minikube-images.sha256") + + commandLine = + listOf( + "sh", + "-c", + """ + # Check if minikube is running + if ! minikube status >/dev/null 2>&1; then + echo "Minikube is not running. Starting minikube..." + minikube start + fi + + # Set up docker environment and build images + eval $(minikube -p minikube docker-env) + + # Build server image + docker build -t apache/polaris:latest \ + -f runtime/server/src/main/docker/Dockerfile.jvm \ + runtime/server + + # Capture image digest + mkdir -p ${outputFile.asFile.parent} + { + docker inspect --format='{{.Id}}' apache/polaris:latest + } > ${outputFile.asFile} + """ + .trimIndent(), + ) + + dependsOn(":polaris-server:quarkusBuild") + + inputs.dir(rootProject.file("runtime/server/build/quarkus-app")) + inputs.file(rootProject.file("runtime/server/src/main/docker/Dockerfile.jvm")) + + outputs.file(outputFile) + } + +// Task to run chart-testing install on minikube +val chartTestingInstall by + tasks.registering(Exec::class) { + group = "verification" + description = "Run chart-testing (install) on minikube" + + workingDir = rootProject.projectDir + + val outputFile = helmTestReportsDir.get().file("ct/install.log") + + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + + # Create namespace if it doesn't exist + kubectl create namespace polaris-ns --dry-run=client -o yaml | kubectl apply -f - + + # Install fixtures + kubectl apply --namespace polaris-ns -f helm/polaris/ci/fixtures + + # Run chart-testing install + ct install \ + --namespace polaris-ns \ + --debug --charts ./helm/polaris > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "ci/**/*", "templates/**/*") } + ) + + outputs.file(outputFile) + + // Depend on the images being built in minikube + dependsOn(buildMinikubeImages) + } + +// Task to generate helm documentation +val helmDocs by + tasks.registering(Exec::class) { + group = "documentation" + description = "Generate Helm chart documentation using helm-docs" + + workingDir = rootProject.projectDir + + commandLine = + listOf( + "sh", + "-c", + """ + helm-docs --chart-search-root=helm + """ + .trimIndent(), + ) + + inputs.files(fileTree(projectDir) { include("Chart.yaml", "values.yaml", "README.md.gotmpl") }) + + outputs.file(projectDir.resolve("README.md")) + } + +val test by + tasks.registering { + group = "verification" + description = "Run all Helm chart tests" + dependsOn(helmTemplateValidation, helmUnitTest, chartTestingLint) + } + +val intTest by + tasks.registering { + group = "verification" + description = "Run Helm chart integration tests on minikube" + dependsOn(chartTestingInstall) + } + +tasks.named("check") { dependsOn(test) } + +tasks.named("build") { + dependsOn(intTest) + dependsOn(helmDocs) +} Review Comment: ```suggestion tasks.named("assemble") { dependsOn(helmDocs) } ``` ########## helm/polaris/build.gradle.kts: ########## @@ -0,0 +1,245 @@ +/* + * 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. + */ + +plugins { + id("base") + id("polaris-spotless") +} + +description = "Apache Polaris (incubating) Helm Chart" + +val helmTestReportsDir = layout.buildDirectory.dir("reports") + +val helmTemplateValidation by + tasks.registering(Exec::class) { + group = "verification" + description = "Run 'helm template' validation with all values files" + + workingDir = projectDir + + val outputFile = helmTestReportsDir.get().file("helm-template/validation.log") + + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + for f in values.yaml ci/*.yaml; do + echo "Validating helm template with ${'$'}f" + helm template --debug --namespace polaris-ns --values ${'$'}f . + done > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "ci/*.yaml", "templates/**/*") } + ) + + outputs.file(outputFile) + } + +val helmUnitTest by + tasks.registering(Exec::class) { + group = "verification" + description = "Run Helm unit tests" + + workingDir = projectDir + + val outputFile = helmTestReportsDir.get().file("helm-unit/test.log") + + // Install the plugin if not already installed, then run tests + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + helm plugin install https://github.com/helm-unittest/helm-unittest.git 2>/dev/null || true + helm unittest . > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( Review Comment: Not sure, but if the helm unit tests require the server, better add: ```suggestion inputs.files(runtimeServerDistribution) inputs.files( ``` ########## helm/polaris/build.gradle.kts: ########## @@ -0,0 +1,245 @@ +/* + * 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. + */ + +plugins { + id("base") + id("polaris-spotless") +} + +description = "Apache Polaris (incubating) Helm Chart" + +val helmTestReportsDir = layout.buildDirectory.dir("reports") + +val helmTemplateValidation by + tasks.registering(Exec::class) { + group = "verification" + description = "Run 'helm template' validation with all values files" + + workingDir = projectDir + + val outputFile = helmTestReportsDir.get().file("helm-template/validation.log") + + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + for f in values.yaml ci/*.yaml; do + echo "Validating helm template with ${'$'}f" + helm template --debug --namespace polaris-ns --values ${'$'}f . + done > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( Review Comment: ```suggestion inputs.files(runtimeServerDistribution) inputs.files( ``` ########## helm/polaris/build.gradle.kts: ########## @@ -0,0 +1,245 @@ +/* + * 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. + */ + +plugins { + id("base") + id("polaris-spotless") +} + +description = "Apache Polaris (incubating) Helm Chart" + +val helmTestReportsDir = layout.buildDirectory.dir("reports") + +val helmTemplateValidation by + tasks.registering(Exec::class) { + group = "verification" + description = "Run 'helm template' validation with all values files" + + workingDir = projectDir + + val outputFile = helmTestReportsDir.get().file("helm-template/validation.log") + + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + for f in values.yaml ci/*.yaml; do + echo "Validating helm template with ${'$'}f" + helm template --debug --namespace polaris-ns --values ${'$'}f . + done > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "ci/*.yaml", "templates/**/*") } + ) + + outputs.file(outputFile) + } + +val helmUnitTest by + tasks.registering(Exec::class) { + group = "verification" + description = "Run Helm unit tests" + + workingDir = projectDir + + val outputFile = helmTestReportsDir.get().file("helm-unit/test.log") + + // Install the plugin if not already installed, then run tests + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + helm plugin install https://github.com/helm-unittest/helm-unittest.git 2>/dev/null || true + helm unittest . > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "templates/**/*", "tests/**/*") } + ) + + outputs.file(outputFile) + } + +val chartTestingLint by + tasks.registering(Exec::class) { + group = "verification" + description = "Run chart-testing (lint)" + + workingDir = rootProject.projectDir + + val outputFile = helmTestReportsDir.get().file("ct/lint.log") + + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + ct lint --debug --charts ./helm/polaris > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "ci/*.yaml", "templates/**/*") } + ) + + outputs.file(outputFile) + } + +// Task to build Docker images in minikube's Docker environment +val buildMinikubeImages by + tasks.registering(Exec::class) { + group = "build" + description = "Build Polaris Docker images in minikube's Docker environment" + + workingDir = rootProject.projectDir + + // Output: file containing SHA digest of built image + val outputFile = helmTestReportsDir.get().file("minikube-images.sha256") + + commandLine = + listOf( + "sh", + "-c", + """ + # Check if minikube is running + if ! minikube status >/dev/null 2>&1; then + echo "Minikube is not running. Starting minikube..." + minikube start + fi + + # Set up docker environment and build images + eval $(minikube -p minikube docker-env) + + # Build server image + docker build -t apache/polaris:latest \ + -f runtime/server/src/main/docker/Dockerfile.jvm \ + runtime/server + + # Capture image digest + mkdir -p ${outputFile.asFile.parent} + { + docker inspect --format='{{.Id}}' apache/polaris:latest + } > ${outputFile.asFile} + """ + .trimIndent(), + ) + + dependsOn(":polaris-server:quarkusBuild") + + inputs.dir(rootProject.file("runtime/server/build/quarkus-app")) + inputs.file(rootProject.file("runtime/server/src/main/docker/Dockerfile.jvm")) Review Comment: Hm - better use another Gradle configuration pair. Referencing other projects leads to issues. ########## helm/polaris/build.gradle.kts: ########## @@ -0,0 +1,245 @@ +/* + * 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. + */ + +plugins { + id("base") + id("polaris-spotless") +} + +description = "Apache Polaris (incubating) Helm Chart" + +val helmTestReportsDir = layout.buildDirectory.dir("reports") + +val helmTemplateValidation by + tasks.registering(Exec::class) { + group = "verification" + description = "Run 'helm template' validation with all values files" + + workingDir = projectDir + + val outputFile = helmTestReportsDir.get().file("helm-template/validation.log") + + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + for f in values.yaml ci/*.yaml; do + echo "Validating helm template with ${'$'}f" + helm template --debug --namespace polaris-ns --values ${'$'}f . + done > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "ci/*.yaml", "templates/**/*") } + ) + + outputs.file(outputFile) + } + +val helmUnitTest by + tasks.registering(Exec::class) { + group = "verification" + description = "Run Helm unit tests" + + workingDir = projectDir + + val outputFile = helmTestReportsDir.get().file("helm-unit/test.log") + + // Install the plugin if not already installed, then run tests + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + helm plugin install https://github.com/helm-unittest/helm-unittest.git 2>/dev/null || true + helm unittest . > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "templates/**/*", "tests/**/*") } + ) + + outputs.file(outputFile) + } + +val chartTestingLint by + tasks.registering(Exec::class) { + group = "verification" + description = "Run chart-testing (lint)" + + workingDir = rootProject.projectDir + + val outputFile = helmTestReportsDir.get().file("ct/lint.log") + + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + ct lint --debug --charts ./helm/polaris > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "ci/*.yaml", "templates/**/*") } + ) + + outputs.file(outputFile) + } + +// Task to build Docker images in minikube's Docker environment +val buildMinikubeImages by + tasks.registering(Exec::class) { + group = "build" + description = "Build Polaris Docker images in minikube's Docker environment" + + workingDir = rootProject.projectDir + + // Output: file containing SHA digest of built image + val outputFile = helmTestReportsDir.get().file("minikube-images.sha256") + + commandLine = + listOf( + "sh", + "-c", + """ + # Check if minikube is running + if ! minikube status >/dev/null 2>&1; then + echo "Minikube is not running. Starting minikube..." + minikube start + fi + + # Set up docker environment and build images + eval $(minikube -p minikube docker-env) + + # Build server image + docker build -t apache/polaris:latest \ + -f runtime/server/src/main/docker/Dockerfile.jvm \ + runtime/server + + # Capture image digest + mkdir -p ${outputFile.asFile.parent} + { + docker inspect --format='{{.Id}}' apache/polaris:latest + } > ${outputFile.asFile} + """ + .trimIndent(), + ) + + dependsOn(":polaris-server:quarkusBuild") + + inputs.dir(rootProject.file("runtime/server/build/quarkus-app")) Review Comment: Use the approach from above. ########## helm/polaris/build.gradle.kts: ########## @@ -0,0 +1,245 @@ +/* + * 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. + */ + +plugins { + id("base") + id("polaris-spotless") +} + +description = "Apache Polaris (incubating) Helm Chart" + +val helmTestReportsDir = layout.buildDirectory.dir("reports") + +val helmTemplateValidation by + tasks.registering(Exec::class) { + group = "verification" + description = "Run 'helm template' validation with all values files" + + workingDir = projectDir Review Comment: Not needed (project directory is the default) ########## helm/polaris/build.gradle.kts: ########## @@ -0,0 +1,245 @@ +/* + * 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. + */ + +plugins { + id("base") + id("polaris-spotless") +} + +description = "Apache Polaris (incubating) Helm Chart" + +val helmTestReportsDir = layout.buildDirectory.dir("reports") + +val helmTemplateValidation by + tasks.registering(Exec::class) { + group = "verification" + description = "Run 'helm template' validation with all values files" + + workingDir = projectDir + + val outputFile = helmTestReportsDir.get().file("helm-template/validation.log") + + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + for f in values.yaml ci/*.yaml; do + echo "Validating helm template with ${'$'}f" + helm template --debug --namespace polaris-ns --values ${'$'}f . + done > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "ci/*.yaml", "templates/**/*") } + ) + + outputs.file(outputFile) + } + +val helmUnitTest by + tasks.registering(Exec::class) { + group = "verification" + description = "Run Helm unit tests" + + workingDir = projectDir + + val outputFile = helmTestReportsDir.get().file("helm-unit/test.log") + + // Install the plugin if not already installed, then run tests + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + helm plugin install https://github.com/helm-unittest/helm-unittest.git 2>/dev/null || true + helm unittest . > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "templates/**/*", "tests/**/*") } + ) + + outputs.file(outputFile) + } + +val chartTestingLint by + tasks.registering(Exec::class) { + group = "verification" + description = "Run chart-testing (lint)" + + workingDir = rootProject.projectDir + + val outputFile = helmTestReportsDir.get().file("ct/lint.log") + + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + ct lint --debug --charts ./helm/polaris > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "ci/*.yaml", "templates/**/*") } + ) + + outputs.file(outputFile) + } + +// Task to build Docker images in minikube's Docker environment +val buildMinikubeImages by + tasks.registering(Exec::class) { + group = "build" + description = "Build Polaris Docker images in minikube's Docker environment" + + workingDir = rootProject.projectDir Review Comment: Hm, can't it run from the project directory? ########## helm/polaris/build.gradle.kts: ########## @@ -0,0 +1,245 @@ +/* + * 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. + */ + +plugins { + id("base") + id("polaris-spotless") +} + +description = "Apache Polaris (incubating) Helm Chart" + +val helmTestReportsDir = layout.buildDirectory.dir("reports") + +val helmTemplateValidation by + tasks.registering(Exec::class) { + group = "verification" + description = "Run 'helm template' validation with all values files" + + workingDir = projectDir + + val outputFile = helmTestReportsDir.get().file("helm-template/validation.log") + + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + for f in values.yaml ci/*.yaml; do + echo "Validating helm template with ${'$'}f" + helm template --debug --namespace polaris-ns --values ${'$'}f . + done > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "ci/*.yaml", "templates/**/*") } + ) + + outputs.file(outputFile) + } + +val helmUnitTest by + tasks.registering(Exec::class) { + group = "verification" + description = "Run Helm unit tests" + + workingDir = projectDir + + val outputFile = helmTestReportsDir.get().file("helm-unit/test.log") + + // Install the plugin if not already installed, then run tests + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + helm plugin install https://github.com/helm-unittest/helm-unittest.git 2>/dev/null || true + helm unittest . > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "templates/**/*", "tests/**/*") } + ) + + outputs.file(outputFile) + } + +val chartTestingLint by + tasks.registering(Exec::class) { + group = "verification" + description = "Run chart-testing (lint)" + + workingDir = rootProject.projectDir + + val outputFile = helmTestReportsDir.get().file("ct/lint.log") + + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + ct lint --debug --charts ./helm/polaris > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "ci/*.yaml", "templates/**/*") } + ) + + outputs.file(outputFile) + } + +// Task to build Docker images in minikube's Docker environment +val buildMinikubeImages by + tasks.registering(Exec::class) { + group = "build" + description = "Build Polaris Docker images in minikube's Docker environment" + + workingDir = rootProject.projectDir + + // Output: file containing SHA digest of built image + val outputFile = helmTestReportsDir.get().file("minikube-images.sha256") + + commandLine = + listOf( + "sh", + "-c", + """ + # Check if minikube is running + if ! minikube status >/dev/null 2>&1; then + echo "Minikube is not running. Starting minikube..." + minikube start + fi + + # Set up docker environment and build images + eval $(minikube -p minikube docker-env) + + # Build server image + docker build -t apache/polaris:latest \ + -f runtime/server/src/main/docker/Dockerfile.jvm \ + runtime/server + + # Capture image digest + mkdir -p ${outputFile.asFile.parent} + { + docker inspect --format='{{.Id}}' apache/polaris:latest + } > ${outputFile.asFile} + """ + .trimIndent(), + ) + + dependsOn(":polaris-server:quarkusBuild") + + inputs.dir(rootProject.file("runtime/server/build/quarkus-app")) + inputs.file(rootProject.file("runtime/server/src/main/docker/Dockerfile.jvm")) + + outputs.file(outputFile) + } + +// Task to run chart-testing install on minikube +val chartTestingInstall by + tasks.registering(Exec::class) { + group = "verification" + description = "Run chart-testing (install) on minikube" + + workingDir = rootProject.projectDir Review Comment: Hm, can't it run from the project directory? ########## helm/polaris/build.gradle.kts: ########## @@ -0,0 +1,245 @@ +/* + * 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. + */ + +plugins { + id("base") + id("polaris-spotless") +} + +description = "Apache Polaris (incubating) Helm Chart" + +val helmTestReportsDir = layout.buildDirectory.dir("reports") + +val helmTemplateValidation by + tasks.registering(Exec::class) { + group = "verification" + description = "Run 'helm template' validation with all values files" + + workingDir = projectDir + + val outputFile = helmTestReportsDir.get().file("helm-template/validation.log") + + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + for f in values.yaml ci/*.yaml; do + echo "Validating helm template with ${'$'}f" + helm template --debug --namespace polaris-ns --values ${'$'}f . + done > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "ci/*.yaml", "templates/**/*") } + ) + + outputs.file(outputFile) + } + +val helmUnitTest by + tasks.registering(Exec::class) { + group = "verification" + description = "Run Helm unit tests" + + workingDir = projectDir + + val outputFile = helmTestReportsDir.get().file("helm-unit/test.log") + + // Install the plugin if not already installed, then run tests + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + helm plugin install https://github.com/helm-unittest/helm-unittest.git 2>/dev/null || true + helm unittest . > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "templates/**/*", "tests/**/*") } + ) + + outputs.file(outputFile) + } + +val chartTestingLint by + tasks.registering(Exec::class) { + group = "verification" + description = "Run chart-testing (lint)" + + workingDir = rootProject.projectDir + + val outputFile = helmTestReportsDir.get().file("ct/lint.log") + + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + ct lint --debug --charts ./helm/polaris > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "ci/*.yaml", "templates/**/*") } + ) + + outputs.file(outputFile) + } + +// Task to build Docker images in minikube's Docker environment +val buildMinikubeImages by + tasks.registering(Exec::class) { + group = "build" + description = "Build Polaris Docker images in minikube's Docker environment" + + workingDir = rootProject.projectDir + + // Output: file containing SHA digest of built image + val outputFile = helmTestReportsDir.get().file("minikube-images.sha256") + + commandLine = + listOf( + "sh", + "-c", + """ + # Check if minikube is running + if ! minikube status >/dev/null 2>&1; then + echo "Minikube is not running. Starting minikube..." + minikube start + fi + + # Set up docker environment and build images + eval $(minikube -p minikube docker-env) + + # Build server image + docker build -t apache/polaris:latest \ + -f runtime/server/src/main/docker/Dockerfile.jvm \ + runtime/server + + # Capture image digest + mkdir -p ${outputFile.asFile.parent} + { + docker inspect --format='{{.Id}}' apache/polaris:latest + } > ${outputFile.asFile} + """ + .trimIndent(), + ) + + dependsOn(":polaris-server:quarkusBuild") + + inputs.dir(rootProject.file("runtime/server/build/quarkus-app")) + inputs.file(rootProject.file("runtime/server/src/main/docker/Dockerfile.jvm")) + + outputs.file(outputFile) + } + +// Task to run chart-testing install on minikube +val chartTestingInstall by + tasks.registering(Exec::class) { + group = "verification" + description = "Run chart-testing (install) on minikube" + + workingDir = rootProject.projectDir + + val outputFile = helmTestReportsDir.get().file("ct/install.log") + + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + + # Create namespace if it doesn't exist + kubectl create namespace polaris-ns --dry-run=client -o yaml | kubectl apply -f - + + # Install fixtures + kubectl apply --namespace polaris-ns -f helm/polaris/ci/fixtures + + # Run chart-testing install + ct install \ + --namespace polaris-ns \ + --debug --charts ./helm/polaris > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "ci/**/*", "templates/**/*") } + ) + + outputs.file(outputFile) + + // Depend on the images being built in minikube + dependsOn(buildMinikubeImages) + } + +// Task to generate helm documentation +val helmDocs by + tasks.registering(Exec::class) { + group = "documentation" + description = "Generate Helm chart documentation using helm-docs" + + workingDir = rootProject.projectDir Review Comment: ```suggestion ``` ########## helm/polaris/build.gradle.kts: ########## @@ -0,0 +1,245 @@ +/* + * 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. + */ + +plugins { + id("base") + id("polaris-spotless") +} + +description = "Apache Polaris (incubating) Helm Chart" + +val helmTestReportsDir = layout.buildDirectory.dir("reports") + +val helmTemplateValidation by + tasks.registering(Exec::class) { + group = "verification" + description = "Run 'helm template' validation with all values files" + + workingDir = projectDir + + val outputFile = helmTestReportsDir.get().file("helm-template/validation.log") + + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + for f in values.yaml ci/*.yaml; do + echo "Validating helm template with ${'$'}f" + helm template --debug --namespace polaris-ns --values ${'$'}f . + done > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "ci/*.yaml", "templates/**/*") } + ) + + outputs.file(outputFile) + } + +val helmUnitTest by + tasks.registering(Exec::class) { + group = "verification" + description = "Run Helm unit tests" + + workingDir = projectDir + + val outputFile = helmTestReportsDir.get().file("helm-unit/test.log") + + // Install the plugin if not already installed, then run tests + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + helm plugin install https://github.com/helm-unittest/helm-unittest.git 2>/dev/null || true + helm unittest . > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "templates/**/*", "tests/**/*") } + ) + + outputs.file(outputFile) + } + +val chartTestingLint by + tasks.registering(Exec::class) { + group = "verification" + description = "Run chart-testing (lint)" + + workingDir = rootProject.projectDir Review Comment: Hm, can't it run from the project directory? ########## helm/polaris/README.md: ########## @@ -143,10 +142,11 @@ The following tools are required to run the tests: * [Helm Unit Test](https://github.com/helm-unittest/helm-unittest) * [Chart Testing](https://github.com/helm/chart-testing) -Quick installation instructions for these tools: +Quick installation of all required tools on macOS: + ```bash -helm plugin install https://github.com/helm-unittest/helm-unittest.git -brew install chart-testing +make install-dependencies-brew +make install-optional-dependencies-brew Review Comment: Mind adding this as a macOS variant but leave the Linux one? (Also for the other occurrences below) ########## helm/polaris/build.gradle.kts: ########## @@ -0,0 +1,245 @@ +/* + * 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. + */ + +plugins { + id("base") + id("polaris-spotless") +} + +description = "Apache Polaris (incubating) Helm Chart" + +val helmTestReportsDir = layout.buildDirectory.dir("reports") + +val helmTemplateValidation by + tasks.registering(Exec::class) { + group = "verification" + description = "Run 'helm template' validation with all values files" + + workingDir = projectDir + + val outputFile = helmTestReportsDir.get().file("helm-template/validation.log") + + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + for f in values.yaml ci/*.yaml; do + echo "Validating helm template with ${'$'}f" + helm template --debug --namespace polaris-ns --values ${'$'}f . + done > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "ci/*.yaml", "templates/**/*") } + ) + + outputs.file(outputFile) + } + +val helmUnitTest by + tasks.registering(Exec::class) { + group = "verification" + description = "Run Helm unit tests" + + workingDir = projectDir + + val outputFile = helmTestReportsDir.get().file("helm-unit/test.log") + + // Install the plugin if not already installed, then run tests + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + helm plugin install https://github.com/helm-unittest/helm-unittest.git 2>/dev/null || true + helm unittest . > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "templates/**/*", "tests/**/*") } + ) + + outputs.file(outputFile) + } + +val chartTestingLint by + tasks.registering(Exec::class) { + group = "verification" + description = "Run chart-testing (lint)" + + workingDir = rootProject.projectDir + + val outputFile = helmTestReportsDir.get().file("ct/lint.log") + + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + ct lint --debug --charts ./helm/polaris > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "ci/*.yaml", "templates/**/*") } + ) + + outputs.file(outputFile) + } + +// Task to build Docker images in minikube's Docker environment +val buildMinikubeImages by + tasks.registering(Exec::class) { + group = "build" + description = "Build Polaris Docker images in minikube's Docker environment" + + workingDir = rootProject.projectDir + + // Output: file containing SHA digest of built image + val outputFile = helmTestReportsDir.get().file("minikube-images.sha256") + + commandLine = + listOf( + "sh", + "-c", + """ + # Check if minikube is running + if ! minikube status >/dev/null 2>&1; then + echo "Minikube is not running. Starting minikube..." + minikube start + fi + + # Set up docker environment and build images + eval $(minikube -p minikube docker-env) + + # Build server image + docker build -t apache/polaris:latest \ + -f runtime/server/src/main/docker/Dockerfile.jvm \ + runtime/server + + # Capture image digest + mkdir -p ${outputFile.asFile.parent} + { + docker inspect --format='{{.Id}}' apache/polaris:latest + } > ${outputFile.asFile} + """ + .trimIndent(), + ) + + dependsOn(":polaris-server:quarkusBuild") + + inputs.dir(rootProject.file("runtime/server/build/quarkus-app")) + inputs.file(rootProject.file("runtime/server/src/main/docker/Dockerfile.jvm")) + + outputs.file(outputFile) + } + +// Task to run chart-testing install on minikube +val chartTestingInstall by + tasks.registering(Exec::class) { + group = "verification" + description = "Run chart-testing (install) on minikube" + + workingDir = rootProject.projectDir + + val outputFile = helmTestReportsDir.get().file("ct/install.log") + + commandLine = + listOf( + "sh", + "-c", + """ + mkdir -p ${outputFile.asFile.parent} + + # Create namespace if it doesn't exist + kubectl create namespace polaris-ns --dry-run=client -o yaml | kubectl apply -f - + + # Install fixtures + kubectl apply --namespace polaris-ns -f helm/polaris/ci/fixtures + + # Run chart-testing install + ct install \ + --namespace polaris-ns \ + --debug --charts ./helm/polaris > ${outputFile.asFile} 2>&1 + """ + .trimIndent(), + ) + + inputs.files( + fileTree(projectDir) { include("Chart.yaml", "values.yaml", "ci/**/*", "templates/**/*") } + ) + + outputs.file(outputFile) Review Comment: All `Exec` tasks also need ```suggestion outputs.cacheIf { true } ``` otherwise only up-to-date checks work, but nothing would be cached. (`Exec` is annotated with `@DisableCachingByDefault`.) ########## .github/workflows/gradle.yml: ########## @@ -213,6 +215,7 @@ jobs: ./gradlew \ intTest \ -x :polaris-runtime-service:intTest \ + -x :polaris-helm:intTest \ Review Comment: ```suggestion -x :polaris-helm:check \ ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
