From da72d558e6f2673fd34b7bc3c96078539178f15f Mon Sep 17 00:00:00 2001 From: gmunozfe Date: Tue, 22 Oct 2024 09:34:19 +0200 Subject: [PATCH] Centralize shared vars for different Github actions workflows --- .github/workflows/issues.yml | 6 +- .github/workflows/pr-backporting.yml | 10 +++- .github/workflows/pr-downstream.yml | 18 ++++-- .github/workflows/pr-jenkins.yml | 6 +- .github/workflows/pr-kogito-apps.yml | 13 +++-- .../publish-jitexecutor-native-rc.yml | 23 +++++--- .../workflows/publish-jitexecutor-native.yml | 25 ++++++--- .github/workflows/shared-vars.yml | 55 +++++++++++++++++++ 8 files changed, 126 insertions(+), 30 deletions(-) create mode 100644 .github/workflows/shared-vars.yml diff --git a/.github/workflows/issues.yml b/.github/workflows/issues.yml index 6779e30d9d..657cd22db4 100644 --- a/.github/workflows/issues.yml +++ b/.github/workflows/issues.yml @@ -23,8 +23,12 @@ on: issues: types: [opened, reopened] jobs: + shared-vars: + uses: ./.github/workflows/shared-vars.yml + message: - runs-on: ubuntu-latest + runs-on: ${{ needs.shared-vars.outputs.os }} + needs: shared-vars steps: - uses: actions/checkout@v4 - name: Send a stream message diff --git a/.github/workflows/pr-backporting.yml b/.github/workflows/pr-backporting.yml index c9dc69c0ed..79eb90d1e9 100644 --- a/.github/workflows/pr-backporting.yml +++ b/.github/workflows/pr-backporting.yml @@ -26,9 +26,13 @@ env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: + shared-vars: + uses: ./.github/workflows/shared-vars.yml + compute-targets: if: ${{ github.event.pull_request.state == 'closed' && github.event.pull_request.merged }} - runs-on: ubuntu-latest + runs-on: ${{ needs.shared-vars.outputs.os }} + needs: shared-vars outputs: target-branches: ${{ steps.set-targets.outputs.targets }} env: @@ -43,8 +47,8 @@ jobs: backporting: if: ${{ github.event.pull_request.state == 'closed' && github.event.pull_request.merged && needs.compute-targets.outputs.target-branches != '[]' }} name: "[${{ matrix.target-branch }}] - Backporting" - runs-on: ubuntu-latest - needs: compute-targets + runs-on: ${{ needs.shared-vars.outputs.os }} + needs: [shared-vars, compute-targets] strategy: matrix: target-branch: ${{ fromJSON(needs.compute-targets.outputs.target-branches) }} diff --git a/.github/workflows/pr-downstream.yml b/.github/workflows/pr-downstream.yml index 0039c62e28..51e8c862b0 100644 --- a/.github/workflows/pr-downstream.yml +++ b/.github/workflows/pr-downstream.yml @@ -32,7 +32,11 @@ on: - '.ci/jenkins/**' jobs: + shared-vars: + uses: ./.github/workflows/shared-vars.yml + kogito-downstream-build: + needs: shared-vars concurrency: group: pr-${{ matrix.job_name }}_${{ matrix.os }}_${{ matrix.java-version }}_${{ matrix.maven-version }}_${{ github.head_ref }} cancel-in-progress: true @@ -40,26 +44,32 @@ jobs: strategy: matrix: job_name: [ kogito-quarkus-examples, kogito-springboot-examples, serverless-workflow-examples ] - os: [ubuntu-latest] - java-version: [17] - maven-version: ['3.9.6'] include: - job_name: kogito-quarkus-examples repository: incubator-kie-kogito-examples env_KOGITO_EXAMPLES_SUBFOLDER_POM: kogito-quarkus-examples/ + os: ${{ needs.shared-vars.outputs.os }} + java-version: ${{ needs.shared-vars.outputs.java-version }} + maven-version: ${{ needs.shared-vars.outputs.maven-version }} - job_name: kogito-springboot-examples repository: incubator-kie-kogito-examples env_KOGITO_EXAMPLES_SUBFOLDER_POM: kogito-springboot-examples/ + os: ${{ needs.shared-vars.outputs.os }} + java-version: ${{ needs.shared-vars.outputs.java-version }} + maven-version: ${{ needs.shared-vars.outputs.maven-version }} - job_name: serverless-workflow-examples repository: incubator-kie-kogito-examples env_KOGITO_EXAMPLES_SUBFOLDER_POM: serverless-workflow-examples/ + os: ${{ needs.shared-vars.outputs.os }} + java-version: ${{ needs.shared-vars.outputs.java-version }} + maven-version: ${{ needs.shared-vars.outputs.maven-version }} fail-fast: false runs-on: ${{ matrix.os }} name: ${{ matrix.job_name }} (${{ matrix.os }} / Java-${{ matrix.java-version }} / Maven-${{ matrix.maven-version }}) steps: - name: Clean Disk Space uses: apache/incubator-kie-kogito-pipelines/.ci/actions/ubuntu-disk-space@main - if: ${{ matrix.os == 'ubuntu-latest' }} + if: ${{ contains(matrix.os, 'ubuntu') }} - name: Support long paths if: ${{ matrix.os == 'windows-latest' }} uses: apache/incubator-kie-kogito-pipelines/.ci/actions/long-paths@main diff --git a/.github/workflows/pr-jenkins.yml b/.github/workflows/pr-jenkins.yml index 454e55ae6f..3ea7f7ef62 100644 --- a/.github/workflows/pr-jenkins.yml +++ b/.github/workflows/pr-jenkins.yml @@ -27,11 +27,15 @@ on: - '.github/workflows/jenkins-tests-PR.yml' jobs: + shared-vars: + uses: ./.github/workflows/shared-vars.yml + dsl-tests: concurrency: group: ${{ github.repository.name }}_dsl_tests-${{ github.head_ref }} cancel-in-progress: true - runs-on: ubuntu-latest + runs-on: ${{ needs.shared-vars.outputs.os }} + needs: shared-vars name: DSL steps: - name: DSL tests diff --git a/.github/workflows/pr-kogito-apps.yml b/.github/workflows/pr-kogito-apps.yml index 27bcbc142c..7bd86a7305 100644 --- a/.github/workflows/pr-kogito-apps.yml +++ b/.github/workflows/pr-kogito-apps.yml @@ -32,23 +32,28 @@ on: - '.ci/jenkins/**' jobs: + shared-vars: + uses: ./.github/workflows/shared-vars.yml + build-chain: + needs: shared-vars concurrency: group: pr-kogito-apps_${{ matrix.os }}_${{ matrix.java-version }}_${{ matrix.maven-version }}_${{ github.head_ref }} cancel-in-progress: true timeout-minutes: 360 strategy: matrix: - os: [ubuntu-latest] - java-version: [17] - maven-version: ['3.9.6'] + include: + - os: ${{ needs.shared-vars.outputs.os }} + java-version: ${{ needs.shared-vars.outputs.java-version }} + maven-version: ${{ needs.shared-vars.outputs.maven-version }} fail-fast: false runs-on: ${{ matrix.os }} name: ${{ matrix.os }} / Java-${{ matrix.java-version }} / Maven-${{ matrix.maven-version }} steps: - name: Clean Disk Space uses: apache/incubator-kie-kogito-pipelines/.ci/actions/ubuntu-disk-space@main - if: ${{ matrix.os == 'ubuntu-latest' }} + if: ${{ contains(matrix.os, 'ubuntu') }} - name: Support long paths if: ${{ matrix.os == 'windows-latest' }} uses: apache/incubator-kie-kogito-pipelines/.ci/actions/long-paths@main diff --git a/.github/workflows/publish-jitexecutor-native-rc.yml b/.github/workflows/publish-jitexecutor-native-rc.yml index ff68a4dbf7..15cbbd03e0 100644 --- a/.github/workflows/publish-jitexecutor-native-rc.yml +++ b/.github/workflows/publish-jitexecutor-native-rc.yml @@ -18,12 +18,19 @@ on: required: true jobs: + shared-vars: + uses: ./.github/workflows/shared-vars.yml + build_jitexecutor_native: + needs: shared-vars runs-on: ${{ matrix.os }} strategy: fail-fast: true matrix: - os: [ubuntu-latest, macos-13, windows-latest] + include: + - os: ${{ needs.shared-vars.outputs.os }} + - os: ${{ needs.shared-vars.outputs.macos }} + - os: ${{ needs.shared-vars.outputs.windows-os }} steps: - name: Set version @@ -53,7 +60,7 @@ jobs: - name: "Set up Maven" uses: stCarolas/setup-maven@v5 with: - maven-version: 3.9.6 + maven-version: ${{ needs.shared-vars.outputs.maven-version }} - name: Import GPG key if: github.event_name != 'pull_request' @@ -243,10 +250,10 @@ jobs: "@ Add-Content "$env:WORKDIR_PATH\.m2\settings.xml" $contentToAdd - - name: "Set up JDK 17" + - name: "Set up JDK" uses: actions/setup-java@v4 with: - java-version: "17" + java-version: ${{ needs.shared-vars.outputs.java-version }} distribution: "temurin" overwrite-settings: false @@ -264,10 +271,10 @@ jobs: if: runner.os == 'macOS' run: | brew install make && \ - wget https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-17.0.9/graalvm-community-jdk-17.0.9_macos-x64_bin.tar.gz && \ - tar -xzf graalvm-community-jdk-17.0.9_macos-x64_bin.tar.gz && \ - sudo mv graalvm-community-openjdk-17.0.9+9.1 /Library/Java/JavaVirtualMachines/graalvm-community-openjdk-17.0.9+9.1 - export GRAALVM_HOME=/Library/Java/JavaVirtualMachines/graalvm-community-openjdk-17.0.9+9.1/Contents/Home + wget ${{ needs.shared-vars.outputs.graalvm-jdk-macos-url }} && \ + tar -xzf ${{ needs.shared-vars.outputs.graalvm-jdk-macos-bin }} && \ + sudo mv ${{ needs.shared-vars.outputs.graalvm-jdk-macos-vm }} /Library/Java/JavaVirtualMachines/${{ needs.shared-vars.outputs.graalvm-jdk-macos-vm }} + export GRAALVM_HOME=/Library/Java/JavaVirtualMachines/${{ needs.shared-vars.outputs.graalvm-jdk-macos-vm }}/Contents/Home export PATH=${GRAALVM_HOME}/bin:$PATH echo "${GRAALVM_HOME}/bin" >> $GITHUB_PATH && \ echo "GRAALVM_HOME=${GRAALVM_HOME}" >> $GITHUB_ENV && \ diff --git a/.github/workflows/publish-jitexecutor-native.yml b/.github/workflows/publish-jitexecutor-native.yml index 99d1cb8ee4..9be860eb40 100644 --- a/.github/workflows/publish-jitexecutor-native.yml +++ b/.github/workflows/publish-jitexecutor-native.yml @@ -13,12 +13,19 @@ on: required: true jobs: + shared-vars: + uses: ./.github/workflows/shared-vars.yml + build_jitexecutor_native: + needs: shared-vars runs-on: ${{ matrix.os }} strategy: fail-fast: true matrix: - os: [ubuntu-latest, macos-13, windows-latest] + include: + - os: ${{ needs.shared-vars.outputs.os }} + - os: ${{ needs.shared-vars.outputs.macos }} + - os: ${{ needs.shared-vars.outputs.windows-os }} steps: - name: Get current date @@ -54,12 +61,12 @@ jobs: - name: "Set up Maven" uses: stCarolas/setup-maven@v5 with: - maven-version: 3.9.6 + maven-version: ${{ needs.shared-vars.outputs.maven-version }} - - name: "Set up JDK 17" + - name: "Set up JDK" uses: actions/setup-java@v4 with: - java-version: "17" + java-version: ${{ needs.shared-vars.outputs.java-version }} distribution: "zulu" server-id: apache.snapshots.https server-username: NEXUS_USER @@ -79,10 +86,10 @@ jobs: if: runner.os == 'macOS' run: | brew install make && \ - wget https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-17.0.9/graalvm-community-jdk-17.0.9_macos-x64_bin.tar.gz && \ - tar -xzf graalvm-community-jdk-17.0.9_macos-x64_bin.tar.gz && \ - sudo mv graalvm-community-openjdk-17.0.9+9.1 /Library/Java/JavaVirtualMachines/graalvm-community-openjdk-17.0.9+9.1 - export GRAALVM_HOME=/Library/Java/JavaVirtualMachines/graalvm-community-openjdk-17.0.9+9.1/Contents/Home + wget ${{ needs.shared-vars.outputs.graalvm-jdk-macos-url }} && \ + tar -xzf ${{ needs.shared-vars.outputs.graalvm-jdk-macos-bin }} && \ + sudo mv ${{ needs.shared-vars.outputs.graalvm-jdk-macos-vm }} /Library/Java/JavaVirtualMachines/${{ needs.shared-vars.outputs.graalvm-jdk-macos-vm }} + export GRAALVM_HOME=/Library/Java/JavaVirtualMachines/${{ needs.shared-vars.outputs.graalvm-jdk-macos-vm }}/Contents/Home export PATH=${GRAALVM_HOME}/bin:$PATH echo "${GRAALVM_HOME}/bin" >> $GITHUB_PATH && \ echo "GRAALVM_HOME=${GRAALVM_HOME}" >> $GITHUB_ENV && \ @@ -100,7 +107,7 @@ jobs: if: runner.os == 'Windows' uses: graalvm/setup-graalvm@v1 with: - java-version: "17" + java-version: ${{ needs.shared-vars.outputs.java-version }} components: "native-image" - name: "Configure Pagefile" diff --git a/.github/workflows/shared-vars.yml b/.github/workflows/shared-vars.yml new file mode 100644 index 0000000000..913a8b67de --- /dev/null +++ b/.github/workflows/shared-vars.yml @@ -0,0 +1,55 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +name: 'Shared Variables to be reused in different workflows' + +on: + workflow_call: + outputs: + os: + description: 'OS to use' + value: 'ubuntu-22.04' + java-version: + description: 'Java version to use' + value: '17' + maven-version: + description: 'Maven version to use' + value: '3.9.6' + macos: + description: 'macOS to use' + value: 'macos-13' + windows-os: + description: 'windows OS to use' + value: 'windows-2022' + graalvm-jdk-macos-url: + description: 'graalvm-community-jdk for macOS URL' + value: 'https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-17.0.9/graalvm-community-jdk-17.0.9_macos-x64_bin.tar.gz' + graalvm-jdk-macos-bin: + description: 'graalvm-community-jdk for macOS binaries' + value: 'graalvm-community-jdk-17.0.9_macos-x64_bin.tar.gz' + graalvm-jdk-macos-vm: + description: 'graalvm-community-jdk for macOS VM' + value: 'graalvm-community-openjdk-17.0.9+9.1' + +jobs: + set-variables: + runs-on: ubuntu-latest + steps: + - name: Set variables + run: echo "This job is set common variables for other workflows."