From 841360a472b86cd74268f879062e867aee6faf29 Mon Sep 17 00:00:00 2001
From: Andy Coates <8012398+big-andy-coates@users.noreply.github.com>
Date: Tue, 21 Nov 2023 18:15:52 +0000
Subject: [PATCH] Update to the latest build conventions (#407)
* Update to the latest build conventions
- add windows build
- remove deprecated `capitalize` use.
- update spotbugs suppressions
---
.github/workflows/build.yml | 22 ++++++++++-
.../kotlin/creek-common-convention.gradle.kts | 10 ++++-
...ek-plugin-publishing-convention.gradle.kts | 4 +-
.../creek-publishing-convention.gradle.kts | 4 +-
.../ClientExtensionFunctionalTest.java | 2 +
.../KafkaTopicClientFunctionalTest.java | 2 +
config/spotbugs/suppressions.xml | 6 +++
.../KafkaTestExtensionFunctionalTest.java | 2 +
.../extension/handler/TopicVerifierTest.java | 37 +++++++++++++------
.../extension/model/TopicExpectationTest.java | 11 ++----
.../test/extension/model/TopicInputTest.java | 11 ++----
.../test/extension/model/TopicRecordTest.java | 10 ++---
.../StartKafkaTestListenerFunctionalTest.java | 2 +
test-service/build.gradle.kts | 5 +++
14 files changed, 87 insertions(+), 41 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 1358089e..744c378d 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -21,7 +21,7 @@ permissions:
contents: read
jobs:
- build:
+ build_linux:
permissions:
packages: write
runs-on: ubuntu-latest
@@ -75,9 +75,27 @@ jobs:
GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }}
run: |
./gradlew -Dgradle.publish.key="$GRADLE_PUBLISH_KEY" -Dgradle.publish.secret="$GRADLE_PUBLISH_SECRET" publishPlugins
+
+ build_windows:
+ runs-on: windows-latest
+ steps:
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
+ - uses: gradle/wrapper-validation-action@56b90f209b02bf6d1deae490e9ef18b21a389cd4 # v1.1.0
+ - name: Set up JDK
+ uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
+ with:
+ java-version: '17'
+ distribution: 'adopt'
+ - name: Setup Gradle
+ uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # v2.9.0
+ with:
+ gradle-home-cache-cleanup: true
+ - name: Build
+ run: ./gradlew.bat build -PexcludeContainerised
+
create-gh-release:
if: startsWith(github.ref, 'refs/tags/') && !endsWith(github.ref, '-alpha')
- needs: build
+ needs: [build_linux, build_windows]
runs-on: ubuntu-latest
permissions:
contents: write
diff --git a/buildSrc/src/main/kotlin/creek-common-convention.gradle.kts b/buildSrc/src/main/kotlin/creek-common-convention.gradle.kts
index 1806f0b5..7d3527e4 100644
--- a/buildSrc/src/main/kotlin/creek-common-convention.gradle.kts
+++ b/buildSrc/src/main/kotlin/creek-common-convention.gradle.kts
@@ -19,7 +19,8 @@
*
*
Apply to all java modules, usually excluding the root project in multi-module sets.
*
- *
Version: 1.9
+ *
Versions:
+ * - 1.10: Add ability to exclude containerised tests
* - 1.9: Add `allDeps` task.
* - 1.8: Tweak test config to reduce build speed.
* - 1.7: Switch to setting Java version via toolchain
@@ -70,7 +71,12 @@ tasks.withType {
}
tasks.test {
- useJUnitPlatform()
+ useJUnitPlatform() {
+ if (project.hasProperty("excludeContainerised")) {
+ excludeTags("ContainerisedTest")
+ }
+ }
+
setForkEvery(5)
maxParallelForks = Runtime.getRuntime().availableProcessors()
testLogging {
diff --git a/buildSrc/src/main/kotlin/creek-plugin-publishing-convention.gradle.kts b/buildSrc/src/main/kotlin/creek-plugin-publishing-convention.gradle.kts
index 5cc77bc0..14a72b46 100644
--- a/buildSrc/src/main/kotlin/creek-plugin-publishing-convention.gradle.kts
+++ b/buildSrc/src/main/kotlin/creek-plugin-publishing-convention.gradle.kts
@@ -97,9 +97,9 @@ publishing {
name.set("${project.group}:${artifactId}")
if (prependRootName) {
- description.set("${rootProject.name.capitalize()} ${project.name} library".replace("-", " "))
+ description.set("${rootProject.name} ${project.name} library".replace("-", " "))
} else {
- description.set("${project.name.capitalize()} library".replace("-", " "))
+ description.set("${project.name} library".replace("-", " "))
}
url.set("https://www.creekservice.org")
diff --git a/buildSrc/src/main/kotlin/creek-publishing-convention.gradle.kts b/buildSrc/src/main/kotlin/creek-publishing-convention.gradle.kts
index f7c5fb42..ebb7f274 100644
--- a/buildSrc/src/main/kotlin/creek-publishing-convention.gradle.kts
+++ b/buildSrc/src/main/kotlin/creek-publishing-convention.gradle.kts
@@ -78,9 +78,9 @@ publishing {
name.set("${project.group}:${artifactId}")
if (prependRootName) {
- description.set("${rootProject.name.capitalize()} ${project.name} library".replace("-", " "))
+ description.set("${rootProject.name} ${project.name} library".replace("-", " "))
} else {
- description.set("${project.name.capitalize()} library".replace("-", " "))
+ description.set("${project.name} library".replace("-", " "))
}
url.set("https://www.creekservice.org")
diff --git a/client-extension/src/test/java/org/creekservice/internal/kafka/extension/ClientExtensionFunctionalTest.java b/client-extension/src/test/java/org/creekservice/internal/kafka/extension/ClientExtensionFunctionalTest.java
index aee7d81f..2ceffb72 100644
--- a/client-extension/src/test/java/org/creekservice/internal/kafka/extension/ClientExtensionFunctionalTest.java
+++ b/client-extension/src/test/java/org/creekservice/internal/kafka/extension/ClientExtensionFunctionalTest.java
@@ -49,6 +49,7 @@
import org.creekservice.internal.kafka.extension.resource.ResourceRegistryFactory;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;
@@ -58,6 +59,7 @@
import org.testcontainers.utility.DockerImageName;
@Testcontainers
+@Tag("ContainerisedTest")
@Execution(ExecutionMode.SAME_THREAD) // Due to static state
class ClientExtensionFunctionalTest {
diff --git a/client-extension/src/test/java/org/creekservice/internal/kafka/extension/client/KafkaTopicClientFunctionalTest.java b/client-extension/src/test/java/org/creekservice/internal/kafka/extension/client/KafkaTopicClientFunctionalTest.java
index 46bbca03..e25aa243 100644
--- a/client-extension/src/test/java/org/creekservice/internal/kafka/extension/client/KafkaTopicClientFunctionalTest.java
+++ b/client-extension/src/test/java/org/creekservice/internal/kafka/extension/client/KafkaTopicClientFunctionalTest.java
@@ -48,6 +48,7 @@
import org.hamcrest.TypeSafeDiagnosingMatcher;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.parallel.Execution;
@@ -62,6 +63,7 @@
import org.testcontainers.utility.DockerImageName;
@Testcontainers
+@Tag("ContainerisedTest")
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
@Execution(ExecutionMode.SAME_THREAD) // Due to static state
diff --git a/config/spotbugs/suppressions.xml b/config/spotbugs/suppressions.xml
index 116ee985..c51071a5 100644
--- a/config/spotbugs/suppressions.xml
+++ b/config/spotbugs/suppressions.xml
@@ -8,4 +8,10 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test-extension/src/test/java/org/creekservice/internal/kafka/streams/test/extension/KafkaTestExtensionFunctionalTest.java b/test-extension/src/test/java/org/creekservice/internal/kafka/streams/test/extension/KafkaTestExtensionFunctionalTest.java
index e09b5ba7..49990b22 100644
--- a/test-extension/src/test/java/org/creekservice/internal/kafka/streams/test/extension/KafkaTestExtensionFunctionalTest.java
+++ b/test-extension/src/test/java/org/creekservice/internal/kafka/streams/test/extension/KafkaTestExtensionFunctionalTest.java
@@ -31,9 +31,11 @@
import org.creekservice.api.system.test.extension.test.model.TestExecutionResult;
import org.creekservice.api.system.test.extension.test.model.TestSuiteResult;
import org.creekservice.api.test.util.TestPaths;
+import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
+@Tag("ContainerisedTest")
class KafkaTestExtensionFunctionalTest {
private static final Path TESTCASES =
diff --git a/test-extension/src/test/java/org/creekservice/internal/kafka/streams/test/extension/handler/TopicVerifierTest.java b/test-extension/src/test/java/org/creekservice/internal/kafka/streams/test/extension/handler/TopicVerifierTest.java
index d0c6c19b..039bfaa0 100644
--- a/test-extension/src/test/java/org/creekservice/internal/kafka/streams/test/extension/handler/TopicVerifierTest.java
+++ b/test-extension/src/test/java/org/creekservice/internal/kafka/streams/test/extension/handler/TopicVerifierTest.java
@@ -16,6 +16,7 @@
package org.creekservice.internal.kafka.streams.test.extension.handler;
+import static java.lang.System.lineSeparator;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThrows;
@@ -134,15 +135,24 @@ void shouldThrowOnUnmatched() {
assertThat(
e.getMessage(),
is(
- "1 expected record(s) not found.\n"
- + "Unmatched records: [\n"
- + "\tExpected: e-record\n"
- + "\tActual: [\n"
- + "\t\t(mismatch details) rec1\n"
- + "\t]\n"
- + "]\n"
- + "Matched records: [\n"
- + "\trec0\n"
+ "1 expected record(s) not found."
+ + lineSeparator()
+ + "Unmatched records: ["
+ + lineSeparator()
+ + "\tExpected: e-record"
+ + lineSeparator()
+ + "\tActual: ["
+ + lineSeparator()
+ + "\t\t(mismatch details) rec1"
+ + lineSeparator()
+ + "\t]"
+ + lineSeparator()
+ + "]"
+ + lineSeparator()
+ + "Matched records: ["
+ + lineSeparator()
+ + "\trec0"
+ + lineSeparator()
+ "]"));
}
@@ -159,9 +169,12 @@ void shouldThrowOnExtra() {
assertThat(
e.getMessage(),
is(
- "Additional records were produced.\n"
- + "Unmatched records: [\n"
- + "\textra\n"
+ "Additional records were produced."
+ + lineSeparator()
+ + "Unmatched records: ["
+ + lineSeparator()
+ + "\textra"
+ + lineSeparator()
+ "]"));
}
}
diff --git a/test-extension/src/test/java/org/creekservice/internal/kafka/streams/test/extension/model/TopicExpectationTest.java b/test-extension/src/test/java/org/creekservice/internal/kafka/streams/test/extension/model/TopicExpectationTest.java
index 473ddc12..7e5ce199 100644
--- a/test-extension/src/test/java/org/creekservice/internal/kafka/streams/test/extension/model/TopicExpectationTest.java
+++ b/test-extension/src/test/java/org/creekservice/internal/kafka/streams/test/extension/model/TopicExpectationTest.java
@@ -16,7 +16,6 @@
package org.creekservice.internal.kafka.streams.test.extension.model;
-import static java.lang.System.lineSeparator;
import static org.creekservice.api.kafka.metadata.KafkaTopicDescriptor.DEFAULT_CLUSTER_NAME;
import static org.creekservice.internal.kafka.streams.test.extension.model.ModelUtil.createParser;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -149,9 +148,8 @@ void shouldThrowIfNothingDefinesTopicName() {
"Cannot construct instance of"
+ " `org.creekservice.internal.kafka.streams.test.extension.model.TopicExpectation`,"
+ " problem: Topic not set. Topic must be supplied either at the file"
- + " or record level. location: unknown"
- + lineSeparator()
- + " at [Source: (StringReader); line: 8, column: 13]"));
+ + " or record level. location: unknown\n"
+ + " at [Source: (StringReader); line: 8, column: 13]"));
}
@Test
@@ -254,9 +252,8 @@ void shouldThrowOnNoRecords() {
is(
"Cannot construct instance of"
+ " `org.creekservice.internal.kafka.streams.test.extension.model.TopicExpectation`,"
- + " problem: At least one record is required"
- + lineSeparator()
- + " at [Source: (StringReader); line: 4, column: 12]"));
+ + " problem: At least one record is required\n"
+ + " at [Source: (StringReader); line: 4, column: 12]"));
}
@Test
diff --git a/test-extension/src/test/java/org/creekservice/internal/kafka/streams/test/extension/model/TopicInputTest.java b/test-extension/src/test/java/org/creekservice/internal/kafka/streams/test/extension/model/TopicInputTest.java
index f4d01b5f..424ccc21 100644
--- a/test-extension/src/test/java/org/creekservice/internal/kafka/streams/test/extension/model/TopicInputTest.java
+++ b/test-extension/src/test/java/org/creekservice/internal/kafka/streams/test/extension/model/TopicInputTest.java
@@ -16,7 +16,6 @@
package org.creekservice.internal.kafka.streams.test.extension.model;
-import static java.lang.System.lineSeparator;
import static org.creekservice.api.kafka.metadata.KafkaTopicDescriptor.DEFAULT_CLUSTER_NAME;
import static org.creekservice.internal.kafka.streams.test.extension.model.ModelUtil.createParser;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -149,9 +148,8 @@ void shouldThrowIfNothingDefinesTopicName() {
"Cannot construct instance of"
+ " `org.creekservice.internal.kafka.streams.test.extension.model.TopicInput`,"
+ " problem: Topic not set. Topic must be supplied either at the file"
- + " or record level. location: unknown"
- + lineSeparator()
- + " at [Source: (StringReader); line: 8, column: 13]"));
+ + " or record level. location: unknown\n"
+ + " at [Source: (StringReader); line: 8, column: 13]"));
}
@Test
@@ -254,9 +252,8 @@ void shouldThrowOnNoRecords() {
is(
"Cannot construct instance of"
+ " `org.creekservice.internal.kafka.streams.test.extension.model.TopicInput`,"
- + " problem: At least one record is required"
- + lineSeparator()
- + " at [Source: (StringReader); line: 4, column: 12]"));
+ + " problem: At least one record is required\n"
+ + " at [Source: (StringReader); line: 4, column: 12]"));
}
@Test
diff --git a/test-extension/src/test/java/org/creekservice/internal/kafka/streams/test/extension/model/TopicRecordTest.java b/test-extension/src/test/java/org/creekservice/internal/kafka/streams/test/extension/model/TopicRecordTest.java
index 4b7ad7f3..057d18a5 100644
--- a/test-extension/src/test/java/org/creekservice/internal/kafka/streams/test/extension/model/TopicRecordTest.java
+++ b/test-extension/src/test/java/org/creekservice/internal/kafka/streams/test/extension/model/TopicRecordTest.java
@@ -16,7 +16,6 @@
package org.creekservice.internal.kafka.streams.test.extension.model;
-import static java.lang.System.lineSeparator;
import static org.creekservice.api.kafka.metadata.KafkaTopicDescriptor.DEFAULT_CLUSTER_NAME;
import static org.creekservice.internal.kafka.streams.test.extension.model.ModelUtil.createParser;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -218,8 +217,7 @@ void shouldThrowOnUnknownProperty() {
assertThat(
e.getMessage(),
is(
- "Unknown property: not_value"
- + lineSeparator()
+ "Unknown property: not_value\n"
+ " at [Source: (StringReader); line: 5, column: 10]"));
}
@@ -241,8 +239,7 @@ void shouldThrowOnEmptyTopicName() {
assertThat(
e.getMessage(),
is(
- "Property can not be blank: topic"
- + lineSeparator()
+ "Property can not be blank: topic\n"
+ " at [Source: (StringReader); line: 2, column: 10]"));
}
@@ -264,8 +261,7 @@ void shouldThrowOnEmptyClusterName() {
assertThat(
e.getMessage(),
is(
- "Property can not be blank: cluster"
- + lineSeparator()
+ "Property can not be blank: cluster\n"
+ " at [Source: (StringReader); line: 3, column: 13]"));
}
diff --git a/test-extension/src/test/java/org/creekservice/internal/kafka/streams/test/extension/testsuite/StartKafkaTestListenerFunctionalTest.java b/test-extension/src/test/java/org/creekservice/internal/kafka/streams/test/extension/testsuite/StartKafkaTestListenerFunctionalTest.java
index 4e9b2684..a2b6435a 100644
--- a/test-extension/src/test/java/org/creekservice/internal/kafka/streams/test/extension/testsuite/StartKafkaTestListenerFunctionalTest.java
+++ b/test-extension/src/test/java/org/creekservice/internal/kafka/streams/test/extension/testsuite/StartKafkaTestListenerFunctionalTest.java
@@ -77,6 +77,7 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.parallel.Execution;
@@ -84,6 +85,7 @@
import org.mockito.internal.stubbing.defaultanswers.ReturnsDeepStubs;
import org.testcontainers.DockerClientFactory;
+@Tag("ContainerisedTest")
@Execution(ExecutionMode.SAME_THREAD) // Due to static state
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class StartKafkaTestListenerFunctionalTest {
diff --git a/test-service/build.gradle.kts b/test-service/build.gradle.kts
index 9fef2b0d..4e29e8e3 100644
--- a/test-service/build.gradle.kts
+++ b/test-service/build.gradle.kts
@@ -42,6 +42,11 @@ val buildAppImage = tasks.create("buildAppImage", DockerBuildImage::class) {
buildArgs.put("APP_NAME", project.name)
buildArgs.put("APP_VERSION", "${project.version}")
images.add("ghcr.io/creek-service/${rootProject.name}-${project.name}:latest")
+
+ onlyIf {
+ // Exclude the task if running on Windows (as images don't build on Windows)
+ !System.getProperty("os.name").lowercase().contains("win")
+ }
}
tasks.register("prepareDocker") {