From e18f43daa4c76caa476bd9a29e2c02493c5daefd Mon Sep 17 00:00:00 2001 From: Jeromy Cannon Date: Fri, 22 Sep 2023 20:12:30 +0100 Subject: [PATCH 01/14] Squashed commit of the following: commit d177c82d71e52012df8c0e7d766913eb5b518625 Author: Jeromy Cannon Date: Thu Sep 21 19:02:43 2023 +0100 updated HelmExecutionBuilder workingDirectory to use PWD instead of new File('.') from FileUtils Signed-off-by: Jeromy Cannon commit 7ef57c193e5c527a58c6d46b0d12b86157c82fd8 Author: Jeromy Cannon Date: Thu Sep 21 14:09:23 2023 +0100 removed commented out code that was previously used for shadowjars Signed-off-by: Jeromy Cannon commit 4891dd59d5bb2eb52c8d31ddd41ce3b4952c46e0 Author: Jeromy Cannon Date: Wed Sep 20 20:02:40 2023 +0100 remove shadowjars Signed-off-by: Jeromy Cannon commit 9d67a54e10ca0fa148a1565cb9067b6a6098df0e Author: Jeromy Cannon Date: Wed Sep 20 19:48:24 2023 +0100 remove shadowjars Signed-off-by: Jeromy Cannon commit 3dc75a046075de48892766db4e4891bf394344b5 Author: Jeromy Cannon Date: Wed Sep 20 19:43:55 2023 +0100 todo Signed-off-by: Jeromy Cannon commit 7660afbf52fb7e012c5e46c6bb72fc7fc2cb892e Author: Jeromy Cannon Date: Wed Sep 20 19:42:46 2023 +0100 more todo's Signed-off-by: Jeromy Cannon commit 51df39336acf2ad22e10e5b1136fe31af2257251 Author: Jeromy Cannon Date: Wed Sep 20 18:04:31 2023 +0100 switch to a different repo to avoid test collisions Signed-off-by: Jeromy Cannon commit 44754c15eb4c77f08cc1026d4e593020db28eddd Author: Jeromy Cannon Date: Wed Sep 20 17:35:19 2023 +0100 remove code smells Signed-off-by: Jeromy Cannon commit d068f262f80206a7a01fe2d4954be779f55585af Author: Jeromy Cannon Date: Wed Sep 20 16:25:05 2023 +0100 updated HelmInstallChartTaskTest to different chart/repo to avoid collisions with other tests Signed-off-by: Jeromy Cannon commit 7821d6f0f29d7956331e1d21952b95e071e951db Author: Jeromy Cannon Date: Wed Sep 20 13:10:07 2023 +0100 add licenses at top of kotlin files Signed-off-by: Jeromy Cannon commit ae3d3c7cd3e356ac074d9c9fec54ef29c40e6274 Author: Jeromy Cannon Date: Wed Sep 20 13:02:06 2023 +0100 added TODO Signed-off-by: Jeromy Cannon commit 4a8226169b896fc140360c42699615fac812037e Author: Jeromy Cannon Date: Wed Sep 20 12:53:04 2023 +0100 Revert "removed unneeded test implementation reference" This reverts commit 8eedff9fe3c6c9443df756e08f11bd3e7170a80e. Signed-off-by: Jeromy Cannon commit 674c155a9775ad12bf6125e096c7617b70502a8b Author: Jeromy Cannon Date: Wed Sep 20 12:49:28 2023 +0100 removed unneeded test implementation reference Signed-off-by: Jeromy Cannon commit 23c310463face8cf62765014e96d41aaa51874b9 Author: Jeromy Cannon Date: Wed Sep 20 12:45:25 2023 +0100 upcoming todo for next PR Signed-off-by: Jeromy Cannon commit 72bf7b34e2d14d173971657a4c8f4a9be9628f64 Author: Jeromy Cannon Date: Tue Sep 19 22:26:19 2023 +0100 removed commented out code Signed-off-by: Jeromy Cannon commit aec75d3c09477e487fc234a6a187c79f150aa70a Author: Jeromy Cannon Date: Tue Sep 19 22:24:54 2023 +0100 FileUtils.getWorkingPath() Signed-off-by: Jeromy Cannon commit 50e2a0e951baf43ba57c36279c61481f0e452948 Author: Jeromy Cannon Date: Tue Sep 19 22:21:05 2023 +0100 remove commented out code Signed-off-by: Jeromy Cannon commit 659283b829c1ec5970af3bb4f55bab6b4ca8425f Author: Jeromy Cannon Date: Tue Sep 19 22:20:56 2023 +0100 remove commented out code Signed-off-by: Jeromy Cannon commit 5fb6e869622137660f6b814da0d269f305491714 Author: Jeromy Cannon Date: Tue Sep 19 22:20:30 2023 +0100 added namespace and create namespace and example chart for installing during build check Signed-off-by: Jeromy Cannon commit 610244141686d233f0b5d36a925cd7af326f8597 Author: Jeromy Cannon Date: Mon Sep 18 19:44:36 2023 +0100 working version Signed-off-by: Jeromy Cannon commit 7e06feb82c183528dbf1afe73a720b3c5ada835e Author: Jeromy Cannon Date: Mon Sep 18 19:29:05 2023 +0100 task working Signed-off-by: Jeromy Cannon commit 19c176bb0a4327934e05150201c9c435c8ae63ba Author: Jeromy Cannon Date: Mon Sep 18 19:06:37 2023 +0100 non-working version Signed-off-by: Jeromy Cannon commit 9e2e66fad05d41c0ecf105f79de128c11879fb98 Author: Jeromy Cannon Date: Mon Sep 18 17:01:59 2023 +0100 compiling version although not executing of moving integration tests into examples Signed-off-by: Jeromy Cannon commit c5a9b8a7af426f6c58b1f39bfbd3b8370098d101 Author: Jeromy Cannon Date: Fri Sep 15 18:30:00 2023 +0100 added logic to set the namespace in the helm install task Signed-off-by: Jeromy Cannon commit dc851979517f8de81bf08973b979a41edf081cd4 Author: Jeromy Cannon Date: Fri Sep 15 17:47:30 2023 +0100 removed duplicate export Signed-off-by: Jeromy Cannon commit 671005905dc539f0a3b7d855d111895183f4f394 Author: Jeromy Cannon Date: Fri Sep 15 17:28:10 2023 +0100 added support for set and values parameters of install subcommand to handle sets Signed-off-by: Jeromy Cannon commit 0d49686b125a15b46a699571a61d4569643de729 Author: Jeromy Cannon Date: Fri Sep 15 17:27:21 2023 +0100 enhanced helm client to handle sets of strings for values and set parameters for the install subcommand Signed-off-by: Jeromy Cannon commit 3f634e0dcd6661a8999acb6ad724a18ce3a9b855 Author: Jeromy Cannon Date: Thu Sep 14 19:39:03 2023 +0100 test nmt install Signed-off-by: Jeromy Cannon commit a760d5252dd4cc1d879f8458a575a9c1c3d4e0ad Author: Jeromy Cannon Date: Thu Sep 14 19:06:12 2023 +0100 update version from 0.7.0 to 0.8.0 Signed-off-by: Jeromy Cannon commit 3c2a99baa72e8da93a36164ceea6fee6e6f46ee5 Author: Jeromy Cannon Date: Thu Sep 14 19:04:34 2023 +0100 todo Signed-off-by: Jeromy Cannon commit 77c59efd807e7cc39c07b9eb32227b690de648b3 Author: Jeromy Cannon Date: Thu Sep 14 18:57:51 2023 +0100 removed comment from FullstackPlugin.java Signed-off-by: Jeromy Cannon commit 840f64bdf6a812f4e941e2158d5747f81cefc6a4 Author: Jeromy Cannon Date: Thu Sep 14 18:56:19 2023 +0100 reordered alphabetically Signed-off-by: Jeromy Cannon commit 28005adc8bf3eed6c9b272b208d720aa1d35dbc4 Author: Jeromy Cannon Date: Thu Sep 14 18:53:54 2023 +0100 added set parameter Signed-off-by: Jeromy Cannon commit 1d03540c971c8023395eff067ce691ec0034bed2 Author: Jeromy Cannon Date: Thu Sep 14 18:32:07 2023 +0100 update after merge from main made a mess (part2) Signed-off-by: Jeromy Cannon commit bb254c67ad698c11120d21c409a9e781173eadd4 Author: Jeromy Cannon Date: Thu Sep 14 18:26:36 2023 +0100 update after merge from main made a mess Signed-off-by: Jeromy Cannon Signed-off-by: Jeromy Cannon --- ...m.hedera.fullstack.jpms-modules.gradle.kts | 2 - .../settings-plugins/build.gradle.kts | 13 ++- ...era.fullstack.settings.settings.gradle.kts | 44 ++++++++ build-logic/settings.gradle.kts | 23 +++- fullstack-examples/build.gradle.kts | 40 +++++-- fullstack-examples/settings.gradle.kts | 29 +++++ fullstack-gradle-plugin/build.gradle.kts | 25 ++++- .../gradle/plugin/FullstackPlugin.java | 27 +++++ .../gradle/plugin/HelmInstallChartTask.java | 94 ++++++++++++++++ .../fullstack/gradle/plugin/package-info.java | 1 - .../src/main/java/module-info.java | 1 - .../plugin/HelmInstallChartTaskTest.java | 105 ++++++++++++++++++ .../src/test/java/module-info.java | 1 - settings.gradle.kts | 7 +- 14 files changed, 384 insertions(+), 28 deletions(-) rename fullstack-gradle-plugin/src/main/java/com/hedera/fullstack/gradle/plugin/Dummy.java => build-logic/settings-plugins/build.gradle.kts (77%) create mode 100644 build-logic/settings-plugins/src/main/kotlin/com.hedera.fullstack.settings.settings.gradle.kts create mode 100644 fullstack-examples/settings.gradle.kts create mode 100644 fullstack-gradle-plugin/src/main/java/com/hedera/fullstack/gradle/plugin/FullstackPlugin.java create mode 100644 fullstack-gradle-plugin/src/main/java/com/hedera/fullstack/gradle/plugin/HelmInstallChartTask.java delete mode 100644 fullstack-gradle-plugin/src/main/java/com/hedera/fullstack/gradle/plugin/package-info.java delete mode 100644 fullstack-gradle-plugin/src/main/java/module-info.java create mode 100644 fullstack-gradle-plugin/src/test/java/com/hedera/fullstack/gradle/plugin/HelmInstallChartTaskTest.java delete mode 100644 fullstack-gradle-plugin/src/test/java/module-info.java diff --git a/build-logic/project-plugins/src/main/kotlin/com.hedera.fullstack.jpms-modules.gradle.kts b/build-logic/project-plugins/src/main/kotlin/com.hedera.fullstack.jpms-modules.gradle.kts index 713db9cf0..b5dd44792 100644 --- a/build-logic/project-plugins/src/main/kotlin/com.hedera.fullstack.jpms-modules.gradle.kts +++ b/build-logic/project-plugins/src/main/kotlin/com.hedera.fullstack.jpms-modules.gradle.kts @@ -22,8 +22,6 @@ plugins { } javaModuleDependencies { - versionsFromConsistentResolution(":fullstack-helm-client") - moduleNameToGA.put("com.hedera.fullstack.junit.support", "com.hedera.fullstack:fullstack-junit-support") moduleNameToGA.put("com.hedera.fullstack.test.toolkit", "com.hedera.fullstack:fullstack-test-toolkit") } diff --git a/fullstack-gradle-plugin/src/main/java/com/hedera/fullstack/gradle/plugin/Dummy.java b/build-logic/settings-plugins/build.gradle.kts similarity index 77% rename from fullstack-gradle-plugin/src/main/java/com/hedera/fullstack/gradle/plugin/Dummy.java rename to build-logic/settings-plugins/build.gradle.kts index bee3588a9..3ef382347 100644 --- a/fullstack-gradle-plugin/src/main/java/com/hedera/fullstack/gradle/plugin/Dummy.java +++ b/build-logic/settings-plugins/build.gradle.kts @@ -14,6 +14,15 @@ * limitations under the License. */ -package com.hedera.fullstack.gradle.plugin; +plugins { + `kotlin-dsl` +} -public class Dummy {} +repositories { + gradlePluginPortal() + mavenCentral() +} + +dependencies { + implementation("com.gradle:gradle-enterprise-gradle-plugin:3.14.1") +} \ No newline at end of file diff --git a/build-logic/settings-plugins/src/main/kotlin/com.hedera.fullstack.settings.settings.gradle.kts b/build-logic/settings-plugins/src/main/kotlin/com.hedera.fullstack.settings.settings.gradle.kts new file mode 100644 index 000000000..68d9408d3 --- /dev/null +++ b/build-logic/settings-plugins/src/main/kotlin/com.hedera.fullstack.settings.settings.gradle.kts @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed 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. + */ + +pluginManagement { + repositories { + gradlePluginPortal() + mavenCentral() + } +} + +plugins { + id("com.gradle.enterprise") +} + +// Enable Gradle Build Scan +gradleEnterprise { + buildScan { + termsOfServiceUrl = "https://gradle.com/terms-of-service" + termsOfServiceAgree = "yes" + + if (!System.getenv("CI").isNullOrEmpty()) { + publishAlways() + tag("CI") + } + } +} + +// Allow projects inside a build to be addressed by dependency coordinates notation. +// https://docs.gradle.org/current/userguide/composite_builds.html#included_build_declaring_substitutions +// Some functionality of the 'java-module-dependencies' plugin relies on this. +includeBuild(".") \ No newline at end of file diff --git a/build-logic/settings.gradle.kts b/build-logic/settings.gradle.kts index ec1812a0c..8f09d6797 100644 --- a/build-logic/settings.gradle.kts +++ b/build-logic/settings.gradle.kts @@ -1,8 +1,19 @@ - -//dependencyResolutionManagement { -// repositories { -// gradlePluginPortal() -// } -//} +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed 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. + */ includeBuild("project-plugins") + +includeBuild("settings-plugins") \ No newline at end of file diff --git a/fullstack-examples/build.gradle.kts b/fullstack-examples/build.gradle.kts index 964ebac30..7710eb6a0 100644 --- a/fullstack-examples/build.gradle.kts +++ b/fullstack-examples/build.gradle.kts @@ -13,23 +13,41 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import com.hedera.fullstack.gradle.plugin.HelmInstallChartTask plugins { + id("java") + id("com.hedera.fullstack.umbrella") id("com.hedera.fullstack.conventions") id("com.hedera.fullstack.jpms-modules") + id("com.hedera.fullstack.fullstack-gradle-plugin") } -dependencies { api(platform(project(":fullstack-bom"))) } +dependencies { + api(platform("com.hedera.fullstack:fullstack-bom")) + implementation("com.hedera.fullstack:fullstack-readiness-api") + implementation("com.hedera.fullstack:fullstack-monitoring-api") + implementation("com.hedera.fullstack:fullstack-test-toolkit") + implementation("com.hedera.fullstack:fullstack-validator-api") +} + +tasks.register("helmInstallFstChart") { + createNamespace.set(true) + namespace.set("fst-ns") + release.set("fst") + chart.set("../charts/hedera-network") +} -testing { - suites { - @Suppress("UnstableApiUsage", "unused") - val fullstack by - registering(JvmTestSuite::class) { - useJUnitJupiter() - dependencies { implementation(project(":fullstack-examples")) } - } - } +tasks.register("helmInstallNginxChart") { + createNamespace.set(true) + namespace.set("nginx-ns") + release.set("nginx-release") + chart.set("oci://ghcr.io/nginxinc/charts/nginx-ingress") } -tasks.assemble.configure { dependsOn(tasks.named("fullstackClasses")) } +// TODO: task register helmUninstallNginxChart + +tasks.check { + dependsOn("helmInstallNginxChart") + // TODO: depends on helmUninstallNginxChart +} \ No newline at end of file diff --git a/fullstack-examples/settings.gradle.kts b/fullstack-examples/settings.gradle.kts new file mode 100644 index 000000000..518cac987 --- /dev/null +++ b/fullstack-examples/settings.gradle.kts @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed 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. + */ + +pluginManagement { + includeBuild("../build-logic") + includeBuild("..") + repositories { + mavenLocal() + mavenCentral() + gradlePluginPortal() + } +} + +rootProject.name = "fullstack-examples" + +includeBuild("..") diff --git a/fullstack-gradle-plugin/build.gradle.kts b/fullstack-gradle-plugin/build.gradle.kts index f9776d955..6a2dc21fd 100644 --- a/fullstack-gradle-plugin/build.gradle.kts +++ b/fullstack-gradle-plugin/build.gradle.kts @@ -14,6 +14,27 @@ * limitations under the License. */ -plugins { id("com.hedera.fullstack.conventions") } +plugins { + id("java-gradle-plugin") + id("com.gradle.plugin-publish").version("1.2.1") + id("com.hedera.fullstack.conventions") + id("com.hedera.fullstack.maven-publish") +} -dependencies { api(platform(project(":fullstack-bom"))) } +dependencies { + api(platform(project(":fullstack-bom"))) + implementation(project(":fullstack-helm-client")) +} + +gradlePlugin { + plugins { + create("fullstackPlugin") { + id = "com.hedera.fullstack.fullstack-gradle-plugin" + group = "com.hedera.fullstack" + implementationClass = "com.hedera.fullstack.gradle.plugin.FullstackPlugin" + displayName = "Fullstack Plugin" + description = + "The Fullstack Plugin provides tools for working with Fullstack infrastructure." + } + } +} diff --git a/fullstack-gradle-plugin/src/main/java/com/hedera/fullstack/gradle/plugin/FullstackPlugin.java b/fullstack-gradle-plugin/src/main/java/com/hedera/fullstack/gradle/plugin/FullstackPlugin.java new file mode 100644 index 000000000..0cf9bcc73 --- /dev/null +++ b/fullstack-gradle-plugin/src/main/java/com/hedera/fullstack/gradle/plugin/FullstackPlugin.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed 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. + */ + +package com.hedera.fullstack.gradle.plugin; + +import org.gradle.api.Plugin; +import org.gradle.api.Project; + +public class FullstackPlugin implements Plugin { + @Override + public void apply(Project project) { + // currently no implementation is needed + } +} diff --git a/fullstack-gradle-plugin/src/main/java/com/hedera/fullstack/gradle/plugin/HelmInstallChartTask.java b/fullstack-gradle-plugin/src/main/java/com/hedera/fullstack/gradle/plugin/HelmInstallChartTask.java new file mode 100644 index 000000000..f923e1cab --- /dev/null +++ b/fullstack-gradle-plugin/src/main/java/com/hedera/fullstack/gradle/plugin/HelmInstallChartTask.java @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed 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. + */ + +package com.hedera.fullstack.gradle.plugin; + +import com.hedera.fullstack.helm.client.HelmClient; +import com.hedera.fullstack.helm.client.HelmClientBuilder; +import com.hedera.fullstack.helm.client.model.Chart; +import com.hedera.fullstack.helm.client.model.install.InstallChartOptionsBuilder; +import org.gradle.api.DefaultTask; +import org.gradle.api.provider.Property; +import org.gradle.api.provider.SetProperty; +import org.gradle.api.tasks.Input; +import org.gradle.api.tasks.Optional; +import org.gradle.api.tasks.TaskAction; +import org.gradle.api.tasks.options.Option; + +public abstract class HelmInstallChartTask extends DefaultTask { + @Input + @Option(option = "chart", description = "The name of the chart to install") + public abstract Property getChart(); + + @Input + @Optional + @Option(option = "createNamespace", description = "Create the release namespace if not present") + public abstract Property getCreateNamespace(); + + @Input + @Optional + @Option(option = "namespace", description = "The namespace to use when installing the chart") + public abstract Property getNamespace(); + + @Input + @Option(option = "release", description = "The name of the release to install") + public abstract Property getRelease(); + + @Input + @Optional + @Option(option = "repo", description = "The name of the repo to install") + public abstract Property getRepo(); + + @Input + @Optional + @Option( + option = "set", + description = + "set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)") + public abstract SetProperty getSet(); + + @Input + @Optional + @Option(option = "values", description = "Specify values in a YAML file or a URL (can specify multiple)") + // TODO: enhance to support multiple values files + public abstract SetProperty getValues(); + + @TaskAction + void installChart() { + HelmClientBuilder helmClientBuilder = HelmClient.builder(); + if (getNamespace().isPresent()) { + helmClientBuilder.defaultNamespace(getNamespace().get()); + } + HelmClient helmClient = helmClientBuilder.build(); + InstallChartOptionsBuilder optionsBuilder = InstallChartOptionsBuilder.builder(); + if (getCreateNamespace().isPresent()) { + optionsBuilder.createNamespace(getCreateNamespace().get()); + } + if (getSet().isPresent()) { + optionsBuilder.set(getSet().get()); + } + if (getValues().isPresent()) { + optionsBuilder.values(getValues().get()); + } + helmClient.installChart( + getRelease().getOrNull(), + new Chart(getChart().getOrNull(), getRepo().getOrNull()), + optionsBuilder.build()); + + getProject().getLogger().info("testing..."); + // TODO log to gradle stdout if there is an error + } +} diff --git a/fullstack-gradle-plugin/src/main/java/com/hedera/fullstack/gradle/plugin/package-info.java b/fullstack-gradle-plugin/src/main/java/com/hedera/fullstack/gradle/plugin/package-info.java deleted file mode 100644 index 47a10352d..000000000 --- a/fullstack-gradle-plugin/src/main/java/com/hedera/fullstack/gradle/plugin/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package com.hedera.fullstack.gradle.plugin; diff --git a/fullstack-gradle-plugin/src/main/java/module-info.java b/fullstack-gradle-plugin/src/main/java/module-info.java deleted file mode 100644 index 37ceb29db..000000000 --- a/fullstack-gradle-plugin/src/main/java/module-info.java +++ /dev/null @@ -1 +0,0 @@ -module com.hedera.fullstack.gradle.plugin {} diff --git a/fullstack-gradle-plugin/src/test/java/com/hedera/fullstack/gradle/plugin/HelmInstallChartTaskTest.java b/fullstack-gradle-plugin/src/test/java/com/hedera/fullstack/gradle/plugin/HelmInstallChartTaskTest.java new file mode 100644 index 000000000..56f7f9aab --- /dev/null +++ b/fullstack-gradle-plugin/src/test/java/com/hedera/fullstack/gradle/plugin/HelmInstallChartTaskTest.java @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed 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. + */ + +package com.hedera.fullstack.gradle.plugin; + +import static com.hedera.fullstack.base.api.util.ExceptionUtils.suppressExceptions; +import static org.junit.jupiter.api.Assertions.*; + +import com.hedera.fullstack.helm.client.HelmClient; +import com.hedera.fullstack.helm.client.model.Chart; +import com.hedera.fullstack.helm.client.model.Repository; +import java.io.File; +import java.io.IOException; +import java.util.List; +import org.gradle.api.Project; +import org.gradle.testfixtures.ProjectBuilder; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +class HelmInstallChartTaskTest { + private static final Repository REPOSITORY = new Repository("stable", "https://charts.helm.sh/stable"); + private static final Chart CHART = new Chart("mysql", "stable"); + + private static final String RELEASE_NAME = "mysql-release"; + + private static Project project; + + @BeforeAll + static void beforeAll() { + project = ProjectBuilder.builder().build(); + } + + @Test + @Disabled("currently this requires manual intervention to run") + // 1. 'make deploy-chart' + // 2. run this test case, assuming it passes and installs fst + // 3. 'make destroy-chart' + @DisplayName("Helm Install Chart Task for Hedera Network Chart") + void testHelmInstallChartTaskForHederaNetworkChart() throws IOException { + HelmClient helmClient = HelmClient.defaultClient(); + suppressExceptions(() -> helmClient.uninstallChart("fst")); + try { + final File hederaNetworkChart = new File("../charts/hedera-network"); + final String hederaNetworkChartPath = hederaNetworkChart.getCanonicalPath(); + final File valuesFile = new File(hederaNetworkChartPath + File.separator + "values.yaml"); + final String valuesFilePath = valuesFile.getCanonicalPath(); + HelmInstallChartTask helmInstallChartTask = project.getTasks() + .create("helmInstallFstChart", HelmInstallChartTask.class, task -> { + task.getChart().set(hederaNetworkChartPath); + task.getRelease().set("fst"); + // set image for nmt-install + task.getSet().add("defaults.root.image.repository=hashgraph/full-stack-testing/ubi8-init-dind"); + task.getValues().add(valuesFilePath); + }); + assertEquals("fst", helmInstallChartTask.getRelease().get()); + helmInstallChartTask.installChart(); + } finally { + // TODO: comment this out as workaround until we no longer need manual use of make command + // suppressExceptions(() -> helmClient.uninstallChart("fst")); + } + } + + @Test + @DisplayName("Simple Helm Install Chart Task") + void testHelmInstallChartTaskSimple() { + HelmClient helmClient = + HelmClient.builder().defaultNamespace("simple-test").build(); + suppressExceptions(() -> helmClient.uninstallChart(RELEASE_NAME)); + suppressExceptions(() -> helmClient.removeRepository(REPOSITORY)); + final List repositories = helmClient.listRepositories(); + if (!repositories.contains(REPOSITORY)) { + helmClient.addRepository(REPOSITORY); + } + try { + HelmInstallChartTask helmInstallChartTask = project.getTasks() + .create("helmInstallChart", HelmInstallChartTask.class, task -> { + task.getChart().set(CHART.name()); + task.getCreateNamespace().set(true); + task.getNamespace().set("simple-test"); + task.getRelease().set(RELEASE_NAME); + task.getRepo().set(CHART.repoName()); + }); + assertEquals(RELEASE_NAME, helmInstallChartTask.getRelease().get()); + helmInstallChartTask.installChart(); + } finally { + suppressExceptions(() -> helmClient.uninstallChart(RELEASE_NAME)); + suppressExceptions(() -> helmClient.removeRepository(REPOSITORY)); + } + } +} diff --git a/fullstack-gradle-plugin/src/test/java/module-info.java b/fullstack-gradle-plugin/src/test/java/module-info.java deleted file mode 100644 index 5cdfd426e..000000000 --- a/fullstack-gradle-plugin/src/test/java/module-info.java +++ /dev/null @@ -1 +0,0 @@ -module com.hedera.fullstack.gradle.plugin.test {} diff --git a/settings.gradle.kts b/settings.gradle.kts index 07befff7a..5c9958f53 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -16,7 +16,10 @@ pluginManagement { includeBuild("build-logic") } -plugins { id("com.gradle.enterprise").version("3.13.2") } +plugins { + id("com.gradle.enterprise").version("3.14.1") + id("com.hedera.fullstack.settings") +} rootProject.name = "full-stack-testing" @@ -45,7 +48,7 @@ include(":fullstack-datasource-api") include(":fullstack-datasource-core") -include(":fullstack-examples") +includeBuild("fullstack-examples") include(":fullstack-gradle-plugin") From 07d96fdc1c513d4037f3559a0d25f543a3699da1 Mon Sep 17 00:00:00 2001 From: Jeromy Cannon Date: Mon, 25 Sep 2023 14:42:22 +0100 Subject: [PATCH 02/14] temporarily disable fullstack-examples until we can resolve intellij and sonar issues Signed-off-by: Jeromy Cannon --- settings.gradle.kts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/settings.gradle.kts b/settings.gradle.kts index 5c9958f53..8f61172e2 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -48,7 +48,8 @@ include(":fullstack-datasource-api") include(":fullstack-datasource-core") -includeBuild("fullstack-examples") +// TODO: re-enable once we have a way to run the fullstack-examples without IntelliJ and Sonar issues +//includeBuild("fullstack-examples") include(":fullstack-gradle-plugin") From b982ecbe6cd4c2ef8dd648bdb2c1b8da8a0a4d0b Mon Sep 17 00:00:00 2001 From: Jeromy Cannon Date: Tue, 26 Sep 2023 09:41:51 +0100 Subject: [PATCH 03/14] updates based on changes in helm install subcommand Signed-off-by: Jeromy Cannon --- .../hedera/fullstack/gradle/plugin/HelmInstallChartTask.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fullstack-gradle-plugin/src/main/java/com/hedera/fullstack/gradle/plugin/HelmInstallChartTask.java b/fullstack-gradle-plugin/src/main/java/com/hedera/fullstack/gradle/plugin/HelmInstallChartTask.java index f923e1cab..4c5e447d3 100644 --- a/fullstack-gradle-plugin/src/main/java/com/hedera/fullstack/gradle/plugin/HelmInstallChartTask.java +++ b/fullstack-gradle-plugin/src/main/java/com/hedera/fullstack/gradle/plugin/HelmInstallChartTask.java @@ -20,6 +20,7 @@ import com.hedera.fullstack.helm.client.HelmClientBuilder; import com.hedera.fullstack.helm.client.model.Chart; import com.hedera.fullstack.helm.client.model.install.InstallChartOptionsBuilder; +import java.util.ArrayList; import org.gradle.api.DefaultTask; import org.gradle.api.provider.Property; import org.gradle.api.provider.SetProperty; @@ -78,10 +79,10 @@ void installChart() { optionsBuilder.createNamespace(getCreateNamespace().get()); } if (getSet().isPresent()) { - optionsBuilder.set(getSet().get()); + optionsBuilder.set(new ArrayList<>(getSet().get())); } if (getValues().isPresent()) { - optionsBuilder.values(getValues().get()); + optionsBuilder.values(new ArrayList<>(getValues().get())); } helmClient.installChart( getRelease().getOrNull(), From 5b9fe04368197cb782516a1ae00b7d66be0a5b6e Mon Sep 17 00:00:00 2001 From: Jeromy Cannon Date: Tue, 26 Sep 2023 17:21:14 +0100 Subject: [PATCH 04/14] updates based on feedback from Jendrick on hedera-services changes. Signed-off-by: Jeromy Cannon --- .../com.hedera.fullstack.root.gradle.kts | 23 +++++++++++++++++++ .../com.hedera.fullstack.umbrella.gradle.kts | 7 ------ build.gradle.kts | 2 +- fullstack-examples/build.gradle.kts | 5 ++-- settings.gradle.kts | 4 ++-- 5 files changed, 29 insertions(+), 12 deletions(-) delete mode 100644 build-logic/project-plugins/src/main/kotlin/com.hedera.fullstack.umbrella.gradle.kts diff --git a/build-logic/project-plugins/src/main/kotlin/com.hedera.fullstack.root.gradle.kts b/build-logic/project-plugins/src/main/kotlin/com.hedera.fullstack.root.gradle.kts index e69de29bb..c85cda355 100644 --- a/build-logic/project-plugins/src/main/kotlin/com.hedera.fullstack.root.gradle.kts +++ b/build-logic/project-plugins/src/main/kotlin/com.hedera.fullstack.root.gradle.kts @@ -0,0 +1,23 @@ +/* + * Copyright 2023 Hedera Hashgraph, LLC + * + * This software is the confidential and proprietary information of + * Hedera Hashgraph, LLC. ("Confidential Information"). You shall not + * disclose such Confidential Information and shall use it only in + * accordance with the terms of the license agreement you entered into + * with Hedera Hashgraph. + * + * HEDERA HASHGRAPH MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF + * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED + * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. HEDERA HASHGRAPH SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. + */ + +plugins { + id("com.autonomousapps.dependency-analysis") + id("com.hedera.fullstack.aggregate-reports") + id("com.hedera.fullstack.spotless-conventions") + id("com.hedera.fullstack.spotless-kotlin-conventions") +} diff --git a/build-logic/project-plugins/src/main/kotlin/com.hedera.fullstack.umbrella.gradle.kts b/build-logic/project-plugins/src/main/kotlin/com.hedera.fullstack.umbrella.gradle.kts deleted file mode 100644 index 9ee7a6707..000000000 --- a/build-logic/project-plugins/src/main/kotlin/com.hedera.fullstack.umbrella.gradle.kts +++ /dev/null @@ -1,7 +0,0 @@ - -plugins { - id("com.autonomousapps.dependency-analysis") - id("com.hedera.fullstack.aggregate-reports") - id("com.hedera.fullstack.spotless-conventions") - id("com.hedera.fullstack.spotless-kotlin-conventions") -} diff --git a/build.gradle.kts b/build.gradle.kts index c50450172..cecc1f3ea 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,7 +14,7 @@ * limitations under the License. */ -plugins { id("com.hedera.fullstack.umbrella") } +plugins { id("com.hedera.fullstack.root") } repositories { // mavenLocal() // uncomment to use local maven repository diff --git a/fullstack-examples/build.gradle.kts b/fullstack-examples/build.gradle.kts index 7710eb6a0..4eabfe398 100644 --- a/fullstack-examples/build.gradle.kts +++ b/fullstack-examples/build.gradle.kts @@ -13,11 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import com.hedera.fullstack.gradle.plugin.HelmInstallChartTask plugins { id("java") - id("com.hedera.fullstack.umbrella") + id("com.hedera.fullstack.root") id("com.hedera.fullstack.conventions") id("com.hedera.fullstack.jpms-modules") id("com.hedera.fullstack.fullstack-gradle-plugin") @@ -50,4 +51,4 @@ tasks.register("helmInstallNginxChart") { tasks.check { dependsOn("helmInstallNginxChart") // TODO: depends on helmUninstallNginxChart -} \ No newline at end of file +} diff --git a/settings.gradle.kts b/settings.gradle.kts index 8f61172e2..bdaa1997b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -48,8 +48,8 @@ include(":fullstack-datasource-api") include(":fullstack-datasource-core") -// TODO: re-enable once we have a way to run the fullstack-examples without IntelliJ and Sonar issues -//includeBuild("fullstack-examples") +// TODO: re-enable once we have a way to run the *-examples without IntelliJ and Sonar issues +// includeBuild("fullstack-examples") include(":fullstack-gradle-plugin") From 82311f624d465e23e5de671a6bf7c25b67e77845 Mon Sep 17 00:00:00 2001 From: Jeromy Cannon Date: Tue, 26 Sep 2023 17:31:18 +0100 Subject: [PATCH 05/14] add compile and unit test jobs for examples project since they are now separate Signed-off-by: Jeromy Cannon --- .github/workflows/zxc-compile-code.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/zxc-compile-code.yaml b/.github/workflows/zxc-compile-code.yaml index 922a50e3c..16dcfc86e 100644 --- a/.github/workflows/zxc-compile-code.yaml +++ b/.github/workflows/zxc-compile-code.yaml @@ -163,6 +163,14 @@ jobs: gradle-version: ${{ inputs.gradle-version }} arguments: assemble --scan + - name: Examples Compile + id: gradle-build + uses: gradle/gradle-build-action@243af859f8ca30903d9d7f7936897ca0358ba691 # v2.7.1 + with: + gradle-version: ${{ inputs.gradle-version }} + arguments: assemble --scan + build-root-directory: fullstack-examples + - name: Spotless Check uses: gradle/gradle-build-action@243af859f8ca30903d9d7f7936897ca0358ba691 # v2.7.1 if: ${{ inputs.enable-spotless-check && steps.gradle-build.conclusion == 'success' && !cancelled() }} @@ -178,6 +186,15 @@ jobs: gradle-version: ${{ inputs.gradle-version }} arguments: check --scan + - name: Examples Unit Tests + id: gradle-test + uses: gradle/gradle-build-action@243af859f8ca30903d9d7f7936897ca0358ba691 # v2.7.1 + if: ${{ inputs.enable-unit-tests && steps.gradle-build.conclusion == 'success' && !cancelled() && !failure() }} + with: + gradle-version: ${{ inputs.gradle-version }} + arguments: check --scan + build-root-directory: fullstack-examples + - name: Publish Unit Test Report uses: actionite/publish-unit-test-result-action@1e01e49081c6c4073913aa4b7980fa83e709f322 # v2.3.0 if: ${{ inputs.enable-unit-tests && steps.gradle-build.conclusion == 'success' && !cancelled() && !failure() }} From 557a56901c569d58d975aba4084bb3bc6ef962fb Mon Sep 17 00:00:00 2001 From: Jeromy Cannon Date: Tue, 26 Sep 2023 17:35:06 +0100 Subject: [PATCH 06/14] update job ids for new jobs Signed-off-by: Jeromy Cannon --- .github/workflows/zxc-compile-code.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/zxc-compile-code.yaml b/.github/workflows/zxc-compile-code.yaml index 16dcfc86e..a50a52478 100644 --- a/.github/workflows/zxc-compile-code.yaml +++ b/.github/workflows/zxc-compile-code.yaml @@ -164,7 +164,7 @@ jobs: arguments: assemble --scan - name: Examples Compile - id: gradle-build + id: gradle-build-examples uses: gradle/gradle-build-action@243af859f8ca30903d9d7f7936897ca0358ba691 # v2.7.1 with: gradle-version: ${{ inputs.gradle-version }} @@ -187,9 +187,9 @@ jobs: arguments: check --scan - name: Examples Unit Tests - id: gradle-test + id: gradle-test-examples uses: gradle/gradle-build-action@243af859f8ca30903d9d7f7936897ca0358ba691 # v2.7.1 - if: ${{ inputs.enable-unit-tests && steps.gradle-build.conclusion == 'success' && !cancelled() && !failure() }} + if: ${{ inputs.enable-unit-tests && steps.gradle-build-examples.conclusion == 'success' && !cancelled() && !failure() }} with: gradle-version: ${{ inputs.gradle-version }} arguments: check --scan From 812b4ead57b563ee7b44539aa33e875f188fcac3 Mon Sep 17 00:00:00 2001 From: Jeromy Cannon Date: Tue, 26 Sep 2023 17:39:47 +0100 Subject: [PATCH 07/14] Examples Spotless Check Signed-off-by: Jeromy Cannon --- .github/workflows/zxc-compile-code.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/zxc-compile-code.yaml b/.github/workflows/zxc-compile-code.yaml index a50a52478..fcc114e68 100644 --- a/.github/workflows/zxc-compile-code.yaml +++ b/.github/workflows/zxc-compile-code.yaml @@ -178,6 +178,14 @@ jobs: gradle-version: ${{ inputs.gradle-version }} arguments: spotlessCheck --scan + - name: Examples Spotless Check + uses: gradle/gradle-build-action@243af859f8ca30903d9d7f7936897ca0358ba691 # v2.7.1 + if: ${{ inputs.enable-spotless-check && steps.gradle-build-examples.conclusion == 'success' && !cancelled() }} + with: + gradle-version: ${{ inputs.gradle-version }} + arguments: spotlessCheck --scan + build-root-directory: fullstack-examples + - name: Unit Tests id: gradle-test uses: gradle/gradle-build-action@243af859f8ca30903d9d7f7936897ca0358ba691 # v2.7.1 From fe2a49b716cd6d0222114f43cb86eef6c1904fb3 Mon Sep 17 00:00:00 2001 From: Jeromy Cannon Date: Tue, 26 Sep 2023 18:03:21 +0100 Subject: [PATCH 08/14] supply gradle executable directory for new jobs Signed-off-by: Jeromy Cannon --- .github/workflows/zxc-compile-code.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/zxc-compile-code.yaml b/.github/workflows/zxc-compile-code.yaml index fcc114e68..f063650ec 100644 --- a/.github/workflows/zxc-compile-code.yaml +++ b/.github/workflows/zxc-compile-code.yaml @@ -170,6 +170,7 @@ jobs: gradle-version: ${{ inputs.gradle-version }} arguments: assemble --scan build-root-directory: fullstack-examples + gradle-executable: ../ - name: Spotless Check uses: gradle/gradle-build-action@243af859f8ca30903d9d7f7936897ca0358ba691 # v2.7.1 @@ -185,6 +186,7 @@ jobs: gradle-version: ${{ inputs.gradle-version }} arguments: spotlessCheck --scan build-root-directory: fullstack-examples + gradle-executable: ../ - name: Unit Tests id: gradle-test @@ -202,6 +204,7 @@ jobs: gradle-version: ${{ inputs.gradle-version }} arguments: check --scan build-root-directory: fullstack-examples + gradle-executable: ../ - name: Publish Unit Test Report uses: actionite/publish-unit-test-result-action@1e01e49081c6c4073913aa4b7980fa83e709f322 # v2.3.0 From 497fdd4c0985b755661bc2cd2f06ffc7915c624d Mon Sep 17 00:00:00 2001 From: Jeromy Cannon Date: Tue, 26 Sep 2023 18:12:35 +0100 Subject: [PATCH 09/14] supply gradle executable directory for new jobs Signed-off-by: Jeromy Cannon --- .github/workflows/zxc-compile-code.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/zxc-compile-code.yaml b/.github/workflows/zxc-compile-code.yaml index f063650ec..fa721352d 100644 --- a/.github/workflows/zxc-compile-code.yaml +++ b/.github/workflows/zxc-compile-code.yaml @@ -170,7 +170,7 @@ jobs: gradle-version: ${{ inputs.gradle-version }} arguments: assemble --scan build-root-directory: fullstack-examples - gradle-executable: ../ + gradle-executable: ../gradlew - name: Spotless Check uses: gradle/gradle-build-action@243af859f8ca30903d9d7f7936897ca0358ba691 # v2.7.1 @@ -186,7 +186,7 @@ jobs: gradle-version: ${{ inputs.gradle-version }} arguments: spotlessCheck --scan build-root-directory: fullstack-examples - gradle-executable: ../ + gradle-executable: ../gradlew - name: Unit Tests id: gradle-test @@ -204,7 +204,7 @@ jobs: gradle-version: ${{ inputs.gradle-version }} arguments: check --scan build-root-directory: fullstack-examples - gradle-executable: ../ + gradle-executable: ../gradlew - name: Publish Unit Test Report uses: actionite/publish-unit-test-result-action@1e01e49081c6c4073913aa4b7980fa83e709f322 # v2.3.0 From f526563387d730020e26876dc4d2bdcc6ea1a1dd Mon Sep 17 00:00:00 2001 From: Jeromy Cannon Date: Tue, 26 Sep 2023 18:35:14 +0100 Subject: [PATCH 10/14] gradle-executable shouldn't be needed... Signed-off-by: Jeromy Cannon --- .github/workflows/zxc-compile-code.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/zxc-compile-code.yaml b/.github/workflows/zxc-compile-code.yaml index fa721352d..fcc114e68 100644 --- a/.github/workflows/zxc-compile-code.yaml +++ b/.github/workflows/zxc-compile-code.yaml @@ -170,7 +170,6 @@ jobs: gradle-version: ${{ inputs.gradle-version }} arguments: assemble --scan build-root-directory: fullstack-examples - gradle-executable: ../gradlew - name: Spotless Check uses: gradle/gradle-build-action@243af859f8ca30903d9d7f7936897ca0358ba691 # v2.7.1 @@ -186,7 +185,6 @@ jobs: gradle-version: ${{ inputs.gradle-version }} arguments: spotlessCheck --scan build-root-directory: fullstack-examples - gradle-executable: ../gradlew - name: Unit Tests id: gradle-test @@ -204,7 +202,6 @@ jobs: gradle-version: ${{ inputs.gradle-version }} arguments: check --scan build-root-directory: fullstack-examples - gradle-executable: ../gradlew - name: Publish Unit Test Report uses: actionite/publish-unit-test-result-action@1e01e49081c6c4073913aa4b7980fa83e709f322 # v2.3.0 From 87c364a95b432e706ffa790b32e6a3bc4434e862 Mon Sep 17 00:00:00 2001 From: Jeromy Cannon Date: Tue, 26 Sep 2023 20:52:32 +0100 Subject: [PATCH 11/14] gradle-executable path provided Signed-off-by: Jeromy Cannon --- .github/workflows/zxc-compile-code.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/zxc-compile-code.yaml b/.github/workflows/zxc-compile-code.yaml index fcc114e68..46d8feda4 100644 --- a/.github/workflows/zxc-compile-code.yaml +++ b/.github/workflows/zxc-compile-code.yaml @@ -170,6 +170,7 @@ jobs: gradle-version: ${{ inputs.gradle-version }} arguments: assemble --scan build-root-directory: fullstack-examples + gradle-executable: fullstack-testing/gradlew - name: Spotless Check uses: gradle/gradle-build-action@243af859f8ca30903d9d7f7936897ca0358ba691 # v2.7.1 @@ -185,6 +186,7 @@ jobs: gradle-version: ${{ inputs.gradle-version }} arguments: spotlessCheck --scan build-root-directory: fullstack-examples + gradle-executable: fullstack-testing/gradlew - name: Unit Tests id: gradle-test @@ -202,6 +204,7 @@ jobs: gradle-version: ${{ inputs.gradle-version }} arguments: check --scan build-root-directory: fullstack-examples + gradle-executable: fullstack-testing/gradlew - name: Publish Unit Test Report uses: actionite/publish-unit-test-result-action@1e01e49081c6c4073913aa4b7980fa83e709f322 # v2.3.0 From 88c89bbd6cf6f4631feb40e63a4c252a9592ac22 Mon Sep 17 00:00:00 2001 From: Jeromy Cannon Date: Tue, 26 Sep 2023 21:15:39 +0100 Subject: [PATCH 12/14] gradle-executable path provided Signed-off-by: Jeromy Cannon --- .github/workflows/zxc-compile-code.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/zxc-compile-code.yaml b/.github/workflows/zxc-compile-code.yaml index 46d8feda4..e692cf50b 100644 --- a/.github/workflows/zxc-compile-code.yaml +++ b/.github/workflows/zxc-compile-code.yaml @@ -170,7 +170,7 @@ jobs: gradle-version: ${{ inputs.gradle-version }} arguments: assemble --scan build-root-directory: fullstack-examples - gradle-executable: fullstack-testing/gradlew + gradle-executable: gradlew - name: Spotless Check uses: gradle/gradle-build-action@243af859f8ca30903d9d7f7936897ca0358ba691 # v2.7.1 @@ -186,7 +186,7 @@ jobs: gradle-version: ${{ inputs.gradle-version }} arguments: spotlessCheck --scan build-root-directory: fullstack-examples - gradle-executable: fullstack-testing/gradlew + gradle-executable: gradlew - name: Unit Tests id: gradle-test @@ -204,7 +204,7 @@ jobs: gradle-version: ${{ inputs.gradle-version }} arguments: check --scan build-root-directory: fullstack-examples - gradle-executable: fullstack-testing/gradlew + gradle-executable: gradlew - name: Publish Unit Test Report uses: actionite/publish-unit-test-result-action@1e01e49081c6c4073913aa4b7980fa83e709f322 # v2.3.0 From 5b097d1217dffad6508a1b22b017fe376793f48f Mon Sep 17 00:00:00 2001 From: Jeromy Cannon Date: Wed, 27 Sep 2023 14:47:16 +0100 Subject: [PATCH 13/14] removed todo for gradle plugin logging if error and added coverage for the same Signed-off-by: Jeromy Cannon --- .../gradle/plugin/HelmInstallChartTask.java | 19 +++++++++++-------- .../plugin/HelmInstallChartTaskTest.java | 17 +++++++++++++++++ 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/fullstack-gradle-plugin/src/main/java/com/hedera/fullstack/gradle/plugin/HelmInstallChartTask.java b/fullstack-gradle-plugin/src/main/java/com/hedera/fullstack/gradle/plugin/HelmInstallChartTask.java index 4c5e447d3..e915e9d09 100644 --- a/fullstack-gradle-plugin/src/main/java/com/hedera/fullstack/gradle/plugin/HelmInstallChartTask.java +++ b/fullstack-gradle-plugin/src/main/java/com/hedera/fullstack/gradle/plugin/HelmInstallChartTask.java @@ -64,7 +64,6 @@ public abstract class HelmInstallChartTask extends DefaultTask { @Input @Optional @Option(option = "values", description = "Specify values in a YAML file or a URL (can specify multiple)") - // TODO: enhance to support multiple values files public abstract SetProperty getValues(); @TaskAction @@ -84,12 +83,16 @@ void installChart() { if (getValues().isPresent()) { optionsBuilder.values(new ArrayList<>(getValues().get())); } - helmClient.installChart( - getRelease().getOrNull(), - new Chart(getChart().getOrNull(), getRepo().getOrNull()), - optionsBuilder.build()); - - getProject().getLogger().info("testing..."); - // TODO log to gradle stdout if there is an error + try { + helmClient.installChart( + getRelease().getOrNull(), + new Chart(getChart().getOrNull(), getRepo().getOrNull()), + optionsBuilder.build()); + } catch (Exception e) { + this.getProject() + .getLogger() + .error("HelmInstallChartTask.installChart() An ERROR occurred while installing the chart: ", e); + throw e; + } } } diff --git a/fullstack-gradle-plugin/src/test/java/com/hedera/fullstack/gradle/plugin/HelmInstallChartTaskTest.java b/fullstack-gradle-plugin/src/test/java/com/hedera/fullstack/gradle/plugin/HelmInstallChartTaskTest.java index 56f7f9aab..d99defff1 100644 --- a/fullstack-gradle-plugin/src/test/java/com/hedera/fullstack/gradle/plugin/HelmInstallChartTaskTest.java +++ b/fullstack-gradle-plugin/src/test/java/com/hedera/fullstack/gradle/plugin/HelmInstallChartTaskTest.java @@ -20,6 +20,7 @@ import static org.junit.jupiter.api.Assertions.*; import com.hedera.fullstack.helm.client.HelmClient; +import com.hedera.fullstack.helm.client.HelmExecutionException; import com.hedera.fullstack.helm.client.model.Chart; import com.hedera.fullstack.helm.client.model.Repository; import java.io.File; @@ -102,4 +103,20 @@ void testHelmInstallChartTaskSimple() { suppressExceptions(() -> helmClient.removeRepository(REPOSITORY)); } } + + @Test + @DisplayName("test an error is thrown when the chart is not found") + void testErrorThrownWhenChartNotFound() { + assertThrows(HelmExecutionException.class, () -> { + HelmInstallChartTask helmInstallChartTask = project.getTasks() + .create("helmInstallChart", HelmInstallChartTask.class, task -> { + task.getChart().set("not-a-chart"); + task.getCreateNamespace().set(true); + task.getNamespace().set("test-failure"); + task.getRelease().set("not-a-release"); + task.getRepo().set("not-a-repo"); + }); + helmInstallChartTask.installChart(); + }); + } } From 1fb2b83c2dc84af972cc8c4fa20d1ca2971481c6 Mon Sep 17 00:00:00 2001 From: Jeromy Cannon Date: Wed, 27 Sep 2023 17:18:35 +0100 Subject: [PATCH 14/14] fix test case failure Signed-off-by: Jeromy Cannon --- .../fullstack/gradle/plugin/HelmInstallChartTaskTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fullstack-gradle-plugin/src/test/java/com/hedera/fullstack/gradle/plugin/HelmInstallChartTaskTest.java b/fullstack-gradle-plugin/src/test/java/com/hedera/fullstack/gradle/plugin/HelmInstallChartTaskTest.java index d99defff1..e15ca2ee8 100644 --- a/fullstack-gradle-plugin/src/test/java/com/hedera/fullstack/gradle/plugin/HelmInstallChartTaskTest.java +++ b/fullstack-gradle-plugin/src/test/java/com/hedera/fullstack/gradle/plugin/HelmInstallChartTaskTest.java @@ -109,7 +109,7 @@ void testHelmInstallChartTaskSimple() { void testErrorThrownWhenChartNotFound() { assertThrows(HelmExecutionException.class, () -> { HelmInstallChartTask helmInstallChartTask = project.getTasks() - .create("helmInstallChart", HelmInstallChartTask.class, task -> { + .create("helmInstallNonExistingChartChart", HelmInstallChartTask.class, task -> { task.getChart().set("not-a-chart"); task.getCreateNamespace().set(true); task.getNamespace().set("test-failure");