diff --git a/.github/workflows/build-and-publish.yaml b/.github/workflows/build-and-publish.yaml new file mode 100644 index 0000000..31fd5e8 --- /dev/null +++ b/.github/workflows/build-and-publish.yaml @@ -0,0 +1,68 @@ +name: Build and Publish + +on: + push: + tags: ["**"] + branches: ["**"] + +env: + java-version: 21 + gradle-version: 8.4 + working-directory: "./word-count/code" + +jobs: + build-and-test: + name: Build, Test and Assess code quality + uses: bakdata/ci-templates/.github/workflows/java-gradle-base.yaml@1.50.1 + with: + java-version: 21 + gradle-version: 8.4 + gradle-cache: true + gradle-cache-read-only: false + gradle-refresh-dependencies: false + working-directory: "./word-count/code" + secrets: + signing-key-id: ${{ secrets.SONATYPE_SIGNING_KEY_ID }} + signing-password: ${{ secrets.SONATYPE_SIGNING_PASSWORD }} + signing-secret-key-ring: ${{ secrets.SONATYPE_SIGNING_SECRET_KEY_RING }} + sonar-token: ${{ secrets.SONARCLOUD_TOKEN }} + sonar-organization: ${{ secrets.SONARCLOUD_ORGANIZATION }} + + build-jib: + name: Build images + runs-on: ubuntu-22.04 + defaults: + run: + working-directory: ${{ env.working-directory }} + needs: build-and-test + + steps: + - name: Login into docker + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push sentence producer image + uses: bakdata/ci-templates/actions/java-gradle-build-jib@1.50.1 + with: + full-image-name: bakdata/kpops-demo-sentence-producer + class: com.bakdata.kpops.examples.SentenceProducer + java-version: ${{ env.java-version }} + gradle-version: ${{ env.gradle-version }} + gradle-cache: true + gradle-cache-read-only: true + gradle-refresh-dependencies: false + working-directory: ${{ env.working-directory }} + + - name: Build and push word count image + uses: bakdata/ci-templates/actions/java-gradle-build-jib@1.50.1 + with: + full-image-name: bakdata/kpops-demo-word-count-app + class: com.bakdata.kpops.examples.WordCountApplication + java-version: ${{ env.java-version }} + gradle-version: ${{ env.gradle-version }} + gradle-cache: true + gradle-cache-read-only: true + gradle-refresh-dependencies: false + working-directory: ${{ env.working-directory }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..a84412e --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,27 @@ +name: Release + +on: + workflow_dispatch: + inputs: + release-type: + description: "The scope of the release (major, minor or patch)." + type: choice + required: true + default: patch + options: + - patch + - minor + - major + +jobs: + java-gradle-release: + name: Java Gradle Release + uses: bakdata/ci-templates/.github/workflows/java-gradle-release.yaml@1.50.1 + with: + java-version: 21 + release-type: "${{ inputs.release-type }}" + working-directory: "./word-count/code" + secrets: + github-email: "${{ secrets.GH_EMAIL }}" + github-username: "${{ secrets.GH_USERNAME }}" + github-token: ${{ secrets.GH_TOKEN }} diff --git a/word-count/README.md b/word-count/README.md index ca4752d..5f7f5cb 100644 --- a/word-count/README.md +++ b/word-count/README.md @@ -12,5 +12,5 @@ gradle jib -Djib.to.image=bakdata/kpops-demo-sentence-producer -Djib.container.m # deploy streams-app -gradle jib -Djib.to.image=bakdata/kpops-demo-word-count-app-Djib.container.mainClass=com.bakdata.kpops.examples.WordCountApplication +gradle jib -Djib.to.image=bakdata/kpops-demo-word-count-app -Djib.container.mainClass=com.bakdata.kpops.examples.WordCountApplication ``` diff --git a/word-count/code/build.gradle.kts b/word-count/code/build.gradle.kts index 0d26c0c..f519fdd 100644 --- a/word-count/code/build.gradle.kts +++ b/word-count/code/build.gradle.kts @@ -1,7 +1,11 @@ description = "Word count pipeline with Kafka Streams" + plugins { java idea + id("com.bakdata.release") version "1.4.1" + id("com.bakdata.sonar") version "1.4.1" + id("com.bakdata.sonatype") version "1.4.1" id("io.freefair.lombok") version "8.11" id("com.google.cloud.tools.jib") version "3.4.4" } @@ -20,6 +24,15 @@ java { } } +configure { + developers { + developer { + name.set("Ramin Gharib") + id.set("raminqaf") + } + } +} + tasks { compileJava { options.encoding = "UTF-8" diff --git a/word-count/code/gradle/wrapper/gradle-wrapper.jar b/word-count/code/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..a4b76b9 Binary files /dev/null and b/word-count/code/gradle/wrapper/gradle-wrapper.jar differ diff --git a/word-count/code/gradle/wrapper/gradle-wrapper.properties b/word-count/code/gradle/wrapper/gradle-wrapper.properties index e2847c8..3fa8f86 100644 --- a/word-count/code/gradle/wrapper/gradle-wrapper.properties +++ b/word-count/code/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/word-count/code/gradlew b/word-count/code/gradlew index 1aa94a4..f5feea6 100755 --- a/word-count/code/gradlew +++ b/word-count/code/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,8 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum diff --git a/word-count/code/gradlew.bat b/word-count/code/gradlew.bat index 6689b85..9b42019 100644 --- a/word-count/code/gradlew.bat +++ b/word-count/code/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail diff --git a/word-count/code/settings.gradle b/word-count/code/settings.gradle index 50e3d9c..a602244 100644 --- a/word-count/code/settings.gradle +++ b/word-count/code/settings.gradle @@ -1,10 +1,6 @@ pluginManagement { repositories { gradlePluginPortal() - maven { - name "JCenter Gradle Plugins" - url "https://dl.bintray.com/gradle/gradle-plugins" - } } } diff --git a/word-count/deployment/values-dataproducer.yaml b/word-count/deployment/values-dataproducer.yaml index 24386de..359f99b 100644 --- a/word-count/deployment/values-dataproducer.yaml +++ b/word-count/deployment/values-dataproducer.yaml @@ -3,13 +3,12 @@ nameOverride: word-count-data-producer replicaCount: 1 image: bakdata/kpops-demo-sentence-producer -imageTag: 1.0.0 +imageTag: 2.0.0 imagePullPolicy: Always -streams: - brokers: "k8kafka-cp-kafka-headless:9092" +kafka: + bootstrapServers: "k8kafka-cp-kafka-headless:9092" outputTopic: word-count-raw-data-producer-topic prometheus: jmx: enabled: false -debug: true diff --git a/word-count/deployment/values-wordcounter.yaml b/word-count/deployment/values-wordcounter.yaml index 3c6557e..474bcd1 100644 --- a/word-count/deployment/values-wordcounter.yaml +++ b/word-count/deployment/values-wordcounter.yaml @@ -3,14 +3,13 @@ nameOverride: word-count-wordcounter replicaCount: 1 image: bakdata/kpops-demo-word-count-app -imageTag: 1.0.0 +imageTag: 2.0.0 imagePullPolicy: Always -streams: - brokers: "k8kafka-cp-kafka-headless:9092" +kafka: + bootstrapServers: "k8kafka-cp-kafka-headless:9092" inputTopics: word-count-raw-data-producer-topic outputTopic: word-count-countedwords-topic - productive: false annotations: consumerGroup: "word-counter-group" @@ -18,5 +17,3 @@ annotations: prometheus: jmx: enabled: false - -debug: true