From f9337f3d58b27567ac600d22228cad74325b91b3 Mon Sep 17 00:00:00 2001 From: gmunozfe Date: Mon, 21 Oct 2024 14:09:18 +0200 Subject: [PATCH] Centralize shared vars for different Github actions workflows --- .github/workflows/issues.yml | 6 ++++- .github/workflows/pr-backporting.yml | 9 +++++-- .github/workflows/pr-downstream.yml | 9 ++++--- .github/workflows/pr-jenkins.yml | 9 +++++-- .github/workflows/pr-kogito-runtimes.yml | 9 ++++--- .github/workflows/shared-vars.yml | 33 ++++++++++++++++++++++++ 6 files changed, 62 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/shared-vars.yml diff --git a/.github/workflows/issues.yml b/.github/workflows/issues.yml index 6779e30d9dd..1e21e687241 100644 --- a/.github/workflows/issues.yml +++ b/.github/workflows/issues.yml @@ -23,8 +23,12 @@ on: issues: types: [opened, reopened] jobs: + shared-vars: + uses: 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 88b297512e8..bbb1ed0c220 100644 --- a/.github/workflows/pr-backporting.yml +++ b/.github/workflows/pr-backporting.yml @@ -46,9 +46,13 @@ env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: + shared-vars: + uses: 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: @@ -63,7 +67,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 + runs-on: ${{ needs.shared-vars.outputs.os }} + needs: shared-vars needs: compute-targets strategy: matrix: diff --git a/.github/workflows/pr-downstream.yml b/.github/workflows/pr-downstream.yml index 66f99718375..d3bec6e9b49 100644 --- a/.github/workflows/pr-downstream.yml +++ b/.github/workflows/pr-downstream.yml @@ -37,12 +37,13 @@ jobs: group: pr-${{ matrix.job_name }}_${{ matrix.os }}_${{ matrix.java-version }}_${{ matrix.maven-version }}_${{ github.head_ref }} cancel-in-progress: true timeout-minutes: 180 + uses: shared-vars.yml strategy: matrix: job_name: [ kogito-apps, kogito-quarkus-examples, kogito-springboot-examples, serverless-workflow-examples ] - os: [ubuntu-latest] - java-version: [17] - maven-version: ['3.9.6'] + os: [${{ needs.shared-vars.outputs.os }}] + java-version: [${{ needs.shared-vars.outputs.java-version }}] + maven-version: [${{ needs.shared-vars.outputs.maven-version }}] include: - job_name: kogito-apps repository: incubator-kie-kogito-apps @@ -62,7 +63,7 @@ jobs: steps: - name: Clean Disk Space uses: apache/incubator-kie-kogito-pipelines/.ci/actions/ubuntu-disk-space@main - if: ${{ matrix.os == 'ubuntu-latest' }} + if: ${{ matrix.os contains('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 9b81584a389..21776f85bc0 100644 --- a/.github/workflows/pr-jenkins.yml +++ b/.github/workflows/pr-jenkins.yml @@ -29,11 +29,15 @@ on: - '.github/workflows/jenkins-tests-PR.yml' jobs: + shared-vars: + uses: shared-vars.yml + jenkinsfile-tests: concurrency: group: ${{ github.repository.name }}_jenkinsfile_tests-${{ github.head_ref }} cancel-in-progress: true - runs-on: ubuntu-latest + runs-on: ${{ needs.shared-vars.outputs.os }} + needs: shared-vars name: Jenkinsfiles steps: - name: Checkout repo @@ -64,7 +68,8 @@ jobs: 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-runtimes.yml b/.github/workflows/pr-kogito-runtimes.yml index 47f96638227..dd7c29895d2 100644 --- a/.github/workflows/pr-kogito-runtimes.yml +++ b/.github/workflows/pr-kogito-runtimes.yml @@ -37,18 +37,19 @@ jobs: group: pr-kogito-runtimes_${{ matrix.os }}_${{ matrix.java-version }}_${{ matrix.maven-version }}_${{ github.head_ref }} cancel-in-progress: true timeout-minutes: 120 + uses: shared-vars.yml strategy: matrix: - os: [ubuntu-latest] - java-version: [17] - maven-version: ['3.9.6'] + 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: ${{ matrix.os contains('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/shared-vars.yml b/.github/workflows/shared-vars.yml new file mode 100644 index 00000000000..b307a936f56 --- /dev/null +++ b/.github/workflows/shared-vars.yml @@ -0,0 +1,33 @@ +# +# 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'