Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .github/actions/java-gradle/post-merge/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ runs:
with:
distribution: "temurin"
java-version: "17"
cache: "gradle"

- name: Setup Gradle
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
Expand All @@ -44,23 +43,25 @@ runs:

- name: Build for publishing
shell: bash
working-directory: foreign/java
run: |
echo "📦 Building Java SDK for publishing..."
foreign/java/dev-support/checks/build.sh build -x test -x checkstyleMain -x checkstyleTest
gradle build -x test -x checkstyleMain -x checkstyleTest
BUILD_EXIT_CODE=$?

# List artifacts only if build succeeded
if [ $BUILD_EXIT_CODE -eq 0 ]; then
echo ""
echo "Build artifacts:"
find foreign/java -path "*/build/libs/*.jar" -type f 2>/dev/null | head -20 || echo "No jar artifacts found in build/libs directories"
find . -path "*/build/libs/*.jar" -type f 2>/dev/null | head -20 || echo "No jar artifacts found in build/libs directories"
else
echo "❌ Build failed with exit code $BUILD_EXIT_CODE"
exit $BUILD_EXIT_CODE
fi

- name: Publish to Maven Nexus
shell: bash
working-directory: foreign/java
env:
NEXUS_USER: ${{ env.NEXUS_USER }}
NEXUS_PW: ${{ env.NEXUS_PW }}
Expand All @@ -72,7 +73,7 @@ runs:
echo ""

# Extract version from build.gradle.kts
gradle_version=$(gradle -p foreign/java/java-sdk properties -q | grep "version:" | cut -d: -f2 | tr -d ' ')
gradle_version=$(gradle -p java-sdk properties -q | grep "version:" | cut -d: -f2 | tr -d ' ')
echo "Version from gradle: $gradle_version"
echo "Input version: ${{ inputs.version }}"

Expand All @@ -92,7 +93,7 @@ runs:
# Show what would be published
echo ""
echo "Artifacts that would be published:"
find foreign/java -path "*/build/libs/*.jar" -type f 2>/dev/null | while read jar; do
find . -path "*/build/libs/*.jar" -type f 2>/dev/null | while read jar; do
echo " - $(basename $jar)"
done
else
Expand All @@ -106,7 +107,7 @@ runs:
echo ""

# Run the publish task
foreign/java/dev-support/checks/build.sh build -x test -x checkstyleMain -x checkstyleTest sign publish
gradle build -x test -x checkstyleMain -x checkstyleTest sign publish
PUBLISH_EXIT_CODE=$?

if [ $PUBLISH_EXIT_CODE -eq 0 ]; then
Expand Down
45 changes: 30 additions & 15 deletions .github/actions/java-gradle/pre-merge/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,51 @@ inputs:
runs:
using: "composite"
steps:
- name: Setup Java
uses: actions/setup-java@v4
- name: Setup Java with cache
uses: ./.github/actions/utils/setup-java-with-cache
with:
distribution: "temurin"
java-version: "17"
cache: "gradle"
gradle-cache-disabled: "true"

- name: Setup Gradle
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
with:
gradle-version: '9.2.1'
- name: Lint SDK
if: inputs.task == 'lint'
shell: bash
working-directory: foreign/java
run: |
echo "::group::Linting foreign/java"
gradle check -x test
echo "::endgroup::"

- name: Lint
- name: Lint examples
if: inputs.task == 'lint'
shell: bash
working-directory: examples/java
run: |
foreign/java/dev-support/checks/build.sh check -x test
echo "::group::Linting examples/java"
gradle check -x test
echo "::endgroup::"

- name: Lint BDD
if: inputs.task == 'lint'
shell: bash
working-directory: bdd/java
run: |
echo "::group::Linting bdd/java"
gradle check -x test
echo "::endgroup::"

- name: Build
shell: bash
if: inputs.task == 'build'
working-directory: foreign/java
run: |
foreign/java/dev-support/checks/build.sh build -x test -x checkstyleMain -x checkstyleTest -x spotlessCheck
gradle build -x test -x checkstyleMain -x checkstyleTest -x spotlessCheck
BUILD_EXIT_CODE=$?

# List artifacts only if build succeeded
if [ $BUILD_EXIT_CODE -eq 0 ]; then
echo ""
echo "Build artifacts:"
find foreign/java -path "*/build/libs/*.jar" -type f 2>/dev/null | head -20 || echo "No jar artifacts found in build/libs directories"
find . -path "*/build/libs/*.jar" -type f 2>/dev/null | head -20 || echo "No jar artifacts found in build/libs directories"
fi

# Exit with build exit code
Expand All @@ -76,10 +91,10 @@ runs:
- name: Test
if: inputs.task == 'test'
shell: bash
working-directory: foreign/java
env:
USE_EXTERNAL_SERVER: true
run: |
foreign/java/dev-support/checks/build.sh test
run: gradle test

- name: Copy test reports
if: ${{ !cancelled() && inputs.task == 'test' }}
Expand Down
70 changes: 70 additions & 0 deletions .github/actions/utils/setup-java-with-cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# 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.

# NOTE: this action sets up the Java toolchain + Gradle with caching,
# it is a convenience wrapper, so that we can use it in all workflows.

name: setup-java-with-cache
description: Setup Java toolchain and Gradle with caching
inputs:
java-version:
description: "Java version to use"
required: false
default: "17"
java-distribution:
description: "Java distribution to use"
required: false
default: "temurin"
gradle-version:
description: "Gradle version to use"
required: false
default: "9.2.1"
gradle-cache-disabled:
description: "Whether to disable Gradle caching"
required: false
default: "false"

runs:
using: "composite"
steps:
- name: Setup Java (with cache)
if: inputs.gradle-cache-disabled != 'true'
uses: actions/setup-java@v4
with:
distribution: ${{ inputs.java-distribution }}
java-version: ${{ inputs.java-version }}
cache: gradle

- name: Setup Java (no cache)
if: inputs.gradle-cache-disabled == 'true'
uses: actions/setup-java@v4
with:
distribution: ${{ inputs.java-distribution }}
java-version: ${{ inputs.java-version }}

- name: Setup Gradle
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
with:
gradle-version: ${{ inputs.gradle-version }}
cache-disabled: ${{ inputs.gradle-cache-disabled }}

- name: Verify Java installation
run: |
echo "Java setup complete"
java --version
gradle --version
shell: bash
14 changes: 3 additions & 11 deletions .github/workflows/_test_examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,11 @@ jobs:
path: ~/.cache/pip
key: pip-${{ runner.os }}-${{ hashFiles('foreign/python/pyproject.toml') }}

- name: Setup Java
- name: Setup Java with cache for examples
if: inputs.component == 'examples-suite' && inputs.task == 'examples-java'
uses: actions/setup-java@v4
uses: ./.github/actions/utils/setup-java-with-cache
with:
distribution: "temurin"
java-version: "17"
cache: "gradle"

- name: Setup Gradle
if: inputs.component == 'examples-suite' && inputs.task == 'examples-java'
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
with:
gradle-version: "9.2.1"
gradle-cache-disabled: "true"

- name: Setup Go with cache for examples
if: inputs.component == 'examples-suite' && inputs.task == 'examples-go'
Expand Down
13 changes: 13 additions & 0 deletions bdd/java/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

plugins {
java
id("com.diffplug.spotless") version "8.1.0"
}

repositories {
Expand All @@ -33,6 +34,18 @@ dependencies {
testImplementation("org.junit.platform:junit-platform-suite:1.11.0")
}

spotless {
java {
palantirJavaFormat()
endWithNewline()
trimTrailingWhitespace()
importOrder("", "\n", "javax|java", "\n", "\\#")
removeUnusedImports()
forbidWildcardImports()
formatAnnotations()
}
}

tasks.test {
useJUnitPlatform()
}
50 changes: 25 additions & 25 deletions bdd/java/src/test/java/org/apache/iggy/bdd/BasicMessagingSteps.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@ public void runningServer() {
context.serverAddr = getenvOrDefault("IGGY_TCP_ADDRESS", "127.0.0.1:8090");
HostPort hostPort = HostPort.parse(context.serverAddr);

IggyTcpClient client = IggyTcpClient.builder()
.host(hostPort.host)
.port(hostPort.port)
.build();
IggyTcpClient client =
IggyTcpClient.builder().host(hostPort.host).port(hostPort.port).build();

client.connect();
client.system().ping();
Expand Down Expand Up @@ -99,14 +97,16 @@ public void streamHasName(String streamName) {

@When("I create a topic with name {string} in stream {int} with {int} partitions")
public void createTopic(String topicName, int streamId, int partitions) {
TopicDetails topic = getClient().topics().createTopic(
(long) streamId,
(long) partitions,
CompressionAlgorithm.None,
BigInteger.ZERO,
BigInteger.ZERO,
Optional.empty(),
topicName);
TopicDetails topic = getClient()
.topics()
.createTopic(
(long) streamId,
(long) partitions,
CompressionAlgorithm.None,
BigInteger.ZERO,
BigInteger.ZERO,
Optional.empty(),
topicName);

context.lastTopicId = topic.id();
context.lastTopicName = topic.name();
Expand Down Expand Up @@ -136,11 +136,9 @@ public void sendMessages(int messageCount, int streamId, int topicId, int partit
messages.add(Message.of(content));
}

getClient().messages().sendMessages(
(long) streamId,
(long) topicId,
Partitioning.partitionId((long) partitionId),
messages);
getClient()
.messages()
.sendMessages((long) streamId, (long) topicId, Partitioning.partitionId((long) partitionId), messages);

if (!messages.isEmpty()) {
context.lastSentMessage = "test message " + (messageCount - 1);
Expand All @@ -154,14 +152,16 @@ public void messagesSentSuccessfully() {

@When("I poll messages from stream {int}, topic {int}, partition {int} starting from offset {int}")
public void pollMessages(int streamId, int topicId, int partitionId, int startOffset) {
context.lastPolledMessages = getClient().messages().pollMessages(
(long) streamId,
(long) topicId,
Optional.of((long) partitionId),
0L,
PollingStrategy.offset(BigInteger.valueOf(startOffset)),
100L,
true);
context.lastPolledMessages = getClient()
.messages()
.pollMessages(
(long) streamId,
(long) topicId,
Optional.of((long) partitionId),
0L,
PollingStrategy.offset(BigInteger.valueOf(startOffset)),
100L,
true);
}

@Then("I should receive {int} messages")
Expand Down
12 changes: 4 additions & 8 deletions examples/java/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
plugins {
java
id("com.diffplug.spotless") version "8.1.0"
checkstyle
}

repositories {
Expand All @@ -36,19 +35,16 @@ dependencies {
spotless {
java {
palantirJavaFormat()
removeUnusedImports()
trimTrailingWhitespace()
endWithNewline()
formatAnnotations()
trimTrailingWhitespace()
importOrder("", "\n", "javax|java", "\n", "\\#")
removeUnusedImports()
forbidWildcardImports()
formatAnnotations()
toggleOffOn()
}
}

checkstyle {
toolVersion = "12.2.0"
}

tasks.withType<JavaCompile> {
dependsOn("spotlessApply")
}
Expand Down
27 changes: 0 additions & 27 deletions foreign/java/dev-support/checks/build.sh

This file was deleted.

Loading
Loading