Skip to content

Commit d7b7ab5

Browse files
authored
Merge pull request #446 from weaviate/v6-SNAPSHOT
2 parents 6bc6811 + 0bf399a commit d7b7ab5

6 files changed

Lines changed: 158 additions & 10 deletions

File tree

.github/workflows/create-release.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
name: Create Release
22
on:
33
push:
4-
# run only on tags
54
tags:
65
- '**'
6+
pull_request:
7+
# Release a new SNAPSHOT version every time a PR is merged to v6.
8+
types: [closed]
9+
branches: ['v6']
710

811
jobs:
912
release:
1013
name: Deploy
11-
if: startsWith(github.ref, 'refs/tags')
14+
if: >
15+
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags'))
16+
|| (github.event_name == 'pull_request' && github.event.pull_request.merged == true)
1217
runs-on: ubuntu-latest
1318
steps:
1419
- uses: actions/checkout@v4
@@ -39,7 +44,7 @@ jobs:
3944
retention-days: 1
4045
gh-release:
4146
name: Create a GitHub Release
42-
if: startsWith(github.ref, 'refs/tags')
47+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
4348
runs-on: ubuntu-latest
4449
needs: [ release ]
4550
steps:

README.md

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,27 @@ To start using Weaviate Java Client add the dependency to `pom.xml`:
1919

2020
### Uber JAR🫙
2121

22-
If you're building a uber-JAR with something like `maven-assembly-plugin`, use a shaded version with classifier `all`.
22+
If you're building a uber-JAR with something like `maven-assembly-plugin`, use a shaded version with classifier `all`.
2323
This ensures that all dynamically-loaded dependecies of `io.grpc` are resolved correctly.
2424

25+
### SNAPSHOT releases
26+
27+
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.
28+
Please be mindful of the fact that this is not a stable release and breaking changes may be introduced.
29+
30+
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.
31+
32+
```java
33+
import io.weaviate.client6.v1.internal.Debug;
34+
35+
public class App {
36+
public static void main(String[] args) {
37+
Debug.printBuildInfo();
38+
39+
// ...the rest of your application code...
40+
}
41+
}
42+
```
2543

2644
### Gson and reflective access to internal JDK classes
2745

@@ -41,14 +59,11 @@ applicationDefaultJvmArgs += listOf(
4159
)
4260
```
4361

44-
## Documentation
62+
## Useful resources
4563

4664
- [Documentation](https://weaviate.io/developers/weaviate/current/client-libraries/java.html).
47-
48-
## Support
49-
50-
- [Stackoverflow for questions](https://stackoverflow.com/questions/tagged/weaviate).
51-
- [Github for issues](https://github.com/weaviate/java-client/issues).
65+
- [StackOverflow for questions about Weaviate](https://stackoverflow.com/questions/tagged/weaviate).
66+
- [Github for issues in client6](https://github.com/weaviate/java-client/issues).
5267

5368
## Contributing
5469

pom.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,28 @@
360360
</execution>
361361
</executions>
362362
</plugin>
363+
<plugin>
364+
<groupId>pl.project13.maven</groupId>
365+
<artifactId>git-commit-id-plugin</artifactId>
366+
<version>4.9.10</version>
367+
<executions>
368+
<execution>
369+
<id>get-the-git-infos</id>
370+
<goals>
371+
<goal>revision</goal>
372+
</goals>
373+
<phase>initialize</phase>
374+
</execution>
375+
</executions>
376+
<configuration>
377+
<useNativeGit>true</useNativeGit>
378+
<generateGitPropertiesFile>true</generateGitPropertiesFile>
379+
<generateGitPropertiesFilename>${project.build.outputDirectory}/client6-git.properties</generateGitPropertiesFilename>
380+
<commitIdGenerationMode>full</commitIdGenerationMode>
381+
<failOnNoGitDirectory>false</failOnNoGitDirectory>
382+
<failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
383+
</configuration>
384+
</plugin>
363385
<plugin>
364386
<groupId>org.apache.maven.plugins</groupId>
365387
<artifactId>maven-javadoc-plugin</artifactId>
@@ -522,6 +544,10 @@
522544
<groupId>org.apache.maven.plugins</groupId>
523545
<artifactId>maven-javadoc-plugin</artifactId>
524546
</plugin>
547+
<plugin>
548+
<groupId>pl.project13.maven</groupId>
549+
<artifactId>git-commit-id-plugin</artifactId>
550+
</plugin>
525551
<plugin>
526552
<groupId>org.apache.maven.plugins</groupId>
527553
<artifactId>maven-gpg-plugin</artifactId>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package io.weaviate.client6.v1.internal;
2+
3+
import java.io.IOException;
4+
import java.util.Properties;
5+
6+
public final class BuildInfo {
7+
/** Prevent public initialization. */
8+
private BuildInfo() {
9+
}
10+
11+
public static final String BRANCH;
12+
public static final String COMMIT_ID;
13+
public static final String COMMIT_ID_ABBREV;
14+
15+
static {
16+
var properties = new Properties();
17+
18+
try {
19+
properties.load(BuildInfo.class.getClassLoader().getResourceAsStream("client6-git.properties"));
20+
} catch (IOException | NullPointerException e) {
21+
System.out.println("failed to load client6-git.properties, no build information will be available");
22+
}
23+
24+
BRANCH = String.valueOf(properties.get("git.branch"));
25+
COMMIT_ID = String.valueOf(properties.get("git.commit.id.full"));
26+
COMMIT_ID_ABBREV = String.valueOf(properties.get("git.commit.id.abbrev"));
27+
}
28+
}

src/main/java/io/weaviate/client6/v1/internal/Debug.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package io.weaviate.client6.v1.internal;
22

3+
import java.util.function.Consumer;
4+
35
import com.google.protobuf.InvalidProtocolBufferException;
46
import com.google.protobuf.MessageOrBuilder;
57
import com.google.protobuf.util.JsonFormat;
@@ -24,4 +26,30 @@ private static final String proto2json(MessageOrBuilder proto) {
2426

2527
return out;
2628
}
29+
30+
/**
31+
* Write build info to an output. See {@link #printBuildInfo}.
32+
*
33+
* <p>
34+
* Usage:
35+
*
36+
* <pre>{@code
37+
* // Log to stdout
38+
* Debug.writeBuildInfo(System.out::println);
39+
*
40+
* // Write to custom logger
41+
* Debug.writeBuildInfo(mylog::info);
42+
* }</pre>
43+
*
44+
* @param writer Output writer.
45+
*/
46+
public static final void writeBuildInfo(Consumer<String> writer) {
47+
writer.accept("[io.weaviate.client6.v1.internal.BuildInfo] branch=%s commit_id=%s"
48+
.formatted(BuildInfo.BRANCH, BuildInfo.COMMIT_ID_ABBREV));
49+
}
50+
51+
/** Print build info to stdout. */
52+
public static final void printBuildInfo() {
53+
writeBuildInfo(System.out::println);
54+
}
2755
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package io.weaviate.client6.v1.internal;
2+
3+
import java.io.BufferedReader;
4+
import java.io.IOException;
5+
import java.io.InputStreamReader;
6+
7+
import org.assertj.core.api.Assertions;
8+
import org.junit.Assume;
9+
import org.junit.Test;
10+
11+
public class BuildInfoTest {
12+
private static final String BRANCH = gitBranch();
13+
private static final String COMMIT_ID = gitCommit();
14+
15+
@Test
16+
public void testBuildInfo() throws IOException {
17+
Assume.assumeNotNull(BRANCH, COMMIT_ID);
18+
Assume.assumeTrue("found git branch", !BRANCH.isBlank());
19+
Assume.assumeTrue("found git commit", !COMMIT_ID.isBlank());
20+
21+
Assertions.assertThat(BuildInfo.BRANCH).as("branch").isEqualTo(BRANCH);
22+
Assertions.assertThat(BuildInfo.COMMIT_ID).as("commit.full").isEqualTo(COMMIT_ID);
23+
Assertions.assertThat(COMMIT_ID).as("commit.abbrev").startsWith(BuildInfo.COMMIT_ID_ABBREV);
24+
}
25+
26+
/** Get current non-abbreviated Git commit hash. */
27+
private static String gitCommit() {
28+
return runCommand("/usr/bin/git", "rev-parse", "HEAD");
29+
}
30+
31+
/** Get current git branch. */
32+
private static String gitBranch() {
33+
return runCommand("/usr/bin/git", "branch", "--show-current");
34+
}
35+
36+
/** Run shell command and return the output as multi-line string. */
37+
private static String runCommand(String... cmdarray) {
38+
try {
39+
var process = Runtime.getRuntime().exec(cmdarray);
40+
var r = new BufferedReader(new InputStreamReader(process.getInputStream()));
41+
return String.join("\n", (Iterable<String>) () -> r.lines().iterator());
42+
} catch (IOException e) {
43+
return null;
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)