Multi-Language Client

name: Multi-Language Client
on:
  push:
    branches:
      - master
      - "rel/*"
    paths-ignore:
      - 'docs/**'
      - 'site/**'
  pull_request:
    branches:
      - master
      - "rel/*"
    paths-ignore:
      - 'docs/**'
      - 'site/**'
  # allow manually run the action:
  workflow_dispatch:

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

env:
  MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3

jobs:
  cpp:
    strategy:
      fail-fast: false
      max-parallel: 15
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
    runs-on: ${{ matrix.os}}

    steps:
      - uses: actions/checkout@v4
      - name: Install CPP Dependencies (Ubuntu)
        if: matrix.os == 'ubuntu-latest'
        shell: bash
        run: sudo apt-get update && sudo apt-get install libboost-all-dev
      - name: Install CPP Dependencies (Mac)
        if: matrix.os == 'macos-latest'
        shell: bash
        run: |
          brew install boost
          brew install bison
          echo 'export PATH="/opt/homebrew/opt/bison/bin:$PATH"' >> ~/.bash_profile
          source ~/.bash_profile && export LDFLAGS="-L/opt/homebrew/opt/bison/lib"
      - name: Install CPP Dependencies (Windows)
        if: matrix.os == 'windows-latest'
        run: |
          choco install winflexbison3
          choco install boost-msvc-14.3 --version=1.84.0.1
          echo C:\\local\\boost_1_84_0 >> $env:GITHUB_PATH
      - name: Cache Maven packages
        uses: actions/cache@v4
        with:
          path: ~/.m2
          key: client-${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
          restore-keys: ${{ runner.os }}-m2-
      - name: Build IoTDB server and client
        shell: bash
        # Explicitly using mvnw here as the build requires maven 3.9 and the default installation is older
        # Explicitly using "install" instead of package in order to be sure we're using libs built on this machine
        # (was causing problems on windows, but could cause problem on linux, when updating the thrift module)
        run: ./mvnw clean install -P with-cpp -pl distribution,example/client-cpp-example -am -DskipTests
      - name: Test with Maven
        shell: bash
        # Explicitly using mvnw here as the build requires maven 3.9 and the default installation is older
        run: ./mvnw clean verify -P with-cpp -pl iotdb-client/client-cpp -am
      - name: Upload Artifact
        if: failure()
        uses: actions/upload-artifact@v4
        with:
          name: cpp-IT-${{ runner.os }}
          path: iotdb-client/client-cpp/target/build/test/Testing
          retention-days: 1

  go:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
        with:
          token: ${{secrets.GITHUB_TOKEN}}
          submodules: recursive
      - name: Cache Maven packages
        uses: actions/cache@v4
        with:
          path: ~/.m2
          key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
          restore-keys: ${{ runner.os }}-m2-
      - name: Compile IoTDB Server
        run: mvn clean package -pl distribution -am -DskipTests
      - name: Integration test
        shell: bash
        run: |
          cd iotdb-client
          git clone https://github.com/apache/iotdb-client-go.git
          cd iotdb-client-go
          make e2e_test_for_parent_git_repo e2e_test_clean_for_parent_git_repo

  python:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
      - name: Cache Maven packages
        uses: actions/cache@v4
        with:
          path: ~/.m2
          key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
          restore-keys: ${{ runner.os }}-m2-
      - name: Build IoTDB server distribution zip and python client
        run: mvn -B clean install -pl distribution,iotdb-client/client-py -am -DskipTests
      - name: Build IoTDB server docker image
        run: |
          docker build . -f docker/src/main/Dockerfile-1c1d -t "iotdb:dev"
          docker images
      - name: Install IoTDB python client requirements
        run: pip3 install -r iotdb-client/client-py/requirements_dev.txt
      - name: Check code style
        shell: bash
        run: black iotdb-client/client-py/ --check --diff
      - name: Integration test
        shell: bash
        run: |
          cd iotdb-client/client-py/ && pytest .


Build and deploy

name: Build and deploy
on:
  push:
    branches:
      - main
  workflow_dispatch:
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
jobs:
  build:
    name: Build and deploy
    runs-on: ubuntu-latest
    steps:
      - name: Check out
        uses: actions/checkout@v4

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

      - name: Cache Maven/Gradle repositories for tests
        uses: actions/cache@v4
        with:
          path: /tmp/start-spring-io-cache
          # See https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache
          key: test-repositories-${{ runner.os }}-${{ github.run_id }}
          restore-keys: test-repositories-${{ runner.os }}-

      - name: Build with Maven
        env:
          START_SPRING_IO_TMPDIR: /tmp/start-spring-io-cache
        run: ./mvnw --batch-mode --update-snapshots verify

      - name: Set up Azure
        uses: azure/login@6c251865b4e6290e7b78be643ea2d005bc51f69a
        with:
          creds: ${{ secrets.AZURE_CREDENTIALS_SPRING_IO }}

      - name: Set up Azure Spring Extension
        run: az extension add --name spring

      - name: Deploy
        run: |
          az spring app deploy \
            --name start-spring-io \
            --service spring-io \
            --resource-group spring-io \
            --artifact-path start-site/target/start-site-exec.jar

      - name: Send notification
        uses: ./.github/actions/send-notification
        if: always()
        with:
          webhook-url: ${{ secrets.GOOGLE_CHAT_WEBHOOK }}
          status: ${{ job.status }}
          run-name: ${{ format('start.spring.io | {0}', github.ref_name) }}


Build Pull Request

name: Build Pull Request
on: pull_request

permissions:
  contents: read

jobs:
  build:
    name: Build pull request
    runs-on: ubuntu-latest
    if: ${{ github.repository == 'spring-io/start.spring.io' }}
    steps:
      - name: Check out
        uses: actions/checkout@v4

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

      - name: Build with Maven
        run: ./mvnw --batch-mode --update-snapshots verify

      - name: Run metadata verification tests
        run: ./mvnw --batch-mode --update-snapshots -Pverification verify


Verification

name: Verification
on:
  schedule:
    - cron: '15 3 * * *'
  workflow_dispatch:

jobs:
  verification:
    name: Verification
    runs-on: ubuntu-latest
    steps:
      - name: Check out
        uses: actions/checkout@v4

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

      - name: Cache Maven/Gradle repositories for tests
        uses: actions/cache@v4
        with:
          path: /tmp/start-spring-io-cache
          # See https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache
          key: test-repositories-ubuntu-latest-${{ github.run_id }}
          restore-keys: test-repositories-ubuntu-latest

      - name: Build with Maven
        env:
          START_SPRING_IO_TMPDIR: /tmp/start-spring-io-cache
        run: ./mvnw --batch-mode --update-snapshots --activate-profiles verification verify

      - name: Send notification
        uses: ./.github/actions/send-notification
        if: always()
        with:
          webhook-url: ${{ secrets.GOOGLE_CHAT_WEBHOOK }}
          status: ${{ job.status }}
          run-name: ${{ format('start.spring.io (Verification) | {0}', github.ref_name) }}


Deploy Docs

name: Deploy Docs
on:
  push:
    branches-ignore: [ gh-pages ]
    tags: '**'
  repository_dispatch:
    types: request-build-reference # legacy
  #schedule:
  #- cron: '0 10 * * *' # Once per day at 10am UTC
  workflow_dispatch:
permissions:
  actions: write
jobs:
  build:
    runs-on: ubuntu-latest
    # if: github.repository_owner == 'spring-cloud'
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          ref: docs-build
          fetch-depth: 1
      - name: Dispatch (partial build)
        if: github.ref_type == 'branch'
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: gh workflow run deploy-docs.yml -r $(git rev-parse --abbrev-ref HEAD) -f build-refname=${{ github.ref_name }}
      - name: Dispatch (full build)
        if: github.ref_type == 'tag'
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: gh workflow run deploy-docs.yml -r $(git rev-parse --abbrev-ref HEAD)


Build

name: Build
on: [push, pull_request, merge_group]
jobs:
  build:
    strategy:
      matrix:
        java: [21-ubuntu]
    runs-on: ubuntu-22.04
    container:
      image: mcr.microsoft.com/openjdk/jdk:${{ matrix.java }}
      options: --user root
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: gradle/wrapper-validation-action@v2
      - run: ./gradlew check build publishToMavenLocal --stacktrace
      - uses: Juuxel/publish-checkstyle-report@v1
        if: ${{ failure() }}
        with:
          reports: |
            **/build/reports/checkstyle/*.xml
      - uses: actions/upload-artifact@v4
        with:
          name: Artifacts ${{ matrix.java }}
          path: |
            build/libs/
            ./*/build/libs/
            build/publishMods/
      - uses: actions/upload-artifact@v4
        with:
          name: Maven Local ${{ matrix.java }}
          path: /root/.m2/repository/net/fabricmc/

  client_test:
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: actions/setup-java@v4
        with:
          distribution: 'microsoft'
          java-version: '21'
      - name: Run Auto test Client
        uses: modmuss50/xvfb-action@v1
        with:
          run: ./gradlew runProductionAutoTestClient --stacktrace --warning-mode=fail
      - uses: actions/upload-artifact@v4
        if: always()
        with:
          name: Test Screenshots
          path: run/screenshots

  server_test:
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: actions/setup-java@v4
        with:
          distribution: 'microsoft'
          java-version: '21'
      - run: mkdir run && echo "eula=true" >> run/eula.txt
      - run: ./gradlew runProductionAutoTestServer --stacktrace --warning-mode=fail

  check_resources:
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: actions/setup-java@v4
        with:
          distribution: 'microsoft'
          java-version: '21'
      - run: ./gradlew generateResources --stacktrace --warning-mode=fail
      - run: if [ -n "$(git status --porcelain)" ]; then exit 1; fi


Manage Issues

name: Manage Issues

on:
  issues:
    types: [ labeled, unlabeled ]

jobs:
  labels:
    runs-on: ubuntu-22.04
    steps:
      - uses: FabricMC/fabric-action-scripts@v2
        with:
          context: ${{ github.event.action }}
          label: ${{ github.event.label.name }}


Release

name: Release
on: [workflow_dispatch] # Manual trigger

permissions:
  contents: write

jobs:
  build:
    runs-on: ubuntu-22.04
    container:
      image: mcr.microsoft.com/openjdk/jdk:21-ubuntu
      options: --user root
    steps:
      - run: apt update && apt install git -y && git --version
      - run: git config --global --add safe.directory /__w/fabric/fabric
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: FabricMC/fabric-action-scripts@v2
        id: changelog
        with:
          context: changelog
          workflow_id: release.yml
      - uses: gradle/wrapper-validation-action@v2
      - run: ./gradlew checkVersion build publish publishMods --stacktrace
        env:
          MAVEN_URL: ${{ secrets.MAVEN_URL }}
          MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
          MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
          CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
          CHANGELOG: ${{ steps.changelog.outputs.changelog }}
          SIGNING_SERVER: ${{ secrets.SIGNING_SERVER }}
          SIGNING_PGP_KEY: ${{ secrets.SIGNING_PGP_KEY }}
          SIGNING_JAR_KEY: ${{ secrets.SIGNING_JAR_KEY }}


Java CI

name: Java CI

on: [workflow_dispatch, push, pull_request]

jobs:
  test:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest]
        java: [17, 21, 22-ea]
        distribution: ['temurin']
      fail-fast: false
      max-parallel: 4
    name: Test JDK ${{ matrix.java }}, ${{ matrix.os }}

    steps:
      - uses: actions/checkout@v4
      - name: Set up JDK ${{ matrix.java }} ${{ matrix.distribution }}
        uses: actions/setup-java@v4
        with:
          java-version: ${{ matrix.java }}
          distribution: ${{ matrix.distribution }}
      - name: Test with Maven
        run: ./mvnw test -B -V --no-transfer-progress -D"license.skip=true"


CodeQL

# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
  push:
    branches: [ "master" ]
  pull_request:
    branches: [ "master" ]
  schedule:
    - cron: '26 13 * * 4'

jobs:
  analyze:
    name: Analyze
    # Runner size impacts CodeQL analysis time. To learn more, please see:
    #   - https://gh.io/recommended-hardware-resources-for-running-codeql
    #   - https://gh.io/supported-runners-and-hardware-resources
    #   - https://gh.io/using-larger-runners
    # Consider using larger runners for possible analysis time improvements.
    runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
    timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
    permissions:
      # required for all workflows
      security-events: write

      # only required for workflows in private repositories
      actions: read
      contents: read

    strategy:
      fail-fast: false
      matrix:
        language: [ 'java-kotlin' ]
        # CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ]
        # Use only 'java-kotlin' to analyze code written in Java, Kotlin or both
        # Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
        # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

    steps:
    - name: Checkout repository
      uses: actions/checkout@v4

    - name: Setup Java
      uses: actions/setup-java@v4
      with:
        java-version: 17
        distribution: 'temurin'

      # Initializes the CodeQL tools for scanning.
    - name: Initialize CodeQL
      uses: github/codeql-action/init@v3
      with:
        languages: ${{ matrix.language }}
        # If you wish to specify custom queries, you can do so here or in a config file.
        # By default, queries listed here will override any specified in a config file.
        # Prefix the list here with "+" to use these queries and those in the config file.

        # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
        # queries: security-extended,security-and-quality

    # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
    # If this step fails, then you should remove it and run the build manually (see below)
    - name: Autobuild
      uses: github/codeql-action/autobuild@v3

    # ℹ Command-line programs to run using the OS shell.
    # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

    #   If the Autobuild fails above, remove it and uncomment the following three lines.
    #   modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

    # - run: |
    #     echo "Run, Build Application using script"
    #     ./location_of_script_within_repo/buildscript.sh

    - name: Perform CodeQL Analysis
      uses: github/codeql-action/analyze@v3
      with:
        category: "/language:${{matrix.language}}"


Coveralls

name: Coveralls

on: [push, pull_request]

jobs:
  build:
    if: github.repository_owner == 'mybatis'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Set up JDK
        uses: actions/setup-java@v4
        with:
          java-version: 21
          distribution: zulu
      - name: Report Coverage to Coveralls for Pull Requests
        if: github.event_name == 'pull_request'
        run: ./mvnw -B -V test jacoco:report coveralls:report -q -Dlicense.skip=true -DrepoToken=$GITHUB_TOKEN -DserviceName=github -DpullRequest=$PR_NUMBER --no-transfer-progress
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          PR_NUMBER: ${{ github.event.number }}
      - name: Report Coverage to Coveralls for General Push
        if: github.event_name == 'push'
        run: ./mvnw -B -V test jacoco:report coveralls:report -q -Dlicense.skip=true -DrepoToken=$GITHUB_TOKEN -DserviceName=github --no-transfer-progress
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


Site

name: Site

on:
  push:
    branches:
      - site

jobs:
  build:
    if: github.repository_owner == 'mybatis' && ! contains(toJSON(github.event.head_commit.message), '[maven-release-plugin]')
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Set up JDK
        uses: actions/setup-java@v4
        with:
          java-version: 21
          distribution: zulu
      - uses: webfactory/ssh-agent@master
        with:
          ssh-private-key: ${{ secrets.DEPLOY_KEY }}
      - name: Build site
        run: ./mvnw site site:stage -DskipTests -B -V --no-transfer-progress -Dlicense.skip=true
        env:
          CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: Deploy Site to gh-pages
        uses: JamesIves/github-pages-deploy-action@v4.6.1
        with:
          ssh-key: true
          branch: gh-pages
          folder: target/staging
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


SonarCloud

name: SonarCloud

on:
  push:
    branches:
      - master

jobs:
  build:
    if: github.repository_owner == 'mybatis'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          # Disabling shallow clone is recommended for improving relevancy of reporting
          fetch-depth: 0
      - name: Set up JDK
        uses: actions/setup-java@v4
        with:
          java-version: 21
          distribution: zulu
      - name: Analyze with SonarCloud
        run: ./mvnw verify jacoco:report sonar:sonar -B -Dsonar.projectKey=mybatis_mybatis-dynamic-sql -Dsonar.organization=mybatis -Dsonar.host.url=https://sonarcloud.io -Dsonar.token=$SONAR_TOKEN -Dlicense.skip=true --no-transfer-progress
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}


Sonatype

name: Sonatype

on:
  push:
    branches:
      - master

jobs:
  build:
    if: github.repository_owner == 'mybatis' && ! contains(toJSON(github.event.head_commit.message), '[maven-release-plugin]')
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Set up JDK
        uses: actions/setup-java@v4
        with:
          java-version: 21
          distribution: zulu
      - name: Deploy to Sonatype
        run: ./mvnw deploy -DskipTests -B -V --no-transfer-progress --settings ./.mvn/settings.xml -Dlicense.skip=true
        env:
          CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }}
          CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }}


Code Scanning - Action

name: "Code Scanning - Action"

on:
  pull_request:
  push:

jobs:
  CodeQL-Build:
    # CodeQL runs on ubuntu-latest, windows-latest, and macos-latest
    runs-on: ubuntu-latest

    permissions:
      # required for all workflows
      security-events: write

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

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

      # Initializes the CodeQL tools for scanning.
      - name: Initialize CodeQL
        uses: github/codeql-action/init@v3
        # Override language selection by uncommenting this and choosing your languages
        # with:
        #   languages: go, javascript, csharp, python, cpp, java

      # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
      # If this step fails, then you should remove it and run the build manually (see below).
      # - name: Autobuild
      #  uses: github/codeql-action/autobuild@v2

      # ℹ Command-line programs to run using the OS shell.
      # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

      # ✏ If the Autobuild fails above, remove it and uncomment the following
      #    three lines and modify them (or add more) to build your code if your
      #    project uses a compiled language

      - run: |
           ./mvnw clean install -B -U -Pspring -DskipTests

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


Deploy Docs

name: Deploy Docs
on:
  push:
    branches-ignore: [ gh-pages ]
    tags: '**'
  repository_dispatch:
    types: request-build-reference # legacy
  #schedule:
  #- cron: '0 10 * * *' # Once per day at 10am UTC
  workflow_dispatch:
permissions:
  actions: write
jobs:
  build:
    runs-on: ubuntu-latest
    # if: github.repository_owner == 'spring-cloud'
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          ref: docs-build
          fetch-depth: 1
      - name: Dispatch (partial build)
        if: github.ref_type == 'branch'
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: gh workflow run deploy-docs.yml -r $(git rev-parse --abbrev-ref HEAD) -f build-refname=${{ github.ref_name }}
      - name: Dispatch (full build)
        if: github.ref_type == 'tag'
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: gh workflow run deploy-docs.yml -r $(git rev-parse --abbrev-ref HEAD)


Build

# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: Build

on:
  push:
    branches: [ main, 3.1.x, 3.0.x ]
  pull_request:
    branches: [ main, 3.1.x, 3.0.x ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v4
    - name: Set up JDK
      uses: actions/setup-java@v4
      with:
        distribution: 'temurin'
        java-version: 17
    - name: Cache local Maven repository
      uses: actions/cache@v4
      with:
        path: ~/.m2/repository
        key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
        restore-keys: |
          ${{ runner.os }}-maven-
    - name: Build with Maven
      run: ./mvnw clean install -B -U -Pspring,integration,docs


# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: Build

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        java: ["17"]

    steps:
      - uses: actions/checkout@v4
      - name: Set up JDK ${{ matrix.java }}
        uses: actions/setup-java@v4
        with:
          distribution: 'temurin'
          java-version: ${{ matrix.java }}
          cache: 'maven'
      - name: Build with Maven
        run: ./mvnw clean install -B -U -P sonar


ci-build

name: ci-build
on:
  push:
    branches:
      - main
    tags-ignore:
      - '*.*'
  pull_request:
    branches:
      - main
  workflow_dispatch:
    inputs:
      debug_enabled:
        description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
        required: false
        default: false

jobs:
  updatewebsite:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
        with:
          fetch-depth: 2
      - name: Verify Changed files in docs
        uses: tj-actions/verify-changed-files@fda469d6b456070da68fa3fdbc07a513d858b200 # v8.8
        id: verify-changed-files
        with:
          files: |
             docs
      - name: update website
        if: ${{ github.ref == 'refs/heads/main' && steps.verify-changed-files.outputs.files_changed == 'true'}}
        uses: benc-uk/workflow-dispatch@25b02cc069be46d637e8fe2f1e8484008e9e9609 # v1
        with:
          workflow: github-pages
          repo: jbangdev/jbang.dev
          token: ${{ secrets.BREW_GITHUB_TOKEN }}
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest]
    name: build-and-testing
    steps:
      - name: Rate limit info
        run: 'curl -H "Accept: application/vnd.github+json" https://api.github.com/rate_limit'
      - name: Setup tmate session
        uses: mxschmitt/action-tmate@a283f9441d2d96eb62436dc46d7014f5d357ac22 # v3
        if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}
        with:
          limit-access-to-actor: true
      - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
      - uses: gradle/wrapper-validation-action@56b90f209b02bf6d1deae490e9ef18b21a389cd4 # v1
      - name: install-java8
        uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3
        with:
          java-version: 11
          distribution: temurin
          cache: gradle
      - name: build-gradle
        run: ./gradlew --no-daemon clean build installDist publish --build-cache --scan -s
      - name: integration-test-non-windows
        if: runner.os != 'Windows'
        run: |
          export PATH=`pwd`/build/install/jbang/bin:$PATH
          cd itests
          ./test_suite.sh
          ./itests.sh
      - name: add-to-path
        run: echo "../build/install/jbang/bin" >> $env:GITHUB_PATH
      - name: integration-test-windows
        if: runner.os == 'Windows'
        working-directory: itests
        run: |
          echo "::add-matcher::.github/karatewindows-matcher.json"
          .\itests.cmd
          echo "::remove-matcher owner=karate-windows::"
      - name: codecoverage-report
        run: |
          ./gradlew --no-daemon jacocoTestReport
      - name: Upload Test Report
        uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
        if: always() # always run even if the previous step fails
        with:
          name: junit-test-results
          path: '**/build/test-results/test/TEST-*.xml'
          retention-days: 1
      - uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2
        with:
          #files: ./coverage1.xml,./coverage2.xml # optional
          flags: ${{ runner.os }} # optional
          name: ${{ runner.os }}-tests # optional
          verbose: true # optional (default = false)
      - name: build-choco-package
        if: runner.os == 'Windows'
        uses: actions/setup-dotnet@608ee757cfcce72c2e91e99aca128e0cae67de87 # v1
        with:
          dotnet-version: '2.2.204' # SDK Version to use.
      - name: build-choco
        if: runner.os == 'Windows'
        run: |
          powershell
          choco pack build/choco/jbang.nuspec
      - name: Archive build results
        uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
        if: always()
        with:
          name: ${{ runner.os }}-build-${{ github.sha }}
          path: build
      - name: Upload jbang.zip
        uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
        if: always() && runner.os != 'Windows'
        with:
          name: jbang-${{ github.sha }}
          path: build/install/jbang

  testing:
    needs: build
    strategy:
      ## disable fail-fast so on variance failing don't fail the rest
      #fail-fast: false
      matrix:
        os: [ubuntu-latest]
        java: [8,11,17,19]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3
        with:
          distribution: 'temurin'
          java-version: ${{ matrix.java }}
      - uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3
        with:
          name: ${{ runner.os }}-build-${{ github.sha }}
          path: build
      - name: smoke-test
        run: |
          java -version
          chmod +x ./build/install/jbang/bin/jbang
          ./build/install/jbang/bin/jbang init --template=cli helloworld.java
          ./build/install/jbang/bin/jbang --verbose helloworld.java
          rm helloworld.java
      - name: smoke-quarkus-test
        run: |
          java -version
          chmod +x ./build/install/jbang/bin/jbang
          ./build/install/jbang/bin/jbang init --template=qcli qcli.java
          ./build/install/jbang/bin/jbang --fresh --verbose qcli.java
          rm qcli.java
      - name: smoke-quarkus-diff-version-test
        run: |
          java -version
          chmod +x ./build/install/jbang/bin/jbang
          ./build/install/jbang/bin/jbang init --template=qcli qcli.java
          ./build/install/jbang/bin/jbang --fresh --verbose --java 17 qcli.java
          rm qcli.java
      - name: integration-test-non-windows
        ## karate can't run on java 17 or higher due to missing nashorn
        if: runner.os != 'Windows' && matrix.java < 17
        run: |
          export PATH=`pwd`/build/install/jbang/bin:$PATH
          cd build/itests
          chmod +x ./test_suite.sh
          chmod +x ./itests.sh
          ./test_suite.sh
          ./itests.sh
      - name: add-to-path
        run: echo "../build/install/jbang/bin" >> $env:GITHUB_PATH
      - name: integration-test-windows
        if: runner.os == 'Windows' && matrix.java < 17
        working-directory: itests
        run: |
          echo "::add-matcher::.github/karatewindows-matcher.json"
          .\itests.cmd
          echo "::remove-matcher owner=karate-windows::"


CodeQL

# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
  push:
    branches: [ main ]
  pull_request:
    # The branches below must be a subset of the branches above
    branches: [ main ]
  schedule:
    - cron: '19 18 * * 2'

jobs:
  analyze:
    name: Analyze
    runs-on: ubuntu-latest
    permissions:
      actions: read
      contents: read
      security-events: write

    strategy:
      fail-fast: false
      matrix:
        language: [ 'java' ]
        # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
        # Learn more about CodeQL language support at https://git.io/codeql-language-support

    steps:
    - name: Checkout repository
      uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3

    # Initializes the CodeQL tools for scanning.
    - name: Initialize CodeQL
      uses: github/codeql-action/init@4355270be187e1b672a7a1c7c7bae5afdc1ab94a # v3
      with:
        languages: ${{ matrix.language }}
        # If you wish to specify custom queries, you can do so here or in a config file.
        # By default, queries listed here will override any specified in a config file.
        # Prefix the list here with "+" to use these queries and those in the config file.
        # queries: ./path/to/local/query, your-org/your-repo/queries@main

    # Autobuild attempts to build any compiled languages  (C/C++, C#, or Java).
    # If this step fails, then you should remove it and run the build manually (see below)
    - name: Autobuild
      uses: github/codeql-action/autobuild@4355270be187e1b672a7a1c7c7bae5afdc1ab94a # v3

    # ℹ Command-line programs to run using the OS shell.
    # 📚 https://git.io/JvXDl

    # ✏ If the Autobuild fails above, remove it and uncomment the following three lines
    #    and modify them (or add more) to build your code if your project
    #    uses a compiled language

    #- run: |
    #   make bootstrap
    #   make release

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


install-tests

name: install-tests
on:
   workflow_dispatch:

jobs:
  macos:
    runs-on: macos-latest
    steps:
    - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
    - name: Remove Java
      run: |
        sudo rm -rf /Library/Java/*
        sudo rm -rf /Users/runner/hostedtoolcache/Java*
    - name: check jbang does not exist
      run: |
        if command -v jbang; then
          echo "jbang already exists!"
          exit 1
        fi
    - name: install jbang
      run: |
        curl -Ls https://sh.jbang.dev | bash -s - app setup
        source ~/.zshrc
        if ! command -v jbang; then
          echo "jbang not found after install!"
          exit 1
        fi
    - name: run jbang no java
      run: |
        source ~/.zshrc
        jbang init -t cli testcli.java
        ./testcli.java
    - name: run jbang java 17
      run: |
        jbang init -t cli testcli.java
        jbang --java 17 testcli.java


on:
  release:
    types:
      - published

name: release-3rdparty
jobs:
  build:
    runs-on: ubuntu-latest
    name: build-and-testing
    env:
      JRELEASER_SDKMAN_CONSUMER_KEY: ${{ secrets.SDKMAN_CONSUMER_KEY }}
      JRELEASER_SDKMAN_CONSUMER_TOKEN: ${{ secrets.SDKMAN_CONSUMER_TOKEN }}
      JRELEASER_TWITTER_CONSUMER_KEY: ${{ secrets.TWITTER_CONSUMER_KEY }}
      JRELEASER_TWITTER_CONSUMER_SECRET: ${{ secrets.TWITTER_CONSUMER_SECRET }}
      JRELEASER_TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }}
      JRELEASER_TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
      JRELEASER_GITHUB_TOKEN: ${{ secrets.BREW_GITHUB_TOKEN }}
      JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
      JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
      JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }}
      JRELEASER_NEXUS2_USERNAME: ${{ secrets.OSSRH_USERNAME}}
      JRELEASER_NEXUS2_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
      JRELEASER_VERSION: 1.9.0
    steps:
      - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
        with:
          fetch-depth: 0
      - name: install-java11
        uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3
        with:
          java-version: 11
          distribution: temurin
          cache: gradle
      - name: build-gradle
        run: ./gradlew --no-daemon clean build -x test --build-cache --scan -s
      - name: version extract
        id: version
        run: |
          RELEASE_VERSION=`cat build/tmp/version.txt`
          echo "::set-output name=RELEASE_VERSION::$RELEASE_VERSION"
      - name: jreleaser publish
        continue-on-error: true
        uses: jreleaser/release-action@v2
        env:
          JRELEASER_PROJECT_VERSION: ${{steps.version.outputs.RELEASE_VERSION}}
        with:
          version: ${{ env.JRELEASER_VERSION }}
          arguments: publish
          setup-java: false
      - name: JReleaser publish output
        if: always()
        uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
        with:
          name: jreleaser-publish
          path: |
            out/jreleaser/trace.log
            out/jreleaser/output.properties
      - name: spec
        continue-on-error: true
        env:
          BREW_GITHUB_TOKEN: ${{ secrets.BREW_GITHUB_TOKEN }}
          BREW_USER: ${{ secrets.BREW_USER }}
        run: ./misc/updatespec.sh
      - name: jreleaser announce
        continue-on-error: true
        uses: jreleaser/release-action@v2
        env:
          JRELEASER_PROJECT_VERSION: ${{steps.version.outputs.RELEASE_VERSION}}
        with:
          version: ${{ env.JRELEASER_VERSION }}
          arguments: announce
          setup-java: false
      - name: JReleaser announce output
        if: always()
        uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
        with:
          name: jreleaser-announce
          path: |
            out/jreleaser/trace.log
            out/jreleaser/output.properties
      - name: upload-choco
        uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
        with:
          name: build-choco
          path: build/choco
  choco:
    needs: build
    runs-on: windows-latest
    name: publish-choco
    continue-on-error: true
    steps:
      - uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3
        with:
          name: build-choco
          path: build/choco
      - uses: actions/setup-dotnet@608ee757cfcce72c2e91e99aca128e0cae67de87 # v1
        with:
          dotnet-version: '2.2.204' # SDK Version to use.
      - name: choco-build
        run: |
          powershell
          choco pack build/choco/jbang.nuspec
      - name: github-nuget
        continue-on-error: true
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          powershell
          dotnet nuget source add -username maxandersen --password $GITHUB_TOKEN --store-password-in-clear-text --name github "https://nuget.pkg.github.com/maxandersen/index.json"
          dotnet nuget push $(ls *.nupkg | % {$_.FullName}) --source github
      - name: choco-publish
        continue-on-error: true
        run: |
          powershell
          choco apikey -k ${{ secrets.CHOCO_API_KEY }} -source https://push.chocolatey.org/
          choco push $(ls *.nupkg | % {$_.FullName}) -s https://push.chocolatey.org/


report

## have to upload via this seperate workflow
## to avoid limitations of PR's from forked
## repos which wont have write access by default.

name: report
on:
  workflow_run:
    workflows: [ci-build]
    types: [completed]

permissions:
  checks: write

jobs:
  checks:
    runs-on: ubuntu-latest
    steps:
      - name: Download Test Report
        uses: dawidd6/action-download-artifact@268677152d06ba59fcec7a7f0b5d961b6ccd7e1e # v2
        with:
          name: junit-test-results
          workflow: ${{ github.event.workflow.id }}
          run_id: ${{ github.event.workflow_run.id }}
      - name: Publish Test Report
        uses: mikepenz/action-junit-report@150e2f992e4fad1379da2056d1d1c279f520e058 # v3
        with:
          commit: ${{github.event.workflow_run.head_sha}}
          report_paths: '**/build/test-results/test/TEST-*.xml'


tag-and-release

on:
  push:
    tags:
      - 'v*'

name: tag-and-release
jobs:
  build:
    runs-on: ubuntu-latest
    name: build-and-testing
    env:
      JRELEASER_SDKMAN_CONSUMER_KEY: ${{ secrets.SDKMAN_CONSUMER_KEY }}
      JRELEASER_SDKMAN_CONSUMER_TOKEN: ${{ secrets.SDKMAN_CONSUMER_TOKEN }}
      JRELEASER_TWITTER_CONSUMER_KEY: ${{ secrets.TWITTER_CONSUMER_KEY }}
      JRELEASER_TWITTER_CONSUMER_SECRET: ${{ secrets.TWITTER_CONSUMER_SECRET }}
      JRELEASER_TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }}
      JRELEASER_TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
      JRELEASER_GITHUB_TOKEN: ${{ secrets.BREW_GITHUB_TOKEN }}
      JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
      JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
      JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }}
      JRELEASER_NEXUS2_USERNAME: ${{ secrets.OSSRH_USERNAME}}
      JRELEASER_NEXUS2_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
      JRELEASER_VERSION: 1.5.1
    steps:
      - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
        with:
          fetch-depth: 0
      - name: install-java11
        uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3
        with:
          java-version: 11
          distribution: temurin
          cache: gradle
      - name: build-gradle
        run: ./gradlew --no-daemon clean build installDist publish --build-cache --scan -s
      - name: integration-test
        run: |
          export PATH=`pwd`/build/install/jbang/bin:$PATH
          pastdir=`pwd`
          cd itests
          ./test_suite.sh
          ./itests.sh
          cd $pastdir
      - name: version extract
        id: version
        run: |
          RELEASE_VERSION=`cat build/tmp/version.txt`
          echo "::set-output name=RELEASE_VERSION::$RELEASE_VERSION"
      - name: Run JReleaser
        uses: jreleaser/release-action@v2
        env:
          JRELEASER_PROJECT_VERSION: ${{steps.version.outputs.RELEASE_VERSION}}
        with:
          version: ${{ env.JRELEASER_VERSION }}
          arguments: release
          setup-java: false
      - name: JReleaser output
        if: always()
        uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
        with:
          name: jreleaser-release
          path: |
            out/jreleaser/trace.log
            out/jreleaser/output.properties


Java CI

name: Java CI

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1
    - name: Set up JDK 11
      uses: actions/setup-java@v1
      with:
        java-version: 11.0.4
    - name: Build with Maven
      run: |
        mvn package -DskipTests -Dskip.unit.tests -Dskip.performance.tests -Dskip.cluster.tests --file pom.xml


Deploy Docs

name: Deploy Docs
on:
  push:
    branches-ignore: [ gh-pages ]
    tags: '**'
  repository_dispatch:
    types: request-build-reference # legacy
  #schedule:
  #- cron: '0 10 * * *' # Once per day at 10am UTC
  workflow_dispatch:
permissions:
  actions: write
jobs:
  build:
    runs-on: ubuntu-latest
    # FIXME: enable when pushed to spring-projects
    # if: github.repository_owner == 'spring-projects'
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          ref: docs-build
          fetch-depth: 1
      - name: Dispatch (partial build)
        if: github.ref_type == 'branch'
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: gh workflow run deploy-docs.yml -r $(git rev-parse --abbrev-ref HEAD) -f build-refname=${{ github.ref_name }}
      - name: Dispatch (full build)
        if: github.ref_type == 'tag'
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: gh workflow run deploy-docs.yml -r $(git rev-parse --abbrev-ref HEAD)


Build

# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: Build

on:
  push:
    branches: [ main, 4.0.x, 3.1.x ]
  pull_request:
    branches: [ main, 4.0.x, 3.1.x ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
      - name: Set up JDK
        uses: actions/setup-java@v4
        with:
          distribution: 'temurin'
          java-version: '17'
      - name: Cache local Maven repository
        uses: actions/cache@v4
        with:
          path: ~/.m2/repository
          key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
          restore-keys: |
            ${{ runner.os }}-maven-
      - name: Build with Maven
        run: ./mvnw -s .settings.xml clean org.jacoco:jacoco-maven-plugin:prepare-agent install -U -P sonar -nsu --batch-mode -Dmaven.test.redirectTestOutputToFile=true -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
      - name: Publish Test Report
        uses: mikepenz/action-junit-report@v4
        if: always() # always run even if the previous step fails
        with:
          report_paths: '**/surefire-reports/TEST-*.xml'
      - name: Archive code coverage results
        uses: actions/upload-artifact@v4
        with:
          name: surefire-reports
          path: '**/surefire-reports/*'


mogu CI/CD/DEV

name: mogu CI/CD/DEV

on:
  push:
    branches:
      - dev

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@master
      with:
        ref: dev
    - uses: actions/setup-java@v1
      with:
        java-version: 1.8
    - name: Set SSH Environment
      run: |
        mkdir -p ~/.ssh/
        echo "${{ secrets.ID_RSA }}" > ~/.ssh/id_rsa
        echo "${{ secrets.ID_RSA_PUB }}" > ~/.ssh/id_rsa.pub
        cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
        chmod 600 ~/.ssh/id_rsa
        chmod 700 ~/.ssh && chmod 700 ~/.ssh/*
        ls -l ~/.ssh/
    - name: Download config file and replace
      run: |
        git clone git@github.com:moxi624/mogu_prod_configuration.git
        mv -f ./mogu_prod_configuration/dev_config/mogu_admin/application.yml ./mogu_admin/src/main/resources/application.yml
        mv -f ./mogu_prod_configuration/dev_config/mogu_eureka/application.yml ./mogu_eureka/src/main/resources/application.yml
        mv -f ./mogu_prod_configuration/dev_config/mogu_picture/application.yml ./mogu_picture/src/main/resources/application.yml
        mv -f ./mogu_prod_configuration/dev_config/mogu_sms/application.yml ./mogu_sms/src/main/resources/application.yml
        mv -f ./mogu_prod_configuration/dev_config/mogu_web/application.yml ./mogu_web/src/main/resources/application.yml
        mv -f ./mogu_prod_configuration/dev_config/mogu_search/application.yml ./mogu_search/src/main/resources/application.yml
        mv -f ./mogu_prod_configuration/dev_config/vue_mogu_admin/prod.env.js ./vue_mogu_admin/config/prod.env.js
        mv -f ./mogu_prod_configuration/dev_config/vue_mogu_web/prod.env.js ./vue_mogu_web/config/prod.env.js
    - name: Build Java jar
      run: |
        mvn clean install
    - name: Use Node.js 12.x
      uses: actions/setup-node@v1
      with:
        node-version: 12.x
    - name: Build vue_mogu_admin and vue_mogu_web
      run: |
        cd ./vue_mogu_admin
        npm install
        npm run build
        cd ..
        cd ./vue_mogu_web
        npm install
        npm run build
        cd ..
    - name: Move files and compress
      run: |
        mkdir -p transfer_files
        mv ./mogu_admin/target/mogu_admin-0.0.1-SNAPSHOT.jar ./transfer_files/mogu_admin-0.0.1-SNAPSHOT.jar
        mv ./mogu_sms/target/mogu_sms-0.0.1-SNAPSHOT.jar ./transfer_files/mogu_sms-0.0.1-SNAPSHOT.jar
        mv ./mogu_eureka/target/mogu_eureka-0.0.1-SNAPSHOT.jar ./transfer_files/mogu_eureka-0.0.1-SNAPSHOT.jar
        mv ./mogu_picture/target/mogu_picture-0.0.1-SNAPSHOT.jar ./transfer_files/mogu_picture-0.0.1-SNAPSHOT.jar
        mv ./mogu_web/target/mogu_web-0.0.1-SNAPSHOT.jar ./transfer_files/mogu_web-0.0.1-SNAPSHOT.jar
        mv ./mogu_search/target/mogu_search-0.0.1-SNAPSHOT.jar ./transfer_files/mogu_search-0.0.1-SNAPSHOT.jar
        mv ./vue_mogu_web/dist ./transfer_files/web_dist
        mv ./vue_mogu_admin/dist ./transfer_files/admin_dist
        tar -zcvf  transfer_files.tar.gz transfer_files/
    - name: Scp file to aliyun
      uses: appleboy/scp-action@master
      with:
        host: ${{ secrets.DOCKER_IP_DEV }}
        username: ${{ secrets.DOCKER_ID }}
        password: ${{ secrets.DOCKER_PASSWORD }}
        port: ${{ secrets.DOCKER_PORT }}
        source: "transfer_files.tar.gz"
        target: "/home"
    - name: Distribution and backup
      uses: appleboy/ssh-action@master
      with:
        host: ${{ secrets.DOCKER_IP_DEV }}
        username: ${{ secrets.DOCKER_ID }}
        password: ${{ secrets.DOCKER_PASSWORD }}
        port: ${{ secrets.DOCKER_PORT }}
        script: |
          cd /home
          tar -zxvf /home/transfer_files.tar.gz

          echo "################# mogu_admin moving #################"

          if [ -f "/home/mogu_blog/mogu_admin/mogu_admin-0.0.1-SNAPSHOT.jar.bak" ];then
            echo "mogu_admin.jar.bak exists and is being deleted"
            rm -f /home/mogu_blog/mogu_admin/mogu_admin-0.0.1-SNAPSHOT.jar.bak
          fi
          if [ -f "/home/mogu_blog/mogu_admin/mogu_admin-0.0.1-SNAPSHOT.jar" ];then
            echo "mogu_admin.jar exists and is being backup"
            mv /home/mogu_blog/mogu_admin/mogu_admin-0.0.1-SNAPSHOT.jar /home/mogu_blog/mogu_admin/mogu_admin-0.0.1-SNAPSHOT.jar.bak
          fi
          mv /home/transfer_files/mogu_admin-0.0.1-SNAPSHOT.jar /home/mogu_blog/mogu_admin/mogu_admin-0.0.1-SNAPSHOT.jar

          echo "################# mogu_sms moving #################"

          if [ -f "/home/mogu_blog/mogu_sms/mogu_sms-0.0.1-SNAPSHOT.jar.bak" ];then
            echo "mogu_sms.jar.bak exists and is being deleted"
            rm -f /home/mogu_blog/mogu_sms/mogu_sms-0.0.1-SNAPSHOT.jar.bak
          fi
          if [ -f "/home/mogu_blog/mogu_admin/mogu_admin-0.0.1-SNAPSHOT.jar" ];then
            echo "mogu_sms.jar exists and is being backup"
            mv /home/mogu_blog/mogu_sms/mogu_sms-0.0.1-SNAPSHOT.jar /home/mogu_blog/mogu_sms/mogu_sms-0.0.1-SNAPSHOT.jar.bak
          fi
          mv /home/transfer_files/mogu_sms-0.0.1-SNAPSHOT.jar /home/mogu_blog/mogu_sms/mogu_sms-0.0.1-SNAPSHOT.jar

          echo "################# mogu_eureka moving #################"

          if [ -f "/home/mogu_blog/mogu_eureka/mogu_eureka-0.0.1-SNAPSHOT.jar.bak" ];then
            echo "mogu_eureka.jar.bak exists and is being deleted"
            rm -f /home/mogu_blog/mogu_eureka/mogu_eureka-0.0.1-SNAPSHOT.jar.bak
          fi
          if [ -f "/home/mogu_blog/mogu_eureka/mogu_eureka-0.0.1-SNAPSHOT.jar" ];then
            echo "mogu_eureka.jar exists and is being backup"
            mv /home/mogu_blog/mogu_eureka/mogu_eureka-0.0.1-SNAPSHOT.jar /home/mogu_blog/mogu_eureka/mogu_eureka-0.0.1-SNAPSHOT.jar.bak
          fi
          mv /home/transfer_files/mogu_eureka-0.0.1-SNAPSHOT.jar /home/mogu_blog/mogu_eureka/mogu_eureka-0.0.1-SNAPSHOT.jar

          echo "################# mogu_picture moving #################"

          if [ -f "/home/mogu_blog/mogu_picture/mogu_picture-0.0.1-SNAPSHOT.jar.bak" ];then
            echo "mogu_picture.jar.bak exists and is being deleted"
            rm -f /home/mogu_blog/mogu_picture/mogu_picture-0.0.1-SNAPSHOT.jar.bak
          fi
          if [ -f "/home/mogu_blog/mogu_picture/mogu_picture-0.0.1-SNAPSHOT.jar" ];then
            echo "mogu_picture.jar exists and is being backup"
            mv /home/mogu_blog/mogu_picture/mogu_picture-0.0.1-SNAPSHOT.jar /home/mogu_blog/mogu_picture/mogu_picture-0.0.1-SNAPSHOT.jar.bak
          fi
          mv /home/transfer_files/mogu_picture-0.0.1-SNAPSHOT.jar /home/mogu_blog/mogu_picture/mogu_picture-0.0.1-SNAPSHOT.jar

          echo "################# mogu_web moving #################"

          if [ -f "/home/mogu_blog/mogu_web/mogu_web-0.0.1-SNAPSHOT.jar.bak" ];then
            echo "mogu_web.jar.bak exists and is being deleted"
            rm -f /home/mogu_blog/mogu_web/mogu_web-0.0.1-SNAPSHOT.jar.bak
          fi
          if [ -f "/home/mogu_blog/mogu_web/mogu_web-0.0.1-SNAPSHOT.jar" ];then
            echo "mogu_web.jar exists and is being backup"
            mv /home/mogu_blog/mogu_web/mogu_web-0.0.1-SNAPSHOT.jar /home/mogu_blog/mogu_web/mogu_web-0.0.1-SNAPSHOT.jar.bak
          fi
          mv /home/transfer_files/mogu_web-0.0.1-SNAPSHOT.jar /home/mogu_blog/mogu_web/mogu_web-0.0.1-SNAPSHOT.jar

          echo "################# mogu_search moving #################"

          if [ -f "/home/mogu_blog/mogu_search/mogu_search-0.0.1-SNAPSHOT.jar.bak" ];then
            echo "mogu_search.jar.bak exists and is being deleted"
            rm -f /home/mogu_blog/mogu_search/mogu_search-0.0.1-SNAPSHOT.jar.bak
          fi
          if [ -f "/home/mogu_blog/mogu_search/mogu_search-0.0.1-SNAPSHOT.jar" ];then
            echo "mogu_search.jar exists and is being backup"
            mv /home/mogu_blog/mogu_search/mogu_search-0.0.1-SNAPSHOT.jar /home/mogu_blog/mogu_search/mogu_search-0.0.1-SNAPSHOT.jar.bak
          fi
          mv /home/transfer_files/mogu_search-0.0.1-SNAPSHOT.jar /home/mogu_blog/mogu_search/mogu_search-0.0.1-SNAPSHOT.jar

          echo "################# vue_mogu_web moving #################"

          if [ -d "/home/mogu_blog/vue_mogu_web/dist.bak/" ];then
            echo "vue_mogu_web dist.bak exists and is being deleted"
            cd /home/mogu_blog/vue_mogu_web
            rm -rf dist.bak/
          fi
          if [ -d "/home/mogu_blog/vue_mogu_web/dist/" ];then
            echo "vue_mogu_web dist exists and is being backup"
            mv /home/mogu_blog/vue_mogu_web/dist /home/mogu_blog/vue_mogu_web/dist.bak
          fi
          mv /home/transfer_files/web_dist /home/mogu_blog/vue_mogu_web/dist

          echo "################# vue_mogu_admin moving #################"

          if [ -d "/home/mogu_blog/vue_mogu_admin/dist.bak/" ];then
            echo "vue_mogu_admin dist.bak exists and is being deleted"
            cd /home/mogu_blog/vue_mogu_admin
            rm -rf dist.bak/
          fi
          if [ -d "/home/mogu_blog/vue_mogu_admin/dist/" ];then
            echo "vue_mogu_admin dist exists and is being backup"
            mv /home/mogu_blog/vue_mogu_admin/dist /home/mogu_blog/vue_mogu_admin/dist.bak
          fi
          mv /home/transfer_files/admin_dist /home/mogu_blog/vue_mogu_admin/dist

          echo "################# rm transfer_files.tar.gz #################"
          rm -rf /home/transfer_files.tar.gz
          echo "################# rm transfer_files #################"
          rm -rf /home/transfer_files

    - name: Start mogu_eureka
      uses: appleboy/ssh-action@master
      with:
        host: ${{ secrets.DOCKER_IP_DEV }}
        username: ${{ secrets.DOCKER_ID }}
        password: ${{ secrets.DOCKER_PASSWORD }}
        port: ${{ secrets.DOCKER_PORT }}
        script: |
          cd /home/mogu_blog/mogu_eureka/
          ./shutdown.sh
          ./startup.sh
    - name: Start mogu_picture
      uses: appleboy/ssh-action@master
      with:
        host: ${{ secrets.DOCKER_IP_DEV }}
        username: ${{ secrets.DOCKER_ID }}
        password: ${{ secrets.DOCKER_PASSWORD }}
        port: ${{ secrets.DOCKER_PORT }}
        script: |
          cd /home/mogu_blog/mogu_picture/
          ./shutdown.sh
          ./startup.sh
    - name: Start mogu_admin
      uses: appleboy/ssh-action@master
      with:
        host: ${{ secrets.DOCKER_IP_DEV }}
        username: ${{ secrets.DOCKER_ID }}
        password: ${{ secrets.DOCKER_PASSWORD }}
        port: ${{ secrets.DOCKER_PORT }}
        script: |
          cd /home/mogu_blog/mogu_admin/
          ./shutdown.sh
          ./startup.sh
    - name: Start mogu_sms
      uses: appleboy/ssh-action@master
      with:
        host: ${{ secrets.DOCKER_IP_DEV }}
        username: ${{ secrets.DOCKER_ID }}
        password: ${{ secrets.DOCKER_PASSWORD }}
        port: ${{ secrets.DOCKER_PORT }}
        script: |
          cd /home/mogu_blog/mogu_sms/
          ./shutdown.sh
          ./startup.sh
    - name: Start mogu_web
      uses: appleboy/ssh-action@master
      with:
        host: ${{ secrets.DOCKER_IP_DEV }}
        username: ${{ secrets.DOCKER_ID }}
        password: ${{ secrets.DOCKER_PASSWORD }}
        port: ${{ secrets.DOCKER_PORT }}
        script: |
          cd /home/mogu_blog/mogu_web/
          ./shutdown.sh
          ./startup.sh
    - name: Start mogu_search
      uses: appleboy/ssh-action@master
      with:
        host: ${{ secrets.DOCKER_IP_DEV }}
        username: ${{ secrets.DOCKER_ID }}
        password: ${{ secrets.DOCKER_PASSWORD }}
        port: ${{ secrets.DOCKER_PORT }}
        script: |
          cd /home/mogu_blog/mogu_search/
          ./shutdown.sh


Master-Build-Docker-Images

name: Master-Build-Docker-Images

#on:
#  push:
#    # 每次 push tag 时进行构建，不需要每次 push 都构建。使用通配符匹配每次 tag 的提交，记得 tag 名一定要以 v 开头
#    tags:
#      - v*

on:
  push:
    branches:
      - Nacos

jobs:
  push:
    # 如果需要在构建前进行测试的话需要取消下面的注释和上面对应的 test 动作的注释。
    # needs: test

    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-java@v1
        with:
          java-version: 1.8
      - uses: docker/setup-buildx-action@v1
      - uses: actions/setup-node@v1
        with:
          node-version: 12.x
      # 安装maven依赖
      - name: Maven Clean Install
        run: |
          echo '=====开始mvn clean====='
          mvn clean

          echo '=====开始mvn install&&package====='
          mvn install -DskipTests=true && mvn package -DskipTests=true

      - name: Build vue_mogu_admin and vue_mogu_web
        run: |
          echo '=====开始安装Vue_mogu_admin依赖====='
          cd ./vue_mogu_admin
          npm install
          npm run build
          cd ..

          echo '=====开始安装Vue_mogu_web依赖====='
          cd ./vue_mogu_web
          npm install
          npm run build
          cd ..

        # 构建镜像，指定镜像名
      - name: Build Java Docker Images
        run: |

          echo '=====开始构建镜像====='
          echo '=====开始构建mogu_admin====='
          cd mogu_admin
          mvn docker:build
          cd ..

          echo '=====开始构建mogu_gateway====='
          cd mogu_gateway
          mvn docker:build
          cd ..

          echo '=====开始构建mogu_monitor====='
          cd mogu_monitor
          mvn docker:build
          cd ..

          echo '=====开始构建mogu_picture====='
          cd mogu_picture
          mvn docker:build
          cd ..

          echo '=====开始构建mogu_search====='
          cd mogu_search
          mvn docker:build
          cd ..

          echo '=====开始构建mogu_sms====='
          cd mogu_sms
          mvn docker:build
          cd ..

          echo '=====开始构建mogu_spider====='
          cd mogu_spider
          mvn docker:build
          cd ..

          echo '=====开始构建mogu_web====='
          cd mogu_web
          mvn docker:build
          cd ..

          echo '=====镜像构建结束====='

      # 构建镜像，指定镜像名
      - name: Build Vue Docker Images
        run: |

          echo '=====开始构建镜像====='
          echo '=====开始构建vue_mogu_admin====='
          cd vue_mogu_admin
          docker build -t registry.cn-shenzhen.aliyuncs.com/mogublog/vue_mogu_admin .
          cd ..

          cd vue_mogu_web
          docker build -t registry.cn-shenzhen.aliyuncs.com/mogublog/vue_mogu_web .
          cd ..

          echo '=====镜像构建结束====='

      # 登录到 阿里云镜像服务，使用 GitHub secrets 传入账号密码，密码被加密存储在 GitHub 服务器
      - name: Login to Aliyun
        uses: docker/login-action@v1
        with:
          registry: registry.cn-shenzhen.aliyuncs.com
          username: ${{ secrets.ALIYUN_USER_NAME }}
          password: ${{ secrets.ALIYUN_PASSWORD }}

      - name: Push Docker Image
        run: |
          echo '=====开始上传镜像====='
          echo '=====开始上传mogu_admin====='
          docker push registry.cn-shenzhen.aliyuncs.com/mogublog/mogu_admin

          echo '=====开始上传mogu_gateway====='
          docker push registry.cn-shenzhen.aliyuncs.com/mogublog/mogu_gateway

          echo '=====开始上传mogu_monitor====='
          docker push registry.cn-shenzhen.aliyuncs.com/mogublog/mogu_monitor

          echo '=====开始上传mogu_picture====='
          docker push registry.cn-shenzhen.aliyuncs.com/mogublog/mogu_picture

          echo '=====开始上传mogu_search====='
          docker push registry.cn-shenzhen.aliyuncs.com/mogublog/mogu_search

          echo '=====开始上传mogu_sms====='
          docker push registry.cn-shenzhen.aliyuncs.com/mogublog/mogu_sms

          echo '=====开始上传mogu_spider====='
          docker push registry.cn-shenzhen.aliyuncs.com/mogublog/mogu_spider

          echo '=====开始上传mogu_web====='
          docker push registry.cn-shenzhen.aliyuncs.com/mogublog/mogu_web

          echo '=====开始上传vue_mogu_admin====='
          docker push registry.cn-shenzhen.aliyuncs.com/mogublog/vue_mogu_admin

          echo '=====开始上传vue_mogu_web====='
          docker push registry.cn-shenzhen.aliyuncs.com/mogublog/vue_mogu_web

          echo '=====镜像上传结束====='

#      - name: Update New Docker Image And Restart Server
#        uses: appleboy/ssh-action@master
#        with:
#          host: ${{ secrets.DOCKER_IP_DEV_NACOS }}
#          username: ${{ secrets.DOCKER_ID }}
#          password: ${{ secrets.DOCKER_PASSWORD }}
#          port: 22
#          script: |
#            cd /root/docker-compose/bin
#            ./update.sh


ci

name: ci

on: [ push, pull_request ]

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        java: [ 11, 17 ]
    name: jdk-${{ matrix.java }}
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - uses: actions/setup-java@v3
        with:
          distribution: "temurin"
          java-version: ${{ matrix.java }}
          cache: "maven"
      - name: "Build"
        run: mvn --batch-mode -no-transfer-progress -V verify
        env:
          JDK_JAVA_OPTIONS: --add-opens=java.base/java.lang=ALL-UNNAMED


Checks

name: Checks
on:
  push:
    branches:
      - '[0-9]+.[0-9]+.x'
  pull_request:
    branches:
      - '[0-9]+.[0-9]+.x'
jobs:
  setup:
    runs-on: ubuntu-latest
    outputs:
      is_default_branch: ${{ steps['info']['outputs']['is-default-branch'] }}
      is_release_branch: ${{ steps['info']['outputs']['is-release-branch'] }}
    steps:
      - name: Fetch repository information
        id: info
        run: |
          DEFAULT_BRANCH=$(curl -s https://api.github.com/repos/syndesisio/syndesis |jq -r .default_branch)
          IS_DEFAULT_BRANCH=$(test "refs/heads/${DEFAULT_BRANCH}" == "${GITHUB_REF}" && echo true || echo false)
          IS_RELEASE_BRANCH=$(echo "${GITHUB_REF}" | grep -q -e '^refs/heads/[0-9]\+\.[0-9]\+\.x' && echo true || echo false)
          echo "is-default-branch=${IS_DEFAULT_BRANCH}" >> $GITHUB_OUTPUT
          echo "is-release-branch=${IS_RELEASE_BRANCH}" >> $GITHUB_OUTPUT
  changes:
    needs: setup
    runs-on: ubuntu-latest
    outputs:
      backend: ${{ steps.filter.outputs.backend }}
      operator: ${{ steps.filter.outputs.operator }}
      ui: ${{ steps.filter.outputs.ui }}
    steps:
      - uses: actions/checkout@v2
        if: needs.setup.outputs.is_release_branch == 'true'
      - uses: dorny/paths-filter@v2
        id: filter
        with:
          base: ${{ github.ref }}
          filters: |
            backend:
              - 'app/(!(ui-react))**'
            operator:
              - 'install/operator/**'
            ui:
              - 'app/ui-react/**'
  backend:
    needs:
      - changes
      - setup
    if: needs.changes.outputs.backend == 'true'
    runs-on: ubuntu-latest
    permissions:
      actions: read
      contents: read
      security-events: write
    strategy:
      fail-fast: false
    steps:
      - uses: actions/checkout@v2
      - name: Set up JDK 8
        uses: actions/setup-java@v1
        with:
          java-version: 8
      - name: Cache local Maven repository
        uses: actions/cache@v2
        with:
          path: |
            ~/.m2/repository
            !~/.m2/repository/io/syndesis
          key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
          restore-keys: ${{ runner.os }}-maven-
      - name: Initialize CodeQL
        uses: github/codeql-action/init@v1
        with:
          config-file: ./.github/codeql/codeql-config.yml
          languages: java
      - name: Build and test
        run: tools/bin/syndesis build --batch-mode --backend
      - name: Archive logs and test results
        uses: actions/upload-artifact@v2
        with:
          name: checks-backend
          path: |
            app/**/target/*.log
            app/**/target/surefire-reports/*
            app/**/target/failsafe-reports/*
      - name: Perform CodeQL Analysis
        uses: github/codeql-action/analyze@v1
      - name: Set up JDK 11
        if: needs.setup.outputs.is_default_branch == 'true'
        uses: actions/setup-java@v1
        with:
          java-version: 11
      - name: Publish Sonar analysis
        if: needs.setup.outputs.is_default_branch == 'true'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
        run: |
          cd app
          ./mvnw -q -B -pl '!:extension-bom,!:integration-bom' jacoco:report \
          && ./mvnw -B -N -Dsonar.login=${{secrets.SONAR_TOKEN}} sonar:sonar  -Dsonar.sources=$(find . -wholename "*/src/main/java" | sed -z 's/\n/,/g;s/,$/\n/') -Dsonar.java.binaries=$(find . -wholename "*/target/classes" | sed -z 's/\n/,/g;s/,$/\n/')
  operator:
    needs: changes
    if: needs.changes.outputs.operator == 'true'
    runs-on: ubuntu-latest
    permissions:
      actions: read
      contents: read
      security-events: write
    strategy:
      fail-fast: false
    steps:
      - uses: actions/checkout@v2
      - name: Initialize CodeQL
        uses: github/codeql-action/init@v1
        with:
          config-file: ./.github/codeql/codeql-config.yml
          languages: go
      - name: Setup Go 1.16
        uses: actions/setup-go@v2
        with:
          go-version: '1.16'
      - name: Build and test
        run: tools/bin/syndesis build --batch-mode -m operator --local
      - name: Perform CodeQL Analysis
        uses: github/codeql-action/analyze@v1
  ui:
    needs: changes
    if: needs.changes.outputs.ui == 'true'
    runs-on: ubuntu-latest
    permissions:
      actions: read
      contents: read
      security-events: write
    strategy:
      fail-fast: false
    steps:
      - uses: actions/checkout@v2
      - name: Set up JDK 8
        uses: actions/setup-java@v1
        with:
          java-version: 8
      - name: Cache local Maven repository
        uses: actions/cache@v2
        with:
          path: |
            ~/.m2/repository
            !~/.m2/repository/io/syndesis
          key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
          restore-keys: ${{ runner.os }}-maven-
      - name: Initialize CodeQL
        uses: github/codeql-action/init@v1
        with:
          config-file: ./.github/codeql/codeql-config.yml
          languages: javascript
      - name: Build and test
        run: tools/bin/syndesis build --batch-mode -m ui-react
      - name: Perform CodeQL Analysis
        uses: github/codeql-action/analyze@v1
  integration-tests:
    needs: changes
    if: needs.changes.outputs.backend == 'true'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Set up JDK 8
        uses: actions/setup-java@v1
        with:
          java-version: 8
      - name: Cache local Maven repository
        uses: actions/cache@v2
        with:
          path: |
            ~/.m2/repository
            !~/.m2/repository/io/syndesis
          key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
          restore-keys: ${{ runner.os }}-maven-
      - name: Build
        run: tools/bin/syndesis build --backend --flash --batch-mode
      - name: Build S2I image
        run: tools/bin/syndesis build -m s2i --flash --docker
      - name: Run integration tests
        run: tools/bin/syndesis integration-test --s2i --logging
      - name: Archive logs and test results
        if: always()
        uses: actions/upload-artifact@v2
        with:
          name: checks-integration-tests
          path: |
            app/test/integration-test/target/*.log
            app/test/integration-test/target/citrus-reports/**/*
            app/test/integration-test/target/failsafe-reports/*
            app/s2i/target/invoker-reports/*
            app/s2i/target/it/project/build.log


Release

name: Release

on:
  release:
    types: [released]

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - name: Git checkout
        uses: actions/checkout@v2
        with:
          persist-credentials: false
      - name: Set up JDK 8
        uses: actions/setup-java@v1
        with:
          java-version: 8
      - name: Setup Go 1.16
        uses: actions/setup-go@v2
        with:
          go-version: '1.16'
      - name: Cache Maven Repository
        uses: actions/cache@v1
        with:
          path: ~/.m2
          key: release-${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
          restore-keys: release-${{ runner.os }}-m2
      - name: Perform release
        env:
          DOCKER_USER: ${{ secrets.DOCKER_USER }}
          DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
          QUAYIO_USER: ${{ secrets.QUAYIO_USER }}
          QUAYIO_PASSWORD: ${{ secrets.QUAYIO_PASSWORD }}
          SYNDESISCI_TOKEN: ${{ secrets.SYNDESISCI_TOKEN }}
          GPG_KEYNAME: ${{ secrets.GPG_KEYNAME }}
          GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
          GPG_KEY: ${{ secrets.GPG_KEY }}
          OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
        run: |
          git config --global user.email ci@syndesis.io
          git config --global user.name 'Syndesis CI'
          git config --global 'http.https://github.com/.extraheader' "Authorization: basic $(echo -n x-access-token:${SYNDESISCI_TOKEN}|base64 --wrap=0)"
          gpg --batch --import <(echo "${GPG_KEY}")
          export GPG_TTY=$(tty)
          tools/bin/syndesis release --settings .mvn/settings.release.xml --release-version ${{ github.event.release.tag_name }} --git-remote origin --docker-user "${DOCKER_USER}" --docker-password "${DOCKER_PASSWORD}" --github-user syndesisci --github-token "${SYNDESISCI_TOKEN}" --quayio-user "${QUAYIO_USER}" --quayio-password "${QUAYIO_PASSWORD}" --gpg-keyname "${GPG_KEYNAME}" --gpg-passphrase "${GPG_PASSPHRASE}"


Create Kustomize Release

# This is workflow for create a release of the kustomize install archive

name: Create Kustomize Release

# Controls when the action will run.
on:
  push:
    tags:
      - '*-installer-*'

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Setup Go 1.16
        uses: actions/setup-go@v2
        with:
          go-version: '1.16'

      - name: Get Release Version
        run: |
          TAG=${GITHUB_REF#refs/tags/} &&
          echo "RELEASE_VERSION=${TAG##*-}" >> $GITHUB_ENV &&
          echo "RELEASE_NAME=${TAG%%-*}" >> $GITHUB_ENV

      - name: Create Release
        id: create_release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
        with:
          tag_name: ${{ github.ref }}
          release_name: ${{ env.RELEASE_NAME }}-installer-${{ env.RELEASE_VERSION }}
          draft: false
          prerelease: true

      - name: Build Kustomize Release
        run: |
          cd install/operator/kustomize/release &&
          RELEASE_VERSION=${{ env.RELEASE_VERSION }} RELEASE_NAME=${{ env.RELEASE_NAME }} make release

      - name: Upload Kustomize Release
        id: upload-kustomize-release-asset
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
          asset_path: install/operator/kustomize/release/${{ env.RELEASE_NAME }}-installer-${{ env.RELEASE_VERSION }}.tar.gz
          asset_name: ${{ env.RELEASE_NAME }}-installer-${{ env.RELEASE_VERSION }}.tar.gz
          asset_content_type: application/tar+gzip


CodeQL

name: "CodeQL"

on:
  schedule:
    - cron: '30 4 * * 1'
  workflow_dispatch:

jobs:
  analyze:
    name: Analyze
    runs-on: ubuntu-latest
    permissions:
      actions: read
      contents: read
      security-events: write
    strategy:
      fail-fast: false
      matrix:
        language: [ 'go', 'java', 'javascript' ]
    steps:
    - name: Checkout repository
      uses: actions/checkout@v2
    - name: Set up JDK 8
      uses: actions/setup-java@v1
      with:
        java-version: 8
    - name: Setup Go 1.16
      uses: actions/setup-go@v2
      with:
        go-version: '1.16'
    - name: Initialize CodeQL
      uses: github/codeql-action/init@v1
      with:
        config-file: ./.github/codeql/codeql-config.yml
        languages: ${{ matrix.language }}
    - name: Cache local Maven repository
      uses: actions/cache@v2
      with:
        path: |
          ~/.m2/repository
          !~/.m2/repository/io/syndesis
        key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
        restore-keys: ${{ runner.os }}-maven-
    - name: Build
      run: tools/bin/syndesis build --batch-mode --flash --backend -m operator
    - name: Perform CodeQL Analysis
      uses: github/codeql-action/analyze@v1


Syndesis daily release

name: Syndesis daily release

on:
  schedule:
    - cron:  '0 5 * * *'
  workflow_dispatch:
    inputs:
      flags:
        description: 'Additional command line flags'
        required: false

jobs:
  release:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        include:
          - branch: 1.15.x
            java: 8
    steps:
      - name: Git checkout
        uses: actions/checkout@v2
        with:
          ref: ${{ matrix.branch }}
          persist-credentials: false
          fetch-depth: 0
      - name: Check for changes
        id: should
        env:
          BRANCH: ${{ matrix.branch }}
        run: |
          RELEASE_TAGS=$(git tag --contains $(git rev-parse HEAD) | grep "^${BRANCH/.x/}") || true
          if [ -n "${RELEASE_TAGS}" ]; then
            echo The latest change was already included in a release, skipping release
            echo "skip=true" >> $GITHUB_OUTPUT
          fi
      - name: Set up JDK ${{ matrix.java }}
        if: steps.should.outputs.skip != 'true'
        uses: actions/setup-java@v1
        with:
          java-version: ${{ matrix.java }}
      - name: Setup Go 1.16
        uses: actions/setup-go@v2
        with:
          go-version: '1.16'
      - name: Cache Maven Repository
        if: steps.should.outputs.skip != 'true'
        uses: actions/cache@v1
        with:
          path: ~/.m2
          key: release-${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
          restore-keys: release-${{ runner.os }}-m2
      - name: Daily release of ${{ matrix.branch }}
        if: steps.should.outputs.skip != 'true'
        env:
          DOCKER_USER: ${{ secrets.DOCKER_USER }}
          DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
          QUAYIO_USER: ${{ secrets.QUAYIO_USER }}
          QUAYIO_PASSWORD: ${{ secrets.QUAYIO_PASSWORD }}
          SYNDESISCI_TOKEN: ${{ secrets.SYNDESISCI_TOKEN }}
          ADDITIONAL_FLAGS: ${{ github.event.inputs.flags }}
        run: |
          git config --global user.email admin@syndesis.io
          git config --global user.name 'Syndesis CI'
          git config --global 'http.https://github.com/.extraheader' "Authorization: basic $(echo -n x-access-token:${SYNDESISCI_TOKEN}|base64 --wrap=0)"
          tools/bin/syndesis release --snapshot-release --git-remote origin --docker-user "${DOCKER_USER}" --docker-password "${DOCKER_PASSWORD}" --github-user syndesisci --github-token "${SYNDESISCI_TOKEN}" --quayio-user "${QUAYIO_USER}" --quayio-password "${QUAYIO_PASSWORD}" ${ADDITIONAL_FLAGS}


CodeQL

# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
  workflow_dispatch:
  schedule:
    # * is a special character in YAML so you have to quote this string
    # expression evaluates to midnight every night
    - cron: '0 0 * * *'

jobs:
  analyze:
    name: Analyze
    runs-on: ubuntu-22.04
    permissions:
      actions: read
      contents: read
      security-events: write
    steps:
    - name: Checkout repository
      uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
    - name: Set up Java
      uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93
      with:
        distribution: 'temurin'
        java-version: 21
    # Initializes the CodeQL tools for scanning.
    - name: Initialize CodeQL
      uses: github/codeql-action/init@2f93e4319b2f04a2efc38fa7f78bd681bc3f7b2f
      with:
        languages: ${{ matrix.language }}
        # If you wish to specify custom queries, you can do so here or in a config file.
        # By default, queries listed here will override any specified in a config file.
        # Prefix the list here with "+" to use these queries and those in the config file.
        queries: security-and-quality,security-extended

    - name: setup gradle
      uses: gradle/actions/setup-gradle@9e899d11ad247ec76be7a60bc1cf9d3abbb9e7f1
      with:
        cache-disabled: true
    - name: compileJava noscan
      run: |
        JAVA_OPTS="-Xmx2048M" ./gradlew --no-scan compileJava
    - name: Perform CodeQL Analysis
      uses: github/codeql-action/analyze@2f93e4319b2f04a2efc38fa7f78bd681bc3f7b2f


SonarCloud analysis

name: SonarCloud analysis

on:
  workflow_dispatch:
  schedule:
    # * is a special character in YAML so you have to quote this string
    # expression evaluates to midnight on Tuesdays UTC
    - cron:  '0 0 * * 2'

permissions:
  pull-requests: read # allows SonarCloud to decorate PRs with analysis results

jobs:
  Analysis:
    runs-on: ubuntu-latest
    steps:
      - name: checkout
        uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
      - name: Set up Java
        uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93
        with:
          distribution: temurin
          java-version: 21
      - name: Cache SonarCloud packages
        uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c
        with:
          path: ~/.sonar/cache
          key: ${{ runner.os }}-sonar
          restore-keys: ${{ runner.os }}-sonar
      - name: setup gradle
        uses: gradle/actions/setup-gradle@9e899d11ad247ec76be7a60bc1cf9d3abbb9e7f1
        with:
          cache-disabled: true
      - name: Build and analyze
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  # Needed to get PR information, if any
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
          SONAR_ORGANIZATION: ${{ vars.SONAR_ORGANIZATION }}
          SONAR_PROJECT_KEY: ${{ vars.SONAR_PROJECT_KEY }}
        run: ./gradlew build sonarqube --continue --info -Dorg.gradle.parallel=true -Dorg.gradle.caching=true


DCO

name: DCO

on: [pull_request]

jobs:
  dco_check:
    runs-on: ubuntu-latest
    name: DCO
    if: ${{ github.actor != 'dependabot[bot]' }}
    steps:
    - name: Get PR Commits
      id: 'get-pr-commits'
      uses: tim-actions/get-pr-commits@198af03565609bb4ed924d1260247b4881f09e7d
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
    - name: DCO Check
      uses: tim-actions/dco@f2279e6e62d5a7d9115b0cb8e837b777b1b02e21
      with:
        commits: ${{ steps.get-pr-commits.outputs.commits }}


release

name: release

on:
  release:
    types: [released]

env:
  registry: docker.io
  GRADLE_OPTS: "-Dorg.gradle.parallel=true -Dorg.gradle.caching=true"

jobs:
  artifacts:
    runs-on: ubuntu-22.04
    permissions:
      contents: write
    outputs:
      tarSha: ${{steps.hashes.outputs.tarSha}}
      zipSha: ${{steps.hashes.outputs.zipSha}}
    steps:
      - name: checkout
        uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
      - name: Set up Java
        uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93
        with:
          distribution: temurin
          java-version: 21
      - name: setup gradle
        uses: gradle/actions/setup-gradle@9e899d11ad247ec76be7a60bc1cf9d3abbb9e7f1
        with:
          cache-disabled: true
      - name: assemble release
        run:
          ./gradlew -Prelease.releaseVersion=${{github.event.release.name}} -Pversion=${{github.event.release.name}} assemble
      - name: hashes
        id: hashes
        run: |
          cd build/distributions
          echo "zipSha=$(shasum -a 256 besu*.zip)"
          echo "tarSha=$(shasum -a 256 besu*.tar.gz)"
          echo "zipSha=$(shasum -a 256 besu*.zip)" >> $GITHUB_OUTPUT
          echo "tarSha=$(shasum -a 256 besu*.tar.gz)" >> $GITHUB_OUTPUT
      - name: upload tarball
        uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3
        with:
          path: 'build/distributions/besu*.tar.gz'
          name: besu-${{ github.event.release.name }}.tar.gz
          compression-level: 0
      - name: upload zipfile
        uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3
        with:
          path: 'build/distributions/besu*.zip'
          name: besu-${{ github.event.release.name }}.zip
          compression-level: 0

  testWindows:
    runs-on: windows-2022
    needs: artifacts
    timeout-minutes: 10
    steps:
      - name: Set up Java
        uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93
        with:
          distribution: temurin
          java-version: 21
      - name: Download zip
        uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe
        with:
          pattern: besu-*.zip
          merge-multiple: true
      - name: test Besu
        run: |
          dir
          unzip besu-*.zip -d besu-tmp
          cd besu-tmp
          mv besu-* ../besu
          cd ..
          besu\bin\besu.bat --help
          besu\bin\besu.bat --version

  publish:
    runs-on: ubuntu-22.04
    needs: [testWindows, artifacts]
    permissions:
      contents: write
    steps:
      - name: Download archives
        uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe
        with:
          pattern: besu-*
          merge-multiple: true
          path: 'build/distributions'
      - name: Upload Release assets
        uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
        with:
          append_body: true
          files: |
            build/distributions/besu*.tar.gz
            build/distributions/besu*.zip
          body: |
            ${{needs.artifacts.outputs.tarSha}}
            ${{needs.artifacts.outputs.zipSha}}

  artifactoryPublish:
    runs-on: ubuntu-22.04
    needs: artifacts
    steps:
      - name: checkout
        uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
      - name: Set up Java
        uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93
        with:
          distribution: temurin
          java-version: 21
      - name: setup gradle
        uses: gradle/actions/setup-gradle@9e899d11ad247ec76be7a60bc1cf9d3abbb9e7f1
        with:
          cache-disabled: true
      - name: Artifactory Publish
        env:
          ARTIFACTORY_USER: ${{ secrets.BESU_ARTIFACTORY_USER }}
          ARTIFACTORY_KEY: ${{ secrets.BESU_ARTIFACTORY_TOKEN }}
        run: ./gradlew -Prelease.releaseVersion=${{ github.event.release.name }} -Pversion=${{github.event.release.name}} artifactoryPublish

  hadolint:
    runs-on: ubuntu-22.04
    steps:
      - name: Checkout Repo
        uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
      - name: Set up Java
        uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93
        with:
          distribution: temurin
          java-version: 21
      - name: setup gradle
        uses: gradle/actions/setup-gradle@9e899d11ad247ec76be7a60bc1cf9d3abbb9e7f1
        with:
          cache-disabled: true
      - name: hadoLint
        run: docker run --rm -i hadolint/hadolint < docker/Dockerfile

  buildDocker:
    needs: hadolint
    permissions:
      contents: read
      packages: write

    strategy:
      fail-fast: false
      matrix:
        platform:
          - ubuntu-22.04
          - besu-arm64
    runs-on: ${{ matrix.platform }}
    steps:
      - name: Prepare
        id: prep
        run: |
          platform=${{ matrix.platform }}
          if [ "$platform" = 'ubuntu-22.04' ]; then
            echo "PLATFORM_PAIR=linux-amd64" >> $GITHUB_OUTPUT
            echo "ARCH=amd64" >> $GITHUB_OUTPUT
          else
            echo "PLATFORM_PAIR=linux-arm64" >> $GITHUB_OUTPUT
            echo "ARCH=arm64" >> $GITHUB_OUTPUT
          fi
      - name: Checkout Repo
        uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
      - name: short sha
        id: shortSha
        run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
      - name: Set up Java
        uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93
        with:
          distribution: temurin
          java-version: 21
      - name: setup gradle
        uses: gradle/actions/setup-gradle@9e899d11ad247ec76be7a60bc1cf9d3abbb9e7f1
        with:
          cache-disabled: true
      - name: install goss
        run: |
          mkdir -p docker/reports
          curl -L https://github.com/aelsabbahy/goss/releases/download/v0.4.4/goss-${{ steps.prep.outputs.PLATFORM_PAIR }} -o ./docker/tests/goss-${{ steps.prep.outputs.PLATFORM_PAIR }}
      - name: login to ${{ env.registry }}
        uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d
        with:
          registry: ${{ env.registry }}
          username: ${{ secrets.DOCKER_USER_RW }}
          password: ${{ secrets.DOCKER_PASSWORD_RW }}
      - name: build and test docker
        uses: gradle/actions/setup-gradle@9e899d11ad247ec76be7a60bc1cf9d3abbb9e7f1
        env:
          architecture: ${{ steps.prep.outputs.ARCH }}
        with:
          cache-disabled: true
          arguments: testDocker -PdockerOrgName=${{ env.registry }}/${{ secrets.DOCKER_ORG }} -Pversion=${{github.event.release.name}} -Prelease.releaseVersion=${{ github.event.release.name }}
      - name: publish
        env:
          architecture: ${{ steps.prep.outputs.ARCH }}
        run: ./gradlew --no-daemon dockerUpload -PdockerOrgName=${{ env.registry }}/${{ secrets.DOCKER_ORG }} -Pversion=${{github.event.release.name}} -Prelease.releaseVersion=${{ github.event.release.name }}

  multiArch:
    needs: buildDocker
    runs-on: ubuntu-22.04
    permissions:
      contents: read
      packages: write
    steps:
      - name: Checkout Repo
        uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
      - name: Set up Java
        uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93
        with:
          distribution: temurin
          java-version: 21
      - name: setup gradle
        uses: gradle/actions/setup-gradle@9e899d11ad247ec76be7a60bc1cf9d3abbb9e7f1
        with:
          cache-disabled: true
      - name: login to ${{ env.registry }}
        uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d
        with:
          registry: ${{ env.registry }}
          username: ${{ secrets.DOCKER_USER_RW }}
          password: ${{ secrets.DOCKER_PASSWORD_RW }}
      - name: multi-arch docker
        run: ./gradlew manifestDocker -PdockerOrgName=${{ env.registry }}/${{ secrets.DOCKER_ORG }} -Pversion=${{github.event.release.name}} -Prelease.releaseVersion=${{ github.event.release.name }}

  amendNotes:
    needs: multiArch
    runs-on: ubuntu-22.04
    permissions:
      contents: write
    steps:
      - name: add pull command to release notes
        uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
        with:
          append_body: true
          body: |
            `docker pull ${{env.registry}}/${{secrets.DOCKER_ORG}}/besu:${{github.event.release.name}}`

  dockerPromoteX64:
    needs: multiArch
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
      - uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93
        with:
          distribution: temurin
          java-version: 21
          cache: gradle
      - name: login to ${{ env.registry }}
        uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d
        with:
          registry: ${{ env.registry }}
          username: ${{ secrets.DOCKER_USER_RW }}
          password: ${{ secrets.DOCKER_PASSWORD_RW }}
      - name: Setup Gradle
        uses: gradle/actions/setup-gradle@9e899d11ad247ec76be7a60bc1cf9d3abbb9e7f1
        with:
          cache-disabled: true
      - name: Docker upload
        run: ./gradlew "-Prelease.releaseVersion=${{ github.event.release.name }}" "-PdockerOrgName=${{ env.registry }}/${{ secrets.DOCKER_ORG }}" dockerUploadRelease
      - name: Docker manifest
        run: ./gradlew "-Prelease.releaseVersion=${{ github.event.release.name }}" "-PdockerOrgName=${{ env.registry }}/${{ secrets.DOCKER_ORG }}" manifestDockerRelease

  verifyContainer:
    needs: dockerPromoteX64
    runs-on: ubuntu-22.04
    permissions:
      contents: read
      actions: write
    steps:
      - name: Checkout
        uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
      - name: Trigger container verify
        run: echo '{"version":"${{ github.event.release.name }}","verify-latest-version":"true"}' | gh workflow run container-verify.yml --json
        env:
          GH_TOKEN: ${{ github.token }}


acceptance-tests

name: acceptance-tests
on:
  workflow_dispatch:
  pull_request:
    branches:
      - main
      - release-*

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

env:
  GRADLE_OPTS: "-Xmx6g"
  total-runners: 12

jobs:
  acceptanceTestEthereum:
    runs-on: ubuntu-22.04
    name: "Acceptance Runner"
    permissions:
      statuses: write
      checks: write
    strategy:
      fail-fast: true
      matrix:
        runner_index: [0,1,2,3,4,5,6,7,8,9,10,11]
    steps:
      - name: Checkout Repo
        uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
        with:
          ref: ${{ github.event.pull_request.head.sha || github.ref }}
      - name: Set up Java
        uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93
        with:
          distribution: temurin
          java-version: 21
      - name: Install required packages
        run:  sudo apt-get install -y xmlstarlet
      - name: setup gradle
        uses: gradle/actions/setup-gradle@9e899d11ad247ec76be7a60bc1cf9d3abbb9e7f1
        with:
          cache-disabled: true
      - name: List unit tests
        run: ./gradlew acceptanceTestNotPrivacy --test-dry-run -Dorg.gradle.parallel=true -Dorg.gradle.caching=true
      - name: Extract current test list
        run: mkdir tmp; find . -type f -name TEST-*.xml | xargs -I{} bash -c "xmlstarlet sel -t -v '/testsuite/@name' '{}'; echo ' acceptanceTestNotPrivacy'" | tee tmp/currentTests.list
      - name: Get acceptance test reports
        uses: dawidd6/action-download-artifact@e7466d1a7587ed14867642c2ca74b5bcc1e19a2d
        continue-on-error: true
        with:
          branch: main
          workflow: update-test-reports.yml
          name: acceptance-test-results
          path: tmp/junit-xml-reports-downloaded
          if_no_artifact_found: ignore
      - name: Split tests
        run: .github/workflows/splitTestsByTime.sh tmp/junit-xml-reports-downloaded "tmp/junit-xml-reports-downloaded/acceptance-node-.*-test-results" "TEST-" ${{env.total-runners}} ${{ matrix.runner_index }} > testList.txt
      - name: format gradle args
        # we do not need the module task here
        run:  cat testList.txt | cut -f 2- -d ' ' | tee gradleArgs.txt
      - name: Upload Timing
        uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3
        if: matrix.runner_index == 0
        with:
          name: acceptance-tests-timing
          path: 'tmp/timing.tsv'
      - name: Upload Lists
        uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3
        if: matrix.runner_index == 0
        with:
          name: acceptance-tests-lists
          path: 'tmp/*.list'
      - name: Upload gradle test tasks
        uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3
        with:
          name: test-args-${{ matrix.runner_index }}.txt
          path: '*.txt'
      - name: run acceptance tests
        run: ./gradlew acceptanceTestNotPrivacy `cat gradleArgs.txt` -Dorg.gradle.parallel=true -Dorg.gradle.caching=true
      - name: Remove downloaded test results
        run: rm -rf tmp/junit-xml-reports-downloaded
      - name: Upload Acceptance Test Results
        uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3
        with:
          name: acceptance-node-${{matrix.runner_index}}-test-results
          path: 'acceptance-tests/tests/build/test-results/**/TEST-*.xml'
  accepttests-passed:
    name: "accepttests-passed"
    runs-on: ubuntu-22.04
    needs: [ acceptanceTestEthereum ]
    permissions:
      checks: write
      statuses: write
    if: always()
    steps:
      # Fail if any `needs` job was not a success.
      # Along with `if: always()`, this allows this job to act as a single required status check for the entire workflow.
      - name: Fail on workflow error
        run: exit 1
        if: >-
          ${{
            contains(needs.*.result, 'failure')
            || contains(needs.*.result, 'cancelled')
            || contains(needs.*.result, 'skipped')
          }}