Skip to content

Commit

Permalink
Centralize shared vars for different Github actions workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
gmunozfe committed Oct 21, 2024
1 parent 1474ab9 commit c01b2b5
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 37 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 7 additions & 23 deletions .github/workflows/pr-backporting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,6 @@
# under the License.
#


#
# 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: Pull Request Backporting

on:
Expand All @@ -46,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:
Expand All @@ -63,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) }}
Expand Down
14 changes: 9 additions & 5 deletions .github/workflows/pr-downstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,21 @@ 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
timeout-minutes: 180
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 }}]
job_name: [kogito-apps, kogito-quarkus-examples, kogito-springboot-examples, serverless-workflow-examples]
include:
- job_name: kogito-apps
repository: incubator-kie-kogito-apps
Expand All @@ -62,7 +66,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: ${{ contains(matrix.os, 'ubuntu') }}
- name: Support long paths
if: ${{ matrix.os == 'windows-latest' }}
uses: apache/incubator-kie-kogito-pipelines/.ci/actions/long-paths@main
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/pr-jenkins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ on:
- '.github/workflows/jenkins-tests-PR.yml'

jobs:
shared-vars:
uses: ./.github/workflows/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
Expand Down Expand Up @@ -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
Expand Down
17 changes: 11 additions & 6 deletions .github/workflows/pr-kogito-runtimes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,28 @@ on:
- '.ci/jenkins/**'

jobs:
shared-vars:
uses: ./.github/workflows/shared-vars.yml

runtime-build:
needs: shared-vars
concurrency:
group: pr-kogito-runtimes_${{ matrix.os }}_${{ matrix.java-version }}_${{ matrix.maven-version }}_${{ github.head_ref }}
cancel-in-progress: true
timeout-minutes: 120
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 }}
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: ${{ startsWith(matrix.os, 'ubuntu') }}
- name: Support long paths
if: ${{ matrix.os == 'windows-latest' }}
uses: apache/incubator-kie-kogito-pipelines/.ci/actions/long-paths@main
Expand All @@ -64,7 +69,7 @@ jobs:
annotations-prefix: ${{ runner.os }}-${{ matrix.java-version }}/${{ matrix.maven-version }}
github-token: "${{ secrets.GITHUB_TOKEN }}"
definition-file: https://raw.githubusercontent.com/${GROUP:apache}/incubator-kie-kogito-pipelines/${BRANCH:main}/.ci/pull-request-config.yaml
env:
env:
BUILD_MVN_OPTS_CURRENT: '-Dvalidate-formatting'
- name: Junit Report
uses: apache/incubator-kie-kogito-pipelines/.ci/actions/action-junit-report@main
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/shared-vars.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#
# 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'

jobs:
set-variables:
runs-on: ubuntu-latest
steps:
- name: Set variables
run: echo "This job is set common variables for other workflows."

0 comments on commit c01b2b5

Please sign in to comment.