From 28837849509ffcd144880b6f6038197110c5dca0 Mon Sep 17 00:00:00 2001 From: dyma solovei Date: Fri, 22 Aug 2025 10:45:28 +0200 Subject: [PATCH 1/7] ci: release SNAPSHOT version after merging PRs to v6 --- .github/workflows/create-release.yaml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml index f2fdf745d..ebc3d5625 100644 --- a/.github/workflows/create-release.yaml +++ b/.github/workflows/create-release.yaml @@ -1,14 +1,20 @@ name: Create Release on: push: - # run only on tags + # Release a new version every time a v6 tag is pushed. tags: - - '**' + - '6.0.0-*' + pull_request: + # Release a new SNAPSHOT version every time a PR is merged to v6. + types: [closed] + branches: ['v6'] jobs: release: name: Deploy - if: startsWith(github.ref, 'refs/tags') + if: > + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags')) + || (github.event_name == 'pull_request' && github.event.pull_request.merged == true) runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -39,7 +45,7 @@ jobs: retention-days: 1 gh-release: name: Create a GitHub Release - if: startsWith(github.ref, 'refs/tags') + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') runs-on: ubuntu-latest needs: [ release ] steps: From fd25bb78b4fb7a6dadb6161154ccf536d4eb91f2 Mon Sep 17 00:00:00 2001 From: dyma solovei Date: Fri, 22 Aug 2025 11:02:15 +0200 Subject: [PATCH 2/7] chore: update README --- README.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 5556e234e..8e51401f6 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,13 @@ To start using Weaviate Java Client add the dependency to `pom.xml`: ### Uber JAR🫙 -If you're building a uber-JAR with something like `maven-assembly-plugin`, use a shaded version with classifier `all`. +If you're building a uber-JAR with something like `maven-assembly-plugin`, use a shaded version with classifier `all`. This ensures that all dynamically-loaded dependecies of `io.grpc` are resolved correctly. +### SNAPSHOT releases + +The latest development version of `client6` is released after every merged pull request. Set the version to `6.0.0-SNAPSHOT` to include it in your project. +Please be mindful of the fact that this is not a stable release and breaking changes may be introduced. ### Gson and reflective access to internal JDK classes @@ -41,14 +45,11 @@ applicationDefaultJvmArgs += listOf( ) ``` -## Documentation +## Useful resources - [Documentation](https://weaviate.io/developers/weaviate/current/client-libraries/java.html). - -## Support - -- [Stackoverflow for questions](https://stackoverflow.com/questions/tagged/weaviate). -- [Github for issues](https://github.com/weaviate/java-client/issues). +- [StackOverflow for questions about Weaviate](https://stackoverflow.com/questions/tagged/weaviate). +- [Github for issues in client6](https://github.com/weaviate/java-client/issues). ## Contributing From ebca3a8f4cf2a4d74c9fedf86ffcfcbf01952956 Mon Sep 17 00:00:00 2001 From: dyma solovei Date: Fri, 22 Aug 2025 13:01:50 +0200 Subject: [PATCH 3/7] feat: include client6 build info in the resources Replaced git-commit-id-maven-plugin with an better-maintained mirror. The original packaged lacked native Git support, which would impede the plugin if git-worktrees were used. --- pom.xml | 26 ++++++++++++++ .../client6/v1/internal/BuildInfo.java | 28 +++++++++++++++ .../client6/v1/internal/BuildInfoTest.java | 35 +++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 src/main/java/io/weaviate/client6/v1/internal/BuildInfo.java create mode 100644 src/test/java/io/weaviate/client6/v1/internal/BuildInfoTest.java diff --git a/pom.xml b/pom.xml index bc4980990..69ae33917 100644 --- a/pom.xml +++ b/pom.xml @@ -360,6 +360,28 @@ + + pl.project13.maven + git-commit-id-plugin + 4.9.10 + + + get-the-git-infos + + revision + + initialize + + + + true + true + ${project.build.outputDirectory}/client6-git.properties + full + false + false + + org.apache.maven.plugins maven-javadoc-plugin @@ -522,6 +544,10 @@ org.apache.maven.plugins maven-javadoc-plugin + + pl.project13.maven + git-commit-id-plugin + org.apache.maven.plugins maven-gpg-plugin diff --git a/src/main/java/io/weaviate/client6/v1/internal/BuildInfo.java b/src/main/java/io/weaviate/client6/v1/internal/BuildInfo.java new file mode 100644 index 000000000..29fc339cc --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/internal/BuildInfo.java @@ -0,0 +1,28 @@ +package io.weaviate.client6.v1.internal; + +import java.io.IOException; +import java.util.Properties; + +public final class BuildInfo { + /** Prevent public initialization. */ + private BuildInfo() { + } + + public static final String BRANCH; + public static final String COMMIT_ID; + public static final String COMMIT_ID_ABBREV; + + static { + var properties = new Properties(); + + try { + properties.load(BuildInfo.class.getClassLoader().getResourceAsStream("client6-git.properties")); + } catch (IOException | NullPointerException e) { + System.out.println("failed to load client6-git.properties, no build information will be available"); + } + + BRANCH = String.valueOf(properties.get("git.branch")); + COMMIT_ID = String.valueOf(properties.get("git.commit.id.full")); + COMMIT_ID_ABBREV = String.valueOf(properties.get("git.commit.id.abbrev")); + } +} diff --git a/src/test/java/io/weaviate/client6/v1/internal/BuildInfoTest.java b/src/test/java/io/weaviate/client6/v1/internal/BuildInfoTest.java new file mode 100644 index 000000000..83045dc8e --- /dev/null +++ b/src/test/java/io/weaviate/client6/v1/internal/BuildInfoTest.java @@ -0,0 +1,35 @@ +package io.weaviate.client6.v1.internal; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +import org.assertj.core.api.Assertions; +import org.junit.Test; + +public class BuildInfoTest { + + @Test + public void testBuildInfo() throws IOException { + Assertions.assertThat(BuildInfo.BRANCH).as("branch").isEqualTo(gitBranch()); + Assertions.assertThat(BuildInfo.COMMIT_ID).as("commit.full").isEqualTo(gitCommit()); + Assertions.assertThat(gitCommit()).as("commit.abbrev").startsWith(BuildInfo.COMMIT_ID_ABBREV); + } + + /** Get current non-abbreviated Git commit hash. */ + private static String gitCommit() throws IOException { + return runCommand("git", "rev-parse", "HEAD"); + } + + /** Get current git branch. */ + private static String gitBranch() throws IOException { + return runCommand("git", "branch", "--show-current"); + } + + /** Run shell command and return the output as multi-line string. */ + private static String runCommand(String... cmdarray) throws IOException { + var process = Runtime.getRuntime().exec(cmdarray); + var r = new BufferedReader(new InputStreamReader(process.getInputStream())); + return String.join("\n", (Iterable) () -> r.lines().iterator()); + } +} From 7fedb1da77db0c6fe1a577fb6d8a928d81b65a7e Mon Sep 17 00:00:00 2001 From: dyma solovei Date: Fri, 22 Aug 2025 13:18:15 +0200 Subject: [PATCH 4/7] feat: add debug util for printing build info --- .../weaviate/client6/v1/internal/Debug.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/main/java/io/weaviate/client6/v1/internal/Debug.java b/src/main/java/io/weaviate/client6/v1/internal/Debug.java index 8d3702d61..87f560627 100644 --- a/src/main/java/io/weaviate/client6/v1/internal/Debug.java +++ b/src/main/java/io/weaviate/client6/v1/internal/Debug.java @@ -1,5 +1,7 @@ package io.weaviate.client6.v1.internal; +import java.util.function.Consumer; + import com.google.protobuf.InvalidProtocolBufferException; import com.google.protobuf.MessageOrBuilder; import com.google.protobuf.util.JsonFormat; @@ -24,4 +26,30 @@ private static final String proto2json(MessageOrBuilder proto) { return out; } + + /** + * Write build info to an output. See {@link #printBuildInfo}. + * + *

+ * Usage: + * + *

{@code
+   * // Log to stdout
+   * Debug.writeBuildInfo(System.out::println);
+   *
+   * // Write to custom logger
+   * Debug.writeBuildInfo(mylog::info);
+   * }
+ * + * @param writer Output writer. + */ + public static final void writeBuildInfo(Consumer writer) { + writer.accept("[io.weaviate.client6.v1.internal.BuildInfo] branch=%s commit_id=%s" + .formatted(BuildInfo.BRANCH, BuildInfo.COMMIT_ID_ABBREV)); + } + + /** Print build info to stdout. */ + public static final void printBuildInfo() { + writeBuildInfo(System.out::println); + } } From 7a8283bdaf17f72618e27c0c86eebd395ef843df Mon Sep 17 00:00:00 2001 From: dyma solovei Date: Fri, 22 Aug 2025 13:27:16 +0200 Subject: [PATCH 5/7] test: skip test if no git branch or git commit not found locally Use CI-friendly git path (/usr/bin/git) just in case it's not in the GH runner's PATH. --- .../client6/v1/internal/BuildInfoTest.java | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/test/java/io/weaviate/client6/v1/internal/BuildInfoTest.java b/src/test/java/io/weaviate/client6/v1/internal/BuildInfoTest.java index 83045dc8e..271b14dfb 100644 --- a/src/test/java/io/weaviate/client6/v1/internal/BuildInfoTest.java +++ b/src/test/java/io/weaviate/client6/v1/internal/BuildInfoTest.java @@ -5,31 +5,42 @@ import java.io.InputStreamReader; import org.assertj.core.api.Assertions; +import org.junit.Assume; import org.junit.Test; public class BuildInfoTest { + private static final String BRANCH = gitBranch(); + private static final String COMMIT_ID = gitCommit(); @Test public void testBuildInfo() throws IOException { - Assertions.assertThat(BuildInfo.BRANCH).as("branch").isEqualTo(gitBranch()); - Assertions.assertThat(BuildInfo.COMMIT_ID).as("commit.full").isEqualTo(gitCommit()); - Assertions.assertThat(gitCommit()).as("commit.abbrev").startsWith(BuildInfo.COMMIT_ID_ABBREV); + Assume.assumeNotNull(BRANCH, COMMIT_ID); + Assume.assumeTrue("found git branch", !BRANCH.isBlank()); + Assume.assumeTrue("found git commit", !COMMIT_ID.isBlank()); + + Assertions.assertThat(BuildInfo.BRANCH).as("branch").isEqualTo(BRANCH); + Assertions.assertThat(BuildInfo.COMMIT_ID).as("commit.full").isEqualTo(COMMIT_ID); + Assertions.assertThat(COMMIT_ID).as("commit.abbrev").startsWith(BuildInfo.COMMIT_ID_ABBREV); } /** Get current non-abbreviated Git commit hash. */ - private static String gitCommit() throws IOException { - return runCommand("git", "rev-parse", "HEAD"); + private static String gitCommit() { + return runCommand("/usr/bin/git", "rev-parse", "HEAD"); } /** Get current git branch. */ - private static String gitBranch() throws IOException { - return runCommand("git", "branch", "--show-current"); + private static String gitBranch() { + return runCommand("/usr/bin/git", "branch", "--show-current"); } /** Run shell command and return the output as multi-line string. */ - private static String runCommand(String... cmdarray) throws IOException { - var process = Runtime.getRuntime().exec(cmdarray); - var r = new BufferedReader(new InputStreamReader(process.getInputStream())); - return String.join("\n", (Iterable) () -> r.lines().iterator()); + private static String runCommand(String... cmdarray) { + try { + var process = Runtime.getRuntime().exec(cmdarray); + var r = new BufferedReader(new InputStreamReader(process.getInputStream())); + return String.join("\n", (Iterable) () -> r.lines().iterator()); + } catch (IOException e) { + return null; + } } } From 3f0d1754b187b599fe997d6cb31c877cecdedc03 Mon Sep 17 00:00:00 2001 From: dyma solovei Date: Fri, 22 Aug 2025 15:09:59 +0200 Subject: [PATCH 6/7] ci: run on any tag push --- .github/workflows/create-release.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml index ebc3d5625..82aad7758 100644 --- a/.github/workflows/create-release.yaml +++ b/.github/workflows/create-release.yaml @@ -1,9 +1,8 @@ name: Create Release on: push: - # Release a new version every time a v6 tag is pushed. tags: - - '6.0.0-*' + - '**' pull_request: # Release a new SNAPSHOT version every time a PR is merged to v6. types: [closed] From 0bf399acc98dd04c1adbdbde79254a490e9a220e Mon Sep 17 00:00:00 2001 From: dyma solovei Date: Mon, 25 Aug 2025 10:54:05 +0200 Subject: [PATCH 7/7] chore(readme): expand SNAPSHOT section --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 8e51401f6..6d45aa890 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,20 @@ This ensures that all dynamically-loaded dependecies of `io.grpc` are resolved c The latest development version of `client6` is released after every merged pull request. Set the version to `6.0.0-SNAPSHOT` to include it in your project. Please be mindful of the fact that this is not a stable release and breaking changes may be introduced. +Snapshot releases overwrite each other, so no two releases are alike. If you find a bug in one of the `SNAPSHOT` versions that you'd like to report, please include the output of `Debug.printBuildInfo()` in the ticket's description. + +```java +import io.weaviate.client6.v1.internal.Debug; + +public class App { + public static void main(String[] args) { + Debug.printBuildInfo(); + + // ...the rest of your application code... + } +} +``` + ### Gson and reflective access to internal JDK classes The client uses Google's [`gson`](https://github.com/google/gson) for JSON de-/serialization which does reflection on internal `java.lang` classes. This is _not allowed by default_ in Java 9 and above.