CI - main build

name: CI - main build

on:
  push:
    branches: [ "develop" ]
  pull_request:
    branches: [ "develop" ]
  workflow_dispatch:

permissions:
  checks: write
  contents: read

jobs:
  test-fast:
    uses: ./.github/workflows/gradleCI-base.yml
    with:
      test-category: 'fast'
      setup-javafx-headless: false

  test-javafx-headless:
    uses: ./.github/workflows/gradleCI-base.yml
    with:
      test-category: 'javafx-headless'
      setup-javafx-headless: true


Build documentation

# 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.

name: "Build documentation"

on:
  pull_request:
    branches:
      - master
      - release-*
    paths:
      - 'docs/**'
  schedule:
    - cron: '0 0 * * *' # Deploy every day
  workflow_dispatch:

concurrency:
  group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.number || github.run_id }}
  cancel-in-progress: true

jobs:
  check-doc:
    if: github.repository == 'apache/flink-cdc'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Check dead links
        uses: gaurav-nelson/github-action-markdown-link-check@1.0.15
        with:
          config-file: '.dlc.json'
      - name: Build doc
        run: |
          docker run --rm --volume "$PWD:/root/flink-cdc" chesnay/flink-ci:java_8_11_17_21_maven_386 bash -c "cd /root/flink-cdc && chmod +x ./.github/workflows/docs.sh && ./.github/workflows/docs.sh"

  build-documentation:
    if: github.event_name != 'pull_request' && github.repository == 'apache/flink-cdc'
    name: "Check and build doc"
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      max-parallel: 1
      matrix:
        branch:
          - master
          - release-3.0
          - release-3.1

    steps:
      - uses: actions/checkout@v3
        with:
          ref: ${{ matrix.branch }}

      - name: Set branch environment variable
        run: |
          currentBranch=$(git branch --show-current)

          echo "flink_branch=${currentBranch}" >> ${GITHUB_ENV}

          if [ "${currentBranch}" = "master" ]; then
          echo "flink_alias=release-3.2" >> ${GITHUB_ENV}
          elif [ "${currentBranch}" = "release-3.1" ]; then
          echo "flink_alias=stable" >> ${GITHUB_ENV}
          fi

      - name: Check dead links
        uses: gaurav-nelson/github-action-markdown-link-check@1.0.15
        with:
          config-file: '.dlc.json'

      - name: Build documentation
        run: |
          docker run --rm --volume "$PWD:/root/flink-cdc" chesnay/flink-ci:java_8_11_17_21_maven_386 bash -c "cd /root/flink-cdc && chmod +x ./.github/workflows/docs.sh && ./.github/workflows/docs.sh"

      - name: Upload documentation
        uses: burnett01/rsync-deployments@5.2
        with:
          switches: --archive --compress --delete
          path: docs/target/
          remote_path: ${{ secrets.NIGHTLIES_RSYNC_PATH }}/flink/flink-cdc-docs-${{ env.flink_branch }}/
          remote_host: ${{ secrets.NIGHTLIES_RSYNC_HOST }}
          remote_port: ${{ secrets.NIGHTLIES_RSYNC_PORT }}
          remote_user: ${{ secrets.NIGHTLIES_RSYNC_USER }}
          remote_key: ${{ secrets.NIGHTLIES_RSYNC_KEY }}

      - name: Upload documentation alias
        if: env.flink_alias != ''
        uses: burnett01/rsync-deployments@5.2
        with:
          switches: --archive --compress --delete
          path: docs/target/
          remote_path: ${{ secrets.NIGHTLIES_RSYNC_PATH }}/flink/flink-cdc-docs-${{ env.flink_alias }}/
          remote_host: ${{ secrets.NIGHTLIES_RSYNC_HOST }}
          remote_port: ${{ secrets.NIGHTLIES_RSYNC_PORT }}
          remote_user: ${{ secrets.NIGHTLIES_RSYNC_USER }}
          remote_key: ${{ secrets.NIGHTLIES_RSYNC_KEY }}


Flink CDC CI

# 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.

name: Flink CDC CI
on:
  push:
    branches:
      - master
      - release-*
    paths-ignore:
      - 'docs/**'
      - 'README.md'
  pull_request:
    branches:
      - master
      - release-*
    paths-ignore:
      - 'docs/**'
      - 'README.md'

# Concurrency strategy:
#   github.workflow: distinguish this workflow from others
#   github.event_name: distinguish `push` event from `pull_request` event
#   github.event.number: set to the number of the pull request if `pull_request` event
#   github.run_id: otherwise, it's a `push` or `schedule` event, only cancel if we rerun the workflow
#
# Reference:
#   https://docs.github.com/en/actions/using-jobs/using-concurrency
#   https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
concurrency:
  group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.number || github.run_id }}
  cancel-in-progress: true

env:
  MODULES_CORE: "\
  flink-cdc-cli,\
  flink-cdc-common,\
  flink-cdc-composer,\
  flink-cdc-runtime"

  MODULES_PIPELINE_CONNECTORS: "\
  flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-values,\
  flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-mysql,\
  flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-doris,\
  flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-starrocks,\
  flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-kafka,\
  flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-paimon"

  MODULES_MYSQL: "\
  flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc,\
  flink-cdc-connect/flink-cdc-source-connectors/flink-sql-connector-mysql-cdc"

  MODULES_POSTGRES: "\
  flink-cdc-connect/flink-cdc-source-connectors/flink-connector-postgres-cdc,\
  flink-cdc-connect/flink-cdc-source-connectors/flink-sql-connector-postgres-cdc"

  MODULES_ORACLE: "\
  flink-cdc-connect/flink-cdc-source-connectors/flink-connector-oracle-cdc,\
  flink-cdc-connect/flink-cdc-source-connectors/flink-sql-connector-oracle-cdc"

  MODULES_MONGODB: "\
  flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mongodb-cdc,\
  flink-cdc-connect/flink-cdc-source-connectors/flink-sql-connector-mongodb-cdc"

  MODULES_SQLSERVER: "\
  flink-cdc-connect/flink-cdc-source-connectors/flink-connector-sqlserver-cdc,\
  flink-cdc-connect/flink-cdc-source-connectors/flink-sql-connector-sqlserver-cdc"

  MODULES_TIDB: "\
  flink-cdc-connect/flink-cdc-source-connectors/flink-connector-tidb-cdc,\
  flink-cdc-connect/flink-cdc-source-connectors/flink-sql-connector-tidb-cdc"

  MODULES_OCEANBASE: "\
  flink-cdc-connect/flink-cdc-source-connectors/flink-connector-oceanbase-cdc,\
  flink-cdc-connect/flink-cdc-source-connectors/flink-sql-connector-oceanbase-cdc"

  MODULES_DB2: "\
  flink-cdc-connect/flink-cdc-source-connectors/flink-connector-db2-cdc,\
  flink-cdc-connect/flink-cdc-source-connectors/flink-sql-connector-db2-cdc"

  MODULES_VITESS: "\
  flink-cdc-connect/flink-cdc-source-connectors/flink-connector-vitess-cdc,\
  flink-cdc-connect/flink-cdc-source-connectors/flink-sql-connector-vitess-cdc"

  MODULES_E2E: "\
  flink-cdc-e2e-tests/flink-cdc-pipeline-e2e-tests,\
  flink-cdc-e2e-tests/flink-cdc-source-e2e-tests"

jobs:
  license_check:
    runs-on: ubuntu-latest
    steps:
      - name: Check out repository code
        uses: actions/checkout@v4
        with:
          submodules: true
      - name: Set up Ruby environment
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: '3.3'
      - name: Compiling jar packages
        run: mvn --no-snapshot-updates -B package -DskipTests
      - name: Run license check
        run: gem install rubyzip -v 2.3.0 && ./tools/ci/license_check.rb

  migration_test:
    runs-on: ubuntu-latest
    steps:
      - name: Check out repository code
        uses: actions/checkout@v4
        with:
          submodules: true
      - name: Compile snapshot CDC version
        run: mvn --no-snapshot-updates -B install -DskipTests
      - name: Run migration tests
        run: cd flink-cdc-migration-tests && mvn clean verify

  compile_and_test:
    # Only run the CI pipeline for the flink-cdc-connectors repository
#    if: github.repository == 'apache/flink-cdc-connectors'
    runs-on: ubuntu-latest
    strategy:
      matrix:
        jdk: [ 8 ]
        module: [ "core",
                  "pipeline_connectors",
                  "mysql",
                  "postgres",
                  "oracle",
                  "mongodb",
                  "sqlserver",
                  "tidb",
                  "oceanbase",
                  "db2",
                  "vitess",
                  "e2e"
        ]
    timeout-minutes: 120
    env:
      MVN_COMMON_OPTIONS: -Dmaven.wagon.http.pool=false \
        -Dorg.slf4j.simpleLogger.showDateTime=true \
        -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss.SSS \
        -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
        --no-snapshot-updates -B \
        --settings /home/vsts/work/1/s/tools/ci/google-mirror-settings.xml \
        -Dfast -Dlog.dir=/home/vsts/work/_temp/debug_files \
        -Dlog4j.configurationFile=file:///home/vsts/work/1/s/tools/ci/log4j.properties
    steps:
      - run: echo "Running CI pipeline for JDK version ${{ matrix.jdk }}"

      - name: Check out repository code
        uses: actions/checkout@v4
        with:
          submodules: true

      - name: Set JDK
        uses: actions/setup-java@v4
        with:
          java-version: ${{ matrix.jdk }}
          distribution: 'temurin'
          cache: 'maven'

      - name: Set Maven 3.8.6
        uses: stCarolas/setup-maven@v5
        with:
          maven-version: 3.8.6

      - name: Compile and test ${{ matrix.module }}
        timeout-minutes: 90
        run: |
          set -o pipefail

          case ${{ matrix.module }} in
              ("core")
               modules=${{ env.MODULES_CORE }}
              ;;
              ("pipeline_connectors")
               modules=${{ env.MODULES_PIPELINE_CONNECTORS }}
              ;;
              ("mysql")
               modules=${{ env.MODULES_MYSQL }}
              ;;
              ("postgres")
               modules=${{ env.MODULES_POSTGRES }}
              ;;
              ("oracle")
               modules=${{ env.MODULES_ORACLE }}
              ;;
              ("mongodb")
               modules=${{ env.MODULES_MONGODB }}
              ;;
              ("sqlserver")
               modules=${{ env.MODULES_SQLSERVER }}
              ;;
              ("tidb")
               modules=${{ env.MODULES_TIDB }}
              ;;
              ("oceanbase")
               modules=${{ env.MODULES_OCEANBASE }}
              ;;
              ("db2")
               modules=${{ env.MODULES_DB2 }}
              ;;
              ("vitess")
               modules=${{ env.MODULES_VITESS }}
              ;;
              ("e2e")
               compile_modules="${{ env.MODULES_CORE }},${{ env.MODULES_PIPELINE_CONNECTORS }},${{ env.MODULES_MYSQL }},${{ env.MODULES_POSTGRES }},${{ env.MODULES_ORACLE }},${{ env.MODULES_MONGODB }},${{ env.MODULES_SQLSERVER }},${{ env.MODULES_TIDB }},${{ env.MODULES_OCEANBASE }},${{ env.MODULES_DB2 }},${{ env.MODULES_VITESS }},${{ env.MODULES_E2E }}"
               modules=${{ env.MODULES_E2E }}
              ;;
          esac

          if [ ${{ matrix.module }} != "e2e" ]; then
            compile_modules=$modules
          fi

          mvn --no-snapshot-updates -B -DskipTests -pl $compile_modules -am install && mvn --no-snapshot-updates -B -pl $modules verify

      - name: Print JVM thread dumps when cancelled
        if: ${{ failure() }}
        run: |
          # ----------------------------------------------------------------------------
          # Copyright 2023 The Netty Project
          #
          # ----------------------------------------------------------------------------
          # Source: https://github.com/netty/netty/blob/main/.github/actions/thread-dump-jvms/action.yml
          echo "$OSTYPE"
          if [[ "$OSTYPE" == "linux-gnu"* ]] && command -v sudo &> /dev/null; then
            echo "Setting up JVM thread dumps"
            # use jattach so that Java processes in docker containers are also covered
            # download jattach
            curl -s -L -o /tmp/jattach https://github.com/apangin/jattach/releases/download/v2.1/jattach
            if command -v sha256sum &> /dev/null; then
              # verify hash of jattach binary
              sha256sum -c <(echo "07885fdc782e02e7302c6d190f54c3930afa10a38140365adf54076ec1086a8e  /tmp/jattach") || exit 1
            fi
            chmod +x /tmp/jattach
            for java_pid in $(sudo pgrep java); do
              echo "----------------------- pid $java_pid -----------------------"
              echo "command line: $(sudo cat /proc/$java_pid/cmdline | xargs -0 echo)"
              sudo /tmp/jattach $java_pid jcmd VM.command_line || true
              sudo /tmp/jattach $java_pid jcmd "Thread.print -l"
              sudo /tmp/jattach $java_pid jcmd GC.heap_info || true
            done
          else
            for java_pid in $(jps -q -J-XX:+PerfDisableSharedMem); do
              echo "----------------------- pid $java_pid -----------------------"
              jcmd $java_pid VM.command_line || true
              jcmd $java_pid Thread.print -l
              jcmd $java_pid GC.heap_info || true
            done
          fi
          exit 0


Labeler

# 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.

# This workflow will triage pull requests and apply a label based on the
# paths that are modified in the pull request.
#
# To use this workflow, you will need to set up a .github/label.yml
# file with configuration.  For more information, see:
# https://github.com/actions/labeler

name: Labeler
on: [pull_request_target]

jobs:
  label:

    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write

    steps:
      - uses: actions/labeler@v4
        with:
          repo-token: "${{ secrets.GITHUB_TOKEN }}"


Maven build

name: Maven build

on:
  push:
    branches:
    - main
  pull_request:
    branches:
    - main

jobs:
  build:

    name: Maven build
    runs-on: ubuntu-latest

    steps:
    - name: Checkout repository
      uses: actions/checkout@v3.5.3

    - name: Set up JDK 17
      uses: actions/setup-java@v3.11.0
      with:
        java-version: '17'
        distribution: 'adopt'
        java-package: jdk
        architecture: x64

    - name: Cache Maven packages
      uses: actions/cache@v3
      with:
        path: ~/.m2
        key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
        restore-keys: ${{ runner.os }}-m2

    - name: Build with Maven
      run: mvn package --file pom.xml


SonarCloud Scanner

name: SonarCloud Scanner

on:
  push:
    branches:
      - main
  pull_request:
    types: [opened, synchronize, reopened]

jobs:
  scan:

    name: SonarCloud Scanner
    runs-on: ubuntu-latest

    ## Do not run this on forks, it will fail ._.
    if: ${{ github.actor == 'baked-libs' }}

    steps:
      - name: Checkout repository
        uses: actions/checkout@v3.5.3
        with:
          fetch-depth: 0

      - name: Set up Java 16
        uses: actions/setup-java@v3.11.0
        with:
          java-version: '16'
          distribution: 'adopt'
          java-package: jdk
          architecture: x64

      - name: Cache SonarCloud packages
        uses: actions/cache@v3
        with:
          path: ~/.sonar/cache
          key: ${{ runner.os }}-sonar
          restore-keys: ${{ runner.os }}-sonar

      - name: Cache Maven packages
        uses: actions/cache@v3
        with:
          path: ~/.m2
          key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
          restore-keys: ${{ runner.os }}-m2

      - name: SonarCloud analysis
        run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}


Infra: PR block merge

name: "Infra: PR block merge"
on:
  pull_request:
    types: [opened, labeled, unlabeled, synchronize]
jobs:
  block_merge:
    runs-on: ubuntu-latest
    steps:
      - uses: mheap/github-action-required-labels@v5
        with:
          mode: exactly
          count: 0
          labels: "status/blocked, status/needs-attention, status/on-hold, status/pending, status/triage, status/pending-backend, status/pending-frontend, status/pending-QA"


Infra: Feature Testing: Init env

name: "Infra: Feature Testing: Init env"

on:
  workflow_dispatch:

  pull_request:
    types: ['labeled']

permissions:
  contents: read
  statuses: write

jobs:
  build:
    if: ${{ github.event.label.name == 'status/feature_testing' || github.event.label.name == 'status/feature_testing_public' }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ github.event.pull_request.head.sha }}
          token: ${{ github.token }}
      - name: get branch name
        id: extract_branch
        run: |
          tag='pr${{ github.event.pull_request.number }}'
          echo "tag=${tag}" >> $GITHUB_OUTPUT
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: Set up JDK
        uses: actions/setup-java@v4
        with:
          java-version: '17'
          distribution: 'zulu'
          cache: 'maven'
      - name: Build
        id: build
        run: |
          ./mvnw -B -ntp versions:set -DnewVersion=$GITHUB_SHA
          ./mvnw -B -V -ntp clean package -Pprod -DskipTests
          export VERSION=$(./mvnw -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
          echo "version=${VERSION}" >> $GITHUB_OUTPUT
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v3
      - name: Set up Docker Buildx
        id: buildx
        uses: docker/setup-buildx-action@v3
      - name: Cache Docker layers
        uses: actions/cache@v4
        with:
          path: /tmp/.buildx-cache
          key: ${{ runner.os }}-buildx-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-buildx-
      - name: Configure AWS credentials for Kafka-UI account
        uses: aws-actions/configure-aws-credentials@v4
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: eu-central-1
      - name: Login to Amazon ECR
        id: login-ecr
        uses: aws-actions/amazon-ecr-login@v2
      - name: Build and push
        id: docker_build_and_push
        uses: docker/build-push-action@v5
        with:
          builder: ${{ steps.buildx.outputs.name }}
          context: api
          push: true
          tags: 297478128798.dkr.ecr.eu-central-1.amazonaws.com/kafka-ui:${{ steps.extract_branch.outputs.tag }}
          build-args: |
            JAR_FILE=api-${{ steps.build.outputs.version }}.jar
          cache-from: type=local,src=/tmp/.buildx-cache
          cache-to: type=local,dest=/tmp/.buildx-cache
    outputs:
      tag: ${{ steps.extract_branch.outputs.tag }}
  make-branch-env:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - name: clone
        run: |
          git clone https://infra-tech:${{ secrets.INFRA_USER_ACCESS_TOKEN }}@github.com/kafbat/kafka-ui-infra.git --branch envs
      - name: create deployment
        run: |
          cd kafka-ui-infra/aws-infrastructure4eks/argocd/scripts
          echo "Branch:${{ needs.build.outputs.tag }}"
          ./kafka-ui-deployment-from-branch.sh ${{ needs.build.outputs.tag }} ${{ github.event.label.name }} ${{ secrets.FEATURE_TESTING_UI_PASSWORD }}
          git config --global user.email "infra@kafbat.io"
          git config --global user.name "infra-tech"
          git add ../kafka-ui-from-branch/
          git commit -m "added env:${{ needs.build.outputs.deploy }}" && git push || true

      - name: update status check for private deployment
        if: ${{ github.event.label.name == 'status/feature_testing' }}
        uses: Sibz/github-status-action@v1.1.6
        with:
          authToken: ${{secrets.GITHUB_TOKEN}}
          context: "Click Details button to open custom deployment page"
          state: "success"
          sha: ${{ github.event.pull_request.head.sha  || github.sha }}
          target_url: "http://${{ needs.build.outputs.tag }}.internal.ui.kafbat.dev"

      - name: update status check for public deployment
        if: ${{ github.event.label.name == 'status/feature_testing_public' }}
        uses: Sibz/github-status-action@v1.1.6
        with:
          authToken: ${{secrets.GITHUB_TOKEN}}
          context: "Click Details button to open custom deployment page"
          state: "success"
          sha: ${{ github.event.pull_request.head.sha  || github.sha }}
          target_url: "http://${{ needs.build.outputs.tag }}.internal.ui.kafbat.dev"


Infra: Feature Testing: Destroy env

name: "Infra: Feature Testing: Destroy env"

on:
  workflow_dispatch:
  pull_request:
    types: ['unlabeled', 'closed']

permissions:
  contents: read

jobs:
  remove:
    runs-on: ubuntu-latest
    if: ${{ (github.event.label.name == 'status/feature_testing' || github.event.label.name == 'status/feature_testing_public') || (github.event.action == 'closed' && (contains(github.event.pull_request.labels.*.name, 'status/feature_testing') || contains(github.event.pull_request.labels.*.name, 'status/feature_testing_public'))) }}
    steps:
      - uses: actions/checkout@v4
        with:
          token: ${{ github.token }}
      - name: clone
        run: |
          git clone https://infra-tech:${{ secrets.INFRA_USER_ACCESS_TOKEN }}@github.com/kafbat/ui-infra.git --branch envs
      - name: remove env
        run: |
          cd kafka-ui-infra/aws-infrastructure4eks/argocd/scripts
          ./delete-env.sh pr${{ github.event.pull_request.number }} || true
          git config --global user.email "infra@kafbat.io"
          git config --global user.name "infra-tech"
          git add ../kafka-ui-from-branch/
          git commit -m "removed env:${{ needs.build.outputs.deploy }}" && git push || true


Infra: Image Testing: Deploy

name: "Infra: Image Testing: Deploy"

on:
  workflow_dispatch:
  pull_request:
    types: ['labeled']

permissions:
  contents: read

jobs:
  build:
    if: ${{ github.event.label.name == 'status/image_testing' }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ github.event.pull_request.head.sha }}
          token: ${{ github.token }}
      - name: get branch name
        id: extract_branch
        run: |
          tag='${{ github.event.pull_request.number }}'
          echo "tag=${tag}" >> $GITHUB_OUTPUT
      - name: Set up JDK
        uses: actions/setup-java@v4
        with:
          java-version: '17'
          distribution: 'zulu'
          cache: 'maven'
      - name: Build
        id: build
        run: |
          ./mvnw -B -ntp versions:set -DnewVersion=$GITHUB_SHA
          ./mvnw -B -V -ntp clean package -Pprod -DskipTests
          export VERSION=$(./mvnw -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
          echo "version=${VERSION}" >> $GITHUB_OUTPUT
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v3
      - name: Set up Docker Buildx
        id: buildx
        uses: docker/setup-buildx-action@v3
      - name: Cache Docker layers
        uses: actions/cache@v4
        with:
          path: /tmp/.buildx-cache
          key: ${{ runner.os }}-buildx-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-buildx-
      - name: Configure AWS credentials for Kafka-UI account
        uses: aws-actions/configure-aws-credentials@v4
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: us-east-1
      - name: Login to Amazon ECR
        id: login-ecr
        uses: aws-actions/amazon-ecr-login@v2
        with:
          registry-type: 'public'
      - name: Build and push
        id: docker_build_and_push
        uses: docker/build-push-action@v5
        with:
          builder: ${{ steps.buildx.outputs.name }}
          context: api
          push: true
          tags: public.ecr.aws/kafbat/kafka-ui-custom-build:${{ steps.extract_branch.outputs.tag }}
          build-args: |
            JAR_FILE=api-${{ steps.build.outputs.version }}.jar
          cache-from: type=local,src=/tmp/.buildx-cache
          cache-to: type=local,dest=/tmp/.buildx-cache
      - name: make comment with private deployment link
        uses: peter-evans/create-or-update-comment@v4
        with:
          issue-number: ${{ github.event.pull_request.number }}
          body: |
            Image published at public.ecr.aws/kafbat/kafka-ui-custom-build:${{ steps.extract_branch.outputs.tag }}
    outputs:
      tag: ${{ steps.extract_branch.outputs.tag }}


CodeQL

name: "CodeQL"

on:
  push:
    branches: [ main ]

  pull_request:
    # The branches below must be a subset of the branches above
    branches: [ main ]
    paths:
      - 'frontend/**'
      - "pom.xml"
      - "contract/**"
      - 'api/**'
      - 'serde-api/**'

  schedule:
    - cron: '39 15 * * 6'

permissions:
  contents: read
  actions: read
  security-events: write

jobs:
  analyze:
    name: Analyze
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        language: [ 'javascript', 'java' ]

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          token: ${{ github.token }}

      - name: Initialize CodeQL
        uses: github/codeql-action/init@v3
        with:
          languages: ${{ matrix.language }}

      - name: Set up JDK
        uses: actions/setup-java@v4
        with:
          java-version: '17'
          distribution: 'zulu'
          cache: 'maven'

      - name: Autobuild
        uses: github/codeql-action/autobuild@v3

      - name: Perform CodeQL Analysis
        uses: github/codeql-action/analyze@v3


Infra: Image Testing: Delete

name: "Infra: Image Testing: Delete"
on:
  workflow_dispatch:
  pull_request:
    types: ['unlabeled', 'closed']
jobs:
  remove:
    if: ${{ github.event.label.name == 'status/image_testing' || ( github.event.action == 'closed' && (contains(github.event.pull_request.labels, 'status/image_testing'))) }}
    runs-on: ubuntu-latest
    steps:
      - name: get branch name
        id: extract_branch
        run: |
          echo
          tag='${{ github.event.pull_request.number }}'
          echo "tag=${tag}" >> $GITHUB_OUTPUT
      - name: Configure AWS credentials for Kafka-UI account
        uses: aws-actions/configure-aws-credentials@v4
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: us-east-1
      - name: Login to Amazon ECR
        id: login-ecr
        uses: aws-actions/amazon-ecr-login@v2
        with:
          registry-type: 'public'
      - name: Remove from ECR
        id: remove_from_ecr
        run: |
          aws ecr-public batch-delete-image \
                --repository-name kafka-ui-custom-build \
                --image-ids imageTag=${{ steps.extract_branch.outputs.tag }} \
                --region us-east-1


E2E: Suite run

name: "E2E: Suite run"
on:
  workflow_dispatch:
    inputs:
      test_suite:
        description: 'Select test suite to run'
        default: 'regression'
        required: true
        type: choice
        options:
          - regression
          - sanity
          - smoke

permissions:
  contents: read
  checks: write
  statuses: write

jobs:
  build-and-test:
    uses: ./.github/workflows/e2e-run.yml
    secrets: inherit
    with:
      suite_name: ${{ github.event.inputs.test_suite }}
      sha: ${{ github.sha }}


E2E: Weekly suite

name: "E2E: Weekly suite"
on:
  schedule:
    - cron: '0 1 * * 1'

permissions:
  contents: read
  checks: write
  statuses: write

jobs:
  build-and-test:
    uses: ./.github/workflows/e2e-run.yml
    secrets: inherit
    with:
      suite_name: "sanity"
      sha: ${{ github.sha }}


Infra: Release Drafter run

name: "Infra: Release Drafter run"

on:
  push:
    branches: [ "main" ]
  workflow_dispatch:
    inputs:
      version:
        description: 'Release version'
        required: false
      branch:
        description: 'Target branch'
        required: false
        default: 'main'

permissions:
  contents: read

jobs:
  update_release_draft:
    runs-on: ubuntu-latest
    permissions:
      contents: write
      pull-requests: write
    steps:
      - uses: release-drafter/release-drafter@v6
        with:
          config-name: release_drafter.yaml
          disable-autolabeler: true
          version: ${{ github.event.inputs.version }}
          commitish: ${{ github.event.inputs.branch }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


Infra: Feature Testing Public: Init env

name: "Infra: Feature Testing Public: Init env"
on:
  workflow_dispatch:
    inputs:
      ENV_NAME:
        description: 'Will be used as subdomain in the public URL.'
        required: true
        default: 'demo'

permissions:
  contents: read

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ github.event.pull_request.head.sha }}
          token: ${{ github.token }}
      - name: get branch name
        id: extract_branch
        run: |
          tag="${{ github.event.inputs.ENV_NAME }}-$(date '+%F-%H-%M-%S')"
          echo "tag=${tag}" >> $GITHUB_OUTPUT
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: Set up JDK
        uses: actions/setup-java@v4
        with:
          java-version: '17'
          distribution: 'zulu'
          cache: 'maven'
      - name: Build
        id: build
        run: |
          ./mvnw -B -ntp versions:set -DnewVersion=$GITHUB_SHA
          ./mvnw -B -V -ntp clean package -Pprod -DskipTests
          export VERSION=$(./mvnw -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
          echo "version=${VERSION}" >> $GITHUB_OUTPUT
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v3
      - name: Set up Docker Buildx
        id: buildx
        uses: docker/setup-buildx-action@v3
      - name: Cache Docker layers
        uses: actions/cache@v4
        with:
          path: /tmp/.buildx-cache
          key: ${{ runner.os }}-buildx-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-buildx-
      - name: Configure AWS credentials for Kafka-UI account
        uses: aws-actions/configure-aws-credentials@v4
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: eu-central-1
      - name: Login to Amazon ECR
        id: login-ecr
        uses: aws-actions/amazon-ecr-login@v2
      - name: Build and push
        id: docker_build_and_push
        uses: docker/build-push-action@v5
        with:
          builder: ${{ steps.buildx.outputs.name }}
          context: api
          push: true
          tags: 297478128798.dkr.ecr.eu-central-1.amazonaws.com/kafka-ui:${{ steps.extract_branch.outputs.tag }}
          build-args: |
            JAR_FILE=api-${{ steps.build.outputs.version }}.jar
          cache-from: type=local,src=/tmp/.buildx-cache
          cache-to: type=local,dest=/tmp/.buildx-cache
    outputs:
      tag: ${{ steps.extract_branch.outputs.tag }}

  separate-env-create:
    runs-on: ubuntu-latest
    needs: build
    steps:
      - name: clone
        run: |
          git clone https://infra-tech:${{ secrets.INFRA_USER_ACCESS_TOKEN }}@github.com/kafbat/ui-infra.git --branch envs

      - name: separate env create
        run: |
          cd kafka-ui-infra/aws-infrastructure4eks/argocd/scripts
          bash separate_env_create.sh ${{ github.event.inputs.ENV_NAME }} ${{ secrets.FEATURE_TESTING_UI_PASSWORD }} ${{ needs.build.outputs.tag }}
          git config --global user.email "infra@kafbat.io"
          git config --global user.name "infra-tech"
          git add -A
          git commit -m "separate env added: ${{ github.event.inputs.ENV_NAME }}" && git push || true

      - name: echo separate environment public link
        run: |
          echo "Please note, separate environment creation takes up to 5-10 minutes."
          echo "Separate environment will be available at http://${{ github.event.inputs.ENV_NAME }}.-ui.kafbat.io"
          echo "Username: admin"


name: "Infra: Feature Testing Public: Destroy env"
on:
  workflow_dispatch:
    inputs:
      ENV_NAME:
        description: 'Will be used to remove previously deployed separate environment.'
        required: true
        default: 'demo'

jobs:
  separate-env-remove:
    runs-on: ubuntu-latest
    steps:
      - name: clone
        run: |
          git clone https://infra-tech:${{ secrets.INFRA_USER_ACCESS_TOKEN }}@github.com/kafbat/ui-infra.git --branch envs
      - name: separate environment remove
        run: |
          cd kafka-ui-infra/aws-infrastructure4eks/argocd/scripts
          bash separate_env_remove.sh ${{ github.event.inputs.ENV_NAME }}
          git config --global user.email "infra@kafbat.io"
          git config --global user.name "infra-tech"
          git add -A
          git commit -m "separate env removed: ${{ github.event.inputs.ENV_NAME }}" && git push || true


Welcome first time contributors

name: Welcome first time contributors

on:
  pull_request_target:
    types:
      - opened
  issues:
    types:
      - opened
permissions:
  issues: write
  pull-requests: write
jobs:
  welcome:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/first-interaction@v1
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          issue-message: |
            Hi ${{ github.actor }}! 👋

            Welcome, and thank you for opening your first issue in the repo!

            Please wait for triaging by our maintainers.

            As development is carried out in our spare time, you can support us by sponsoring our activities or even funding the development of specific issues.
            [Sponsorship link](https://github.com/kafbat)

            If you plan to raise a PR for this issue, please take a look at our [contributing guide](https://ui.docs.kafbat.io/development/contributing).

          pr-message: |
            Hi ${{ github.actor }}! 👋

            Welcome, and thank you for opening your first PR in the repo!

            Please wait for triaging by our maintainers.

            Please take a look at our [contributing guide](https://ui.docs.kafbat.io/development/contributing).


Infra: Workflow linter

name: "Infra: Workflow linter"
on:
  pull_request:
    types: ["opened", "reopened", "synchronize"]
    paths:
      - ".github/workflows/**"

permissions:
  contents: read

jobs:
  build-and-test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
          ref: ${{ github.event.pull_request.head.sha }}
          token: ${{ github.token }}
      - name: Install yamllint
        run: sudo apt install -y yamllint
      - name: Validate workflow yaml files
        run: yamllint .github/workflows/. -d relaxed -f github --no-warnings


Backend: Main: Build and test

name: "Backend: Main: Build and test"

on:
  push:
    branches: [ "main" ]
    paths:
      - "pom.xml"
      - "contract/**"
      - "api/**"
      - "serde-api/**"

permissions:
  contents: read
  checks: write
  pull-requests: write

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  build:
    uses: ./.github/workflows/backend_tests.yml
    with:
      event_name: ${{ github.event_name }}


Backend: PR: Build and test

name: "Backend: PR: Build and test"

on:

  pull_request_target:
    types: [ "opened", "reopened", "synchronize" ]
    paths:
      - "pom.xml"
      - "contract/**"
      - "api/**"
      - "serde-api/**"

permissions:
  contents: read
  checks: write
  pull-requests: write

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  build:
    uses: ./.github/workflows/backend_tests.yml
    with:
      event_name: ${{ github.event_name }}


Backend: build and test

name: "Backend: build and test"

on:
  workflow_call:
    inputs:
      event_name:
        description: 'Original github.event_name'
        required: true
        type: string

permissions:
  contents: read
  checks: write
  pull-requests: write

jobs:
  build-and-test:
    runs-on: ubuntu-latest
    steps:

      - name: Checkout
        uses: actions/checkout@v4
        with:
          token: ${{ github.token }}
          fetch-depth: 0
          ref: ${{ github.event.pull_request.head.sha }}

      - name: Set up JDK
        uses: actions/setup-java@v4
        with:
          java-version: '17'
          distribution: 'zulu'
          cache: 'maven'

      - name: Cache SonarCloud packages
        uses: actions/cache@v4
        with:
          path: ~/.sonar/cache
          key: ${{ runner.os }}-sonar
          restore-keys: ${{ runner.os }}-sonar

      - name: "Pull request: Maven tests & sonar"
        if: ${{ inputs.event_name == 'pull_request' || inputs.event_name == 'pull_request_target' }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_BACKEND }}
          HEAD_REF: ${{ github.head_ref }}
          BASE_REF: ${{ github.base_ref }}
          SKIP_SONAR: "true" # TODO remove when public
        run: |
          ./mvnw -B -ntp versions:set -DnewVersion=${{ github.event.pull_request.head.sha }}
          ./mvnw -B -V -ntp verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
          -Dsonar.skip=${SKIP_SONAR} \
          -Dsonar.projectKey=io.kafbat:kafbat-ui_backend \
          -Dsonar.pullrequest.key=${{ github.event.pull_request.number }} \
          -Dsonar.pullrequest.branch=$HEAD_REF \
          -Dsonar.pullrequest.base=$BASE_REF

      - name: "Main: Maven tests & sonar"
        if: ${{ inputs.event_name == 'push' }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_BACKEND }}
          SKIP_SONAR: "true" # TODO remove when public
        run: |
          ./mvnw -B -ntp versions:set -DnewVersion=$GITHUB_SHA
          ./mvnw -B -V -ntp verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
          -Dsonar.skip=${SKIP_SONAR} \
          -Dsonar.projectKey=io.kafbat:kafbat-ui_backend


Frontend: Main: Build and test

name: "Frontend: Main: Build and test"

on:
  push:
    branches: [ "main" ]
    paths:
      - "contract/**"
      - "frontend/**"

permissions:
  contents: read

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  build:
    uses: ./.github/workflows/frontend_tests.yml


Frontend: PR: Build and test

name: "Frontend: PR: Build and test"

on:

  pull_request_target:
    types: [ "opened", "reopened", "synchronize" ]
    paths:
      - "contract/**"
      - "frontend/**"

permissions:
  contents: read

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  build:
    uses: ./.github/workflows/frontend_tests.yml


Frontend: build and test

name: "Frontend: build and test"

on:
  workflow_call:

permissions:
  contents: read

jobs:
  build-and-test:
    env:
      CI: true
      NODE_ENV: dev
    runs-on: ubuntu-latest
    steps:

      - uses: actions/checkout@v4
        with:
          # Disabling shallow clone is recommended for improving relevancy of reporting
          fetch-depth: 0
          ref: ${{ github.event.pull_request.head.sha }}
          token: ${{ github.token }}

      - uses: pnpm/action-setup@v4.0.0
        with:
          version: 9.1.2

      - name: Install node
        uses: actions/setup-node@v4.0.2
        with:
          node-version: "18.17.1"
          cache: "pnpm"
          cache-dependency-path: "./frontend/pnpm-lock.yaml"

      - name: Install Node dependencies
        run: |
          cd frontend/
          pnpm install --frozen-lockfile

      - name: Compile
        run: |
          cd frontend/
          pnpm compile

      - name: Linter
        run: |
          cd frontend/
          pnpm lint:CI

      - name: Tests
        run: |
          cd frontend/
          pnpm test:CI

      - name: SonarCloud Scan
        if: false # TODO remove when public
        uses: sonarsource/sonarcloud-github-action@master
        with:
          projectBaseDir: ./frontend
          args: -Dsonar.pullrequest.key=${{ github.event.pull_request.number }} -Dsonar.pullrequest.branch=${{ github.head_ref }} -Dsonar.pullrequest.base=${{ github.base_ref }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_FRONTEND }}


Main: Build & deploy

name: "Main: Build & deploy"
on:
  workflow_dispatch:

  push:
    branches: [ "main" ]

permissions:
  contents: read

jobs:
  build:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write

    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          ref: ${{ github.event.pull_request.head.sha }}
          token: ${{ github.token }}

      - name: Set up JDK
        uses: actions/setup-java@v4
        with:
          java-version: '17'
          distribution: 'zulu'
          cache: 'maven'

      - name: Build a jar
        id: build
        run: |
          ./mvnw -B -ntp versions:set -DnewVersion=$GITHUB_SHA
          ./mvnw -V -B -ntp clean package -Pprod -DskipTests
          export VERSION=$(./mvnw -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
          echo "version=${VERSION}" >> $GITHUB_OUTPUT

      # docker images

      - name: Set up QEMU
        uses: docker/setup-qemu-action@v3

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      - name: Cache Docker layers
        uses: actions/cache@v4
        with:
          path: /tmp/.buildx-cache
          key: ${{ runner.os }}-buildx-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-buildx-

      - name: Login to GitHub Container Registry
        uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Build & push docker image
        id: docker_build_and_push
        uses: docker/build-push-action@v5
        with:
          builder: ${{ steps.buildx.outputs.name }}
          context: api
          platforms: linux/amd64,linux/arm64
          provenance: false
          push: true
          tags: |
            ghcr.io/kafbat/kafka-ui:${{ steps.build.outputs.version }}
            ghcr.io/kafbat/kafka-ui:main
          build-args: |
            JAR_FILE=api-${{ steps.build.outputs.version }}.jar
          cache-from: type=local,src=/tmp/.buildx-cache
          cache-to: type=local,dest=/tmp/.buildx-cache


Infra: Markdown: URL linter

name: "Infra: Markdown: URL linter"
on:
  pull_request:
    types:
      - opened
      - labeled
      - reopened
      - synchronize
    paths:
      - '**.md'

permissions:
  contents: read

jobs:
  build-and-test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
        with:
          token: ${{ github.token }}
      - name: Check URLs in files
        uses: urlstechie/urlchecker-action@0.0.34
        with:
          exclude_patterns: localhost,127.0.,192.168.
          exclude_urls: https://api.server,https://graph.microsoft.com/User.Read,https://dev-a63ggcut.auth0.com/,http://main-schema-registry:8081,http://schema-registry:8081,http://another-yet-schema-registry:8081,http://another-schema-registry:8081
          print_all: false
          file_types: .md


PR: Checklist linter

name: "PR: Checklist linter"
on:
  pull_request_target:
    types: [opened, edited, synchronize, reopened]
permissions:
  checks: write
jobs:
  task-check:
    runs-on: ubuntu-latest
    steps:
      - uses: kentaro-m/task-completed-checker-action@v0.1.2
        with:
          repo-token: "${{ secrets.GITHUB_TOKEN }}"
      - uses: dekinderfiets/pr-description-enforcer@0.0.1
        if: false # TODO remove when public
        with:
          repo-token: "${{ secrets.GITHUB_TOKEN }}"


Infra: Release: Serde API

name: "Infra: Release: Serde API"

on: workflow_dispatch

permissions:
  contents: read

jobs:
  release-serde-api:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
          token: ${{ github.token }}

      - run: |
          git config user.name github-actions
          git config user.email github-actions@github.com

      - name: Set up JDK
        uses: actions/setup-java@v4
        with:
          java-version: "17"
          distribution: "zulu"
          cache: "maven"

      - id: install-secret-key
        name: Install GPG secret key
        run: |
          cat <(echo -e "${{ secrets.GPG_PRIVATE_KEY }}") | gpg --batch --import

      - name: Publish to Maven Central
        run: |
          mvn source:jar javadoc:jar package gpg:sign \
          -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} \
          -Dserver.username=${{ secrets.NEXUS_USERNAME }} \
          -Dserver.password=${{ secrets.NEXUS_PASSWORD }} \
          central-publishing:publish -pl serde-api -s settings.xml


Infra: Release

name: "Infra: Release"
on:
  release:
    types: [ published ]

permissions:
  contents: read

jobs:
  release:
    runs-on: ubuntu-latest
    permissions:
      contents: write
      packages: write
    outputs:
      version: ${{steps.build.outputs.version}}
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
          ref: ${{ github.event.pull_request.head.sha }}
          token: ${{ github.token }}

      - run: |
          git config user.name github-actions
          git config user.email github-actions@github.com

      - name: Set up JDK
        uses: actions/setup-java@v4
        with:
          java-version: '17'
          distribution: 'zulu'
          cache: 'maven'

      - name: Build with Maven
        id: build
        run: |
          ./mvnw -B -ntp versions:set -DnewVersion=${{ github.event.release.tag_name }}
          ./mvnw -B -V -ntp clean package -Pprod -DskipTests
          export VERSION=$(./mvnw -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
          echo "version=${VERSION}" >> $GITHUB_OUTPUT

      - name: Upload files to a GitHub release
        uses: svenstaro/upload-release-action@2.9.0
        with:
          repo_token: ${{ secrets.GITHUB_TOKEN }}
          file: api/target/api-${{ steps.build.outputs.version }}.jar
          tag: ${{ github.event.release.tag_name }}

      - name: Archive JAR
        uses: actions/upload-artifact@v4
        with:
          name: kafbat-ui-${{ steps.build.outputs.version }}
          path: api/target/api-${{ steps.build.outputs.version }}.jar
      #################
      #               #
      # Docker images #
      #               #
      #################
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v3

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      - name: Cache Docker layers
        uses: actions/cache@v4
        with:
          path: /tmp/.buildx-cache
          key: ${{ runner.os }}-buildx-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-buildx-

      - name: Login to GitHub Container Registry
        uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - name: Build and push
        id: docker_build_and_push
        uses: docker/build-push-action@v5
        with:
          builder: ${{ steps.buildx.outputs.name }}
          context: api
          platforms: linux/amd64,linux/arm64
          provenance: false
          push: true
          tags: |
            ghcr.io/kafbat/kafka-ui:${{ steps.build.outputs.version }}
            ghcr.io/kafbat/kafka-ui:latest
          build-args: |
            JAR_FILE=api-${{ steps.build.outputs.version }}.jar
          cache-from: type=local,src=/tmp/.buildx-cache
          cache-to: type=local,dest=/tmp/.buildx-cache

  charts:
    runs-on: ubuntu-latest
    needs: release
    steps:
      - name: Repository Dispatch
        uses: peter-evans/repository-dispatch@v3
        with:
          token: ${{ secrets.CHARTS_ACTIONS_TOKEN }}
          repository: kafbat/helm-charts
          event-type: prepare-helm-release
          client-payload: '{"appversion": "${{ needs.release.outputs.version }}"}'


E2E: PR smoke tests

name: "E2E: PR smoke tests"
on:
  pull_request:
    types: [ "opened", "reopened", "synchronize" ]
    paths:
      - "pom.xml"
      - "contract/**"
      - "api/**"
      - "serde-api/**"
      - "frontend/**"
      - "e2e-tests/**"

permissions:
  contents: read
  checks: write
  statuses: write

jobs:
  build-and-test:
    uses: ./.github/workflows/e2e-run.yml
    secrets: inherit
    with:
      suite_name: "smoke"
      sha: ${{ github.event.pull_request.head.sha }}


E2E: Run tests

name: "E2E: Run tests"

on:
  workflow_call:
    inputs:
      suite_name:
        description: 'Test suite name to run'
        default: 'regression'
        required: true
        type: string
      sha:
        required: true
        type: string

permissions:
  contents: read
  checks: write
  statuses: write

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          token: ${{ github.token }}
          ref: ${{ inputs.sha }}

      - name: Set up JDK
        uses: actions/setup-java@v3
        with:
          java-version: '17'
          distribution: 'zulu'
          cache: 'maven'

      - name: Build with Maven
        id: build_app
        run: |
          ./mvnw -B -ntp versions:set -DnewVersion=${{ inputs.sha }}
          ./mvnw -B -V -ntp clean install -Pprod -Dmaven.test.skip=true

      - name: Upload maven artifacts
        uses: actions/upload-artifact@v4
        with:
          name: artifacts
          path: ~/.m2/repository/io/kafbat/ui/**/*
          retention-days: 7

      - name: Dump docker image
        run: |
          docker image save ghcr.io/kafbat/kafka-ui:latest > /tmp/image.tar

      - name: Upload docker image
        uses: actions/upload-artifact@v4
        with:
          name: image
          path: /tmp/image.tar
          retention-days: 7

  tests:
    runs-on: ubuntu-latest
    needs: build
    steps:

      - name: Checkout
        uses: actions/checkout@v4
        with:
          token: ${{ github.token }}
          ref: ${{ inputs.sha }}

      - name: Set up JDK
        uses: actions/setup-java@v3
        with:
          java-version: '17'
          distribution: 'zulu'
          cache: 'maven'

      - name: Download maven artifacts
        uses: actions/download-artifact@v4
        with:
          name: artifacts
          path: ~/.m2/repository/io/kafbat/ui

      - name: Download docker image
        uses: actions/download-artifact@v4
        with:
          name: image
          path: /tmp

      - name: Load Docker image
        run: |
          docker load --input /tmp/image.tar

      - name: Cache Docker images.
        uses: ScribeMD/docker-cache@0.5.0
        with:
          key: docker-${{ runner.os }}-${{ hashFiles('./e2e-tests/selenoid/selenoid-ci.yaml', './documentation/compose/e2e-tests.yaml') }}

      - name: Compose up
        id: compose_app
        # use the following command until #819 will be fixed # TODO recheck 819
        run: |
          mkdir -p ./e2e-tests/target/selenoid-results/video
          mkdir -p ./e2e-tests/target/selenoid-results/logs
          docker-compose -f ./e2e-tests/selenoid/selenoid-ci.yaml up -d
          docker-compose -f ./documentation/compose/e2e-tests.yaml up -d

      - name: Dump Docker logs on failure
        if: failure()
        uses: jwalton/gh-docker-logs@v2.2.2

      - name: Run test suite
        run: |
          ./mvnw -B -ntp versions:set -DnewVersion=${{ inputs.sha }}
          ./mvnw -B -V -ntp -Dsurefire.suiteXmlFiles='src/test/resources/${{ inputs.suite_name }}.xml' -f 'e2e-tests' test -Pprod

      - name: Upload allure reports artifact
        if: '!cancelled()'
        uses: actions/upload-artifact@v4
        with:
          name: reports
          path: ./e2e-tests/target/allure-results
          retention-days: 7

      - name: Upload selenide results artifact
        if: failure()
        uses: actions/upload-artifact@v4
        with:
          name: selenide-results
          path: ./e2e-tests/target/selenide-results
          retention-days: 3

  reports:
    runs-on: ubuntu-latest
    needs: tests
    if: ${{ !cancelled() && github.repository == 'kafbat/kafka-ui' }}
    steps:
      - name: Download allure reports artifact
        uses: actions/download-artifact@v4
        with:
          name: reports
          path: ./e2e-tests/target/allure-results

      - name: Generate Allure report
        uses: simple-elf/allure-report-action@v1.9
        id: allure-report
        with:
          allure_results: ./e2e-tests/target/allure-results
          gh_pages: allure-results
          allure_report: allure-report
          subfolder: allure-results
          report_url: "https://reports.kafbat.dev"

      - name: Upload allure report to R2
        uses: ryand56/r2-upload-action@latest
        with:
          source-dir: allure-history/allure-results
          destination-dir: .
          r2-bucket: "reports"
          r2-account-id: ${{ secrets.R2_ACCOUNT_ID }}
          r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }}
          r2-secret-access-key: ${{ secrets.R2_ACCESS_SECRET_KEY }}

      - name: Add allure link status check
        uses: Sibz/github-status-action@v1.1.6
        with:
          authToken: ${{secrets.GITHUB_TOKEN}}
          context: "Click Details button to view Allure report"
          state: "success"
          sha: ${{ inputs.sha }}
          target_url: https://reports.kafbat.dev/${{ github.run_number }}


name: "Infra: Release: AWS Marketplace Publisher"
on:
  workflow_dispatch:
    inputs:
      KafkaUIInfraBranch:
        description: 'Branch name of Kafka-UI-Infra repo, build commands will be executed from this branch'
        required: true
        default: 'main'
      KafkaUIReleaseVersion:
        description: 'Version of KafkaUI'
        required: true
        default: '0.3.2'
      PublishOnMarketplace:
        description: 'If set to true, the request to update AWS Server product version will be raised'
        required: true
        default: false
        type: boolean

jobs:
  build-ami:
    name: Build AMI
    runs-on: ubuntu-latest
    steps:
      - name: Clone infra repo
        run: |
          echo "Cloning repo..."
          git clone https://infra-tech:${{ secrets.INFRA_USER_ACCESS_TOKEN }}@github.com/kafbat/kafka-ui-infra.git --branch ${{ github.event.inputs.KafkaUIInfraBranch }}
          echo "Cd to packer DIR..."
          cd kafka-ui-infra/ami
          echo "WORK_DIR=$(pwd)" >> $GITHUB_ENV
          echo "Packer will be triggered in this dir $WORK_DIR"

      - name: Configure AWS credentials for Kafka-UI account
        uses: aws-actions/configure-aws-credentials@v4
        with:
          aws-access-key-id: ${{ secrets.AWS_AMI_PUBLISH_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_AMI_PUBLISH_KEY_SECRET }}
          aws-region: us-east-1

      # validate templates
      - name: Validate Template
        uses: hashicorp/packer-github-actions@master
        with:
          command: validate
          arguments: -syntax-only
          target: kafka-ui-infra/ami/kafka-ui.pkr.hcl

      # build artifact
      - name: Build Artifact
        uses: hashicorp/packer-github-actions@master
        with:
          command: build
          arguments: "-color=false -on-error=abort -var=kafka_ui_release_version=${{ github.event.inputs.KafkaUIReleaseVersion }}"
          target: kafka-ui.pkr.hcl
          working_directory: ${{ env.WORK_DIR }}
        env:
          PACKER_LOG: 1

      # add fresh AMI to AWS Marketplace
      - name: Publish Artifact at Marketplace
        if: ${{ github.event.inputs.PublishOnMarketplace == 'true' }}
        env:
          PRODUCT_ID: ${{ secrets.AWS_SERVER_PRODUCT_ID }}
          RELEASE_VERSION: "${{ github.event.inputs.KafkaUIReleaseVersion }}"
          RELEASE_NOTES: "https://github.com/kafbat/kafka-ui/releases/tag/v${{ github.event.inputs.KafkaUIReleaseVersion }}"
          MP_ROLE_ARN: ${{ secrets.AWS_MARKETPLACE_AMI_ACCESS_ROLE }} # https://docs.aws.amazon.com/marketplace/latest/userguide/ami-single-ami-products.html#single-ami-marketplace-ami-access
          AMI_OS_VERSION: "amzn2-ami-kernel-5.10-hvm-*-x86_64-gp2"
        run: |
          set -x
          pwd
          ls -la kafka-ui-infra/ami
          echo $WORK_DIR/manifest.json
          export AMI_ID=$(jq -r '.builds[-1].artifact_id' kafka-ui-infra/ami/manifest.json | cut -d ":" -f2)
          /bin/bash kafka-ui-infra/aws-marketplace/prepare_changeset.sh > changeset.json
          aws marketplace-catalog start-change-set \
            --catalog "AWSMarketplace" \
            --change-set "$(cat changeset.json)"


Infra: CVE checks

name: "Infra: CVE checks"
on:
  workflow_dispatch:
  schedule:
    # * is a special character in YAML so you have to quote this string
    - cron: '0 8 15 * *'

permissions:
  contents: read

jobs:
  build-and-test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
        with:
          token: ${{ github.token }}

      - name: Set up JDK
        uses: actions/setup-java@v4
        with:
          java-version: '17'
          distribution: 'zulu'
          cache: 'maven'

      - name: Build project
        id: build
        run: |
          ./mvnw -B -ntp versions:set -DnewVersion=$GITHUB_SHA
          ./mvnw -B -V -ntp clean package -DskipTests
          export VERSION=$(./mvnw -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
          echo "version=${VERSION}" >> $GITHUB_OUTPUT

      - name: Set up QEMU
        uses: docker/setup-qemu-action@v3

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      - name: Cache Docker layers
        uses: actions/cache@v4
        with:
          path: /tmp/.buildx-cache
          key: ${{ runner.os }}-buildx-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-buildx-

      - name: Build docker image
        uses: docker/build-push-action@v5
        with:
          builder: ${{ steps.buildx.outputs.name }}
          context: api
          platforms: linux/amd64
          push: false
          load: true
          tags: |
            ghcr.io/kafbat/kafka-ui:${{ steps.build.outputs.version }}
          build-args: |
            JAR_FILE=api-${{ steps.build.outputs.version }}.jar
          cache-from: type=local,src=/tmp/.buildx-cache
          cache-to: type=local,dest=/tmp/.buildx-cache

      - name: Run CVE checks
        uses: aquasecurity/trivy-action@0.19.0
        with:
          image-ref: "ghcr.io/kafbat/kafka-ui:${{ steps.build.outputs.version }}"
          format: "table"
          exit-code: "1"


Checkstyle

name: Checkstyle
on: [pull_request]
jobs:
  checkstyle:
    name: runner / checkstyle
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dbelyaev/action-checkstyle@v0.7.4
        with:
          github_token: ${{ secrets.github_token }}
          reporter: github-pr-review


Conventional Commits

name: Conventional Commits
on: [push, pull_request]
jobs:
  build:
    name: Conventional Commits
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: webiny/action-conventional-commits@v1.1.0


Conventional PR Title

name: Conventional PR Title
on:
  pull_request_target:
    types:
      - opened
      - reopened
      - edited
      - synchronize
jobs:
  lint:
    runs-on: ubuntu-latest
    permissions:
      statuses: write
    steps:
      - uses: aslafy-z/conventional-pr-title-action@v3
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


Bump Version

name: Bump Version

on:
  workflow_dispatch:
    inputs:
      version:
        description: "Version number"
        required: true
      createTag:
        description: "Create a new release"
        type: boolean
        required: false
        default: false
      prerelease:
        description: "Is prerelease ?"
        type: boolean
        required: false
        default: false
      draft:
        description: "Is draft ?"
        type: boolean
        required: false
        default: false

jobs:
  bumpVersion:
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v4

      - name: Install xmlstarlet
        run: sudo apt install -y xmlstarlet

      - name: Install Maven
        run: sudo apt install maven

      - name: Bump version in POM files
        run: mvn versions:set -DnewVersion=${{ github.event.inputs.version }} -q

      - name: Commit & Push changes
        run: |
          git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
          git config --local user.name "github-actions[bot]"
          git commit -a -m "build: bump version to ${{ github.event.inputs.version }}"
          git push origin HEAD:${{ github.ref }}

      - name: Create Release
        if: ${{ github.event.inputs.createTag == 'true' }}
        uses: ncipollo/release-action@v1
        with:
          allowUpdates: true
          generateReleaseNotes: true
          tag: ${{ github.event.inputs.version }}
          name: Release v${{ github.event.inputs.version }}
          draft: ${{ github.event.inputs.draft }}
          prerelease: ${{ github.event.inputs.prerelease }}
          makeLatest: ${{ github.event.inputs.prerelease == 'false' }}


Pull Request Labeler

name: "Pull Request Labeler"
on:
- pull_request_target

jobs:
  labeler:
    permissions:
      contents: read
      pull-requests: write
    runs-on: ubuntu-latest
    steps:
    - uses: actions/labeler@v5


Dependency review

name: 'Dependency review'
on:
  pull_request:
    branches: [ "main" ]

permissions:
  contents: read
  pull-requests: write

jobs:
  dependency-review:
    runs-on: ubuntu-latest
    steps:
      - name: 'Checkout repository'
        uses: actions/checkout@v4
      - name: 'Dependency Review'
        uses: actions/dependency-review-action@v4
        with:
          comment-summary-in-pr: always
          fail-on-severity: moderate


Publish

name: Publish
on:
  workflow_run:
    workflows: ["Tests", "Bump Version"]
    types: [completed]
    branches: [main]

jobs:
  setup:
    runs-on: ubuntu-latest
    if: ${{ github.event.workflow_run.conclusion == 'success' }}
    outputs:
      version: ${{ steps.extract-version.outputs.version }}
      version-without-suffix: ${{ steps.extract-version.outputs.version-without-suffix }}
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Install xmlstarlet
        run: sudo apt update && sudo apt install -y xmlstarlet

      - name: Extract BBj Version
        id: extract-version
        run: |
          version=$(xmlstarlet sel -N pom="http://maven.apache.org/POM/4.0.0" \
            -t -v "/pom:project/pom:version" \
            pom.xml)
          version_without_suffix="${version%-SNAPSHOT}"
          echo "::set-output name=version::$version"
          echo "::set-output name=version-without-suffix::$version_without_suffix"
  publish:
    needs: setup
    runs-on: ubuntu-latest
    container: "webforj/sandbox:${{ needs.setup.outputs.version-without-suffix }}"
    steps:
      - uses: actions/checkout@v4

      - name: Install gpg
        run: apk add gnupg

      - name: Import GPG Key
        uses: crazy-max/ghaction-import-gpg@v1
        env:
          GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
          PASSPHRASE: ""

      - name: Install Maven
        run: apk add maven

      - name: Write maven settings
        uses: whelk-io/maven-settings-xml-action@v20
        with:
          servers: >
            [
              {
                "id": "ossrh",
                "username": "${{secrets.OSSRH_USERNAME}}",
                "password": "${{secrets.OSSRH_TOKEN}}"
              },
              {
                "id": "sonatype-nexus-snapshots",
                "username": "${{secrets.OSSRH_USERNAME}}",
                "password": "${{secrets.OSSRH_TOKEN}}"
              },
              {
                "id": "sonatype-nexus-staging",
                "username": "${{secrets.OSSRH_USERNAME}}",
                "password": "${{secrets.OSSRH_TOKEN}}"
              }
            ]
          profiles: >
            [
              {
                "id": "ossrh",
                "activation": {
                  "activeByDefault": true
                }
              }
            ]

      - name: Install Maven Dependencies
        run: >
          mvn install:install-file "-Dfile=/opt/bbx/.lib/BBjStartup.jar" "-DgroupId=com.basis.lib" "-DartifactId=BBjStartup" "-Dversion=${{ needs.setup.outputs.version }}" "-Dpackaging=jar" -q
          && mvn install:install-file "-Dfile=/opt/bbx/.lib/BBj.jar" "-DgroupId=com.basis.lib" "-DartifactId=BBj" "-Dversion=${{ needs.setup.outputs.version }}" "-Dpackaging=jar" -q
          && mvn install:install-file "-Dfile=/opt/bbx/.lib/BBjUtil.jar" "-DgroupId=com.basis.lib" "-DartifactId=BBjUtil" "-Dversion=${{ needs.setup.outputs.version }}" "-Dpackaging=jar" -q
          && mvn install:install-file "-Dfile=/opt/bbx/.lib/BBjsp.jar" "-DgroupId=com.basis.lib" "-DartifactId=BBjsp" "-Dversion=${{ needs.setup.outputs.version }}" "-Dpackaging=jar" -q
          && mvn install:install-file "-Dfile=/opt/bbx/.lib/BBjAdminAPI.jar" "-DgroupId=com.basis.lib" "-DartifactId=BBjAdminAPI" "-Dversion=${{ needs.setup.outputs.version }}" "-Dpackaging=jar" -q
          && mvn install -q -DskipTests

      - name: Publish to Nexus
        run: mvn clean deploy -DskipTests -P perform-release -s /github/home/.m2/settings.xml -q


Tests

name: Tests
on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

jobs:
  setup:
    runs-on: ubuntu-latest
    outputs:
      version: ${{ steps.extract-version.outputs.version }}
      version-without-suffix: ${{ steps.extract-version.outputs.version-without-suffix }}
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Install xmlstarlet
        run: sudo apt update && sudo apt install -y xmlstarlet

      - name: Extract Project Version
        id: extract-version
        run: |
          version=$(xmlstarlet sel -N pom="http://maven.apache.org/POM/4.0.0" \
            -t -v "/pom:project/pom:version" \
            pom.xml)
          version_without_suffix="${version%-SNAPSHOT}"
          echo "::set-output name=version::$version"
          echo "::set-output name=version-without-suffix::$version_without_suffix"
  tests:
    needs: setup
    runs-on: ubuntu-latest
    container: "webforj/sandbox:${{ needs.setup.outputs.version-without-suffix }}"
    permissions:
      pull-requests: write
    steps:
      - uses: actions/checkout@v4

      - name: Install Maven
        run: apk add maven

      - name: Install Maven Dependencies
        run: >
          mvn install:install-file "-Dfile=/opt/bbx/.lib/BBjStartup.jar" "-DgroupId=com.basis.lib" "-DartifactId=BBjStartup" "-Dversion=${{ needs.setup.outputs.version }}" "-Dpackaging=jar" -q
          && mvn install:install-file "-Dfile=/opt/bbx/.lib/BBj.jar" "-DgroupId=com.basis.lib" "-DartifactId=BBj" "-Dversion=${{ needs.setup.outputs.version }}" "-Dpackaging=jar" -q
          && mvn install:install-file "-Dfile=/opt/bbx/.lib/BBjUtil.jar" "-DgroupId=com.basis.lib" "-DartifactId=BBjUtil" "-Dversion=${{ needs.setup.outputs.version }}" "-Dpackaging=jar" -q
          && mvn install:install-file "-Dfile=/opt/bbx/.lib/BBjsp.jar" "-DgroupId=com.basis.lib" "-DartifactId=BBjsp" "-Dversion=${{ needs.setup.outputs.version }}" "-Dpackaging=jar" -q
          && mvn install:install-file "-Dfile=/opt/bbx/.lib/BBjAdminAPI.jar" "-DgroupId=com.basis.lib" "-DartifactId=BBjAdminAPI" "-Dversion=${{ needs.setup.outputs.version }}" "-Dpackaging=jar" -q
          && mvn install -q -DskipTests

      - name: Build with Maven
        run: mvn -B verify

      - name: Jacoco Report
        # if: github.event_name == 'pull_request'
        id: jacoco
        uses: madrapps/jacoco-report@v1.6.1
        with:
          paths: |
            ${{ github.workspace }}/webforj-report-aggregate/target/site/jacoco-aggregate/jacoco.xml
          token: ${{ secrets.GITHUB_TOKEN }}
          min-coverage-overall: 40
          min-coverage-changed-files: 60
          title: Code Coverage
          update-comment: true

      - name: Get the Coverage info
        run: |
          echo "Total coverage ${{ steps.jacoco.outputs.coverage-overall }}"
          echo "Changed Files coverage ${{ steps.jacoco.outputs.coverage-changed-files }}"


Automatic Rebase

name: Automatic Rebase
on:
  issue_comment:
    types: [created]
jobs:
  rebase:
    name: Rebase
    runs-on: ubuntu-latest
    if: >-
      github.event.issue.pull_request != '' &&
      (
        contains(github.event.comment.body, '/rebase') ||
        contains(github.event.comment.body, '/autosquash')
      )
    steps:
      - name: Checkout the latest code
        uses: actions/checkout@v4
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
      - name: Automatic Rebase
        uses: cirrus-actions/rebase@1.8
        with:
          autosquash: ${{ contains(github.event.comment.body, '/autosquash') || contains(github.event.comment.body, '/rebase-autosquash') }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


Check licensing

# 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.

name: Check licensing

on: [push, pull_request]

concurrency:
  group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.number || github.run_id }}
  cancel-in-progress: true

jobs:
  build:
    runs-on: ubuntu-latest
    env:
      MVN_COMMON_OPTIONS: -U -B --no-transfer-progress
      MVN_BUILD_OUTPUT_FILE: "/tmp/mvn_build_output.out"
      MVN_VALIDATION_DIR: "/tmp/paimon-validation-deployment"

    steps:
      - uses: actions/checkout@v2

      - name: Set JDK
        uses: actions/setup-java@v2
        with:
          java-version: 8
          distribution: 'adopt'
      - name: Build
        run: |
          set -o pipefail

          mvn clean deploy ${{ env.MVN_COMMON_OPTIONS }} -DskipTests \
            -DaltDeploymentRepository=validation_repository::default::file:${{ env.MVN_VALIDATION_DIR }} \
            | tee ${{ env.MVN_BUILD_OUTPUT_FILE }}

      - name: Check licensing
        run: |
          mvn ${{ env.MVN_COMMON_OPTIONS }} exec:java@check-licensing -N \
            -Dexec.args="${{ env.MVN_BUILD_OUTPUT_FILE }} $(pwd) ${{ env.MVN_VALIDATION_DIR }}" \
            -Dlog4j.configurationFile=file://$(pwd)/tools/ci/log4j.properties
        env:
          MAVEN_OPTS: -Xmx4096m


docs-tests

# 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.

name: docs-tests
on:
  push:
  pull_request:
    paths:
      - 'docs/**'

concurrency:
  group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.number || github.run_id }}
  cancel-in-progress: true

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Setup Hugo
        uses: peaceiris/actions-hugo@v2
        with:
          hugo-version: '0.124.1'
          extended: true

      - name: Build
        run: |
          cd docs
          # Fetch the theme submodule
          git submodule update --init --recursive
          hugo


End to End Tests Flink 1.15 on JDK 11

################################################################################
#  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.
################################################################################

name: End to End Tests Flink 1.15 on JDK 11

on:
  issue_comment:
    types: [created, edited, deleted]

  # daily run
  schedule:
    - cron: "0 0 * * *"

env:
  JDK_VERSION: 11

jobs:
  build:
    if: |
      github.event_name == 'schedule' ||
      (contains(github.event.comment.html_url, '/pull/') && contains(github.event.comment.body, '/jdk11'))
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Set up JDK ${{ env.JDK_VERSION }}
        uses: actions/setup-java@v2
        with:
          java-version: ${{ env.JDK_VERSION }}
          distribution: 'adopt'
      - name: Build Flink 1.15
        run: mvn -T 1C -B clean install -DskipTests -Pflink-1.15
      - name: Test Flink 1.15
        timeout-minutes: 60
        run: |
          # run tests with random timezone to find out timezone related bugs
          . .github/workflows/utils.sh
          jvm_timezone=$(random_timezone)
          echo "JVM timezone is set to $jvm_timezone"
          mvn -T 1C -B test -pl paimon-e2e-tests -Duser.timezone=$jvm_timezone -Pflink-1.15
        env:
          MAVEN_OPTS: -Xmx4096m


End to End Tests Flink 1.15

################################################################################
#  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.
################################################################################

name: End to End Tests Flink 1.15

on:
  push:
  pull_request:
    paths-ignore:
      - 'docs/**'
      - '**/*.md'

env:
  JDK_VERSION: 8

concurrency:
  group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.number || github.run_id }}
  cancel-in-progress: true

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Set up JDK ${{ env.JDK_VERSION }}
        uses: actions/setup-java@v2
        with:
          java-version: ${{ env.JDK_VERSION }}
          distribution: 'adopt'
      - name: Build Flink 1.15
        run: mvn -T 1C -B clean install -DskipTests -Pflink-1.15
      - name: Test Flink 1.15
        timeout-minutes: 60
        run: |
          # run tests with random timezone to find out timezone related bugs
          . .github/workflows/utils.sh
          jvm_timezone=$(random_timezone)
          echo "JVM timezone is set to $jvm_timezone"
          mvn -T 1C -B test -pl paimon-e2e-tests -Duser.timezone=$jvm_timezone -Pflink-1.15
        env:
          MAVEN_OPTS: -Xmx4096m


End to End Tests Flink 1.16 on JDK 11

################################################################################
#  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.
################################################################################

name: End to End Tests Flink 1.16 on JDK 11

on:
  issue_comment:
    types: [created, edited, deleted]

  # daily run
  schedule:
    - cron: "0 0 * * *"

env:
  JDK_VERSION: 11

jobs:
  build:
    if: |
      github.event_name == 'schedule' ||
      (contains(github.event.comment.html_url, '/pull/') && contains(github.event.comment.body, '/jdk11'))
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Set up JDK ${{ env.JDK_VERSION }}
        uses: actions/setup-java@v2
        with:
          java-version: ${{ env.JDK_VERSION }}
          distribution: 'adopt'
      - name: Build Flink 1.16
        run: mvn -T 1C -B clean install -DskipTests -Pflink-1.16
      - name: Test Flink 1.16
        timeout-minutes: 60
        run: |
          # run tests with random timezone to find out timezone related bugs
          . .github/workflows/utils.sh
          jvm_timezone=$(random_timezone)
          echo "JVM timezone is set to $jvm_timezone"
          mvn -T 1C -B test -pl paimon-e2e-tests -Duser.timezone=$jvm_timezone -Pflink-1.16
        env:
          MAVEN_OPTS: -Xmx4096m


End to End Tests Flink 1.16

################################################################################
#  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.
################################################################################

name: End to End Tests Flink 1.16

on:
  push:
  pull_request:
    paths-ignore:
      - 'docs/**'
      - '**/*.md'

env:
  JDK_VERSION: 8

concurrency:
  group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.number || github.run_id }}
  cancel-in-progress: true

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Set up JDK ${{ env.JDK_VERSION }}
        uses: actions/setup-java@v2
        with:
          java-version: ${{ env.JDK_VERSION }}
          distribution: 'adopt'
      - name: Build Flink 1.16
        run: mvn -T 1C -B clean install -DskipTests -Pflink-1.16
      - name: Test Flink 1.16
        timeout-minutes: 60
        run: |
          # run tests with random timezone to find out timezone related bugs
          . .github/workflows/utils.sh
          jvm_timezone=$(random_timezone)
          echo "JVM timezone is set to $jvm_timezone"
          mvn -T 1C -B test -pl paimon-e2e-tests -Duser.timezone=$jvm_timezone -Pflink-1.16
        env:
          MAVEN_OPTS: -Xmx4096m


End to End Tests Flink 1.17 on JDK 11

################################################################################
#  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.
################################################################################

name: End to End Tests Flink 1.17 on JDK 11

on:
  issue_comment:
    types: [created, edited, deleted]

  # daily run
  schedule:
    - cron: "0 0 * * *"

env:
  JDK_VERSION: 11

jobs:
  build:
    if: |
      github.event_name == 'schedule' ||
      (contains(github.event.comment.html_url, '/pull/') && contains(github.event.comment.body, '/jdk11'))
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Set up JDK ${{ env.JDK_VERSION }}
        uses: actions/setup-java@v2
        with:
          java-version: ${{ env.JDK_VERSION }}
          distribution: 'adopt'
      - name: Build Flink 1.17
        run: mvn -T 1C -B clean install -DskipTests -Pflink-1.17
      - name: Test Flink 1.17
        timeout-minutes: 60
        run: |
          # run tests with random timezone to find out timezone related bugs
          . .github/workflows/utils.sh
          jvm_timezone=$(random_timezone)
          echo "JVM timezone is set to $jvm_timezone"
          mvn -T 1C -B test -pl paimon-e2e-tests -Duser.timezone=$jvm_timezone -Pflink-1.17
        env:
          MAVEN_OPTS: -Xmx4096m


End to End Tests Flink 1.17

################################################################################
#  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.
################################################################################

name: End to End Tests Flink 1.17

on:
  push:
  pull_request:
    paths-ignore:
      - 'docs/**'
      - '**/*.md'

env:
  JDK_VERSION: 8

concurrency:
  group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.number || github.run_id }}
  cancel-in-progress: true

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Set up JDK ${{ env.JDK_VERSION }}
        uses: actions/setup-java@v2
        with:
          java-version: ${{ env.JDK_VERSION }}
          distribution: 'adopt'
      - name: Build Flink 1.17
        run: mvn -T 1C -B clean install -DskipTests -Pflink-1.17
      - name: Test Flink 1.17
        timeout-minutes: 60
        run: |
          # run tests with random timezone to find out timezone related bugs
          . .github/workflows/utils.sh
          jvm_timezone=$(random_timezone)
          echo "JVM timezone is set to $jvm_timezone"
          mvn -T 1C -B test -pl paimon-e2e-tests -Duser.timezone=$jvm_timezone -Pflink-1.17
        env:
          MAVEN_OPTS: -Xmx4096m


End to End Tests Flink 1.18 on JDK 11

################################################################################
#  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.
################################################################################

name: End to End Tests Flink 1.18 on JDK 11

on:
  issue_comment:
    types: [created, edited, deleted]

  # daily run
  schedule:
    - cron: "0 0 * * *"

env:
  JDK_VERSION: 11

jobs:
  build:
    if: |
      github.event_name == 'schedule' ||
      (contains(github.event.comment.html_url, '/pull/') && contains(github.event.comment.body, '/jdk11'))
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Set up JDK ${{ env.JDK_VERSION }}
        uses: actions/setup-java@v2
        with:
          java-version: ${{ env.JDK_VERSION }}
          distribution: 'adopt'
      - name: Build Flink 1.18
        run: mvn -T 1C -B clean install -DskipTests
      - name: Test Flink 1.18
        timeout-minutes: 60
        run: |
          # run tests with random timezone to find out timezone related bugs
          . .github/workflows/utils.sh
          jvm_timezone=$(random_timezone)
          echo "JVM timezone is set to $jvm_timezone"
          mvn -T 1C -B test -pl paimon-e2e-tests -Duser.timezone=$jvm_timezone -Pflink-1.18
        env:
          MAVEN_OPTS: -Xmx4096m


End to End Tests Flink 1.18

################################################################################
#  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.
################################################################################

name: End to End Tests Flink 1.18

on:
  push:
  pull_request:
    paths-ignore:
      - 'docs/**'
      - '**/*.md'

env:
  JDK_VERSION: 8

concurrency:
  group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.number || github.run_id }}
  cancel-in-progress: true

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Set up JDK ${{ env.JDK_VERSION }}
        uses: actions/setup-java@v2
        with:
          java-version: ${{ env.JDK_VERSION }}
          distribution: 'adopt'
      - name: Build Flink 1.18
        run: mvn -T 1C -B clean install -DskipTests
      - name: Test Flink 1.18
        timeout-minutes: 60
        run: |
          # run tests with random timezone to find out timezone related bugs
          . .github/workflows/utils.sh
          jvm_timezone=$(random_timezone)
          echo "JVM timezone is set to $jvm_timezone"
          mvn -T 1C -B test -pl paimon-e2e-tests -Duser.timezone=$jvm_timezone -Pflink-1.18
        env:
          MAVEN_OPTS: -Xmx4096m


End to End Tests Flink 1.19 on JDK 11

################################################################################
#  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.
################################################################################

name: End to End Tests Flink 1.19 on JDK 11

on:
  issue_comment:
    types: [created, edited, deleted]

  # daily run
  schedule:
    - cron: "0 0 * * *"

env:
  JDK_VERSION: 11

jobs:
  build:
    if: |
      github.event_name == 'schedule' ||
      (contains(github.event.comment.html_url, '/pull/') && contains(github.event.comment.body, '/jdk11'))
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Set up JDK ${{ env.JDK_VERSION }}
        uses: actions/setup-java@v2
        with:
          java-version: ${{ env.JDK_VERSION }}
          distribution: 'adopt'
      - name: Build Flink 1.19
        run: mvn -T 1C -B clean install -DskipTests
      - name: Test Flink 1.19
        timeout-minutes: 60
        run: |
          # run tests with random timezone to find out timezone related bugs
          . .github/workflows/utils.sh
          jvm_timezone=$(random_timezone)
          echo "JVM timezone is set to $jvm_timezone"
          mvn -T 1C -B test -pl paimon-e2e-tests -Duser.timezone=$jvm_timezone
        env:
          MAVEN_OPTS: -Xmx4096m


End to End Tests Flink 1.19

################################################################################
#  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.
################################################################################

name: End to End Tests Flink 1.19

on:
  push:
  pull_request:
    paths-ignore:
      - 'docs/**'
      - '**/*.md'

env:
  JDK_VERSION: 8

concurrency:
  group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.number || github.run_id }}
  cancel-in-progress: true

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Set up JDK ${{ env.JDK_VERSION }}
        uses: actions/setup-java@v2
        with:
          java-version: ${{ env.JDK_VERSION }}
          distribution: 'adopt'
      - name: Build Flink 1.19
        run: mvn -T 1C -B clean install -DskipTests
      - name: Test Flink 1.19
        timeout-minutes: 60
        run: |
          # run tests with random timezone to find out timezone related bugs
          . .github/workflows/utils.sh
          jvm_timezone=$(random_timezone)
          echo "JVM timezone is set to $jvm_timezone"
          mvn -T 1C -B test -pl paimon-e2e-tests -Duser.timezone=$jvm_timezone
        env:
          MAVEN_OPTS: -Xmx4096m


Flink CDC Tests on JDK 11

################################################################################
#  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.
################################################################################
name: Flink CDC Tests on JDK 11

on:
  issue_comment:
    types: [created, edited, deleted]

  # daily run
  schedule:
    - cron: "0 0 * * *"

env:
  JDK_VERSION: 11

jobs:
  build:
    if: |
      github.event_name == 'schedule' ||
      (contains(github.event.comment.html_url, '/pull/') && contains(github.event.comment.body, '/jdk11'))
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Set up JDK ${{ env.JDK_VERSION }}
        uses: actions/setup-java@v2
        with:
          java-version: ${{ env.JDK_VERSION }}
          distribution: 'adopt'
      - name: Build Flink CDC
        run:  mvn -T 1C -B clean install -DskipTests
      - name: Test Flink CDC
        timeout-minutes: 60
        run: |
          . .github/workflows/utils.sh
          jvm_timezone=$(random_timezone)
          echo "JVM timezone is set to $jvm_timezone"
          mvn -T 1C -B clean install -pl 'org.apache.paimon:paimon-flink-cdc' -Duser.timezone=$jvm_timezone
        env:
          MAVEN_OPTS: -Xmx4096m